Merge pull request #947 from maticnetwork/shivam/POS-1608

add : statesync execution verbosity
This commit is contained in:
SHIVAM SHARMA 2023-08-21 15:36:02 +05:30 committed by GitHub
commit 66e8296287
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -88,10 +88,13 @@ func (gc *GenesisContractsClient) CommitState(
} }
msg := statefull.GetSystemMessage(common.HexToAddress(gc.StateReceiverContract), data) 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) gasUsed, err := statefull.ApplyMessage(context.Background(), msg, state, header, gc.chainConfig, chCtx)
// Logging event log with time and individual gasUsed // 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 { if err != nil {
return 0, err return 0, err

View file

@ -12,6 +12,7 @@ import (
"github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
) )
@ -76,8 +77,9 @@ func ApplyMessage(
// about the transaction and calling mechanisms. // about the transaction and calling mechanisms.
vmenv := vm.NewEVM(blockContext, vm.TxContext{}, state, chainConfig, vm.Config{}) vmenv := vm.NewEVM(blockContext, vm.TxContext{}, state, chainConfig, vm.Config{})
// nolint : contextcheck
// Apply the transaction to the current state (included in the env) // Apply the transaction to the current state (included in the env)
_, gasLeft, err := vmenv.Call( ret, gasLeft, err := vmenv.Call(
vm.AccountRef(msg.From()), vm.AccountRef(msg.From()),
*msg.To(), *msg.To(),
msg.Data(), msg.Data(),
@ -85,6 +87,13 @@ func ApplyMessage(
msg.Value(), msg.Value(),
nil, 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 // Update the state with pending changes
if err != nil { if err != nil {
state.Finalise(true) state.Finalise(true)