Skip to content
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

Merged
merged 3 commits into from Feb 20, 2024

Conversation

iulianpascalau
Copy link
Contributor

Reasoning behind the pull request

  • fixed recreate trie in sc query service

Proposed changes

Testing procedure

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

@@ -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
Copy link
Collaborator

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) {
Copy link
Collaborator

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.

Copy link
Contributor Author

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,
Copy link
Collaborator

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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of context message?

Copy link
Contributor Author

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)
Copy link
Collaborator

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.

Copy link
Contributor Author

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
Copy link
Collaborator

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.

Copy link
Contributor Author

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of context message?

Copy link
Contributor Author

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@andreibancioiu andreibancioiu merged commit a929406 into vm-query-logs Feb 20, 2024
3 checks passed
@andreibancioiu andreibancioiu deleted the fix-recreate-trie-in-sc-query-service branch February 20, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants