mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
Focus on gas charges and remove witness-building parts
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
This commit is contained in:
parent
04a4fe14d9
commit
3777222b86
5 changed files with 8 additions and 17 deletions
|
|
@ -360,12 +360,6 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.
|
|||
amount := new(uint256.Int).SetUint64(w.Amount)
|
||||
amount = amount.Mul(amount, uint256.NewInt(params.GWei))
|
||||
state.AddBalance(w.Address, amount, tracing.BalanceIncreaseWithdrawal)
|
||||
|
||||
// Add the balance of each withdrawal to the witness, no gas will
|
||||
// be charged.
|
||||
if chain.Config().IsEIP4762(header.Number, header.Time) {
|
||||
state.AccessEvents().BalanceGas(w.Address[:], true)
|
||||
}
|
||||
}
|
||||
// No block reward which is issued by consensus layer instead.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ func (ae *AccessEvents) Merge(other *AccessEvents) {
|
|||
}
|
||||
}
|
||||
|
||||
// Key returns, predictably, the list of keys that were touched during the
|
||||
// Keys returns, predictably, the list of keys that were touched during the
|
||||
// buildup of the access witness.
|
||||
func (ae *AccessEvents) Keys() [][]byte {
|
||||
// TODO: consider if parallelizing this is worth it, probably depending on len(ae.chunks).
|
||||
|
|
@ -173,7 +173,6 @@ func (ae *AccessEvents) touchAddressAndChargeGas(addr []byte, treeIndex uint256.
|
|||
if selectorFill {
|
||||
gas += params.WitnessChunkFillCost
|
||||
}
|
||||
|
||||
return gas
|
||||
}
|
||||
|
||||
|
|
@ -206,10 +205,8 @@ func (ae *AccessEvents) touchAddress(addr []byte, treeIndex uint256.Int, subInde
|
|||
chunkWrite = true
|
||||
ae.chunks[chunkKey] |= AccessWitnessWriteFlag
|
||||
}
|
||||
|
||||
// TODO: charge chunk filling costs if the leaf was previously empty in the state
|
||||
}
|
||||
|
||||
return branchRead, chunkRead, branchWrite, chunkWrite, chunkFill
|
||||
}
|
||||
|
||||
|
|
@ -268,7 +265,6 @@ func (ae *AccessEvents) CodeChunksRangeGas(contractAddr []byte, startPC, size ui
|
|||
panic("overflow when adding gas")
|
||||
}
|
||||
}
|
||||
|
||||
return statelessGasCharged
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1297,6 +1297,9 @@ func (s *StateDB) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, er
|
|||
// - Add coinbase to access list (EIP-3651)
|
||||
// - Reset transient storage (EIP-1153)
|
||||
func (s *StateDB) Prepare(rules params.Rules, sender, coinbase common.Address, dst *common.Address, precompiles []common.Address, list types.AccessList) {
|
||||
if rules.IsEIP2929 && rules.IsEIP4762 {
|
||||
panic("eip2929 and eip4762 are both activated")
|
||||
}
|
||||
if rules.IsEIP2929 {
|
||||
// Clear out any leftover from previous executions
|
||||
al := newAccessList()
|
||||
|
|
|
|||
|
|
@ -208,8 +208,5 @@ func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *stat
|
|||
statedb.AddAddressToAccessList(params.BeaconRootsAddress)
|
||||
}
|
||||
_, _, _ = vmenv.Call(vm.AccountRef(msg.From), *msg.To, msg.Data, 30_000_000, common.U2560)
|
||||
if vmenv.ChainConfig().Rules(vmenv.Context.BlockNumber, true, vmenv.Context.Time).IsEIP4762 {
|
||||
statedb.AccessEvents().Merge(txctx.AccessEvents)
|
||||
}
|
||||
statedb.Finalise(true)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -921,6 +921,7 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
|
|||
}
|
||||
// disallow setting Merge out of order
|
||||
isMerge = isMerge && c.IsLondon(num)
|
||||
isVerkle := isMerge && c.IsVerkle(num, timestamp)
|
||||
return Rules{
|
||||
ChainID: new(big.Int).Set(chainID),
|
||||
IsHomestead: c.IsHomestead(num),
|
||||
|
|
@ -932,13 +933,13 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
|
|||
IsPetersburg: c.IsPetersburg(num),
|
||||
IsIstanbul: c.IsIstanbul(num),
|
||||
IsBerlin: c.IsBerlin(num),
|
||||
IsEIP2929: c.IsBerlin(num) && !c.IsVerkle(num, timestamp),
|
||||
IsEIP4762: c.IsVerkle(num, timestamp),
|
||||
IsEIP2929: c.IsBerlin(num) && !isVerkle,
|
||||
IsLondon: c.IsLondon(num),
|
||||
IsMerge: isMerge,
|
||||
IsShanghai: isMerge && c.IsShanghai(num, timestamp),
|
||||
IsCancun: isMerge && c.IsCancun(num, timestamp),
|
||||
IsPrague: isMerge && c.IsPrague(num, timestamp),
|
||||
IsVerkle: isMerge && c.IsVerkle(num, timestamp),
|
||||
IsVerkle: isVerkle,
|
||||
IsEIP4762: isVerkle,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue