Skip to content

Commit f8241e6

Browse files
committed
Update OverrideAccount & BlockOverrides Ethereum types
1 parent e8999f4 commit f8241e6

File tree

5 files changed

+29
-26
lines changed

5 files changed

+29
-26
lines changed

api/debug.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ func (d *DebugAPI) TraceCall(
181181

182182
if config.BlockOverrides != nil {
183183
blocksProvider = blocksProvider.WithBlockOverrides(&ethTypes.BlockOverrides{
184-
Number: config.BlockOverrides.Number,
185-
Time: config.BlockOverrides.Time,
186-
Coinbase: config.BlockOverrides.FeeRecipient,
187-
Random: config.BlockOverrides.PrevRandao,
184+
Number: config.BlockOverrides.Number,
185+
Time: config.BlockOverrides.Time,
186+
FeeRecipient: config.BlockOverrides.FeeRecipient,
187+
PrevRandao: config.BlockOverrides.PrevRandao,
188188
})
189189
}
190190
viewProvider := query.NewViewProvider(

eth/types/types.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -433,29 +433,32 @@ type SignTransactionResult struct {
433433
// of a message call.
434434
// Note, state and stateDiff can't be specified at the same time. If state is
435435
// set, message execution will only use the data in the given state. Otherwise
436-
// if statDiff is set, all diff will be applied first and then execute the call
436+
// if stateDiff is set, all diff will be applied first and then execute the call
437437
// message.
438438
type OverrideAccount struct {
439-
Nonce *hexutil.Uint64 `json:"nonce"`
440-
Code *hexutil.Bytes `json:"code"`
441-
Balance **hexutil.Big `json:"balance"`
442-
State *map[common.Hash]common.Hash `json:"state"`
443-
StateDiff *map[common.Hash]common.Hash `json:"stateDiff"`
439+
Nonce *hexutil.Uint64 `json:"nonce"`
440+
Code *hexutil.Bytes `json:"code"`
441+
Balance *hexutil.Big `json:"balance"`
442+
State map[common.Hash]common.Hash `json:"state"`
443+
StateDiff map[common.Hash]common.Hash `json:"stateDiff"`
444+
MovePrecompileTo *common.Address `json:"movePrecompileToAddress"`
444445
}
445446

446447
// StateOverride is the collection of overridden accounts.
447448
type StateOverride map[common.Address]OverrideAccount
448449

449450
// BlockOverrides is a set of header fields to override.
450451
type BlockOverrides struct {
451-
Number *hexutil.Big
452-
Difficulty *hexutil.Big
453-
Time *hexutil.Uint64
454-
GasLimit *hexutil.Uint64
455-
Coinbase *common.Address
456-
Random *common.Hash
457-
BaseFee *hexutil.Big
458-
BlobBaseFee *hexutil.Big
452+
Number *hexutil.Big
453+
Difficulty *hexutil.Big // No-op if we're simulating post-merge calls.
454+
Time *hexutil.Uint64
455+
GasLimit *hexutil.Uint64
456+
FeeRecipient *common.Address
457+
PrevRandao *common.Hash
458+
BaseFeePerGas *hexutil.Big
459+
BlobBaseFee *hexutil.Big
460+
BeaconRoot *common.Hash
461+
Withdrawals *types.Withdrawals
459462
}
460463

461464
type Block struct {

services/requester/overridable_blocks_provider.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ func (bs *blockSnapshot) BlockContext() (evmTypes.BlockContext, error) {
5454
blockContext.BlockTimestamp = uint64(*bs.blockOverrides.Time)
5555
}
5656

57-
if bs.blockOverrides.Random != nil {
58-
blockContext.Random = *bs.blockOverrides.Random
57+
if bs.blockOverrides.PrevRandao != nil {
58+
blockContext.Random = *bs.blockOverrides.PrevRandao
5959
}
6060

61-
if bs.blockOverrides.Coinbase != nil {
62-
blockContext.GasFeeCollector = evmTypes.NewAddress(*bs.blockOverrides.Coinbase)
61+
if bs.blockOverrides.FeeRecipient != nil {
62+
blockContext.GasFeeCollector = evmTypes.NewAddress(*bs.blockOverrides.FeeRecipient)
6363
}
6464

6565
return blockContext, nil

services/requester/requester.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,18 +538,18 @@ func (e *EVM) dryRunTx(
538538
}
539539
// Override account balance.
540540
if account.Balance != nil {
541-
opts = append(opts, query.WithStateOverrideBalance(addr, (*big.Int)(*account.Balance)))
541+
opts = append(opts, query.WithStateOverrideBalance(addr, (*big.Int)(account.Balance)))
542542
}
543543
if account.State != nil && account.StateDiff != nil {
544544
return nil, fmt.Errorf("account %s has both 'state' and 'stateDiff'", addr.Hex())
545545
}
546546
// Replace entire state if caller requires.
547547
if account.State != nil {
548-
opts = append(opts, query.WithStateOverrideState(addr, *account.State))
548+
opts = append(opts, query.WithStateOverrideState(addr, account.State))
549549
}
550550
// Apply state diff into specified accounts.
551551
if account.StateDiff != nil {
552-
opts = append(opts, query.WithStateOverrideStateDiff(addr, *account.StateDiff))
552+
opts = append(opts, query.WithStateOverrideStateDiff(addr, account.StateDiff))
553553
}
554554
}
555555
}

tests/web3js/contract_call_overrides_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ it('should apply block overrides on eth_call', async () => {
8787
let random = '0x7914bb5b13bac6f621bc37bbf6e406fbf4472aaaaf17ec2f309a92aca4e27fc0'
8888
response = await helpers.callRPCMethod(
8989
'eth_call',
90-
[call, 'latest', null, { random: random }]
90+
[call, 'latest', null, { prevRandao: random }]
9191
)
9292
assert.equal(response.status, 200)
9393
assert.isDefined(response.body)

0 commit comments

Comments
 (0)