-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed recreate trie in sc query service #5983
Fixed recreate trie in sc query service #5983
Conversation
@@ -33,6 +33,7 @@ var logQueryService = logger.GetOrCreate("process/smartcontract.queryService") | |||
|
|||
// MaxGasLimitPerQuery - each unit is the equivalent of 1 nanosecond processing time | |||
const MaxGasLimitPerQuery = 300_000_000_000 | |||
const epochDifferenceToConsiderHistory = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right to be a constant here, for all practical purposes 👍
|
||
func (service *SCQueryService) getCurrentEpoch() uint32 { | ||
header := service.mainBlockChain.GetCurrentBlockHeader() | ||
if check.IfNil(header) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming this is not a happy & common case, all good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this actually used at genesis time
argsNewSCQuery.MainBlockChain = &testscommon.ChainHandlerStub{ | ||
GetCurrentBlockHeaderCalled: func() data.HeaderHandler { | ||
return &block.Header{ | ||
Epoch: 37, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
GetFromEpochCalled: func(key []byte, epoch uint32) ([]byte, error) { | ||
counter++ | ||
if counter > 2 { | ||
return nil, fmt.Errorf("no scheduled") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of context message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
|
||
_, _, err := target.ExecuteQuery(&query) | ||
assert.True(t, runWasCalled) | ||
assert.True(t, wasRecreateTrieCalled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recreateTrieWasCalled
- for consistency with runWasCalled
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
providedHash := []byte("provided hash") | ||
providedRootHash := []byte("provided root hash") | ||
argsNewSCQuery.Marshaller = &marshallerMock.MarshalizerMock{} | ||
counter := 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be renamed to getFromEpochCallsCounter
(if makes sense).
Oh, now I see, can be left as it is - seen in other tests, as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed, anyway
}, | ||
GetFromEpochCalled: func(key []byte, epoch uint32) ([]byte, error) { | ||
counter++ | ||
if counter > 2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of context message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
assert.Nil(t, err) | ||
assert.True(t, recreateTrieCalled) | ||
}) | ||
t.Run("should call RecreateTrieFromEpoch for block on epoch 3", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Reasoning behind the pull request
Proposed changes
Testing procedure
Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
feat
branch created?feat
branch merging, do all satellite projects have a proper tag insidego.mod
?