Skip to content

Commit 71ade50

Browse files
committed
core: implement simple beacon root system call
1 parent 8c0f8e0 commit 71ade50

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-31
lines changed

consensus/misc/eip4788.go

Lines changed: 0 additions & 30 deletions
This file was deleted.

core/state_processor.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,22 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
8787
signer = types.MakeSigner(p.config, header.Number, header.Time)
8888
)
8989
if beaconRoot != nil {
90-
misc.ApplyBeaconRoot(vmenv, *beaconRoot)
90+
// If EIP-4788 is enabled, we need to invoke the beaconroot storage contract with
91+
// the new root
92+
// TODO: Right now, I set the GasXX fields to 0. If this does not work,
93+
// we can use the header.BaseFee and set that instead.
94+
msg := &Message{
95+
From: params.SystemAddress,
96+
GasLimit: 100_000,
97+
GasPrice: new(big.Int).SetUint64(0), // TODO use nil?
98+
GasFeeCap: new(big.Int).SetUint64(0), // TODO use basefee?
99+
GasTipCap: new(big.Int).SetUint64(0), // TODO use zero?
100+
To: &params.BeaconRootsStorageAddress,
101+
Data: (*beaconRoot)[:], // TODO use 4byte invocation?
102+
}
103+
vmenv.Reset(NewEVMTxContext(msg), statedb)
104+
_, _, _ = vmenv.Call(vm.AccountRef(msg.From), *msg.To, msg.Data, 100_000, nil)
105+
statedb.Finalise(true)
91106
}
92107
// Iterate over and process the individual transactions
93108
for i, tx := range block.Transactions() {

params/protocol_params.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,5 @@ var (
185185
DurationLimit = big.NewInt(13) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not.
186186

187187
BeaconRootsStorageAddress common.Address = common.BytesToAddress([]byte{0xb}) // Address where historical beacon roots are stored as per EIP-4788
188+
SystemAddress common.Address = common.Address{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe}
188189
)

0 commit comments

Comments
 (0)