mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
rename AccessWitness to AccessEvents
This commit is contained in:
parent
c65d117a92
commit
4030cdd81f
10 changed files with 82 additions and 82 deletions
|
|
@ -364,7 +364,7 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.
|
||||||
// Add the balance of each withdrawal to the witness, no gas will
|
// Add the balance of each withdrawal to the witness, no gas will
|
||||||
// be charged.
|
// be charged.
|
||||||
if chain.Config().IsEIP4762(header.Number, header.Time) {
|
if chain.Config().IsEIP4762(header.Number, header.Time) {
|
||||||
state.Witness().BalanceGas(w.Address[:], true)
|
state.AccessEvents().BalanceGas(w.Address[:], true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// No block reward which is issued by consensus layer instead.
|
// No block reward which is issued by consensus layer instead.
|
||||||
|
|
|
||||||
|
|
@ -37,27 +37,27 @@ const (
|
||||||
|
|
||||||
var zeroTreeIndex uint256.Int
|
var zeroTreeIndex uint256.Int
|
||||||
|
|
||||||
// AccessWitness lists the locations of the state that are being accessed
|
// AccessEvents lists the locations of the state that are being accessed
|
||||||
// during the production of a block.
|
// during the production of a block.
|
||||||
type AccessWitness struct {
|
type AccessEvents struct {
|
||||||
branches map[branchAccessKey]mode
|
branches map[branchAccessKey]mode
|
||||||
chunks map[chunkAccessKey]mode
|
chunks map[chunkAccessKey]mode
|
||||||
|
|
||||||
pointCache *utils.PointCache
|
pointCache *utils.PointCache
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAccessWitness(pointCache *utils.PointCache) *AccessWitness {
|
func NewAccessEvents(pointCache *utils.PointCache) *AccessEvents {
|
||||||
return &AccessWitness{
|
return &AccessEvents{
|
||||||
branches: make(map[branchAccessKey]mode),
|
branches: make(map[branchAccessKey]mode),
|
||||||
chunks: make(map[chunkAccessKey]mode),
|
chunks: make(map[chunkAccessKey]mode),
|
||||||
pointCache: pointCache,
|
pointCache: pointCache,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge is used to merge the witness that got generated during the execution
|
// Merge is used to merge the access events that were generated during the
|
||||||
// of a tx, with the accumulation of witnesses that were generated during the
|
// execution of a tx, with the accumulation of all access events that were
|
||||||
// execution of all the txs preceding this one in a given block.
|
// generated during the execution of all txs preceding this one in a block.
|
||||||
func (aw *AccessWitness) Merge(other *AccessWitness) {
|
func (aw *AccessEvents) Merge(other *AccessEvents) {
|
||||||
for k := range other.branches {
|
for k := range other.branches {
|
||||||
aw.branches[k] |= other.branches[k]
|
aw.branches[k] |= other.branches[k]
|
||||||
}
|
}
|
||||||
|
|
@ -68,7 +68,7 @@ func (aw *AccessWitness) Merge(other *AccessWitness) {
|
||||||
|
|
||||||
// Key returns, predictably, the list of keys that were touched during the
|
// Key returns, predictably, the list of keys that were touched during the
|
||||||
// buildup of the access witness.
|
// buildup of the access witness.
|
||||||
func (aw *AccessWitness) Keys() [][]byte {
|
func (aw *AccessEvents) Keys() [][]byte {
|
||||||
// TODO: consider if parallelizing this is worth it, probably depending on len(aw.chunks).
|
// TODO: consider if parallelizing this is worth it, probably depending on len(aw.chunks).
|
||||||
keys := make([][]byte, 0, len(aw.chunks))
|
keys := make([][]byte, 0, len(aw.chunks))
|
||||||
for chunk := range aw.chunks {
|
for chunk := range aw.chunks {
|
||||||
|
|
@ -79,8 +79,8 @@ func (aw *AccessWitness) Keys() [][]byte {
|
||||||
return keys
|
return keys
|
||||||
}
|
}
|
||||||
|
|
||||||
func (aw *AccessWitness) Copy() *AccessWitness {
|
func (aw *AccessEvents) Copy() *AccessEvents {
|
||||||
naw := &AccessWitness{
|
naw := &AccessEvents{
|
||||||
branches: make(map[branchAccessKey]mode),
|
branches: make(map[branchAccessKey]mode),
|
||||||
chunks: make(map[chunkAccessKey]mode),
|
chunks: make(map[chunkAccessKey]mode),
|
||||||
pointCache: aw.pointCache,
|
pointCache: aw.pointCache,
|
||||||
|
|
@ -91,7 +91,7 @@ func (aw *AccessWitness) Copy() *AccessWitness {
|
||||||
|
|
||||||
// AddAccount returns the gas to be charged for each of the currently cold
|
// AddAccount returns the gas to be charged for each of the currently cold
|
||||||
// member fields of an account.
|
// member fields of an account.
|
||||||
func (aw *AccessWitness) AddAccount(addr []byte, isWrite bool) uint64 {
|
func (aw *AccessEvents) AddAccount(addr []byte, isWrite bool) uint64 {
|
||||||
var gas uint64
|
var gas uint64
|
||||||
for i := utils.VersionLeafKey; i <= utils.CodeSizeLeafKey; i++ {
|
for i := utils.VersionLeafKey; i <= utils.CodeSizeLeafKey; i++ {
|
||||||
gas += aw.touchAddressAndChargeGas(addr, zeroTreeIndex, byte(i), isWrite)
|
gas += aw.touchAddressAndChargeGas(addr, zeroTreeIndex, byte(i), isWrite)
|
||||||
|
|
@ -102,7 +102,7 @@ func (aw *AccessWitness) AddAccount(addr []byte, isWrite bool) uint64 {
|
||||||
// MessageCallGas returns the gas to be charged for each of the currently
|
// MessageCallGas returns the gas to be charged for each of the currently
|
||||||
// cold member fields of an account, that need to be touched when making a message
|
// cold member fields of an account, that need to be touched when making a message
|
||||||
// call to that account.
|
// call to that account.
|
||||||
func (aw *AccessWitness) MessageCallGas(destination []byte) uint64 {
|
func (aw *AccessEvents) MessageCallGas(destination []byte) uint64 {
|
||||||
var gas uint64
|
var gas uint64
|
||||||
gas += aw.touchAddressAndChargeGas(destination, zeroTreeIndex, utils.VersionLeafKey, false)
|
gas += aw.touchAddressAndChargeGas(destination, zeroTreeIndex, utils.VersionLeafKey, false)
|
||||||
gas += aw.touchAddressAndChargeGas(destination, zeroTreeIndex, utils.CodeSizeLeafKey, false)
|
gas += aw.touchAddressAndChargeGas(destination, zeroTreeIndex, utils.CodeSizeLeafKey, false)
|
||||||
|
|
@ -111,7 +111,7 @@ func (aw *AccessWitness) MessageCallGas(destination []byte) uint64 {
|
||||||
|
|
||||||
// ValueTransferGas returns the gas to be charged for each of the currently
|
// ValueTransferGas returns the gas to be charged for each of the currently
|
||||||
// cold balance member fields of the caller and the callee accounts.
|
// cold balance member fields of the caller and the callee accounts.
|
||||||
func (aw *AccessWitness) ValueTransferGas(callerAddr, targetAddr []byte) uint64 {
|
func (aw *AccessEvents) ValueTransferGas(callerAddr, targetAddr []byte) uint64 {
|
||||||
var gas uint64
|
var gas uint64
|
||||||
gas += aw.touchAddressAndChargeGas(callerAddr, zeroTreeIndex, utils.BalanceLeafKey, true)
|
gas += aw.touchAddressAndChargeGas(callerAddr, zeroTreeIndex, utils.BalanceLeafKey, true)
|
||||||
gas += aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.BalanceLeafKey, true)
|
gas += aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.BalanceLeafKey, true)
|
||||||
|
|
@ -120,7 +120,7 @@ func (aw *AccessWitness) ValueTransferGas(callerAddr, targetAddr []byte) uint64
|
||||||
|
|
||||||
// ContractCreateInitGas returns the access gas costs for the initialization of
|
// ContractCreateInitGas returns the access gas costs for the initialization of
|
||||||
// a contract creation.
|
// a contract creation.
|
||||||
func (aw *AccessWitness) ContractCreateInitGas(addr []byte, createSendsValue bool) uint64 {
|
func (aw *AccessEvents) ContractCreateInitGas(addr []byte, createSendsValue bool) uint64 {
|
||||||
var gas uint64
|
var gas uint64
|
||||||
gas += aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.VersionLeafKey, true)
|
gas += aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.VersionLeafKey, true)
|
||||||
gas += aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.NonceLeafKey, true)
|
gas += aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.NonceLeafKey, true)
|
||||||
|
|
@ -132,7 +132,7 @@ func (aw *AccessWitness) ContractCreateInitGas(addr []byte, createSendsValue boo
|
||||||
|
|
||||||
// AddTxOrigin adds the member fields of the sender account to the witness,
|
// AddTxOrigin adds the member fields of the sender account to the witness,
|
||||||
// so that cold accesses are not charged, since they are covered by the 21000 gas.
|
// so that cold accesses are not charged, since they are covered by the 21000 gas.
|
||||||
func (aw *AccessWitness) AddTxOrigin(originAddr []byte) {
|
func (aw *AccessEvents) AddTxOrigin(originAddr []byte) {
|
||||||
for i := utils.VersionLeafKey; i <= utils.CodeSizeLeafKey; i++ {
|
for i := utils.VersionLeafKey; i <= utils.CodeSizeLeafKey; i++ {
|
||||||
aw.touchAddressAndChargeGas(originAddr, zeroTreeIndex, byte(i), i == utils.BalanceLeafKey || i == utils.NonceLeafKey)
|
aw.touchAddressAndChargeGas(originAddr, zeroTreeIndex, byte(i), i == utils.BalanceLeafKey || i == utils.NonceLeafKey)
|
||||||
}
|
}
|
||||||
|
|
@ -140,21 +140,21 @@ func (aw *AccessWitness) AddTxOrigin(originAddr []byte) {
|
||||||
|
|
||||||
// AddTxDestination adds the member fields of the sender account to the witness,
|
// AddTxDestination adds the member fields of the sender account to the witness,
|
||||||
// so that cold accesses are not charged, since they are covered by the 21000 gas.
|
// so that cold accesses are not charged, since they are covered by the 21000 gas.
|
||||||
func (aw *AccessWitness) AddTxDestination(targetAddr []byte, sendsValue bool) {
|
func (aw *AccessEvents) AddTxDestination(targetAddr []byte, sendsValue bool) {
|
||||||
for i := utils.VersionLeafKey; i <= utils.CodeSizeLeafKey; i++ {
|
for i := utils.VersionLeafKey; i <= utils.CodeSizeLeafKey; i++ {
|
||||||
aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, byte(i), i == utils.VersionLeafKey && sendsValue)
|
aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, byte(i), i == utils.VersionLeafKey && sendsValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SlotGas returns the amount of gas to be charged for a cold storage access.
|
// SlotGas returns the amount of gas to be charged for a cold storage access.
|
||||||
func (aw *AccessWitness) SlotGas(addr []byte, slot common.Hash, isWrite bool) uint64 {
|
func (aw *AccessEvents) SlotGas(addr []byte, slot common.Hash, isWrite bool) uint64 {
|
||||||
treeIndex, subIndex := utils.StorageIndex(slot.Bytes())
|
treeIndex, subIndex := utils.StorageIndex(slot.Bytes())
|
||||||
return aw.touchAddressAndChargeGas(addr, *treeIndex, subIndex, isWrite)
|
return aw.touchAddressAndChargeGas(addr, *treeIndex, subIndex, isWrite)
|
||||||
}
|
}
|
||||||
|
|
||||||
// touchAddressAndChargeGas adds any missing access event to the witness, and returns the cold
|
// touchAddressAndChargeGas adds any missing access event to the witness, and returns the cold
|
||||||
// access cost to be charged, if need be.
|
// access cost to be charged, if need be.
|
||||||
func (aw *AccessWitness) touchAddressAndChargeGas(addr []byte, treeIndex uint256.Int, subIndex byte, isWrite bool) uint64 {
|
func (aw *AccessEvents) touchAddressAndChargeGas(addr []byte, treeIndex uint256.Int, subIndex byte, isWrite bool) uint64 {
|
||||||
stemRead, selectorRead, stemWrite, selectorWrite, selectorFill := aw.touchAddress(addr, treeIndex, subIndex, isWrite)
|
stemRead, selectorRead, stemWrite, selectorWrite, selectorFill := aw.touchAddress(addr, treeIndex, subIndex, isWrite)
|
||||||
|
|
||||||
var gas uint64
|
var gas uint64
|
||||||
|
|
@ -178,7 +178,7 @@ func (aw *AccessWitness) touchAddressAndChargeGas(addr []byte, treeIndex uint256
|
||||||
}
|
}
|
||||||
|
|
||||||
// touchAddress adds any missing access event to the witness.
|
// touchAddress adds any missing access event to the witness.
|
||||||
func (aw *AccessWitness) touchAddress(addr []byte, treeIndex uint256.Int, subIndex byte, isWrite bool) (bool, bool, bool, bool, bool) {
|
func (aw *AccessEvents) touchAddress(addr []byte, treeIndex uint256.Int, subIndex byte, isWrite bool) (bool, bool, bool, bool, bool) {
|
||||||
branchKey := newBranchAccessKey(addr, treeIndex)
|
branchKey := newBranchAccessKey(addr, treeIndex)
|
||||||
chunkKey := newChunkAccessKey(branchKey, subIndex)
|
chunkKey := newChunkAccessKey(branchKey, subIndex)
|
||||||
|
|
||||||
|
|
@ -238,7 +238,7 @@ func newChunkAccessKey(branchKey branchAccessKey, leafKey byte) chunkAccessKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
// touchCodeChunksRangeOnReadAndChargeGas is a helper function to touch every chunk in a code range and charge witness gas costs
|
// touchCodeChunksRangeOnReadAndChargeGas is a helper function to touch every chunk in a code range and charge witness gas costs
|
||||||
func (aw *AccessWitness) CodeChunksRangeGas(contractAddr []byte, startPC, size uint64, codeLen uint64, isWrite bool) uint64 {
|
func (aw *AccessEvents) CodeChunksRangeGas(contractAddr []byte, startPC, size uint64, codeLen uint64, isWrite bool) uint64 {
|
||||||
// note that in the case where the copied code is outside the range of the
|
// note that in the case where the copied code is outside the range of the
|
||||||
// contract code but touches the last leaf with contract code in it,
|
// contract code but touches the last leaf with contract code in it,
|
||||||
// we don't include the last leaf of code in the AccessWitness. The
|
// we don't include the last leaf of code in the AccessWitness. The
|
||||||
|
|
@ -272,22 +272,22 @@ func (aw *AccessWitness) CodeChunksRangeGas(contractAddr []byte, startPC, size u
|
||||||
return statelessGasCharged
|
return statelessGasCharged
|
||||||
}
|
}
|
||||||
|
|
||||||
func (aw *AccessWitness) VersionGas(addr []byte, isWrite bool) uint64 {
|
func (aw *AccessEvents) VersionGas(addr []byte, isWrite bool) uint64 {
|
||||||
return aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.VersionLeafKey, isWrite)
|
return aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.VersionLeafKey, isWrite)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (aw *AccessWitness) BalanceGas(addr []byte, isWrite bool) uint64 {
|
func (aw *AccessEvents) BalanceGas(addr []byte, isWrite bool) uint64 {
|
||||||
return aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.BalanceLeafKey, isWrite)
|
return aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.BalanceLeafKey, isWrite)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (aw *AccessWitness) NonceGas(addr []byte, isWrite bool) uint64 {
|
func (aw *AccessEvents) NonceGas(addr []byte, isWrite bool) uint64 {
|
||||||
return aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.NonceLeafKey, isWrite)
|
return aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.NonceLeafKey, isWrite)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (aw *AccessWitness) CodeSizeGas(addr []byte, isWrite bool) uint64 {
|
func (aw *AccessEvents) CodeSizeGas(addr []byte, isWrite bool) uint64 {
|
||||||
return aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.CodeSizeLeafKey, isWrite)
|
return aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.CodeSizeLeafKey, isWrite)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (aw *AccessWitness) CodeHashGas(addr []byte, isWrite bool) uint64 {
|
func (aw *AccessEvents) CodeHashGas(addr []byte, isWrite bool) uint64 {
|
||||||
return aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.CodeKeccakLeafKey, isWrite)
|
return aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.CodeKeccakLeafKey, isWrite)
|
||||||
}
|
}
|
||||||
|
|
@ -140,8 +140,8 @@ type StateDB struct {
|
||||||
// Transient storage
|
// Transient storage
|
||||||
transientStorage transientStorage
|
transientStorage transientStorage
|
||||||
|
|
||||||
// Verkle witness
|
// State access events, used for Verkle tries/EIP4762
|
||||||
witness *AccessWitness
|
accessEvents *AccessEvents
|
||||||
|
|
||||||
// Journal of state modifications. This is the backbone of
|
// Journal of state modifications. This is the backbone of
|
||||||
// Snapshot and RevertToSnapshot.
|
// Snapshot and RevertToSnapshot.
|
||||||
|
|
@ -198,7 +198,7 @@ func New(root common.Hash, db Database, snaps *snapshot.Tree) (*StateDB, error)
|
||||||
hasher: crypto.NewKeccakState(),
|
hasher: crypto.NewKeccakState(),
|
||||||
}
|
}
|
||||||
if tr.IsVerkle() {
|
if tr.IsVerkle() {
|
||||||
sdb.witness = sdb.NewAccessWitness()
|
sdb.accessEvents = sdb.NewAccessEvents()
|
||||||
}
|
}
|
||||||
if sdb.snaps != nil {
|
if sdb.snaps != nil {
|
||||||
sdb.snap = sdb.snaps.Snapshot(root)
|
sdb.snap = sdb.snaps.Snapshot(root)
|
||||||
|
|
@ -206,19 +206,19 @@ func New(root common.Hash, db Database, snaps *snapshot.Tree) (*StateDB, error)
|
||||||
return sdb, nil
|
return sdb, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StateDB) NewAccessWitness() *AccessWitness {
|
func (s *StateDB) NewAccessEvents() *AccessEvents {
|
||||||
return NewAccessWitness(utils.NewPointCache(100))
|
return NewAccessEvents(utils.NewPointCache(100))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StateDB) Witness() *AccessWitness {
|
func (s *StateDB) AccessEvents() *AccessEvents {
|
||||||
if s.witness == nil {
|
if s.accessEvents == nil {
|
||||||
s.witness = s.NewAccessWitness()
|
s.accessEvents = s.NewAccessEvents()
|
||||||
}
|
}
|
||||||
return s.witness
|
return s.accessEvents
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StateDB) SetWitness(aw *AccessWitness) {
|
func (s *StateDB) SetAccessEvents(ae *AccessEvents) {
|
||||||
s.witness = aw
|
s.accessEvents = ae
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLogger sets the logger for account update hooks.
|
// SetLogger sets the logger for account update hooks.
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ func ApplyTransactionWithEVM(msg *Message, config *params.ChainConfig, gp *GasPo
|
||||||
}
|
}
|
||||||
// Create a new context to be used in the EVM environment.
|
// Create a new context to be used in the EVM environment.
|
||||||
txContext := NewEVMTxContext(msg)
|
txContext := NewEVMTxContext(msg)
|
||||||
txContext.Accesses = statedb.NewAccessWitness()
|
txContext.AccessEvents = statedb.NewAccessEvents()
|
||||||
evm.Reset(txContext, statedb)
|
evm.Reset(txContext, statedb)
|
||||||
|
|
||||||
// Apply the transaction to the current state (included in the env).
|
// Apply the transaction to the current state (included in the env).
|
||||||
|
|
@ -159,8 +159,8 @@ func ApplyTransactionWithEVM(msg *Message, config *params.ChainConfig, gp *GasPo
|
||||||
receipt.ContractAddress = crypto.CreateAddress(evm.TxContext.Origin, tx.Nonce())
|
receipt.ContractAddress = crypto.CreateAddress(evm.TxContext.Origin, tx.Nonce())
|
||||||
}
|
}
|
||||||
|
|
||||||
if statedb.Witness() != nil {
|
if statedb.AccessEvents() != nil {
|
||||||
statedb.Witness().Merge(txContext.Accesses)
|
statedb.AccessEvents().Merge(txContext.AccessEvents)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the receipt logs and create the bloom filter.
|
// Set the receipt logs and create the bloom filter.
|
||||||
|
|
@ -209,7 +209,7 @@ func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *stat
|
||||||
}
|
}
|
||||||
_, _, _ = vmenv.Call(vm.AccountRef(msg.From), *msg.To, msg.Data, 30_000_000, common.U2560)
|
_, _, _ = 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 {
|
if vmenv.ChainConfig().Rules(vmenv.Context.BlockNumber, true, vmenv.Context.Time).IsEIP4762 {
|
||||||
statedb.Witness().Merge(txctx.Accesses)
|
statedb.AccessEvents().Merge(txctx.AccessEvents)
|
||||||
}
|
}
|
||||||
statedb.Finalise(true)
|
statedb.Finalise(true)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -422,10 +422,10 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
|
||||||
targetAddr := msg.To
|
targetAddr := msg.To
|
||||||
originAddr := msg.From
|
originAddr := msg.From
|
||||||
|
|
||||||
st.evm.Accesses.AddTxOrigin(originAddr.Bytes())
|
st.evm.AccessEvents.AddTxOrigin(originAddr.Bytes())
|
||||||
|
|
||||||
if msg.To != nil {
|
if msg.To != nil {
|
||||||
st.evm.Accesses.AddTxDestination(targetAddr.Bytes(), msg.Value.Sign() != 0)
|
st.evm.AccessEvents.AddTxDestination(targetAddr.Bytes(), msg.Value.Sign() != 0)
|
||||||
|
|
||||||
// ensure the code size ends up in the access witness
|
// ensure the code size ends up in the access witness
|
||||||
st.evm.StateDB.GetCodeSize(*targetAddr)
|
st.evm.StateDB.GetCodeSize(*targetAddr)
|
||||||
|
|
@ -488,7 +488,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
|
||||||
|
|
||||||
// add the coinbase to the witness iff the fee is greater than 0
|
// add the coinbase to the witness iff the fee is greater than 0
|
||||||
if rules.IsEIP4762 && fee.Sign() != 0 {
|
if rules.IsEIP4762 && fee.Sign() != 0 {
|
||||||
st.evm.Accesses.BalanceGas(st.evm.Context.Coinbase[:], true)
|
st.evm.AccessEvents.BalanceGas(st.evm.Context.Coinbase[:], true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,7 @@ func opCreateEIP4762(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContex
|
||||||
var endowment = scope.Stack.peek()
|
var endowment = scope.Stack.peek()
|
||||||
|
|
||||||
contractAddress := crypto.CreateAddress(scope.Contract.Address(), interpreter.evm.StateDB.GetNonce(scope.Contract.Address()))
|
contractAddress := crypto.CreateAddress(scope.Contract.Address(), interpreter.evm.StateDB.GetNonce(scope.Contract.Address()))
|
||||||
statelessGas := interpreter.evm.Accesses.ContractCreateInitGas(contractAddress.Bytes()[:], endowment.Sign() != 0)
|
statelessGas := interpreter.evm.AccessEvents.ContractCreateInitGas(contractAddress.Bytes()[:], endowment.Sign() != 0)
|
||||||
if !scope.Contract.UseGas(statelessGas, interpreter.evm.Config.Tracer, tracing.GasChangeUnspecified) {
|
if !scope.Contract.UseGas(statelessGas, interpreter.evm.Config.Tracer, tracing.GasChangeUnspecified) {
|
||||||
return nil, ErrExecutionReverted
|
return nil, ErrExecutionReverted
|
||||||
}
|
}
|
||||||
|
|
@ -352,7 +352,7 @@ func opCreate2EIP4762(pc *uint64, interpreter *EVMInterpreter, scope *ScopeConte
|
||||||
|
|
||||||
codeAndHash := &codeAndHash{code: input}
|
codeAndHash := &codeAndHash{code: input}
|
||||||
contractAddress := crypto.CreateAddress2(scope.Contract.Address(), salt.Bytes32(), codeAndHash.Hash().Bytes())
|
contractAddress := crypto.CreateAddress2(scope.Contract.Address(), salt.Bytes32(), codeAndHash.Hash().Bytes())
|
||||||
statelessGas := interpreter.evm.Accesses.ContractCreateInitGas(contractAddress.Bytes()[:], endowment.Sign() != 0)
|
statelessGas := interpreter.evm.AccessEvents.ContractCreateInitGas(contractAddress.Bytes()[:], endowment.Sign() != 0)
|
||||||
if !scope.Contract.UseGas(statelessGas, interpreter.evm.Config.Tracer, tracing.GasChangeUnspecified) {
|
if !scope.Contract.UseGas(statelessGas, interpreter.evm.Config.Tracer, tracing.GasChangeUnspecified) {
|
||||||
return nil, ErrExecutionReverted
|
return nil, ErrExecutionReverted
|
||||||
}
|
}
|
||||||
|
|
@ -379,7 +379,7 @@ func opExtCodeCopyEIP4762(pc *uint64, interpreter *EVMInterpreter, scope *ScopeC
|
||||||
self: AccountRef(addr),
|
self: AccountRef(addr),
|
||||||
}
|
}
|
||||||
paddedCodeCopy, copyOffset, nonPaddedCopyLength := getDataAndAdjustedBounds(code, uint64CodeOffset, length.Uint64())
|
paddedCodeCopy, copyOffset, nonPaddedCopyLength := getDataAndAdjustedBounds(code, uint64CodeOffset, length.Uint64())
|
||||||
statelessGas := interpreter.evm.Accesses.CodeChunksRangeGas(addr[:], copyOffset, nonPaddedCopyLength, uint64(len(contract.Code)), false)
|
statelessGas := interpreter.evm.AccessEvents.CodeChunksRangeGas(addr[:], copyOffset, nonPaddedCopyLength, uint64(len(contract.Code)), false)
|
||||||
if !scope.Contract.UseGas(statelessGas, interpreter.evm.Config.Tracer, tracing.GasChangeUnspecified) {
|
if !scope.Contract.UseGas(statelessGas, interpreter.evm.Config.Tracer, tracing.GasChangeUnspecified) {
|
||||||
scope.Contract.Gas = 0
|
scope.Contract.Gas = 0
|
||||||
return nil, ErrOutOfGas
|
return nil, ErrOutOfGas
|
||||||
|
|
@ -403,7 +403,7 @@ func opPush1EIP4762(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext
|
||||||
// touch next chunk if PUSH1 is at the boundary. if so, *pc has
|
// touch next chunk if PUSH1 is at the boundary. if so, *pc has
|
||||||
// advanced past this boundary.
|
// advanced past this boundary.
|
||||||
contractAddr := scope.Contract.Address()
|
contractAddr := scope.Contract.Address()
|
||||||
statelessGas := interpreter.evm.Accesses.CodeChunksRangeGas(contractAddr[:], *pc+1, uint64(1), uint64(len(scope.Contract.Code)), false)
|
statelessGas := interpreter.evm.AccessEvents.CodeChunksRangeGas(contractAddr[:], *pc+1, uint64(1), uint64(len(scope.Contract.Code)), false)
|
||||||
if !scope.Contract.UseGas(statelessGas, interpreter.evm.Config.Tracer, tracing.GasChangeUnspecified) {
|
if !scope.Contract.UseGas(statelessGas, interpreter.evm.Config.Tracer, tracing.GasChangeUnspecified) {
|
||||||
scope.Contract.Gas = 0
|
scope.Contract.Gas = 0
|
||||||
return nil, ErrOutOfGas
|
return nil, ErrOutOfGas
|
||||||
|
|
@ -431,7 +431,7 @@ func makePushEIP4762(size uint64, pushByteSize int) executionFunc {
|
||||||
|
|
||||||
if !scope.Contract.IsDeployment {
|
if !scope.Contract.IsDeployment {
|
||||||
contractAddr := scope.Contract.Address()
|
contractAddr := scope.Contract.Address()
|
||||||
statelessGas := interpreter.evm.Accesses.CodeChunksRangeGas(contractAddr[:], uint64(start), uint64(pushByteSize), uint64(len(scope.Contract.Code)), false)
|
statelessGas := interpreter.evm.AccessEvents.CodeChunksRangeGas(contractAddr[:], uint64(start), uint64(pushByteSize), uint64(len(scope.Contract.Code)), false)
|
||||||
if !scope.Contract.UseGas(statelessGas, interpreter.evm.Config.Tracer, tracing.GasChangeUnspecified) {
|
if !scope.Contract.UseGas(statelessGas, interpreter.evm.Config.Tracer, tracing.GasChangeUnspecified) {
|
||||||
scope.Contract.Gas = 0
|
scope.Contract.Gas = 0
|
||||||
return nil, ErrOutOfGas
|
return nil, ErrOutOfGas
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ type TxContext struct {
|
||||||
GasPrice *big.Int // Provides information for GASPRICE (and is used to zero the basefee if NoBaseFee is set)
|
GasPrice *big.Int // Provides information for GASPRICE (and is used to zero the basefee if NoBaseFee is set)
|
||||||
BlobHashes []common.Hash // Provides information for BLOBHASH
|
BlobHashes []common.Hash // Provides information for BLOBHASH
|
||||||
BlobFeeCap *big.Int // Is used to zero the blobbasefee if NoBaseFee is set
|
BlobFeeCap *big.Int // Is used to zero the blobbasefee if NoBaseFee is set
|
||||||
Accesses *state.AccessWitness // Capture all state accesses for this tx
|
AccessEvents *state.AccessEvents // Capture all state accesses for this tx
|
||||||
}
|
}
|
||||||
|
|
||||||
// EVM is the Ethereum Virtual Machine base object and provides
|
// EVM is the Ethereum Virtual Machine base object and provides
|
||||||
|
|
@ -151,8 +151,8 @@ func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig
|
||||||
chainConfig: chainConfig,
|
chainConfig: chainConfig,
|
||||||
chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Random != nil, blockCtx.Time),
|
chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Random != nil, blockCtx.Time),
|
||||||
}
|
}
|
||||||
if txCtx.Accesses == nil && chainConfig.IsPrague(blockCtx.BlockNumber, blockCtx.Time) {
|
if txCtx.AccessEvents == nil && chainConfig.IsPrague(blockCtx.BlockNumber, blockCtx.Time) {
|
||||||
evm.Accesses = evm.StateDB.(*state.StateDB).NewAccessWitness()
|
evm.AccessEvents = evm.StateDB.(*state.StateDB).NewAccessEvents()
|
||||||
}
|
}
|
||||||
evm.interpreter = NewEVMInterpreter(evm)
|
evm.interpreter = NewEVMInterpreter(evm)
|
||||||
return evm
|
return evm
|
||||||
|
|
@ -161,8 +161,8 @@ func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig
|
||||||
// Reset resets the EVM with a new transaction context.Reset
|
// Reset resets the EVM with a new transaction context.Reset
|
||||||
// This is not threadsafe and should only be done very cautiously.
|
// This is not threadsafe and should only be done very cautiously.
|
||||||
func (evm *EVM) Reset(txCtx TxContext, statedb StateDB) {
|
func (evm *EVM) Reset(txCtx TxContext, statedb StateDB) {
|
||||||
if txCtx.Accesses == nil && evm.chainRules.IsPrague {
|
if txCtx.AccessEvents == nil && evm.chainRules.IsPrague {
|
||||||
txCtx.Accesses = evm.StateDB.(*state.StateDB).NewAccessWitness()
|
txCtx.AccessEvents = evm.StateDB.(*state.StateDB).NewAccessEvents()
|
||||||
}
|
}
|
||||||
evm.TxContext = txCtx
|
evm.TxContext = txCtx
|
||||||
evm.StateDB = statedb
|
evm.StateDB = statedb
|
||||||
|
|
@ -211,7 +211,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
|
||||||
if !evm.StateDB.Exist(addr) {
|
if !evm.StateDB.Exist(addr) {
|
||||||
if !isPrecompile && evm.chainRules.IsEIP4762 {
|
if !isPrecompile && evm.chainRules.IsEIP4762 {
|
||||||
// add proof of absence to witness
|
// add proof of absence to witness
|
||||||
wgas := evm.Accesses.AddAccount(addr.Bytes(), false)
|
wgas := evm.AccessEvents.AddAccount(addr.Bytes(), false)
|
||||||
if gas < wgas {
|
if gas < wgas {
|
||||||
evm.StateDB.RevertToSnapshot(snapshot)
|
evm.StateDB.RevertToSnapshot(snapshot)
|
||||||
return nil, 0, ErrOutOfGas
|
return nil, 0, ErrOutOfGas
|
||||||
|
|
@ -504,7 +504,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
|
||||||
|
|
||||||
// Charge the contract creation init gas in verkle mode
|
// Charge the contract creation init gas in verkle mode
|
||||||
if evm.chainRules.IsEIP4762 {
|
if evm.chainRules.IsEIP4762 {
|
||||||
if !contract.UseGas(evm.Accesses.ContractCreateInitGas(address.Bytes(), value.Sign() != 0), evm.Config.Tracer, tracing.GasChangeWitnessContractInit) {
|
if !contract.UseGas(evm.AccessEvents.ContractCreateInitGas(address.Bytes(), value.Sign() != 0), evm.Config.Tracer, tracing.GasChangeWitnessContractInit) {
|
||||||
err = ErrOutOfGas
|
err = ErrOutOfGas
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -535,11 +535,11 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Contract creation completed, touch the missing fields in the contract
|
// Contract creation completed, touch the missing fields in the contract
|
||||||
if !contract.UseGas(evm.Accesses.AddAccount(address.Bytes()[:], true), evm.Config.Tracer, tracing.GasChangeWitnessContractCreation) {
|
if !contract.UseGas(evm.AccessEvents.AddAccount(address.Bytes()[:], true), evm.Config.Tracer, tracing.GasChangeWitnessContractCreation) {
|
||||||
err = ErrCodeStoreOutOfGas
|
err = ErrCodeStoreOutOfGas
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil && len(ret) > 0 && !contract.UseGas(evm.Accesses.CodeChunksRangeGas(address.Bytes(), 0, uint64(len(ret)), uint64(len(ret)), true), evm.Config.Tracer, tracing.GasChangeWitnessCodeChunk) {
|
if err == nil && len(ret) > 0 && !contract.UseGas(evm.AccessEvents.CodeChunksRangeGas(address.Bytes(), 0, uint64(len(ret)), uint64(len(ret)), true), evm.Config.Tracer, tracing.GasChangeWitnessCodeChunk) {
|
||||||
err = ErrCodeStoreOutOfGas
|
err = ErrCodeStoreOutOfGas
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -404,7 +404,7 @@ func gasCall(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize
|
||||||
}
|
}
|
||||||
if evm.chainRules.IsEIP4762 {
|
if evm.chainRules.IsEIP4762 {
|
||||||
if transfersValue {
|
if transfersValue {
|
||||||
gas, overflow = math.SafeAdd(gas, evm.Accesses.ValueTransferGas(contract.Address().Bytes()[:], address.Bytes()[:]))
|
gas, overflow = math.SafeAdd(gas, evm.AccessEvents.ValueTransferGas(contract.Address().Bytes()[:], address.Bytes()[:]))
|
||||||
if overflow {
|
if overflow {
|
||||||
return 0, ErrGasUintOverflow
|
return 0, ErrGasUintOverflow
|
||||||
}
|
}
|
||||||
|
|
@ -440,7 +440,7 @@ func gasCallCode(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memory
|
||||||
address := common.Address(stack.Back(1).Bytes20())
|
address := common.Address(stack.Back(1).Bytes20())
|
||||||
transfersValue := !stack.Back(2).IsZero()
|
transfersValue := !stack.Back(2).IsZero()
|
||||||
if transfersValue {
|
if transfersValue {
|
||||||
gas, overflow = math.SafeAdd(gas, evm.Accesses.ValueTransferGas(contract.Address().Bytes()[:], address.Bytes()[:]))
|
gas, overflow = math.SafeAdd(gas, evm.AccessEvents.ValueTransferGas(contract.Address().Bytes()[:], address.Bytes()[:]))
|
||||||
if overflow {
|
if overflow {
|
||||||
return 0, ErrGasUintOverflow
|
return 0, ErrGasUintOverflow
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
// if the PC ends up in a new "chunk" of verkleized code, charge the
|
// if the PC ends up in a new "chunk" of verkleized code, charge the
|
||||||
// associated costs.
|
// associated costs.
|
||||||
contractAddr := contract.Address()
|
contractAddr := contract.Address()
|
||||||
contract.Gas -= in.evm.TxContext.Accesses.CodeChunksRangeGas(contractAddr[:], pc, 1, uint64(len(contract.Code)), false)
|
contract.Gas -= in.evm.TxContext.AccessEvents.CodeChunksRangeGas(contractAddr[:], pc, 1, uint64(len(contract.Code)), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the operation from the jump table and validate the stack to ensure there are
|
// Get the operation from the jump table and validate the stack to ensure there are
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func gasSStore4762(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
|
func gasSStore4762(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
|
||||||
gas := evm.Accesses.SlotGas(contract.Address().Bytes(), common.Hash(stack.peek().Bytes32()), true)
|
gas := evm.AccessEvents.SlotGas(contract.Address().Bytes(), common.Hash(stack.peek().Bytes32()), true)
|
||||||
if gas == 0 {
|
if gas == 0 {
|
||||||
gas = params.WarmStorageReadCostEIP2929
|
gas = params.WarmStorageReadCostEIP2929
|
||||||
}
|
}
|
||||||
|
|
@ -31,7 +31,7 @@ func gasSStore4762(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memo
|
||||||
}
|
}
|
||||||
|
|
||||||
func gasSLoad4762(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
|
func gasSLoad4762(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
|
||||||
gas := evm.Accesses.SlotGas(contract.Address().Bytes(), common.Hash(stack.peek().Bytes32()), false)
|
gas := evm.AccessEvents.SlotGas(contract.Address().Bytes(), common.Hash(stack.peek().Bytes32()), false)
|
||||||
if gas == 0 {
|
if gas == 0 {
|
||||||
gas = params.WarmStorageReadCostEIP2929
|
gas = params.WarmStorageReadCostEIP2929
|
||||||
}
|
}
|
||||||
|
|
@ -40,7 +40,7 @@ func gasSLoad4762(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memor
|
||||||
|
|
||||||
func gasBalance4762(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
|
func gasBalance4762(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
|
||||||
address := stack.peek().Bytes20()
|
address := stack.peek().Bytes20()
|
||||||
gas := evm.Accesses.BalanceGas(address[:], false)
|
gas := evm.AccessEvents.BalanceGas(address[:], false)
|
||||||
if gas == 0 {
|
if gas == 0 {
|
||||||
gas = params.WarmStorageReadCostEIP2929
|
gas = params.WarmStorageReadCostEIP2929
|
||||||
}
|
}
|
||||||
|
|
@ -52,8 +52,8 @@ func gasExtCodeSize4762(evm *EVM, contract *Contract, stack *Stack, mem *Memory,
|
||||||
if _, isPrecompile := evm.precompile(address); isPrecompile {
|
if _, isPrecompile := evm.precompile(address); isPrecompile {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
wgas := evm.Accesses.VersionGas(address[:], false)
|
wgas := evm.AccessEvents.VersionGas(address[:], false)
|
||||||
wgas += evm.Accesses.CodeSizeGas(address[:], false)
|
wgas += evm.AccessEvents.CodeSizeGas(address[:], false)
|
||||||
if wgas == 0 {
|
if wgas == 0 {
|
||||||
wgas = params.WarmStorageReadCostEIP2929
|
wgas = params.WarmStorageReadCostEIP2929
|
||||||
}
|
}
|
||||||
|
|
@ -65,7 +65,7 @@ func gasExtCodeHash4762(evm *EVM, contract *Contract, stack *Stack, mem *Memory,
|
||||||
if _, isPrecompile := evm.precompile(address); isPrecompile {
|
if _, isPrecompile := evm.precompile(address); isPrecompile {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
codehashgas := evm.Accesses.CodeHashGas(address[:], false)
|
codehashgas := evm.AccessEvents.CodeHashGas(address[:], false)
|
||||||
if codehashgas == 0 {
|
if codehashgas == 0 {
|
||||||
codehashgas = params.WarmStorageReadCostEIP2929
|
codehashgas = params.WarmStorageReadCostEIP2929
|
||||||
}
|
}
|
||||||
|
|
@ -81,7 +81,7 @@ func makeCallVariantGasEIP4762(oldCalculator gasFunc) gasFunc {
|
||||||
if _, isPrecompile := evm.precompile(contract.Address()); isPrecompile {
|
if _, isPrecompile := evm.precompile(contract.Address()); isPrecompile {
|
||||||
return gas, nil
|
return gas, nil
|
||||||
}
|
}
|
||||||
wgas := evm.Accesses.MessageCallGas(contract.Address().Bytes())
|
wgas := evm.AccessEvents.MessageCallGas(contract.Address().Bytes())
|
||||||
if wgas == 0 {
|
if wgas == 0 {
|
||||||
wgas = params.WarmStorageReadCostEIP2929
|
wgas = params.WarmStorageReadCostEIP2929
|
||||||
}
|
}
|
||||||
|
|
@ -102,17 +102,17 @@ func gasSelfdestructEIP4762(evm *EVM, contract *Contract, stack *Stack, mem *Mem
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
contractAddr := contract.Address()
|
contractAddr := contract.Address()
|
||||||
statelessGas := evm.Accesses.VersionGas(contractAddr[:], false)
|
statelessGas := evm.AccessEvents.VersionGas(contractAddr[:], false)
|
||||||
statelessGas += evm.Accesses.CodeSizeGas(contractAddr[:], false)
|
statelessGas += evm.AccessEvents.CodeSizeGas(contractAddr[:], false)
|
||||||
statelessGas += evm.Accesses.BalanceGas(contractAddr[:], false)
|
statelessGas += evm.AccessEvents.BalanceGas(contractAddr[:], false)
|
||||||
if contractAddr != beneficiaryAddr {
|
if contractAddr != beneficiaryAddr {
|
||||||
statelessGas += evm.Accesses.BalanceGas(beneficiaryAddr[:], false)
|
statelessGas += evm.AccessEvents.BalanceGas(beneficiaryAddr[:], false)
|
||||||
}
|
}
|
||||||
// Charge write costs if it transfers value
|
// Charge write costs if it transfers value
|
||||||
if evm.StateDB.GetBalance(contractAddr).Sign() != 0 {
|
if evm.StateDB.GetBalance(contractAddr).Sign() != 0 {
|
||||||
statelessGas += evm.Accesses.BalanceGas(contractAddr[:], true)
|
statelessGas += evm.AccessEvents.BalanceGas(contractAddr[:], true)
|
||||||
if contractAddr != beneficiaryAddr {
|
if contractAddr != beneficiaryAddr {
|
||||||
statelessGas += evm.Accesses.BalanceGas(beneficiaryAddr[:], true)
|
statelessGas += evm.AccessEvents.BalanceGas(beneficiaryAddr[:], true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return statelessGas, nil
|
return statelessGas, nil
|
||||||
|
|
@ -133,7 +133,7 @@ func gasCodeCopyEip4762(evm *EVM, contract *Contract, stack *Stack, mem *Memory,
|
||||||
}
|
}
|
||||||
_, copyOffset, nonPaddedCopyLength := getDataAndAdjustedBounds(contract.Code, uint64CodeOffset, length.Uint64())
|
_, copyOffset, nonPaddedCopyLength := getDataAndAdjustedBounds(contract.Code, uint64CodeOffset, length.Uint64())
|
||||||
if !contract.IsDeployment {
|
if !contract.IsDeployment {
|
||||||
gas += evm.Accesses.CodeChunksRangeGas(contract.Address().Bytes(), copyOffset, nonPaddedCopyLength, uint64(len(contract.Code)), false)
|
gas += evm.AccessEvents.CodeChunksRangeGas(contract.Address().Bytes(), copyOffset, nonPaddedCopyLength, uint64(len(contract.Code)), false)
|
||||||
}
|
}
|
||||||
return gas, nil
|
return gas, nil
|
||||||
}
|
}
|
||||||
|
|
@ -145,8 +145,8 @@ func gasExtCodeCopyEIP4762(evm *EVM, contract *Contract, stack *Stack, mem *Memo
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
addr := common.Address(stack.peek().Bytes20())
|
addr := common.Address(stack.peek().Bytes20())
|
||||||
wgas := evm.Accesses.VersionGas(addr[:], false)
|
wgas := evm.AccessEvents.VersionGas(addr[:], false)
|
||||||
wgas += evm.Accesses.CodeSizeGas(addr[:], false)
|
wgas += evm.AccessEvents.CodeSizeGas(addr[:], false)
|
||||||
if wgas == 0 {
|
if wgas == 0 {
|
||||||
wgas = params.WarmStorageReadCostEIP2929
|
wgas = params.WarmStorageReadCostEIP2929
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue