@@ -22,13 +22,21 @@ import (
2222
2323 "github.com/ethereum/go-ethereum/common"
2424 "github.com/ethereum/go-ethereum/core/types"
25+ "github.com/ethereum/go-ethereum/log"
2526)
2627
2728type accessList struct {
2829 addresses map [common.Address ]int
2930 slots []map [common.Hash ]struct {}
3031}
3132
33+ // newAccessList creates a new accessList.
34+ func newAccessList () * accessList {
35+ return & accessList {
36+ addresses : make (map [common.Address ]int ),
37+ }
38+ }
39+
3240func (al * accessList ) AddAddress (address common.Address ) {
3341 // Set address if not previously present
3442 if _ , present := al .addresses [address ]; ! present {
@@ -61,7 +69,7 @@ func (al *accessList) DeleteAddressIfNoSlotSet(address common.Address) {
6169
6270// Copy creates an independent copy of an accessList.
6371func (a * accessList ) Copy () * accessList {
64- cp := new ( accessList )
72+ cp := newAccessList ( )
6573 for k , v := range a .addresses {
6674 cp .addresses [k ] = v
6775 }
@@ -82,7 +90,7 @@ func (a *accessList) ToAccessList() *types.AccessList {
8290 var tuple types.AccessTuple
8391 tuple .Address = addr
8492 // addresses without slots are saved as -1
85- if idx > 0 {
93+ if idx >= 0 {
8694 keys := make ([]common.Hash , 0 , len (a .slots [idx ]))
8795 for key := range a .slots [idx ] {
8896 keys = append (keys , key )
@@ -96,14 +104,15 @@ func (a *accessList) ToAccessList() *types.AccessList {
96104}
97105
98106type AccessListTracer struct {
99- list accessList
100- err error
107+ list * accessList
101108}
102109
103110func (a * AccessListTracer ) CaptureStart (env * EVM , from common.Address , to common.Address , create bool , input []byte , gas uint64 , value * big.Int ) {
111+ a .list = newAccessList ()
104112}
105113
106114func (a * AccessListTracer ) CaptureState (env * EVM , pc uint64 , op OpCode , gas , cost uint64 , scope * ScopeContext , rData []byte , depth int , err error ) {
115+ log .Trace ("Capturing State" , "op" , op )
107116 stack := scope .Stack
108117 if (op == SLOAD || op == SSTORE ) && stack .len () >= 1 {
109118 slot := common .Hash (stack .data [stack .len ()- 1 ].Bytes32 ())
0 commit comments