Skip to content
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

Use the same data type as go-ethereum in the stateDiff override for eth_call #10531

Merged
merged 2 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions turbo/adapter/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,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]libcommon.Hash `json:"state"`
StateDiff *map[libcommon.Hash]libcommon.Hash `json:"stateDiff"`
}

func NewRevertError(result *core.ExecutionResult) *RevertError {
Expand Down
10 changes: 8 additions & 2 deletions turbo/adapter/ethapi/state_overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ func (overrides *StateOverrides) Override(state *state.IntraBlockState) error {
}
// Replace entire state if caller requires.
if account.State != nil {
state.SetStorage(addr, *account.State)
intState := map[libcommon.Hash]uint256.Int{}
for key, value := range *account.State {
intValue := new(uint256.Int).SetBytes32(value.Bytes())
intState[key] = *intValue
}
state.SetStorage(addr, intState)
}
// Apply state diff into specified accounts.
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)
}
}
}
Expand Down
Loading