diff --git a/eth/core/state/journal/access_list.go b/eth/core/state/journal/access_list.go index ef8757613..ca8d2b59b 100644 --- a/eth/core/state/journal/access_list.go +++ b/eth/core/state/journal/access_list.go @@ -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()) diff --git a/eth/core/state/journal/access_list_test.go b/eth/core/state/journal/access_list_test.go index 4bf31905a..e1cf53a0b 100644 --- a/eth/core/state/journal/access_list_test.go +++ b/eth/core/state/journal/access_list_test.go @@ -21,6 +21,8 @@ package journal import ( + "fmt" + "pkg.berachain.dev/polaris/eth/common" "pkg.berachain.dev/polaris/lib/utils" @@ -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())