Skip to content

Commit bddfe08

Browse files
address PR comments
1 parent 7470c19 commit bddfe08

File tree

5 files changed

+26
-63
lines changed

5 files changed

+26
-63
lines changed

core/tracing/hooks.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ type (
172172
LogHook = func(log *types.Log)
173173

174174
CaptureArbitrumTransferHook = func(from, to *common.Address, value *big.Int, before bool, purpose string)
175-
CaptureArbitrumStorageGetHook = func(addr common.Address, key, mappedKey common.Hash, depth int, before bool)
176-
CaptureArbitrumStorageSetHook = func(addr common.Address, key, mappedKey, value common.Hash, depth int, before bool)
175+
CaptureArbitrumStorageGetHook = func(key common.Hash, depth int, before bool)
176+
CaptureArbitrumStorageSetHook = func(key, value common.Hash, depth int, before bool)
177177

178178
CaptureStylusHostioHook = func(name string, args, outs []byte, startInk, endInk uint64)
179179
)

eth/tracers/native/gen_account_json.go

+8-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eth/tracers/native/mux.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,18 @@ func (t *muxTracer) OnLog(log *types.Log) {
177177
}
178178
}
179179

180-
func (t *muxTracer) CaptureArbitrumStorageGet(addr common.Address, key, mappedKey common.Hash, depth int, before bool) {
180+
func (t *muxTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {
181181
for _, t := range t.tracers {
182182
if t.CaptureArbitrumStorageGet != nil {
183-
t.CaptureArbitrumStorageGet(addr, key, mappedKey, depth, before)
183+
t.CaptureArbitrumStorageGet(key, depth, before)
184184
}
185185
}
186186
}
187187

188-
func (t *muxTracer) CaptureArbitrumStorageSet(addr common.Address, key, mappedKey, value common.Hash, depth int, before bool) {
188+
func (t *muxTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {
189189
for _, t := range t.tracers {
190190
if t.CaptureArbitrumStorageSet != nil {
191-
t.CaptureArbitrumStorageSet(addr, key, mappedKey, value, depth, before)
191+
t.CaptureArbitrumStorageSet(key, value, depth, before)
192192
}
193193
}
194194
}

eth/tracers/native/prestate.go

+5-37
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,10 @@ type account struct {
4747
Nonce uint64 `json:"nonce,omitempty"`
4848
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
4949
empty bool
50-
51-
ArbitrumStorage map[common.Hash]common.Hash `json:"arbitrumStorage,omitempty"`
52-
arbStorageKeyMap map[common.Hash]common.Hash
5350
}
5451

5552
func (a *account) exists() bool {
56-
return a.Nonce > 0 || len(a.Code) > 0 || len(a.Storage) > 0 || (a.Balance != nil && a.Balance.Sign() != 0) || len(a.ArbitrumStorage) > 0
53+
return a.Nonce > 0 || len(a.Code) > 0 || len(a.Storage) > 0 || (a.Balance != nil && a.Balance.Sign() != 0)
5754
}
5855

5956
type accountMarshaling struct {
@@ -214,7 +211,6 @@ func (t *prestateTracer) processDiffState() {
214211
}
215212
modified := false
216213
postAccount := &account{Storage: make(map[common.Hash]common.Hash)}
217-
postAccount.ArbitrumStorage = make(map[common.Hash]common.Hash)
218214
newBalance := t.env.StateDB.GetBalance(addr).ToBig()
219215
newNonce := t.env.StateDB.GetNonce(addr)
220216
newCode := t.env.StateDB.GetCode(addr)
@@ -250,24 +246,6 @@ func (t *prestateTracer) processDiffState() {
250246
}
251247
}
252248

253-
for key, val := range state.ArbitrumStorage {
254-
// don't include the empty slot
255-
if val == (common.Hash{}) {
256-
delete(t.pre[addr].ArbitrumStorage, key)
257-
}
258-
259-
newVal := t.env.StateDB.GetState(types.ArbosStateAddress, state.arbStorageKeyMap[key])
260-
if val == newVal {
261-
// Omit unchanged slots
262-
delete(t.pre[addr].ArbitrumStorage, key)
263-
} else {
264-
modified = true
265-
if newVal != (common.Hash{}) {
266-
postAccount.ArbitrumStorage[key] = newVal
267-
}
268-
}
269-
}
270-
271249
if modified {
272250
t.post[addr] = postAccount
273251
} else {
@@ -285,12 +263,10 @@ func (t *prestateTracer) lookupAccount(addr common.Address) {
285263
}
286264

287265
acc := &account{
288-
Balance: t.env.StateDB.GetBalance(addr).ToBig(),
289-
Nonce: t.env.StateDB.GetNonce(addr),
290-
Code: t.env.StateDB.GetCode(addr),
291-
Storage: make(map[common.Hash]common.Hash),
292-
ArbitrumStorage: make(map[common.Hash]common.Hash),
293-
arbStorageKeyMap: make(map[common.Hash]common.Hash),
266+
Balance: t.env.StateDB.GetBalance(addr).ToBig(),
267+
Nonce: t.env.StateDB.GetNonce(addr),
268+
Code: t.env.StateDB.GetCode(addr),
269+
Storage: make(map[common.Hash]common.Hash),
294270
}
295271
if !acc.exists() {
296272
acc.empty = true
@@ -307,11 +283,3 @@ func (t *prestateTracer) lookupStorage(addr common.Address, key common.Hash) {
307283
}
308284
t.pre[addr].Storage[key] = t.env.StateDB.GetState(addr, key)
309285
}
310-
311-
func (t *prestateTracer) lookupArbitrumStorage(addr common.Address, key, mappedKey common.Hash) {
312-
if _, ok := t.pre[addr].ArbitrumStorage[key]; ok {
313-
return
314-
}
315-
t.pre[addr].ArbitrumStorage[key] = t.env.StateDB.GetState(types.ArbosStateAddress, mappedKey)
316-
t.pre[addr].arbStorageKeyMap[key] = mappedKey
317-
}

eth/tracers/native/tracer_arbitrum.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"math/big"
2121

2222
"github.com/ethereum/go-ethereum/common"
23+
"github.com/ethereum/go-ethereum/core/types"
2324
)
2425

2526
type arbitrumTransfer struct {
@@ -74,14 +75,14 @@ func (t *flatCallTracer) CaptureArbitrumTransfer(from, to *common.Address, value
7475
}
7576
}
7677

77-
func (t *prestateTracer) CaptureArbitrumStorageGet(addr common.Address, key, mappedKey common.Hash, depth int, before bool) {
78-
t.lookupAccount(addr)
79-
t.lookupArbitrumStorage(addr, key, mappedKey)
78+
func (t *prestateTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {
79+
t.lookupAccount(types.ArbosStateAddress)
80+
t.lookupStorage(types.ArbosStateAddress, key)
8081
}
8182

82-
func (t *prestateTracer) CaptureArbitrumStorageSet(addr common.Address, key, mappedKey, value common.Hash, depth int, before bool) {
83-
t.lookupAccount(addr)
84-
t.lookupArbitrumStorage(addr, key, mappedKey)
83+
func (t *prestateTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {
84+
t.lookupAccount(types.ArbosStateAddress)
85+
t.lookupStorage(types.ArbosStateAddress, key)
8586
}
8687

8788
func bigToHex(n *big.Int) string {

0 commit comments

Comments
 (0)