Skip to content

Commit

Permalink
simulators/ethereum/engine: Update beacon root to latest spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-tb committed Sep 4, 2023
1 parent 5d3adb8 commit e9003e6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions simulators/ethereum/engine/suites/cancun/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ func (cs *CancunBaseSpec) GetGenesis() *core.Genesis {
}

// Add bytecode pre deploy to the EIP-4788 address.
genesis.Alloc[HISTORY_STORAGE_ADDRESS] = core.GenesisAccount{
genesis.Alloc[BEACON_ROOTS_ADDRESS] = core.GenesisAccount{
Balance: common.Big0,
Nonce: 1,
Code: common.Hex2Bytes("3373fffffffffffffffffffffffffffffffffffffffe14604457602036146024575f5ffd5b620180005f350680545f35146037575f5ffd5b6201800001545f5260205ff35b42620180004206555f3562018000420662018000015500"),
Code: common.Hex2Bytes("3373fffffffffffffffffffffffffffffffffffffffe14604457602036146024575f5ffd5b620180005f350680545f35146037575f5ffd5b6201800001545f5260205ff35b6201800042064281555f359062018000015500"),
}

return genesis
Expand Down
4 changes: 2 additions & 2 deletions simulators/ethereum/engine/suites/cancun/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ func VerifyTransactionFromNode(ctx context.Context, eth client.Eth, tx typ.Trans

func BeaconRootStorageIndexes(timestamp uint64) (common.Hash, common.Hash) {
// Calculate keys
timestampReduced := timestamp % HISTORICAL_ROOTS_MODULUS
timestampExtended := timestampReduced + HISTORICAL_ROOTS_MODULUS
timestampReduced := timestamp % HISTORY_BUFFER_LENGTH
timestampExtended := timestampReduced + HISTORY_BUFFER_LENGTH

return common.BigToHash(new(big.Int).SetUint64(timestampReduced)), common.BigToHash(new(big.Int).SetUint64(timestampExtended))
}
2 changes: 1 addition & 1 deletion simulators/ethereum/engine/suites/cancun/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func VerifyBeaconRootStorage(ctx context.Context, testEngine *test.TestEngineCli
// Read the storage keys from the stateful precompile that stores the beacon roots and verify
// that the beacon root is the same as the one in the payload
blockNumber := new(big.Int).SetUint64(payload.Number)
precompileAddress := HISTORY_STORAGE_ADDRESS
precompileAddress := BEACON_ROOTS_ADDRESS

timestampKey, beaconRootKey := BeaconRootStorageIndexes(payload.Timestamp)

Expand Down
4 changes: 2 additions & 2 deletions simulators/ethereum/engine/suites/cancun/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ var (
BLOB_COMMITMENT_VERSION_KZG = byte(0x01)

// EIP 4788 specific constants
HISTORY_STORAGE_ADDRESS = common.HexToAddress("0x000000000000000000000000000000000000000b")
HISTORICAL_ROOTS_MODULUS = uint64(98304)
BEACON_ROOTS_ADDRESS = common.HexToAddress("0xbEac00dDB15f3B6d645C48263dC93862413A222D")
HISTORY_BUFFER_LENGTH = uint64(98304)

// Engine API errors
INVALID_PARAMS_ERROR = pInt(-32602)
Expand Down

0 comments on commit e9003e6

Please sign in to comment.