forked from forks/go-ethereum
internal/ethapi: exclude 7702 authorities from result in eth_createAccessList (#31336)
closes https://github.com/ethereum/go-ethereum/issues/31335 --------- Co-authored-by: sashabeton <sashabeton2007@gmail.com>
This commit is contained in:
parent
4dfec7e83e
commit
c49aadc4b6
2 changed files with 29 additions and 12 deletions
|
|
@ -103,16 +103,10 @@ type AccessListTracer struct {
|
|||
// NewAccessListTracer creates a new tracer that can generate AccessLists.
|
||||
// An optional AccessList can be specified to occupy slots and addresses in
|
||||
// the resulting accesslist.
|
||||
func NewAccessListTracer(acl types.AccessList, from, to common.Address, precompiles []common.Address) *AccessListTracer {
|
||||
excl := map[common.Address]struct{}{
|
||||
from: {}, to: {},
|
||||
}
|
||||
for _, addr := range precompiles {
|
||||
excl[addr] = struct{}{}
|
||||
}
|
||||
func NewAccessListTracer(acl types.AccessList, addressesToExclude map[common.Address]struct{}) *AccessListTracer {
|
||||
list := newAccessList()
|
||||
for _, al := range acl {
|
||||
if _, ok := excl[al.Address]; !ok {
|
||||
if _, ok := addressesToExclude[al.Address]; !ok {
|
||||
list.addAddress(al.Address)
|
||||
}
|
||||
for _, slot := range al.StorageKeys {
|
||||
|
|
@ -120,7 +114,7 @@ func NewAccessListTracer(acl types.AccessList, from, to common.Address, precompi
|
|||
}
|
||||
}
|
||||
return &AccessListTracer{
|
||||
excl: excl,
|
||||
excl: addressesToExclude,
|
||||
list: list,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1166,10 +1166,33 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
|
|||
// Retrieve the precompiles since they don't need to be added to the access list
|
||||
precompiles := vm.ActivePrecompiles(b.ChainConfig().Rules(header.Number, isPostMerge, header.Time))
|
||||
|
||||
// addressesToExclude contains sender, receiver, precompiles and valid authorizations
|
||||
addressesToExclude := map[common.Address]struct{}{args.from(): {}, to: {}}
|
||||
for _, addr := range precompiles {
|
||||
addressesToExclude[addr] = struct{}{}
|
||||
}
|
||||
|
||||
// Prevent redundant operations if args contain more authorizations than EVM may handle
|
||||
maxAuthorizations := uint64(*args.Gas) / params.CallNewAccountGas
|
||||
if uint64(len(args.AuthorizationList)) > maxAuthorizations {
|
||||
return nil, 0, nil, errors.New("insufficient gas to process all authorizations")
|
||||
}
|
||||
|
||||
for _, auth := range args.AuthorizationList {
|
||||
// Duplicating stateTransition.validateAuthorization() logic
|
||||
if (!auth.ChainID.IsZero() && auth.ChainID.CmpBig(b.ChainConfig().ChainID) != 0) || auth.Nonce+1 < auth.Nonce {
|
||||
continue
|
||||
}
|
||||
|
||||
if authority, err := auth.Authority(); err == nil {
|
||||
addressesToExclude[authority] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// Create an initial tracer
|
||||
prevTracer := logger.NewAccessListTracer(nil, args.from(), to, precompiles)
|
||||
prevTracer := logger.NewAccessListTracer(nil, addressesToExclude)
|
||||
if args.AccessList != nil {
|
||||
prevTracer = logger.NewAccessListTracer(*args.AccessList, args.from(), to, precompiles)
|
||||
prevTracer = logger.NewAccessListTracer(*args.AccessList, addressesToExclude)
|
||||
}
|
||||
for {
|
||||
if err := ctx.Err(); err != nil {
|
||||
|
|
@ -1186,7 +1209,7 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
|
|||
msg := args.ToMessage(header.BaseFee, true, true)
|
||||
|
||||
// Apply the transaction with the access list tracer
|
||||
tracer := logger.NewAccessListTracer(accessList, args.from(), to, precompiles)
|
||||
tracer := logger.NewAccessListTracer(accessList, addressesToExclude)
|
||||
config := vm.Config{Tracer: tracer.Hooks(), NoBaseFee: true}
|
||||
evm := b.GetEVM(ctx, statedb, header, &config, nil)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue