From 3f2acd9d64ad4e7d7a47237d8c31df16a063c99d Mon Sep 17 00:00:00 2001 From: Michael Montour Date: Thu, 9 May 2024 23:00:38 -0700 Subject: [PATCH 1/2] Change the datatype used for the "stateDiff" override to eth_call to a hash instead of a uint256. Needed for rundler-hc account abstraction, which is expecting geth behaviour. Changes to be committed: modified: turbo/adapter/ethapi/api.go modified: turbo/adapter/ethapi/state_overrides.go --- turbo/adapter/ethapi/api.go | 10 +++++----- turbo/adapter/ethapi/state_overrides.go | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/turbo/adapter/ethapi/api.go b/turbo/adapter/ethapi/api.go index d40b0c2e795..6fcf309a5e0 100644 --- a/turbo/adapter/ethapi/api.go +++ b/turbo/adapter/ethapi/api.go @@ -165,11 +165,11 @@ func (args *CallArgs) ToMessage(globalGasCap uint64, baseFee *uint256.Int) (type // if statDiff is set, all diff will be applied first and then execute the call // message. type Account struct { - Nonce *hexutil.Uint64 `json:"nonce"` - Code *hexutility.Bytes `json:"code"` - Balance **hexutil.Big `json:"balance"` - State *map[libcommon.Hash]uint256.Int `json:"state"` - StateDiff *map[libcommon.Hash]uint256.Int `json:"stateDiff"` + Nonce *hexutil.Uint64 `json:"nonce"` + Code *hexutility.Bytes `json:"code"` + Balance **hexutil.Big `json:"balance"` + State *map[libcommon.Hash]uint256.Int `json:"state"` + StateDiff *map[libcommon.Hash]libcommon.Hash `json:"stateDiff"` } func NewRevertError(result *core.ExecutionResult) *RevertError { diff --git a/turbo/adapter/ethapi/state_overrides.go b/turbo/adapter/ethapi/state_overrides.go index 1ce2655acad..e8ba057c9b1 100644 --- a/turbo/adapter/ethapi/state_overrides.go +++ b/turbo/adapter/ethapi/state_overrides.go @@ -42,7 +42,8 @@ func (overrides *StateOverrides) Override(state *state.IntraBlockState) error { if account.StateDiff != nil { for key, value := range *account.StateDiff { key := key - state.SetState(addr, &key, value) + intValue := new(uint256.Int).SetBytes32(value.Bytes()) + state.SetState(addr, &key, *intValue) } } } From 96c25b7970b76295e46ca652b2ee7b6734281e69 Mon Sep 17 00:00:00 2001 From: Michael Montour Date: Mon, 20 May 2024 08:33:46 -0700 Subject: [PATCH 2/2] Add a log message (temporary). Changes to be committed: modified: turbo/adapter/ethapi/state_overrides.go --- turbo/adapter/ethapi/state_overrides.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/turbo/adapter/ethapi/state_overrides.go b/turbo/adapter/ethapi/state_overrides.go index e8ba057c9b1..f47718a8fc1 100644 --- a/turbo/adapter/ethapi/state_overrides.go +++ b/turbo/adapter/ethapi/state_overrides.go @@ -8,6 +8,7 @@ import ( libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/core/state" + "github.com/ledgerwatch/log/v3" ) type StateOverrides map[libcommon.Address]Account @@ -41,6 +42,7 @@ func (overrides *StateOverrides) Override(state *state.IntraBlockState) error { // Apply state diff into specified accounts. if account.StateDiff != nil { for key, value := range *account.StateDiff { + log.Info("StateDiff override at", "addr", addr, "key", key, "value", value); key := key intValue := new(uint256.Int).SetBytes32(value.Bytes()) state.SetState(addr, &key, *intValue)