From 669f6e749aab0080f90969e92ba815e7d1b5b8b7 Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Thu, 27 Jul 2023 17:49:50 +0530 Subject: [PATCH 1/2] add : statesync execution verbosity --- consensus/bor/contract/client.go | 5 ++++- consensus/bor/statefull/processor.go | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/consensus/bor/contract/client.go b/consensus/bor/contract/client.go index fa8ad215f2..246939f1ac 100644 --- a/consensus/bor/contract/client.go +++ b/consensus/bor/contract/client.go @@ -88,10 +88,13 @@ func (gc *GenesisContractsClient) CommitState( } msg := statefull.GetSystemMessage(common.HexToAddress(gc.StateReceiverContract), data) + + log.Info("→ committing new state", "eventRecord", event.ID) + gasUsed, err := statefull.ApplyMessage(context.Background(), msg, state, header, gc.chainConfig, chCtx) // Logging event log with time and individual gasUsed - log.Info("→ committing new state", "eventRecord", event.String(gasUsed)) + log.Info("→ committed new state", "eventRecord", event.String(gasUsed)) if err != nil { return 0, err diff --git a/consensus/bor/statefull/processor.go b/consensus/bor/statefull/processor.go index a78359a309..89e3bfafba 100644 --- a/consensus/bor/statefull/processor.go +++ b/consensus/bor/statefull/processor.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" ) @@ -77,7 +78,7 @@ func ApplyMessage( vmenv := vm.NewEVM(blockContext, vm.TxContext{}, state, chainConfig, vm.Config{}) // Apply the transaction to the current state (included in the env) - _, gasLeft, err := vmenv.Call( + ret, gasLeft, err := vmenv.Call( vm.AccountRef(msg.From()), *msg.To(), msg.Data(), @@ -85,6 +86,13 @@ func ApplyMessage( msg.Value(), nil, ) + + success := big.NewInt(5).SetBytes(ret) + + if success.Cmp(big.NewInt(0)) == 0 { + log.Error("message execution failed on contract", "msgData", msg.Data) + } + // Update the state with pending changes if err != nil { state.Finalise(true) From d43ad036ae619a99379a509ef7e0180fbffec2b6 Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Mon, 14 Aug 2023 16:06:48 +0530 Subject: [PATCH 2/2] fix : lint --- consensus/bor/statefull/processor.go | 1 + 1 file changed, 1 insertion(+) diff --git a/consensus/bor/statefull/processor.go b/consensus/bor/statefull/processor.go index 89e3bfafba..039f3daae0 100644 --- a/consensus/bor/statefull/processor.go +++ b/consensus/bor/statefull/processor.go @@ -77,6 +77,7 @@ func ApplyMessage( // about the transaction and calling mechanisms. vmenv := vm.NewEVM(blockContext, vm.TxContext{}, state, chainConfig, vm.Config{}) + // nolint : contextcheck // Apply the transaction to the current state (included in the env) ret, gasLeft, err := vmenv.Call( vm.AccountRef(msg.From()),