From 2ba19a3303983b1fdc7834757320193e61db1ceb Mon Sep 17 00:00:00 2001 From: Faye Amacker <33205765+fxamacker@users.noreply.github.com> Date: Mon, 29 Jan 2024 09:58:15 -0600 Subject: [PATCH 1/9] Integrate Atree inlining & Cadence v0.42 to flow-go --- .../migrations/atree_register_migration.go | 2 +- cmd/util/ledger/migrations/utils.go | 4 +- .../ledger/reporters/atree_decode_test.go | 2 +- cmd/util/ledger/util/util.go | 20 ++-- fvm/environment/account_key_updater_test.go | 4 +- fvm/environment/accounts.go | 12 +-- fvm/environment/accounts_status.go | 6 +- fvm/environment/accounts_status_test.go | 4 +- fvm/environment/accounts_test.go | 14 +-- fvm/environment/mock/accounts.go | 12 +-- fvm/environment/mock/environment.go | 12 +-- fvm/environment/mock/value_store.go | 12 +-- fvm/environment/value_store.go | 20 ++-- fvm/evm/backends/wrappedEnv.go | 4 +- fvm/evm/emulator/state/collection.go | 97 +++++++++++-------- fvm/evm/emulator/state/stateDB_test.go | 8 +- fvm/evm/testutils/backend.go | 28 +++--- fvm/evm/testutils/cadence.go | 20 ++-- go.mod | 4 +- go.sum | 8 +- insecure/go.mod | 4 +- insecure/go.sum | 8 +- integration/go.mod | 2 +- integration/go.sum | 4 +- model/flow/ledger_test.go | 2 +- 25 files changed, 163 insertions(+), 150 deletions(-) diff --git a/cmd/util/ledger/migrations/atree_register_migration.go b/cmd/util/ledger/migrations/atree_register_migration.go index 222217572ff..e0001fa1120 100644 --- a/cmd/util/ledger/migrations/atree_register_migration.go +++ b/cmd/util/ledger/migrations/atree_register_migration.go @@ -215,7 +215,7 @@ func (m *AtreeRegisterMigrator) convertStorageDomain( // no storage for this domain return nil } - storageMapIds[string(atree.SlabIndexToLedgerKey(storageMap.StorageID().Index))] = struct{}{} + storageMapIds[string(atree.SlabIndexToLedgerKey(storageMap.SlabID().Index()))] = struct{}{} iterator := storageMap.Iterator(nil) keys := make([]interpreter.StorageMapKey, 0, storageMap.Count()) diff --git a/cmd/util/ledger/migrations/utils.go b/cmd/util/ledger/migrations/utils.go index f9ce19b84e8..a746c2f05b0 100644 --- a/cmd/util/ledger/migrations/utils.go +++ b/cmd/util/ledger/migrations/utils.go @@ -29,9 +29,9 @@ func checkStorageHealth( } // Convert the register ID to a storage ID. - slabID := atree.NewStorageID( + slabID := atree.NewSlabID( atree.Address([]byte(registerID.Owner)), - atree.StorageIndex([]byte(registerID.Key[1:]))) + atree.SlabIndex([]byte(registerID.Key[1:]))) // Retrieve the slab. _, _, err = storage.Retrieve(slabID) diff --git a/cmd/util/ledger/reporters/atree_decode_test.go b/cmd/util/ledger/reporters/atree_decode_test.go index 73b69a7e54b..8d06f1e28fa 100644 --- a/cmd/util/ledger/reporters/atree_decode_test.go +++ b/cmd/util/ledger/reporters/atree_decode_test.go @@ -145,7 +145,7 @@ func TestMapDataSlabCollisionCount(t *testing.T) { 0x82, 0x76, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x76, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, - // element: [hhhhhhhhhhhhhhhhhhhhhh:StorageID(1,2,3,4,5,6,7,8,0,0,0,0,0,0,0,4)] + // element: [hhhhhhhhhhhhhhhhhhhhhh:SlabID(1,2,3,4,5,6,7,8,0,0,0,0,0,0,0,4)] 0x82, 0x76, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0xd8, 0xff, 0x50, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, diff --git a/cmd/util/ledger/util/util.go b/cmd/util/ledger/util/util.go index f486c21edb4..fde0465a602 100644 --- a/cmd/util/ledger/util/util.go +++ b/cmd/util/ledger/util/util.go @@ -55,11 +55,11 @@ func (a *AccountsAtreeLedger) ValueExists(owner, key []byte) (exists bool, err e return len(v) > 0, nil } -// AllocateStorageIndex allocates new storage index under the owner accounts to store a new register -func (a *AccountsAtreeLedger) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error) { - v, err := a.Accounts.AllocateStorageIndex(flow.BytesToAddress(owner)) +// AllocateSlabIndex allocates new storage index under the owner accounts to store a new register +func (a *AccountsAtreeLedger) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error) { + v, err := a.Accounts.AllocateSlabIndex(flow.BytesToAddress(owner)) if err != nil { - return atree.StorageIndex{}, fmt.Errorf("storage index allocation failed: %w", err) + return atree.SlabIndex{}, fmt.Errorf("storage index allocation failed: %w", err) } return v, nil } @@ -99,8 +99,8 @@ func (p PayloadSnapshot) Get(id flow.RegisterID) (flow.RegisterValue, error) { type PayloadsReadonlyLedger struct { Snapshot *PayloadSnapshot - AllocateStorageIndexFunc func(owner []byte) (atree.StorageIndex, error) - SetValueFunc func(owner, key, value []byte) (err error) + AllocateSlabIndexFunc func(owner []byte) (atree.SlabIndex, error) + SetValueFunc func(owner, key, value []byte) (err error) } func (p *PayloadsReadonlyLedger) GetValue(owner, key []byte) (value []byte, err error) { @@ -124,12 +124,12 @@ func (p *PayloadsReadonlyLedger) ValueExists(owner, key []byte) (exists bool, er return ok, nil } -func (p *PayloadsReadonlyLedger) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error) { - if p.AllocateStorageIndexFunc != nil { - return p.AllocateStorageIndexFunc(owner) +func (p *PayloadsReadonlyLedger) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error) { + if p.AllocateSlabIndexFunc != nil { + return p.AllocateSlabIndexFunc(owner) } - panic("AllocateStorageIndex not expected to be called") + panic("AllocateSlabIndex not expected to be called") } func NewPayloadsReadonlyLedger(snapshot *PayloadSnapshot) *PayloadsReadonlyLedger { diff --git a/fvm/environment/account_key_updater_test.go b/fvm/environment/account_key_updater_test.go index 09cb1ba9491..106bcde1959 100644 --- a/fvm/environment/account_key_updater_test.go +++ b/fvm/environment/account_key_updater_test.go @@ -217,8 +217,8 @@ func (f FakeAccounts) Create(_ []flow.AccountPublicKey, _ flow.Address) error { func (f FakeAccounts) GetValue(_ flow.RegisterID) (flow.RegisterValue, error) { return nil, nil } func (f FakeAccounts) GetStorageUsed(_ flow.Address) (uint64, error) { return 0, nil } func (f FakeAccounts) SetValue(_ flow.RegisterID, _ []byte) error { return nil } -func (f FakeAccounts) AllocateStorageIndex(_ flow.Address) (atree.StorageIndex, error) { - return atree.StorageIndex{}, nil +func (f FakeAccounts) AllocateSlabIndex(_ flow.Address) (atree.SlabIndex, error) { + return atree.SlabIndex{}, nil } func (f FakeAccounts) GenerateAccountLocalID(address flow.Address) (uint64, error) { return 0, nil diff --git a/fvm/environment/accounts.go b/fvm/environment/accounts.go index 01041f19a3f..2cf63b9f582 100644 --- a/fvm/environment/accounts.go +++ b/fvm/environment/accounts.go @@ -36,7 +36,7 @@ type Accounts interface { GetValue(id flow.RegisterID) (flow.RegisterValue, error) GetStorageUsed(address flow.Address) (uint64, error) SetValue(id flow.RegisterID, value flow.RegisterValue) error - AllocateStorageIndex(address flow.Address) (atree.StorageIndex, error) + AllocateSlabIndex(address flow.Address) (atree.SlabIndex, error) GenerateAccountLocalID(address flow.Address) (uint64, error) } @@ -52,16 +52,16 @@ func NewAccounts(txnState state.NestedTransactionPreparer) *StatefulAccounts { } } -func (a *StatefulAccounts) AllocateStorageIndex( +func (a *StatefulAccounts) AllocateSlabIndex( address flow.Address, ) ( - atree.StorageIndex, + atree.SlabIndex, error, ) { // get status status, err := a.getAccountStatus(address) if err != nil { - return atree.StorageIndex{}, err + return atree.SlabIndex{}, err } // get and increment the index @@ -79,7 +79,7 @@ func (a *StatefulAccounts) AllocateStorageIndex( []byte{}) }) if err != nil { - return atree.StorageIndex{}, fmt.Errorf( + return atree.SlabIndex{}, fmt.Errorf( "failed to allocate an storage index: %w", err) } @@ -88,7 +88,7 @@ func (a *StatefulAccounts) AllocateStorageIndex( status.SetStorageIndex(newIndexBytes) err = a.setAccountStatus(address, status) if err != nil { - return atree.StorageIndex{}, fmt.Errorf( + return atree.SlabIndex{}, fmt.Errorf( "failed to allocate an storage index: %w", err) } diff --git a/fvm/environment/accounts_status.go b/fvm/environment/accounts_status.go index a420051550f..93c9a81db6e 100644 --- a/fvm/environment/accounts_status.go +++ b/fvm/environment/accounts_status.go @@ -105,13 +105,13 @@ func (a *AccountStatus) StorageUsed() uint64 { } // SetStorageIndex updates the storage index of the account -func (a *AccountStatus) SetStorageIndex(index atree.StorageIndex) { +func (a *AccountStatus) SetStorageIndex(index atree.SlabIndex) { copy(a[storageIndexStartIndex:storageIndexStartIndex+storageIndexSize], index[:storageIndexSize]) } // StorageIndex returns the storage index of the account -func (a *AccountStatus) StorageIndex() atree.StorageIndex { - var index atree.StorageIndex +func (a *AccountStatus) StorageIndex() atree.SlabIndex { + var index atree.SlabIndex copy(index[:], a[storageIndexStartIndex:storageIndexStartIndex+storageIndexSize]) return index } diff --git a/fvm/environment/accounts_status_test.go b/fvm/environment/accounts_status_test.go index 543ee2b05f1..4ab3c9c1ee5 100644 --- a/fvm/environment/accounts_status_test.go +++ b/fvm/environment/accounts_status_test.go @@ -15,7 +15,7 @@ func TestAccountStatus(t *testing.T) { s := environment.NewAccountStatus() t.Run("test setting values", func(t *testing.T) { - index := atree.StorageIndex{1, 2, 3, 4, 5, 6, 7, 8} + index := atree.SlabIndex{1, 2, 3, 4, 5, 6, 7, 8} s.SetStorageIndex(index) s.SetPublicKeyCount(34) s.SetStorageUsed(56) @@ -58,7 +58,7 @@ func TestAccountStatus(t *testing.T) { migrated, err := environment.AccountStatusFromBytes(oldBytes) require.NoError(t, err) - require.Equal(t, atree.StorageIndex{0, 0, 0, 0, 0, 0, 0, 6}, migrated.StorageIndex()) + require.Equal(t, atree.SlabIndex{0, 0, 0, 0, 0, 0, 0, 6}, migrated.StorageIndex()) require.Equal(t, uint64(5), migrated.PublicKeyCount()) require.Equal(t, uint64(7)+increaseInSize, migrated.StorageUsed()) require.Equal(t, uint64(0), migrated.AccountIdCounter()) diff --git a/fvm/environment/accounts_test.go b/fvm/environment/accounts_test.go index c6ef3cce467..aea1c564eca 100644 --- a/fvm/environment/accounts_test.go +++ b/fvm/environment/accounts_test.go @@ -413,7 +413,7 @@ func createByteArray(size int) []byte { return bytes } -func TestAccounts_AllocateStorageIndex(t *testing.T) { +func TestAccounts_AllocateSlabIndex(t *testing.T) { txnState := testutils.NewSimpleTransaction(nil) accounts := environment.NewAccounts(txnState) address := flow.HexToAddress("01") @@ -422,17 +422,17 @@ func TestAccounts_AllocateStorageIndex(t *testing.T) { require.NoError(t, err) // no register set case - i, err := accounts.AllocateStorageIndex(address) + i, err := accounts.AllocateSlabIndex(address) require.NoError(t, err) - require.Equal(t, i, atree.StorageIndex([8]byte{0, 0, 0, 0, 0, 0, 0, 1})) + require.Equal(t, i, atree.SlabIndex([8]byte{0, 0, 0, 0, 0, 0, 0, 1})) // register already set case - i, err = accounts.AllocateStorageIndex(address) + i, err = accounts.AllocateSlabIndex(address) require.NoError(t, err) - require.Equal(t, i, atree.StorageIndex([8]byte{0, 0, 0, 0, 0, 0, 0, 2})) + require.Equal(t, i, atree.SlabIndex([8]byte{0, 0, 0, 0, 0, 0, 0, 2})) // register update successful - i, err = accounts.AllocateStorageIndex(address) + i, err = accounts.AllocateSlabIndex(address) require.NoError(t, err) - require.Equal(t, i, atree.StorageIndex([8]byte{0, 0, 0, 0, 0, 0, 0, 3})) + require.Equal(t, i, atree.SlabIndex([8]byte{0, 0, 0, 0, 0, 0, 0, 3})) } diff --git a/fvm/environment/mock/accounts.go b/fvm/environment/mock/accounts.go index ee4656a4be8..413a25b9b4e 100644 --- a/fvm/environment/mock/accounts.go +++ b/fvm/environment/mock/accounts.go @@ -15,20 +15,20 @@ type Accounts struct { mock.Mock } -// AllocateStorageIndex provides a mock function with given fields: address -func (_m *Accounts) AllocateStorageIndex(address flow.Address) (atree.StorageIndex, error) { +// AllocateSlabIndex provides a mock function with given fields: address +func (_m *Accounts) AllocateSlabIndex(address flow.Address) (atree.SlabIndex, error) { ret := _m.Called(address) - var r0 atree.StorageIndex + var r0 atree.SlabIndex var r1 error - if rf, ok := ret.Get(0).(func(flow.Address) (atree.StorageIndex, error)); ok { + if rf, ok := ret.Get(0).(func(flow.Address) (atree.SlabIndex, error)); ok { return rf(address) } - if rf, ok := ret.Get(0).(func(flow.Address) atree.StorageIndex); ok { + if rf, ok := ret.Get(0).(func(flow.Address) atree.SlabIndex); ok { r0 = rf(address) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(atree.StorageIndex) + r0 = ret.Get(0).(atree.SlabIndex) } } diff --git a/fvm/environment/mock/environment.go b/fvm/environment/mock/environment.go index aac5cad5d31..c7dd375f1c4 100644 --- a/fvm/environment/mock/environment.go +++ b/fvm/environment/mock/environment.go @@ -134,20 +134,20 @@ func (_m *Environment) AddEncodedAccountKey(address common.Address, publicKey [] return r0 } -// AllocateStorageIndex provides a mock function with given fields: owner -func (_m *Environment) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error) { +// AllocateSlabIndex provides a mock function with given fields: owner +func (_m *Environment) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error) { ret := _m.Called(owner) - var r0 atree.StorageIndex + var r0 atree.SlabIndex var r1 error - if rf, ok := ret.Get(0).(func([]byte) (atree.StorageIndex, error)); ok { + if rf, ok := ret.Get(0).(func([]byte) (atree.SlabIndex, error)); ok { return rf(owner) } - if rf, ok := ret.Get(0).(func([]byte) atree.StorageIndex); ok { + if rf, ok := ret.Get(0).(func([]byte) atree.SlabIndex); ok { r0 = rf(owner) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(atree.StorageIndex) + r0 = ret.Get(0).(atree.SlabIndex) } } diff --git a/fvm/environment/mock/value_store.go b/fvm/environment/mock/value_store.go index acfc3918545..59c54d7dac2 100644 --- a/fvm/environment/mock/value_store.go +++ b/fvm/environment/mock/value_store.go @@ -13,20 +13,20 @@ type ValueStore struct { mock.Mock } -// AllocateStorageIndex provides a mock function with given fields: owner -func (_m *ValueStore) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error) { +// AllocateSlabIndex provides a mock function with given fields: owner +func (_m *ValueStore) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error) { ret := _m.Called(owner) - var r0 atree.StorageIndex + var r0 atree.SlabIndex var r1 error - if rf, ok := ret.Get(0).(func([]byte) (atree.StorageIndex, error)); ok { + if rf, ok := ret.Get(0).(func([]byte) (atree.SlabIndex, error)); ok { return rf(owner) } - if rf, ok := ret.Get(0).(func([]byte) atree.StorageIndex); ok { + if rf, ok := ret.Get(0).(func([]byte) atree.SlabIndex); ok { r0 = rf(owner) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(atree.StorageIndex) + r0 = ret.Get(0).(atree.SlabIndex) } } diff --git a/fvm/environment/value_store.go b/fvm/environment/value_store.go index 8113de6762c..4f768378500 100644 --- a/fvm/environment/value_store.go +++ b/fvm/environment/value_store.go @@ -20,7 +20,7 @@ type ValueStore interface { ValueExists(owner []byte, key []byte) (bool, error) - AllocateStorageIndex(owner []byte) (atree.StorageIndex, error) + AllocateSlabIndex(owner []byte) (atree.SlabIndex, error) } type ParseRestrictedValueStore struct { @@ -82,16 +82,16 @@ func (store ParseRestrictedValueStore) ValueExists( key) } -func (store ParseRestrictedValueStore) AllocateStorageIndex( +func (store ParseRestrictedValueStore) AllocateSlabIndex( owner []byte, ) ( - atree.StorageIndex, + atree.SlabIndex, error, ) { return parseRestrict1Arg1Ret( store.txnState, trace.FVMEnvAllocateStorageIndex, - store.impl.AllocateStorageIndex, + store.impl.AllocateSlabIndex, owner) } @@ -189,26 +189,26 @@ func (store *valueStore) ValueExists( return len(v) > 0, nil } -// AllocateStorageIndex allocates new storage index under the owner accounts +// AllocateSlabIndex allocates new storage index under the owner accounts // to store a new register. -func (store *valueStore) AllocateStorageIndex( +func (store *valueStore) AllocateSlabIndex( owner []byte, ) ( - atree.StorageIndex, + atree.SlabIndex, error, ) { defer store.tracer.StartChildSpan(trace.FVMEnvAllocateStorageIndex).End() err := store.meter.MeterComputation(ComputationKindAllocateStorageIndex, 1) if err != nil { - return atree.StorageIndex{}, fmt.Errorf( + return atree.SlabIndex{}, fmt.Errorf( "allocate storage index failed: %w", err) } - v, err := store.accounts.AllocateStorageIndex(flow.BytesToAddress(owner)) + v, err := store.accounts.AllocateSlabIndex(flow.BytesToAddress(owner)) if err != nil { - return atree.StorageIndex{}, fmt.Errorf( + return atree.SlabIndex{}, fmt.Errorf( "storage address allocation failed: %w", err) } diff --git a/fvm/evm/backends/wrappedEnv.go b/fvm/evm/backends/wrappedEnv.go index d22aabc191c..152d54236ab 100644 --- a/fvm/evm/backends/wrappedEnv.go +++ b/fvm/evm/backends/wrappedEnv.go @@ -40,8 +40,8 @@ func (we *WrappedEnvironment) ValueExists(owner, key []byte) (bool, error) { return b, handleEnvironmentError(err) } -func (we *WrappedEnvironment) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error) { - index, err := we.env.AllocateStorageIndex(owner) +func (we *WrappedEnvironment) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error) { + index, err := we.env.AllocateSlabIndex(owner) return index, handleEnvironmentError(err) } diff --git a/fvm/evm/emulator/state/collection.go b/fvm/evm/emulator/state/collection.go index 780d81652df..80b8c9621e6 100644 --- a/fvm/evm/emulator/state/collection.go +++ b/fvm/evm/emulator/state/collection.go @@ -47,16 +47,16 @@ func NewCollectionProvider( // calling twice for the same collection might result in odd-behaviours // currently collection provider doesn't do any internal caching to protect aginast these cases func (cp *CollectionProvider) CollectionByID(collectionID []byte) (*Collection, error) { - storageID, err := atree.NewStorageIDFromRawBytes(collectionID) + slabID, err := atree.NewSlabIDFromRawBytes(collectionID) if err != nil { return nil, err } - // sanity check the storage ID address - if storageID.Address != cp.rootAddr { - return nil, fmt.Errorf("root address mismatch %x != %x", storageID.Address, cp.rootAddr) - } + // TODO: sanity check the slab ID address + // if slabID.Address != cp.rootAddr { + // return nil, fmt.Errorf("root address mismatch %x != %x", storageID.Address, cp.rootAddr) + // } - omap, err := atree.NewMapWithRootID(cp.storage, storageID, atree.NewDefaultDigesterBuilder()) + omap, err := atree.NewMapWithRootID(cp.storage, slabID, atree.NewDefaultDigesterBuilder()) if err != nil { return nil, err } @@ -74,7 +74,7 @@ func (cp *CollectionProvider) NewCollection() (*Collection, error) { return nil, err } storageIDBytes := make([]byte, storageIDSize) - _, err = omap.StorageID().ToRawBytes(storageIDBytes) + _, err = omap.SlabID().ToRawBytes(storageIDBytes) if err != nil { return nil, err } @@ -110,7 +110,7 @@ func (c *Collection) CollectionID() []byte { // // if key doesn't exist it returns nil (no error) func (c *Collection) Get(key []byte) ([]byte, error) { - data, err := c.omap.Get(compare, hashInputProvider, NewByteStringValue(key)) + value, err := c.omap.Get(compare, hashInputProvider, NewByteStringValue(key)) if err != nil { var keyNotFoundError *atree.KeyNotFoundError if errors.As(err, &keyNotFoundError) { @@ -119,11 +119,6 @@ func (c *Collection) Get(key []byte) ([]byte, error) { return nil, err } - value, err := data.StoredValue(c.omap.Storage) - if err != nil { - return nil, err - } - return value.(ByteStringValue).Bytes(), nil } @@ -136,9 +131,9 @@ func (c *Collection) Set(key, value []byte) error { return err } - if id, ok := existingValueStorable.(atree.StorageIDStorable); ok { + if id, ok := existingValueStorable.(atree.SlabIDStorable); ok { // NOTE: deep remove isn't necessary because value is ByteStringValue (not container) - err := c.storage.Remove(atree.StorageID(id)) + err := c.storage.Remove(atree.SlabID(id)) if err != nil { return err } @@ -159,9 +154,9 @@ func (c *Collection) Remove(key []byte) error { return err } - if id, ok := existingValueStorable.(atree.StorageIDStorable); ok { + if id, ok := existingValueStorable.(atree.SlabIDStorable); ok { // NOTE: deep remove isn't necessary because value is ByteStringValue (not container) - err := c.storage.Remove(atree.StorageID(id)) + err := c.storage.Remove(atree.SlabID(id)) if err != nil { return err } @@ -175,8 +170,8 @@ func (c *Collection) Destroy() ([][]byte, error) { keys := make([][]byte, c.omap.Count()) i := 0 err := c.omap.PopIterate(func(keyStorable atree.Storable, valueStorable atree.Storable) { - if id, ok := valueStorable.(atree.StorageIDStorable); ok { - err := c.storage.Remove(atree.StorageID(id)) + if id, ok := valueStorable.(atree.SlabIDStorable); ok { + err := c.storage.Remove(atree.SlabID(id)) if err != nil && cachedErr == nil { cachedErr = err } @@ -194,7 +189,7 @@ func (c *Collection) Destroy() ([][]byte, error) { if err != nil { return keys, err } - return keys, c.storage.Remove(c.omap.StorageID()) + return keys, c.storage.Remove(c.omap.SlabID()) } // Size returns the number of items in the collection @@ -229,24 +224,7 @@ func (v ByteStringValue) Storable(storage atree.SlabStorage, address atree.Addre } // Create StorableSlab - id, err := storage.GenerateStorageID(address) - if err != nil { - return nil, err - } - - slab := &atree.StorableSlab{ - StorageID: id, - Storable: v, - } - - // Store StorableSlab in storage - err = storage.Store(id, slab) - if err != nil { - return nil, err - } - - // Return storage id as storable - return atree.StorageIDStorable(id), nil + return atree.NewStorableSlab(storage, address, v) } func (v ByteStringValue) Encode(enc *atree.Encoder) error { @@ -311,7 +289,7 @@ func (v ByteStringValue) Bytes() []byte { return v.data } -func decodeStorable(dec *cbor.StreamDecoder, _ atree.StorageID) (atree.Storable, error) { +func decodeStorable(dec *cbor.StreamDecoder, slabID atree.SlabID, inlinedExtraData []atree.ExtraData) (atree.Storable, error) { t, err := dec.NextType() if err != nil { return nil, err @@ -333,8 +311,31 @@ func decodeStorable(dec *cbor.StreamDecoder, _ atree.StorageID) (atree.Storable, switch tagNumber { - case atree.CBORTagStorageID: - return atree.DecodeStorageIDStorable(dec) + case atree.CBORTagSlabID: + return atree.DecodeSlabIDStorable(dec) + + case atree.CBORTagInlinedArray: + return atree.DecodeInlinedArrayStorable( + dec, + decodeStorable, + slabID, + inlinedExtraData) + + case atree.CBORTagInlinedMap: + return atree.DecodeInlinedMapStorable( + dec, + decodeStorable, + slabID, + inlinedExtraData, + ) + + case atree.CBORTagInlinedCompactMap: + return atree.DecodeInlinedCompactMapStorable( + dec, + decodeStorable, + slabID, + inlinedExtraData, + ) default: return nil, fmt.Errorf("invalid tag number %d", tagNumber) @@ -403,11 +404,23 @@ type emptyTypeInfo struct{} var _ atree.TypeInfo = emptyTypeInfo{} +func (emptyTypeInfo) IsComposite() bool { + return false +} + +func (emptyTypeInfo) Identifier() string { + return "" +} + +func (e emptyTypeInfo) Copy() atree.TypeInfo { + return e +} + func (emptyTypeInfo) Encode(e *cbor.StreamEncoder) error { return e.EncodeNil() } -func (i emptyTypeInfo) Equal(other atree.TypeInfo) bool { +func (emptyTypeInfo) Equal(other atree.TypeInfo) bool { _, ok := other.(emptyTypeInfo) return ok } diff --git a/fvm/evm/emulator/state/stateDB_test.go b/fvm/evm/emulator/state/stateDB_test.go index 5d526fc4ae7..90d30bf7123 100644 --- a/fvm/evm/emulator/state/stateDB_test.go +++ b/fvm/evm/emulator/state/stateDB_test.go @@ -247,8 +247,8 @@ func TestStateDB(t *testing.T) { SetValueFunc: func(owner, key, value []byte) error { return atree.NewUserError(fmt.Errorf("key not found")) }, - AllocateStorageIndexFunc: func(owner []byte) (atree.StorageIndex, error) { - return atree.StorageIndex{}, nil + AllocateSlabIndexFunc: func(owner []byte) (atree.SlabIndex, error) { + return atree.SlabIndex{}, nil }, } db, err := state.NewStateDB(ledger, rootAddr) @@ -271,8 +271,8 @@ func TestStateDB(t *testing.T) { SetValueFunc: func(owner, key, value []byte) error { return atree.NewFatalError(fmt.Errorf("key not found")) }, - AllocateStorageIndexFunc: func(owner []byte) (atree.StorageIndex, error) { - return atree.StorageIndex{}, nil + AllocateSlabIndexFunc: func(owner []byte) (atree.SlabIndex, error) { + return atree.SlabIndex{}, nil }, } db, err := state.NewStateDB(ledger, rootAddr) diff --git a/fvm/evm/testutils/backend.go b/fvm/evm/testutils/backend.go index 472d38201f4..3b0d6212a94 100644 --- a/fvm/evm/testutils/backend.go +++ b/fvm/evm/testutils/backend.go @@ -80,7 +80,7 @@ func GetSimpleValueStore() *TestValueStore { bytesRead += len(fk) + len(value) return len(value) > 0, nil }, - AllocateStorageIndexFunc: func(owner []byte) (atree.StorageIndex, error) { + AllocateSlabIndexFunc: func(owner []byte) (atree.SlabIndex, error) { index := allocator[string(owner)] // TODO: figure out why it result in a collision if index == 0 { @@ -91,7 +91,7 @@ func GetSimpleValueStore() *TestValueStore { binary.BigEndian.PutUint64(data[:], index) bytesRead += len(owner) + 8 bytesWritten += len(owner) + 8 - return atree.StorageIndex(data), nil + return atree.SlabIndex(data), nil }, TotalStorageSizeFunc: func() int { size := 0 @@ -208,15 +208,15 @@ func (tb *TestBackend) Get(id flow.RegisterID) (flow.RegisterValue, error) { } type TestValueStore struct { - GetValueFunc func(owner, key []byte) ([]byte, error) - SetValueFunc func(owner, key, value []byte) error - ValueExistsFunc func(owner, key []byte) (bool, error) - AllocateStorageIndexFunc func(owner []byte) (atree.StorageIndex, error) - TotalStorageSizeFunc func() int - TotalBytesReadFunc func() int - TotalBytesWrittenFunc func() int - TotalStorageItemsFunc func() int - ResetStatsFunc func() + GetValueFunc func(owner, key []byte) ([]byte, error) + SetValueFunc func(owner, key, value []byte) error + ValueExistsFunc func(owner, key []byte) (bool, error) + AllocateSlabIndexFunc func(owner []byte) (atree.SlabIndex, error) + TotalStorageSizeFunc func() int + TotalBytesReadFunc func() int + TotalBytesWrittenFunc func() int + TotalStorageItemsFunc func() int + ResetStatsFunc func() } var _ environment.ValueStore = &TestValueStore{} @@ -242,11 +242,11 @@ func (vs *TestValueStore) ValueExists(owner, key []byte) (bool, error) { return vs.ValueExistsFunc(owner, key) } -func (vs *TestValueStore) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error) { - if vs.AllocateStorageIndexFunc == nil { +func (vs *TestValueStore) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error) { + if vs.AllocateSlabIndexFunc == nil { panic("method not set") } - return vs.AllocateStorageIndexFunc(owner) + return vs.AllocateSlabIndexFunc(owner) } func (vs *TestValueStore) TotalBytesRead() int { diff --git a/fvm/evm/testutils/cadence.go b/fvm/evm/testutils/cadence.go index 0ec8fd7ca87..7b28abab157 100644 --- a/fvm/evm/testutils/cadence.go +++ b/fvm/evm/testutils/cadence.go @@ -108,11 +108,11 @@ func EncodeArgs(argValues []cadence.Value) [][]byte { } type TestLedger struct { - StoredValues map[string][]byte - OnValueExists func(owner, key []byte) (exists bool, err error) - OnGetValue func(owner, key []byte) (value []byte, err error) - OnSetValue func(owner, key, value []byte) (err error) - OnAllocateStorageIndex func(owner []byte) (atree.StorageIndex, error) + StoredValues map[string][]byte + OnValueExists func(owner, key []byte) (exists bool, err error) + OnGetValue func(owner, key []byte) (value []byte, err error) + OnSetValue func(owner, key, value []byte) (err error) + OnAllocateSlabIndex func(owner []byte) (atree.SlabIndex, error) } var _ atree.Ledger = TestLedger{} @@ -129,8 +129,8 @@ func (s TestLedger) ValueExists(owner, key []byte) (exists bool, err error) { return s.OnValueExists(owner, key) } -func (s TestLedger) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error) { - return s.OnAllocateStorageIndex(owner) +func (s TestLedger) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error) { + return s.OnAllocateSlabIndex(owner) } func (s TestLedger) Dump() { @@ -175,7 +175,7 @@ func NewTestLedger( } return nil }, - OnAllocateStorageIndex: func(owner []byte) (result atree.StorageIndex, err error) { + OnAllocateSlabIndex: func(owner []byte) (result atree.SlabIndex, err error) { index := storageIndices[string(owner)] + 1 storageIndices[string(owner)] = index binary.BigEndian.PutUint64(result[:], index) @@ -358,8 +358,8 @@ func (i *TestRuntimeInterface) SetValue(owner, key, value []byte) (err error) { return i.Storage.SetValue(owner, key, value) } -func (i *TestRuntimeInterface) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error) { - return i.Storage.AllocateStorageIndex(owner) +func (i *TestRuntimeInterface) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error) { + return i.Storage.AllocateSlabIndex(owner) } func (i *TestRuntimeInterface) CreateAccount(payer runtime.Address) (address runtime.Address, err error) { diff --git a/go.mod b/go.mod index 8ddab239286..b78e0b88dba 100644 --- a/go.mod +++ b/go.mod @@ -50,8 +50,8 @@ require ( github.com/multiformats/go-multiaddr v0.12.2 github.com/multiformats/go-multiaddr-dns v0.3.1 github.com/multiformats/go-multihash v0.2.3 - github.com/onflow/atree v0.6.0 - github.com/onflow/cadence v0.42.10 + github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6 + github.com/onflow/cadence v0.42.8-0.20240124212703-3e2e257416db github.com/onflow/crypto v0.25.1 github.com/onflow/flow v0.3.4 github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1 diff --git a/go.sum b/go.sum index e38d2ea2a20..cba9e541881 100644 --- a/go.sum +++ b/go.sum @@ -1346,13 +1346,13 @@ github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1 github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onflow/atree v0.1.0-beta1.0.20211027184039-559ee654ece9/go.mod h1:+6x071HgCF/0v5hQcaE5qqjc2UqN5gCU8h5Mk6uqpOg= -github.com/onflow/atree v0.6.0 h1:j7nQ2r8npznx4NX39zPpBYHmdy45f4xwoi+dm37Jk7c= -github.com/onflow/atree v0.6.0/go.mod h1:gBHU0M05qCbv9NN0kijLWMgC47gHVNBIp4KmsVFi0tc= +github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6 h1:FwSfDsR7ipLoL5Iq0TR5Oe7PwOftjbksodIoY1nx6bM= +github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A= github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483 h1:LpiQhTAfM9CAmNVEs0n//cBBgCg+vJSiIxTHYUklZ84= github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA= -github.com/onflow/cadence v0.42.10 h1:3oC5ceeXhdCrhHcf9H0yYXQKW3Tw/vkSXLe+PUZa4i0= -github.com/onflow/cadence v0.42.10/go.mod h1:1wFd+LiNiN6qoZXof3MBdpM6d8BsxbVIxOA77LbIYmE= +github.com/onflow/cadence v0.42.8-0.20240124212703-3e2e257416db h1:YfH6CL5JrE1vbXCBkhx5apdq6QK6mXsYvfpvyLQkdNY= +github.com/onflow/cadence v0.42.8-0.20240124212703-3e2e257416db/go.mod h1:/0kNF0UGnFEJhWaPqVH7zZAA82sSh9udBgCGACw4PEM= github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A= github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/flow v0.3.4 h1:FXUWVdYB90f/rjNcY0Owo30gL790tiYff9Pb/sycXYE= diff --git a/insecure/go.mod b/insecure/go.mod index 3195eeaa334..6de82db765f 100644 --- a/insecure/go.mod +++ b/insecure/go.mod @@ -203,8 +203,8 @@ require ( github.com/multiformats/go-multistream v0.5.0 // indirect github.com/multiformats/go-varint v0.0.7 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/onflow/atree v0.6.0 // indirect - github.com/onflow/cadence v0.42.10 // indirect + github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6 // indirect + github.com/onflow/cadence v0.42.9 // indirect github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1 // indirect github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1 // indirect github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 // indirect diff --git a/insecure/go.sum b/insecure/go.sum index 29793ab10f4..9a02b797726 100644 --- a/insecure/go.sum +++ b/insecure/go.sum @@ -1313,11 +1313,11 @@ github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1 github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onflow/atree v0.1.0-beta1.0.20211027184039-559ee654ece9/go.mod h1:+6x071HgCF/0v5hQcaE5qqjc2UqN5gCU8h5Mk6uqpOg= -github.com/onflow/atree v0.6.0 h1:j7nQ2r8npznx4NX39zPpBYHmdy45f4xwoi+dm37Jk7c= -github.com/onflow/atree v0.6.0/go.mod h1:gBHU0M05qCbv9NN0kijLWMgC47gHVNBIp4KmsVFi0tc= +github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6 h1:FwSfDsR7ipLoL5Iq0TR5Oe7PwOftjbksodIoY1nx6bM= +github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A= github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA= -github.com/onflow/cadence v0.42.10 h1:3oC5ceeXhdCrhHcf9H0yYXQKW3Tw/vkSXLe+PUZa4i0= -github.com/onflow/cadence v0.42.10/go.mod h1:1wFd+LiNiN6qoZXof3MBdpM6d8BsxbVIxOA77LbIYmE= +github.com/onflow/cadence v0.42.9 h1:EX+eak/Jjy9PyKcAEmOViGOHMyP/nCOwJO+deodZlJE= +github.com/onflow/cadence v0.42.9/go.mod h1:1wFd+LiNiN6qoZXof3MBdpM6d8BsxbVIxOA77LbIYmE= github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A= github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1 h1:xF5wHug6H8vKfz7p1LYy9jck6eD9K1HLjTdi6o4kg1k= diff --git a/integration/go.mod b/integration/go.mod index 215e20f7307..d524db26250 100644 --- a/integration/go.mod +++ b/integration/go.mod @@ -252,7 +252,7 @@ require ( github.com/multiformats/go-multistream v0.5.0 // indirect github.com/multiformats/go-varint v0.0.7 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f // indirect + github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6 // indirect github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 // indirect github.com/onflow/flow-nft/lib/go/contracts v1.1.0 // indirect github.com/onflow/nft-storefront/lib/go/contracts v0.0.0-20221222181731-14b90207cead // indirect diff --git a/integration/go.sum b/integration/go.sum index 3cc3f03a335..1f97b61a42c 100644 --- a/integration/go.sum +++ b/integration/go.sum @@ -1403,8 +1403,8 @@ github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1 github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onflow/atree v0.1.0-beta1.0.20211027184039-559ee654ece9/go.mod h1:+6x071HgCF/0v5hQcaE5qqjc2UqN5gCU8h5Mk6uqpOg= -github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f h1:Z8/PgTqOgOg02MTRpTBYO2k16FE6z4wEOtaC2WBR9Xo= -github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f/go.mod h1:xvP61FoOs95K7IYdIYRnNcYQGf4nbF/uuJ0tHf4DRuM= +github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6 h1:FwSfDsR7ipLoL5Iq0TR5Oe7PwOftjbksodIoY1nx6bM= +github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A= github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA= github.com/onflow/cadence v0.42.10 h1:3oC5ceeXhdCrhHcf9H0yYXQKW3Tw/vkSXLe+PUZa4i0= github.com/onflow/cadence v0.42.10/go.mod h1:1wFd+LiNiN6qoZXof3MBdpM6d8BsxbVIxOA77LbIYmE= diff --git a/model/flow/ledger_test.go b/model/flow/ledger_test.go index b287c3d3bb0..f188e1625cf 100644 --- a/model/flow/ledger_test.go +++ b/model/flow/ledger_test.go @@ -87,7 +87,7 @@ func TestRegisterID_IsInternalState(t *testing.T) { func TestRegisterID_String(t *testing.T) { t.Run("atree slab", func(t *testing.T) { // slab with 189 should result in \\xbd - slabIndex := atree.StorageIndex([8]byte{0, 0, 0, 0, 0, 0, 0, 189}) + slabIndex := atree.SlabIndex([8]byte{0, 0, 0, 0, 0, 0, 0, 189}) id := flow.NewRegisterID( flow.BytesToAddress([]byte{1, 2, 3, 10}), From 2660a7bbf7888ffbf62704ccb91841aa99661415 Mon Sep 17 00:00:00 2001 From: Faye Amacker <33205765+fxamacker@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:51:17 -0600 Subject: [PATCH 2/9] Update genesis commit with atree inlining in tests --- utils/unittest/execution_state.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/unittest/execution_state.go b/utils/unittest/execution_state.go index 1225de5936c..b26f9c8e89b 100644 --- a/utils/unittest/execution_state.go +++ b/utils/unittest/execution_state.go @@ -87,7 +87,7 @@ func genesisCommitHexByChainID(chainID flow.ChainID) string { return GenesisStateCommitmentHex } if chainID == flow.Testnet { - return "b048e9114f816d26f71aeb6aa425161b281ebeddbcd323a5f30e571ac911dfa3" + return "0bff6bb390188ecb177012d8bc6358f6f4828e36ab217f45ecb31a58fb75e588" } - return "ef65504ae38f3666acdd1a3cc260620464827082a7c554751527a82bdee4dc89" + return "3d1d0f6f0c347522edc370d3182c22b9345c288c76d3b46c4f5b33e4b7545041" } From a705d1e1bb614c8536d01bb63c3d62922a5f553c Mon Sep 17 00:00:00 2001 From: Faye Amacker <33205765+fxamacker@users.noreply.github.com> Date: Fri, 9 Feb 2024 17:10:43 -0600 Subject: [PATCH 3/9] Update bootstrap zero token commit hash in test This commit updates bootstrap zero token commit hash in test because atree payloads changed with atree inlining. --- engine/execution/state/bootstrap/bootstrap_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/execution/state/bootstrap/bootstrap_test.go b/engine/execution/state/bootstrap/bootstrap_test.go index 68751e41772..74882ee91c8 100644 --- a/engine/execution/state/bootstrap/bootstrap_test.go +++ b/engine/execution/state/bootstrap/bootstrap_test.go @@ -53,7 +53,7 @@ func TestBootstrapLedger(t *testing.T) { } func TestBootstrapLedger_ZeroTokenSupply(t *testing.T) { - expectedStateCommitmentBytes, _ := hex.DecodeString("394b02bd8207a8f8b86d3af0fe428bc2b11228311b652037175db7823446bcbe") + expectedStateCommitmentBytes, _ := hex.DecodeString("c5db3f88be8f6944747576929afca0bfa4bf82359d235c76e78fbb478f8438f2") expectedStateCommitment, err := flow.ToStateCommitment(expectedStateCommitmentBytes) require.NoError(t, err) From 2c60597cb926702523aba83fb2cf0cbc9200adc9 Mon Sep 17 00:00:00 2001 From: Faye Amacker <33205765+fxamacker@users.noreply.github.com> Date: Fri, 9 Feb 2024 17:35:28 -0600 Subject: [PATCH 4/9] Update account balance in test --- fvm/accounts_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fvm/accounts_test.go b/fvm/accounts_test.go index 02613379e73..c04bf5329ad 100644 --- a/fvm/accounts_test.go +++ b/fvm/accounts_test.go @@ -1606,7 +1606,7 @@ func TestAccountBalanceFields(t *testing.T) { _, output, err = vm.Run(ctx, script, snapshotTree) assert.NoError(t, err) assert.NoError(t, output.Err) - assert.Equal(t, cadence.UFix64(99_993_040), output.Value) + assert.Equal(t, cadence.UFix64(99_993_770), output.Value) }), ) From a6c96d72143711b0c571621572c62f47e3d1e0c5 Mon Sep 17 00:00:00 2001 From: Faye Amacker <33205765+fxamacker@users.noreply.github.com> Date: Thu, 18 Apr 2024 15:44:20 -0500 Subject: [PATCH 5/9] Update hash in tests due to Atree format changes --- utils/unittest/execution_state.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/unittest/execution_state.go b/utils/unittest/execution_state.go index b26f9c8e89b..346cf0b0aad 100644 --- a/utils/unittest/execution_state.go +++ b/utils/unittest/execution_state.go @@ -23,7 +23,7 @@ const ServiceAccountPrivateKeySignAlgo = crypto.ECDSAP256 const ServiceAccountPrivateKeyHashAlgo = hash.SHA2_256 // Pre-calculated state commitment with root account with the above private key -const GenesisStateCommitmentHex = "f52a276f66910559916f46d5d4e59013e8f4b217f0ca01f098e16e9a76c921c5" +const GenesisStateCommitmentHex = "c2e4cf56d5447f5a3b6524c35117b9df3adee4465806962dfc48ceac65f6b8cb" var GenesisStateCommitment flow.StateCommitment From 11ccf70fc2d739e281650751a847e2499409bc4d Mon Sep 17 00:00:00 2001 From: Faye Amacker <33205765+fxamacker@users.noreply.github.com> Date: Thu, 18 Apr 2024 16:09:40 -0500 Subject: [PATCH 6/9] Bump Cadence v0.42 version to latest --- go.mod | 4 ++-- go.sum | 8 ++++---- insecure/go.mod | 4 ++-- insecure/go.sum | 8 ++++---- integration/go.mod | 4 ++-- integration/go.sum | 8 ++++---- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index b78e0b88dba..1bd8be63043 100644 --- a/go.mod +++ b/go.mod @@ -50,8 +50,8 @@ require ( github.com/multiformats/go-multiaddr v0.12.2 github.com/multiformats/go-multiaddr-dns v0.3.1 github.com/multiformats/go-multihash v0.2.3 - github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6 - github.com/onflow/cadence v0.42.8-0.20240124212703-3e2e257416db + github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189 + github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6 github.com/onflow/crypto v0.25.1 github.com/onflow/flow v0.3.4 github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1 diff --git a/go.sum b/go.sum index cba9e541881..e10917f92db 100644 --- a/go.sum +++ b/go.sum @@ -1346,13 +1346,13 @@ github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1 github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onflow/atree v0.1.0-beta1.0.20211027184039-559ee654ece9/go.mod h1:+6x071HgCF/0v5hQcaE5qqjc2UqN5gCU8h5Mk6uqpOg= -github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6 h1:FwSfDsR7ipLoL5Iq0TR5Oe7PwOftjbksodIoY1nx6bM= -github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A= +github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189 h1:9PWA8BpJUrnSAGHXNNBvgzH3bv71fectqZokZw1++jE= +github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A= github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483 h1:LpiQhTAfM9CAmNVEs0n//cBBgCg+vJSiIxTHYUklZ84= github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA= -github.com/onflow/cadence v0.42.8-0.20240124212703-3e2e257416db h1:YfH6CL5JrE1vbXCBkhx5apdq6QK6mXsYvfpvyLQkdNY= -github.com/onflow/cadence v0.42.8-0.20240124212703-3e2e257416db/go.mod h1:/0kNF0UGnFEJhWaPqVH7zZAA82sSh9udBgCGACw4PEM= +github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6 h1:Ho3MozYaNyuPkA89US+eUhl1vCZu13AkEgsVL6hPelk= +github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6/go.mod h1:8JBGPGBUb4M7QT171djWQrpDO8LPEeJ4lH1z3uo/ZKQ= github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A= github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/flow v0.3.4 h1:FXUWVdYB90f/rjNcY0Owo30gL790tiYff9Pb/sycXYE= diff --git a/insecure/go.mod b/insecure/go.mod index 6de82db765f..c63abe5f4d6 100644 --- a/insecure/go.mod +++ b/insecure/go.mod @@ -203,8 +203,8 @@ require ( github.com/multiformats/go-multistream v0.5.0 // indirect github.com/multiformats/go-varint v0.0.7 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6 // indirect - github.com/onflow/cadence v0.42.9 // indirect + github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189 // indirect + github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6 // indirect github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1 // indirect github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1 // indirect github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 // indirect diff --git a/insecure/go.sum b/insecure/go.sum index 9a02b797726..a11e6e00681 100644 --- a/insecure/go.sum +++ b/insecure/go.sum @@ -1313,11 +1313,11 @@ github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1 github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onflow/atree v0.1.0-beta1.0.20211027184039-559ee654ece9/go.mod h1:+6x071HgCF/0v5hQcaE5qqjc2UqN5gCU8h5Mk6uqpOg= -github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6 h1:FwSfDsR7ipLoL5Iq0TR5Oe7PwOftjbksodIoY1nx6bM= -github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A= +github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189 h1:9PWA8BpJUrnSAGHXNNBvgzH3bv71fectqZokZw1++jE= +github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A= github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA= -github.com/onflow/cadence v0.42.9 h1:EX+eak/Jjy9PyKcAEmOViGOHMyP/nCOwJO+deodZlJE= -github.com/onflow/cadence v0.42.9/go.mod h1:1wFd+LiNiN6qoZXof3MBdpM6d8BsxbVIxOA77LbIYmE= +github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6 h1:Ho3MozYaNyuPkA89US+eUhl1vCZu13AkEgsVL6hPelk= +github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6/go.mod h1:8JBGPGBUb4M7QT171djWQrpDO8LPEeJ4lH1z3uo/ZKQ= github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A= github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1 h1:xF5wHug6H8vKfz7p1LYy9jck6eD9K1HLjTdi6o4kg1k= diff --git a/integration/go.mod b/integration/go.mod index d524db26250..dee6e424a8e 100644 --- a/integration/go.mod +++ b/integration/go.mod @@ -20,7 +20,7 @@ require ( github.com/ipfs/go-ds-badger2 v0.1.3 github.com/ipfs/go-ipfs-blockstore v1.3.0 github.com/libp2p/go-libp2p v0.32.2 - github.com/onflow/cadence v0.42.10 + github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6 github.com/onflow/crypto v0.25.1 github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1 github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1 @@ -252,7 +252,7 @@ require ( github.com/multiformats/go-multistream v0.5.0 // indirect github.com/multiformats/go-varint v0.0.7 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6 // indirect + github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189 // indirect github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 // indirect github.com/onflow/flow-nft/lib/go/contracts v1.1.0 // indirect github.com/onflow/nft-storefront/lib/go/contracts v0.0.0-20221222181731-14b90207cead // indirect diff --git a/integration/go.sum b/integration/go.sum index 1f97b61a42c..85d3b128452 100644 --- a/integration/go.sum +++ b/integration/go.sum @@ -1403,11 +1403,11 @@ github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1 github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onflow/atree v0.1.0-beta1.0.20211027184039-559ee654ece9/go.mod h1:+6x071HgCF/0v5hQcaE5qqjc2UqN5gCU8h5Mk6uqpOg= -github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6 h1:FwSfDsR7ipLoL5Iq0TR5Oe7PwOftjbksodIoY1nx6bM= -github.com/onflow/atree v0.6.1-0.20240124211117-2fbf86010ae6/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A= +github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189 h1:9PWA8BpJUrnSAGHXNNBvgzH3bv71fectqZokZw1++jE= +github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A= github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA= -github.com/onflow/cadence v0.42.10 h1:3oC5ceeXhdCrhHcf9H0yYXQKW3Tw/vkSXLe+PUZa4i0= -github.com/onflow/cadence v0.42.10/go.mod h1:1wFd+LiNiN6qoZXof3MBdpM6d8BsxbVIxOA77LbIYmE= +github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6 h1:Ho3MozYaNyuPkA89US+eUhl1vCZu13AkEgsVL6hPelk= +github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6/go.mod h1:8JBGPGBUb4M7QT171djWQrpDO8LPEeJ4lH1z3uo/ZKQ= github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A= github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1 h1:xF5wHug6H8vKfz7p1LYy9jck6eD9K1HLjTdi6o4kg1k= From 5c24862d69bc0ef2c22c5175ae0438f82677210a Mon Sep 17 00:00:00 2001 From: Faye Amacker <33205765+fxamacker@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:35:51 -0500 Subject: [PATCH 7/9] Bump Cadence version to v0.42.11-atree-register-inlining --- go.mod | 4 ++-- go.sum | 8 ++++---- insecure/go.mod | 4 ++-- insecure/go.sum | 8 ++++---- integration/go.mod | 4 ++-- integration/go.sum | 8 ++++---- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index 1bd8be63043..a274c0cdef0 100644 --- a/go.mod +++ b/go.mod @@ -50,8 +50,8 @@ require ( github.com/multiformats/go-multiaddr v0.12.2 github.com/multiformats/go-multiaddr-dns v0.3.1 github.com/multiformats/go-multihash v0.2.3 - github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189 - github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6 + github.com/onflow/atree v0.6.1-0.20240417191405-e11f55fa33a3 + github.com/onflow/cadence v0.42.11-atree-register-inlining github.com/onflow/crypto v0.25.1 github.com/onflow/flow v0.3.4 github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1 diff --git a/go.sum b/go.sum index e10917f92db..bb3274f6173 100644 --- a/go.sum +++ b/go.sum @@ -1346,13 +1346,13 @@ github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1 github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onflow/atree v0.1.0-beta1.0.20211027184039-559ee654ece9/go.mod h1:+6x071HgCF/0v5hQcaE5qqjc2UqN5gCU8h5Mk6uqpOg= -github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189 h1:9PWA8BpJUrnSAGHXNNBvgzH3bv71fectqZokZw1++jE= -github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A= +github.com/onflow/atree v0.6.1-0.20240417191405-e11f55fa33a3 h1:K8LKxRn1rRdDXLCvYlDNdlQyB28b+fx2doYiIaNGnQU= +github.com/onflow/atree v0.6.1-0.20240417191405-e11f55fa33a3/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A= github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483 h1:LpiQhTAfM9CAmNVEs0n//cBBgCg+vJSiIxTHYUklZ84= github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA= -github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6 h1:Ho3MozYaNyuPkA89US+eUhl1vCZu13AkEgsVL6hPelk= -github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6/go.mod h1:8JBGPGBUb4M7QT171djWQrpDO8LPEeJ4lH1z3uo/ZKQ= +github.com/onflow/cadence v0.42.11-atree-register-inlining h1:WLZfTpUjyE6df/IS6cLur1CC13te9yohuHcl1GeURfg= +github.com/onflow/cadence v0.42.11-atree-register-inlining/go.mod h1:yLghyxuE56vMMncpU9fC+Km/t/+Y0B+ZXhXOGRLd29g= github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A= github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/flow v0.3.4 h1:FXUWVdYB90f/rjNcY0Owo30gL790tiYff9Pb/sycXYE= diff --git a/insecure/go.mod b/insecure/go.mod index c63abe5f4d6..324c0709f55 100644 --- a/insecure/go.mod +++ b/insecure/go.mod @@ -203,8 +203,8 @@ require ( github.com/multiformats/go-multistream v0.5.0 // indirect github.com/multiformats/go-varint v0.0.7 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189 // indirect - github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6 // indirect + github.com/onflow/atree v0.6.1-0.20240417191405-e11f55fa33a3 // indirect + github.com/onflow/cadence v0.42.11-atree-register-inlining // indirect github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1 // indirect github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1 // indirect github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 // indirect diff --git a/insecure/go.sum b/insecure/go.sum index a11e6e00681..4e03516c2e3 100644 --- a/insecure/go.sum +++ b/insecure/go.sum @@ -1313,11 +1313,11 @@ github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1 github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onflow/atree v0.1.0-beta1.0.20211027184039-559ee654ece9/go.mod h1:+6x071HgCF/0v5hQcaE5qqjc2UqN5gCU8h5Mk6uqpOg= -github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189 h1:9PWA8BpJUrnSAGHXNNBvgzH3bv71fectqZokZw1++jE= -github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A= +github.com/onflow/atree v0.6.1-0.20240417191405-e11f55fa33a3 h1:K8LKxRn1rRdDXLCvYlDNdlQyB28b+fx2doYiIaNGnQU= +github.com/onflow/atree v0.6.1-0.20240417191405-e11f55fa33a3/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A= github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA= -github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6 h1:Ho3MozYaNyuPkA89US+eUhl1vCZu13AkEgsVL6hPelk= -github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6/go.mod h1:8JBGPGBUb4M7QT171djWQrpDO8LPEeJ4lH1z3uo/ZKQ= +github.com/onflow/cadence v0.42.11-atree-register-inlining h1:WLZfTpUjyE6df/IS6cLur1CC13te9yohuHcl1GeURfg= +github.com/onflow/cadence v0.42.11-atree-register-inlining/go.mod h1:yLghyxuE56vMMncpU9fC+Km/t/+Y0B+ZXhXOGRLd29g= github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A= github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1 h1:xF5wHug6H8vKfz7p1LYy9jck6eD9K1HLjTdi6o4kg1k= diff --git a/integration/go.mod b/integration/go.mod index dee6e424a8e..67339ef448e 100644 --- a/integration/go.mod +++ b/integration/go.mod @@ -20,7 +20,7 @@ require ( github.com/ipfs/go-ds-badger2 v0.1.3 github.com/ipfs/go-ipfs-blockstore v1.3.0 github.com/libp2p/go-libp2p v0.32.2 - github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6 + github.com/onflow/cadence v0.42.11-atree-register-inlining github.com/onflow/crypto v0.25.1 github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1 github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1 @@ -252,7 +252,7 @@ require ( github.com/multiformats/go-multistream v0.5.0 // indirect github.com/multiformats/go-varint v0.0.7 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189 // indirect + github.com/onflow/atree v0.6.1-0.20240417191405-e11f55fa33a3 // indirect github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 // indirect github.com/onflow/flow-nft/lib/go/contracts v1.1.0 // indirect github.com/onflow/nft-storefront/lib/go/contracts v0.0.0-20221222181731-14b90207cead // indirect diff --git a/integration/go.sum b/integration/go.sum index 85d3b128452..7f5fe9cf64d 100644 --- a/integration/go.sum +++ b/integration/go.sum @@ -1403,11 +1403,11 @@ github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1 github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onflow/atree v0.1.0-beta1.0.20211027184039-559ee654ece9/go.mod h1:+6x071HgCF/0v5hQcaE5qqjc2UqN5gCU8h5Mk6uqpOg= -github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189 h1:9PWA8BpJUrnSAGHXNNBvgzH3bv71fectqZokZw1++jE= -github.com/onflow/atree v0.6.1-0.20240405171204-c6c951de7189/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A= +github.com/onflow/atree v0.6.1-0.20240417191405-e11f55fa33a3 h1:K8LKxRn1rRdDXLCvYlDNdlQyB28b+fx2doYiIaNGnQU= +github.com/onflow/atree v0.6.1-0.20240417191405-e11f55fa33a3/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A= github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA= -github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6 h1:Ho3MozYaNyuPkA89US+eUhl1vCZu13AkEgsVL6hPelk= -github.com/onflow/cadence v0.42.10-0.20240409201024-d000241476d6/go.mod h1:8JBGPGBUb4M7QT171djWQrpDO8LPEeJ4lH1z3uo/ZKQ= +github.com/onflow/cadence v0.42.11-atree-register-inlining h1:WLZfTpUjyE6df/IS6cLur1CC13te9yohuHcl1GeURfg= +github.com/onflow/cadence v0.42.11-atree-register-inlining/go.mod h1:yLghyxuE56vMMncpU9fC+Km/t/+Y0B+ZXhXOGRLd29g= github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A= github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1 h1:xF5wHug6H8vKfz7p1LYy9jck6eD9K1HLjTdi6o4kg1k= From 860d515e63e73b03222acda7f54c9859b643b8ce Mon Sep 17 00:00:00 2001 From: Faye Amacker <33205765+fxamacker@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:59:14 -0500 Subject: [PATCH 8/9] Update hash and balance in tests --- engine/execution/state/bootstrap/bootstrap_test.go | 2 +- fvm/accounts_test.go | 2 +- utils/unittest/execution_state.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/engine/execution/state/bootstrap/bootstrap_test.go b/engine/execution/state/bootstrap/bootstrap_test.go index 74882ee91c8..b1c74165c30 100644 --- a/engine/execution/state/bootstrap/bootstrap_test.go +++ b/engine/execution/state/bootstrap/bootstrap_test.go @@ -53,7 +53,7 @@ func TestBootstrapLedger(t *testing.T) { } func TestBootstrapLedger_ZeroTokenSupply(t *testing.T) { - expectedStateCommitmentBytes, _ := hex.DecodeString("c5db3f88be8f6944747576929afca0bfa4bf82359d235c76e78fbb478f8438f2") + expectedStateCommitmentBytes, _ := hex.DecodeString("63460bc100d7d6a2f5dde4eeaba9c65e195d80585ecec77665b2c2ce754c1c24") expectedStateCommitment, err := flow.ToStateCommitment(expectedStateCommitmentBytes) require.NoError(t, err) diff --git a/fvm/accounts_test.go b/fvm/accounts_test.go index c04bf5329ad..69cc7130927 100644 --- a/fvm/accounts_test.go +++ b/fvm/accounts_test.go @@ -1606,7 +1606,7 @@ func TestAccountBalanceFields(t *testing.T) { _, output, err = vm.Run(ctx, script, snapshotTree) assert.NoError(t, err) assert.NoError(t, output.Err) - assert.Equal(t, cadence.UFix64(99_993_770), output.Value) + assert.Equal(t, cadence.UFix64(99_993_750), output.Value) }), ) diff --git a/utils/unittest/execution_state.go b/utils/unittest/execution_state.go index 346cf0b0aad..a16d4147682 100644 --- a/utils/unittest/execution_state.go +++ b/utils/unittest/execution_state.go @@ -23,7 +23,7 @@ const ServiceAccountPrivateKeySignAlgo = crypto.ECDSAP256 const ServiceAccountPrivateKeyHashAlgo = hash.SHA2_256 // Pre-calculated state commitment with root account with the above private key -const GenesisStateCommitmentHex = "c2e4cf56d5447f5a3b6524c35117b9df3adee4465806962dfc48ceac65f6b8cb" +const GenesisStateCommitmentHex = "8532eeb487ee2b9cd09f1901724f3d208d03f6a32ed2f1adca54d020856f6196" var GenesisStateCommitment flow.StateCommitment @@ -87,7 +87,7 @@ func genesisCommitHexByChainID(chainID flow.ChainID) string { return GenesisStateCommitmentHex } if chainID == flow.Testnet { - return "0bff6bb390188ecb177012d8bc6358f6f4828e36ab217f45ecb31a58fb75e588" + return "541e601892c653d4c11ef6f851acda92f0f4c6be6f413308d20cbe2e6ee47e28" } - return "3d1d0f6f0c347522edc370d3182c22b9345c288c76d3b46c4f5b33e4b7545041" + return "b4dbbc9dbe0f238176770ed5590890c75a1316ed286f7ed7a5012fe485b82960" } From 62c77802b05e0dc93a3139c1bde3ed2461d4354b Mon Sep 17 00:00:00 2001 From: Faye Amacker <33205765+fxamacker@users.noreply.github.com> Date: Thu, 18 Apr 2024 22:46:51 -0500 Subject: [PATCH 9/9] Check slab ID address --- fvm/evm/emulator/state/collection.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fvm/evm/emulator/state/collection.go b/fvm/evm/emulator/state/collection.go index 80b8c9621e6..bc78fce234b 100644 --- a/fvm/evm/emulator/state/collection.go +++ b/fvm/evm/emulator/state/collection.go @@ -51,10 +51,14 @@ func (cp *CollectionProvider) CollectionByID(collectionID []byte) (*Collection, if err != nil { return nil, err } - // TODO: sanity check the slab ID address - // if slabID.Address != cp.rootAddr { - // return nil, fmt.Errorf("root address mismatch %x != %x", storageID.Address, cp.rootAddr) - // } + + // sanity check the slab ID address + var address atree.Address + binary.BigEndian.PutUint64(address[:], slabID.AddressAsUint64()) + + if address != cp.rootAddr { + return nil, fmt.Errorf("root address mismatch %x != %x", address, cp.rootAddr) + } omap, err := atree.NewMapWithRootID(cp.storage, slabID, atree.NewDefaultDigesterBuilder()) if err != nil {