all: fix rebasing issues

This commit is contained in:
Marius van der Wijden 2026-04-22 10:31:53 +02:00 committed by MariusVanDerWijden
parent 7e4656581f
commit 29d86ccca5
3 changed files with 16 additions and 15 deletions

View file

@ -211,7 +211,7 @@ func (s *EncodedStorage) ToHash() common.Hash {
return s.inner.Bytes32() return s.inner.Bytes32()
} }
func newEncodedStorageFromHash(hash common.Hash) *EncodedStorage { func NewEncodedStorageFromHash(hash common.Hash) *EncodedStorage {
return &EncodedStorage{ return &EncodedStorage{
new(uint256.Int).SetBytes(hash[:]), new(uint256.Int).SetBytes(hash[:]),
} }
@ -469,7 +469,7 @@ func (a *ConstructionAccountAccesses) toEncodingObj(addr common.Address) Account
slices.SortFunc(writeSlots, common.Hash.Cmp) slices.SortFunc(writeSlots, common.Hash.Cmp)
for _, slot := range writeSlots { for _, slot := range writeSlots {
var obj encodingSlotWrites var obj encodingSlotWrites
obj.Slot = newEncodedStorageFromHash(slot) obj.Slot = NewEncodedStorageFromHash(slot)
slotWrites := a.StorageWrites[slot] slotWrites := a.StorageWrites[slot]
obj.Accesses = make([]encodingStorageWrite, 0, len(slotWrites)) obj.Accesses = make([]encodingStorageWrite, 0, len(slotWrites))
@ -479,7 +479,7 @@ func (a *ConstructionAccountAccesses) toEncodingObj(addr common.Address) Account
for _, index := range indices { for _, index := range indices {
obj.Accesses = append(obj.Accesses, encodingStorageWrite{ obj.Accesses = append(obj.Accesses, encodingStorageWrite{
TxIdx: index, TxIdx: index,
ValueAfter: newEncodedStorageFromHash(slotWrites[index]), ValueAfter: NewEncodedStorageFromHash(slotWrites[index]),
}) })
} }
res.StorageChanges = append(res.StorageChanges, obj) res.StorageChanges = append(res.StorageChanges, obj)
@ -489,7 +489,7 @@ func (a *ConstructionAccountAccesses) toEncodingObj(addr common.Address) Account
readSlots := slices.Collect(maps.Keys(a.StorageReads)) readSlots := slices.Collect(maps.Keys(a.StorageReads))
slices.SortFunc(readSlots, common.Hash.Cmp) slices.SortFunc(readSlots, common.Hash.Cmp)
for _, slot := range readSlots { for _, slot := range readSlots {
res.StorageReads = append(res.StorageReads, newEncodedStorageFromHash(slot)) res.StorageReads = append(res.StorageReads, NewEncodedStorageFromHash(slot))
} }
// Convert balance changes // Convert balance changes

View file

@ -117,12 +117,12 @@ func makeTestAccountAccess(sort bool) AccountAccess {
) )
for i := 0; i < 5; i++ { for i := 0; i < 5; i++ {
slot := encodingSlotWrites{ slot := encodingSlotWrites{
Slot: newEncodedStorageFromHash(testrand.Hash()), Slot: NewEncodedStorageFromHash(testrand.Hash()),
} }
for j := 0; j < 3; j++ { for j := 0; j < 3; j++ {
slot.Accesses = append(slot.Accesses, encodingStorageWrite{ slot.Accesses = append(slot.Accesses, encodingStorageWrite{
TxIdx: uint16(i*3 + j), TxIdx: uint16(i*3 + j),
ValueAfter: newEncodedStorageFromHash(testrand.Hash()), ValueAfter: NewEncodedStorageFromHash(testrand.Hash()),
}) })
} }
if sort { if sort {
@ -173,7 +173,7 @@ func makeTestAccountAccess(sort bool) AccountAccess {
var encodedStorageReads []*EncodedStorage var encodedStorageReads []*EncodedStorage
for _, slot := range storageReads { for _, slot := range storageReads {
encodedStorageReads = append(encodedStorageReads, newEncodedStorageFromHash(slot)) encodedStorageReads = append(encodedStorageReads, NewEncodedStorageFromHash(slot))
} }
return AccountAccess{ return AccountAccess{
Address: [20]byte(testrand.Bytes(20)), Address: [20]byte(testrand.Bytes(20)),
@ -208,20 +208,20 @@ func TestBlockAccessListCopy(t *testing.T) {
cpy := list.Copy() cpy := list.Copy()
cpyCpy := cpy.Copy() cpyCpy := cpy.Copy()
if !reflect.DeepEqual(list, cpy) { if !reflect.DeepEqual(list, *cpy) {
t.Fatal("block access mismatch") t.Fatal("block access mismatch")
} }
if !reflect.DeepEqual(cpy, cpyCpy) { if !reflect.DeepEqual(*cpy, *cpyCpy) {
t.Fatal("block access mismatch") t.Fatal("block access mismatch")
} }
// Make sure the mutations on copy won't affect the origin // Make sure the mutations on copy won't affect the origin
for _, aa := range *cpyCpy { for i := range *cpyCpy {
for i := 0; i < len(aa.StorageReads); i++ { for j := 0; j < len((*cpyCpy)[i].StorageReads); j++ {
aa.StorageReads[i] = &EncodedStorage{new(uint256.Int).SetBytes(testrand.Bytes(32))} (*cpyCpy)[i].StorageReads[j] = NewEncodedStorageFromHash(testrand.Hash())
} }
} }
if !reflect.DeepEqual(list, cpy) { if !reflect.DeepEqual(list, *cpy) {
t.Fatal("block access mismatch") t.Fatal("block access mismatch")
} }
} }

View file

@ -40,8 +40,9 @@ func makeTestBAL(minSize int) *bal.BlockAccessList {
StorageReads: make([]*bal.EncodedStorage, n), StorageReads: make([]*bal.EncodedStorage, n),
} }
for i := range access.StorageReads { for i := range access.StorageReads {
read := access.StorageReads[i].ToHash() var slot common.Hash
binary.BigEndian.PutUint64(read[24:], uint64(i)) binary.BigEndian.PutUint64(slot[24:], uint64(i))
access.StorageReads[i] = bal.NewEncodedStorageFromHash(slot)
} }
return &bal.BlockAccessList{access} return &bal.BlockAccessList{access}
} }