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

View file

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

View file

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