mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
add beacon block hash to the witness
This commit is contained in:
parent
2b3391ecb3
commit
a21c021b51
3 changed files with 12 additions and 6 deletions
|
|
@ -102,7 +102,7 @@ func (b *BlockGen) SetParentBeaconRoot(root common.Hash) {
|
|||
blockContext = NewEVMBlockContext(b.header, b.cm, &b.header.Coinbase)
|
||||
vmenv = vm.NewEVM(blockContext, vm.TxContext{}, b.statedb, b.cm.config, vm.Config{})
|
||||
)
|
||||
ProcessBeaconBlockRoot(root, vmenv, b.statedb)
|
||||
ProcessBeaconBlockRoot(root, vmenv, b.statedb, b.Number(), b.Timestamp())
|
||||
}
|
||||
|
||||
// addTx adds a transaction to the generated block. If no coinbase has
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
|||
signer = types.MakeSigner(p.config, header.Number, header.Time)
|
||||
)
|
||||
if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
|
||||
ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb)
|
||||
ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb, header.Number, header.Time)
|
||||
}
|
||||
// Iterate over and process the individual transactions
|
||||
for i, tx := range block.Transactions() {
|
||||
|
|
@ -190,7 +190,7 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
|
|||
|
||||
// ProcessBeaconBlockRoot applies the EIP-4788 system call to the beacon block root
|
||||
// contract. This method is exported to be used in tests.
|
||||
func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *state.StateDB) {
|
||||
func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *state.StateDB, num *big.Int, time uint64) {
|
||||
// If EIP-4788 is enabled, we need to invoke the beaconroot storage contract with
|
||||
// the new root
|
||||
msg := &Message{
|
||||
|
|
@ -202,8 +202,14 @@ func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *stat
|
|||
To: ¶ms.BeaconRootsAddress,
|
||||
Data: beaconRoot[:],
|
||||
}
|
||||
vmenv.Reset(NewEVMTxContext(msg), statedb)
|
||||
statedb.AddAddressToAccessList(params.BeaconRootsAddress)
|
||||
txctx := NewEVMTxContext(msg)
|
||||
vmenv.Reset(txctx, statedb)
|
||||
if vmenv.ChainConfig().Rules(num, true, time).IsEIP2929 {
|
||||
statedb.AddAddressToAccessList(params.BeaconRootsAddress)
|
||||
}
|
||||
_, _, _ = vmenv.Call(vm.AccountRef(msg.From), *msg.To, msg.Data, 30_000_000, common.U2560)
|
||||
if vmenv.ChainConfig().Rules(num, true, time).IsEIP4762 {
|
||||
statedb.Witness().Merge(txctx.Accesses)
|
||||
}
|
||||
statedb.Finalise(true)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ func (miner *Miner) prepareWork(genParams *generateParams) (*environment, error)
|
|||
if header.ParentBeaconRoot != nil {
|
||||
context := core.NewEVMBlockContext(header, miner.chain, nil)
|
||||
vmenv := vm.NewEVM(context, vm.TxContext{}, env.state, miner.chainConfig, vm.Config{})
|
||||
core.ProcessBeaconBlockRoot(*header.ParentBeaconRoot, vmenv, env.state)
|
||||
core.ProcessBeaconBlockRoot(*header.ParentBeaconRoot, vmenv, env.state, env.header.Number, env.header.Time)
|
||||
}
|
||||
return env, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue