Skip to content

Commit

Permalink
Fix error logging in script execution (#3070)
Browse files Browse the repository at this point in the history
* fix error handling

* log highest executed height
  • Loading branch information
zhangchiqing authored Aug 23, 2022
1 parent 3339eac commit b6e9a98
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/execution_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,16 +562,21 @@ func (e *ExecutionNodeBuilder) LoadComponentsAndModules() {

// Get latest executed block and a view at that block
ctx := context.Background()
_, blockID, err := executionState.GetHighestExecutedBlockID(ctx)
highestExecutedHeight, blockID, err := executionState.GetHighestExecutedBlockID(ctx)
if err != nil {
return nil, fmt.Errorf("cannot get the latest executed block id: %w", err)
}

node.Logger.Info().Msgf("highest executed block (id: %v, height: %v)", blockID, highestExecutedHeight)

stateCommit, err := executionState.StateCommitmentByBlockID(ctx, blockID)
if err != nil {
return nil, fmt.Errorf("cannot get the state comitment at latest executed block id %s: %w", blockID.String(), err)
}
blockView := executionState.NewView(stateCommit)

node.Logger.Info().Msgf("highest executed block statecommitment: %x", stateCommit)

// Get the epoch counter from the smart contract at the last executed block.
contractEpochCounter, err := getContractEpochCounter(vm, vmCtx, blockView)
// Failing to fetch the epoch counter from the smart contract is a fatal error.
Expand Down Expand Up @@ -826,7 +831,7 @@ func getContractEpochCounter(vm *fvm.VirtualMachine, vmCtx fvm.Context, view *de
// execute the script
err = vm.Run(vmCtx, script, view, p)
if err != nil {
return 0, fmt.Errorf("could not read epoch counter, script internal error: %w", script.Err)
return 0, fmt.Errorf("could not read epoch counter, script internal error: %w", err)
}
if script.Err != nil {
return 0, fmt.Errorf("could not read epoch counter, script error: %w", script.Err)
Expand Down

0 comments on commit b6e9a98

Please sign in to comment.