Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
copy accesslist
Browse files Browse the repository at this point in the history
  • Loading branch information
Devon Bear committed Sep 22, 2023
1 parent 5f0193f commit 4fb9e0a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions eth/core/state/journal/access_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ func (al *accessList) SlotInAccessList(addr common.Address, slot common.Hash) (b
return al.Peek().Contains(addr, slot)
}

func (al *accessList) Snapshot() int {
al.Push(al.Peek().Copy())
return al.baseJournal.Size() - 1
}

// Finalize implements `libtypes.Controllable`.
func (al *accessList) Finalize() {
*al = *utils.MustGetAs[*accessList](NewAccesslist())
Expand Down
10 changes: 9 additions & 1 deletion eth/core/state/journal/access_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
package journal

import (
"fmt"

"pkg.berachain.dev/polaris/eth/common"
"pkg.berachain.dev/polaris/lib/utils"

Expand Down Expand Up @@ -55,12 +57,18 @@ var _ = Describe("AccessList", func() {
al.AddSlotToAccessList(a1, s1)
al.AddSlotToAccessList(a1, s2)

fmt.Println(al.Peek())
fmt.Println(al.Size())
id := al.Snapshot()

fmt.Println("SNAPSHOT", id)
al.AddSlotToAccessList(a2, s1)
fmt.Println(al.Peek())
fmt.Println(al.Size())

Expect(al.AddressInAccessList(a2)).To(BeTrue())

al.RevertToSnapshot(id)
fmt.Println(al.Size())
Expect(al.AddressInAccessList(a2)).To(BeFalse())

Expect(func() { al.Finalize() }).ToNot(Panic())
Expand Down

0 comments on commit 4fb9e0a

Please sign in to comment.