-
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
Optimized trie re-creation for VM Queries, adjust some logs #5977
Changes from 7 commits
c8e3b6d
d553a93
a6aa80b
22e0cd2
3e3aed0
3fcb27e
abfecd3
13bc2e4
6be2c90
b9ecacf
9f3d010
a929406
8e7be72
f9bcc00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,12 +22,15 @@ import ( | |
"github.com/multiversx/mx-chain-go/process" | ||
"github.com/multiversx/mx-chain-go/process/smartContract/scrCommon" | ||
"github.com/multiversx/mx-chain-go/sharding" | ||
logger "github.com/multiversx/mx-chain-logger-go" | ||
vmcommon "github.com/multiversx/mx-chain-vm-common-go" | ||
"github.com/multiversx/mx-chain-vm-common-go/parsers" | ||
) | ||
|
||
var _ process.SCQueryService = (*SCQueryService)(nil) | ||
|
||
var logQueryService = logger.GetOrCreate("process/smartcontract.queryService") | ||
|
||
// MaxGasLimitPerQuery - each unit is the equivalent of 1 nanosecond processing time | ||
const MaxGasLimitPerQuery = 300_000_000_000 | ||
|
||
|
@@ -39,7 +42,6 @@ type SCQueryService struct { | |
blockChainHook process.BlockChainHookWithAccountsAdapter | ||
mainBlockChain data.ChainHandler | ||
apiBlockChain data.ChainHandler | ||
numQueries int | ||
gasForQuery uint64 | ||
wasmVMChangeLocker common.Locker | ||
bootstrapper process.Bootstrapper | ||
|
@@ -179,8 +181,7 @@ func (service *SCQueryService) shouldAllowQueriesExecution() bool { | |
} | ||
|
||
func (service *SCQueryService) executeScCall(query *process.SCQuery, gasPrice uint64) (*vmcommon.VMOutput, common.BlockInfo, error) { | ||
log.Trace("executeScCall", "function", query.FuncName, "numQueries", service.numQueries) | ||
service.numQueries++ | ||
logQueryService.Trace("executeScCall", "address", query.ScAddress, "function", query.FuncName, "blockNonce", query.BlockNonce.Value, "blockHash", query.BlockHash) | ||
|
||
shouldEarlyExitBecauseOfSyncState := query.ShouldBeSynced && service.bootstrapper.GetNodeState() == common.NsNotSynchronized | ||
if shouldEarlyExitBecauseOfSyncState { | ||
|
@@ -193,6 +194,8 @@ func (service *SCQueryService) executeScCall(query *process.SCQuery, gasPrice ui | |
} | ||
|
||
if len(blockRootHash) > 0 { | ||
logQueryService.Trace("preparing execution for block and root hash", "block", blockHeader.GetNonce(), "rootHash", blockRootHash) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the check for nil blockHeader from L243 should also be done before this log also needed for recreateTrie There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed (moved log in |
||
|
||
err = service.apiBlockChain.SetCurrentBlockHeaderAndRootHash(blockHeader, blockRootHash) | ||
if err != nil { | ||
return nil, nil, err | ||
|
@@ -230,15 +233,6 @@ func (service *SCQueryService) executeScCall(query *process.SCQuery, gasPrice ui | |
return nil, nil, err | ||
} | ||
|
||
if service.hasRetriableExecutionError(vmOutput) { | ||
log.Error("Retriable execution error detected. Will retry (once) executeScCall()", "returnCode", vmOutput.ReturnCode, "returnMessage", vmOutput.ReturnMessage) | ||
|
||
vmOutput, err = vm.RunSmartContractCall(vmInput) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
} | ||
|
||
if query.SameScState { | ||
err = service.checkForRootHashChanges(rootHashBeforeExecution) | ||
if err != nil { | ||
|
@@ -417,10 +411,6 @@ func (service *SCQueryService) createVMCallInput(query *process.SCQuery, gasPric | |
return vmContractCallInput | ||
} | ||
|
||
func (service *SCQueryService) hasRetriableExecutionError(vmOutput *vmcommon.VMOutput) bool { | ||
return vmOutput.ReturnMessage == "allocation error" | ||
} | ||
|
||
// ComputeScCallGasLimit will estimate how many gas a transaction will consume | ||
func (service *SCQueryService) ComputeScCallGasLimit(tx *transaction.Transaction) (uint64, error) { | ||
argParser := parsers.NewCallArgsParser() | ||
|
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.
Debate-able if L184 and L197 should be at debug level.