From 40310140cee55bdc898bff784a7f1482bd7d6cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Sat, 10 Aug 2024 21:37:18 -0700 Subject: [PATCH 1/5] Update to Cadence v1.0.0-preview.44 --- go.mod | 2 +- go.sum | 4 ++-- insecure/go.mod | 2 +- insecure/go.sum | 4 ++-- integration/go.mod | 2 +- integration/go.sum | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 1a24448c28d..ae57b143296 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,7 @@ require ( github.com/onflow/flow v0.3.4 github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1 github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1 - github.com/onflow/flow-go-sdk v1.0.0-preview.46 + github.com/onflow/flow-go-sdk v1.0.0-preview.47 github.com/onflow/flow/protobuf/go/flow v0.4.5 github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 github.com/pierrec/lz4 v2.6.1+incompatible diff --git a/go.sum b/go.sum index e50b11b40b1..a228161f5cc 100644 --- a/go.sum +++ b/go.sum @@ -2183,8 +2183,8 @@ github.com/onflow/flow-ft/lib/go/contracts v1.0.0/go.mod h1:PwsL8fC81cjnUnTfmyL/ github.com/onflow/flow-ft/lib/go/templates v1.0.0 h1:6cMS/lUJJ17HjKBfMO/eh0GGvnpElPgBXx7h5aoWJhs= github.com/onflow/flow-ft/lib/go/templates v1.0.0/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE= github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo= -github.com/onflow/flow-go-sdk v1.0.0-preview.46 h1:bJRrM1t1xAT/ckvHT3AOmg9W9mljKUIfurSzIiNDNkY= -github.com/onflow/flow-go-sdk v1.0.0-preview.46/go.mod h1:giVRWZHuXcKbJCB666/cL67l/Z7d3SuH+N/N32lnFDo= +github.com/onflow/flow-go-sdk v1.0.0-preview.47 h1:vdolgj6nFCR/xPoEOHyYzAg9o9hdXQpPnL7HJPPTXGU= +github.com/onflow/flow-go-sdk v1.0.0-preview.47/go.mod h1:YAYzmUUytKqri3aMgeKGjvDjvawignNobUI9s2mKdXY= github.com/onflow/flow-nft/lib/go/contracts v1.2.1 h1:woAAS5z651sDpi7ihAHll8NvRS9uFXIXkL6xR+bKFZY= github.com/onflow/flow-nft/lib/go/contracts v1.2.1/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE= github.com/onflow/flow-nft/lib/go/templates v1.2.0 h1:JSQyh9rg0RC+D1930BiRXN8lrtMs+ubVMK6aQPon6Yc= diff --git a/insecure/go.mod b/insecure/go.mod index 4a5a8fb5d2f..1f367abeed7 100644 --- a/insecure/go.mod +++ b/insecure/go.mod @@ -207,7 +207,7 @@ require ( github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1 // indirect github.com/onflow/flow-ft/lib/go/contracts v1.0.0 // indirect github.com/onflow/flow-ft/lib/go/templates v1.0.0 // indirect - github.com/onflow/flow-go-sdk v1.0.0-preview.46 // indirect + github.com/onflow/flow-go-sdk v1.0.0-preview.47 // indirect github.com/onflow/flow-nft/lib/go/contracts v1.2.1 // indirect github.com/onflow/flow-nft/lib/go/templates v1.2.0 // indirect github.com/onflow/flow/protobuf/go/flow v0.4.5 // indirect diff --git a/insecure/go.sum b/insecure/go.sum index bb81e58ac7f..453154bfcd3 100644 --- a/insecure/go.sum +++ b/insecure/go.sum @@ -2171,8 +2171,8 @@ github.com/onflow/flow-ft/lib/go/contracts v1.0.0/go.mod h1:PwsL8fC81cjnUnTfmyL/ github.com/onflow/flow-ft/lib/go/templates v1.0.0 h1:6cMS/lUJJ17HjKBfMO/eh0GGvnpElPgBXx7h5aoWJhs= github.com/onflow/flow-ft/lib/go/templates v1.0.0/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE= github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo= -github.com/onflow/flow-go-sdk v1.0.0-preview.46 h1:bJRrM1t1xAT/ckvHT3AOmg9W9mljKUIfurSzIiNDNkY= -github.com/onflow/flow-go-sdk v1.0.0-preview.46/go.mod h1:giVRWZHuXcKbJCB666/cL67l/Z7d3SuH+N/N32lnFDo= +github.com/onflow/flow-go-sdk v1.0.0-preview.47 h1:vdolgj6nFCR/xPoEOHyYzAg9o9hdXQpPnL7HJPPTXGU= +github.com/onflow/flow-go-sdk v1.0.0-preview.47/go.mod h1:YAYzmUUytKqri3aMgeKGjvDjvawignNobUI9s2mKdXY= github.com/onflow/flow-nft/lib/go/contracts v1.2.1 h1:woAAS5z651sDpi7ihAHll8NvRS9uFXIXkL6xR+bKFZY= github.com/onflow/flow-nft/lib/go/contracts v1.2.1/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE= github.com/onflow/flow-nft/lib/go/templates v1.2.0 h1:JSQyh9rg0RC+D1930BiRXN8lrtMs+ubVMK6aQPon6Yc= diff --git a/integration/go.mod b/integration/go.mod index 0658515807c..4303d3960bb 100644 --- a/integration/go.mod +++ b/integration/go.mod @@ -26,7 +26,7 @@ require ( github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1 github.com/onflow/flow-emulator v1.0.0-preview.36.0.20240729195722-d4eb1c30eb9f github.com/onflow/flow-go v0.36.8-0.20240729193633-433a32eeb0cd - github.com/onflow/flow-go-sdk v1.0.0-preview.46 + github.com/onflow/flow-go-sdk v1.0.0-preview.47 github.com/onflow/flow-go/insecure v0.0.0-00010101000000-000000000000 github.com/onflow/flow/protobuf/go/flow v0.4.5 github.com/onflow/go-ethereum v1.14.7 diff --git a/integration/go.sum b/integration/go.sum index b8039a7b298..dff41fd195e 100644 --- a/integration/go.sum +++ b/integration/go.sum @@ -2157,8 +2157,8 @@ github.com/onflow/flow-ft/lib/go/contracts v1.0.0/go.mod h1:PwsL8fC81cjnUnTfmyL/ github.com/onflow/flow-ft/lib/go/templates v1.0.0 h1:6cMS/lUJJ17HjKBfMO/eh0GGvnpElPgBXx7h5aoWJhs= github.com/onflow/flow-ft/lib/go/templates v1.0.0/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE= github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo= -github.com/onflow/flow-go-sdk v1.0.0-preview.46 h1:bJRrM1t1xAT/ckvHT3AOmg9W9mljKUIfurSzIiNDNkY= -github.com/onflow/flow-go-sdk v1.0.0-preview.46/go.mod h1:giVRWZHuXcKbJCB666/cL67l/Z7d3SuH+N/N32lnFDo= +github.com/onflow/flow-go-sdk v1.0.0-preview.47 h1:vdolgj6nFCR/xPoEOHyYzAg9o9hdXQpPnL7HJPPTXGU= +github.com/onflow/flow-go-sdk v1.0.0-preview.47/go.mod h1:YAYzmUUytKqri3aMgeKGjvDjvawignNobUI9s2mKdXY= github.com/onflow/flow-nft/lib/go/contracts v1.2.1 h1:woAAS5z651sDpi7ihAHll8NvRS9uFXIXkL6xR+bKFZY= github.com/onflow/flow-nft/lib/go/contracts v1.2.1/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE= github.com/onflow/flow-nft/lib/go/templates v1.2.0 h1:JSQyh9rg0RC+D1930BiRXN8lrtMs+ubVMK6aQPon6Yc= From 1bdf71a3f84f466dda0a2f553dace936a9eaaad3 Mon Sep 17 00:00:00 2001 From: Supun Setunga Date: Mon, 12 Aug 2024 10:16:53 -0700 Subject: [PATCH 2/5] Avoid conversion from sema-type to StaticType in storage cap migration --- cmd/util/ledger/migrations/cadence.go | 16 +- .../migrations/cadence_values_migration.go | 10 +- .../cadence_values_migration_test.go | 137 ++++++++++++++++-- 3 files changed, 137 insertions(+), 26 deletions(-) diff --git a/cmd/util/ledger/migrations/cadence.go b/cmd/util/ledger/migrations/cadence.go index 69b3948951c..463a6e30165 100644 --- a/cmd/util/ledger/migrations/cadence.go +++ b/cmd/util/ledger/migrations/cadence.go @@ -227,7 +227,7 @@ type IssueStorageCapConMigration struct { accountsCapabilities *capcons.AccountsCapabilities interpreterMigrationRuntimeConfig InterpreterMigrationRuntimeConfig programs map[runtime.Location]*interpreter.Program - mapping *capcons.CapabilityMapping + mapping *capcons.PathTypeCapabilityMapping reporter reporters.ReportWriter logVerboseDiff bool verboseErrorOutput bool @@ -243,7 +243,7 @@ func NewIssueStorageCapConMigration( chainID flow.ChainID, storageDomainCapabilities *capcons.AccountsCapabilities, programs map[runtime.Location]*interpreter.Program, - capabilityMapping *capcons.CapabilityMapping, + storageCapabilityMapping *capcons.PathTypeCapabilityMapping, opts Options, ) *IssueStorageCapConMigration { return &IssueStorageCapConMigration{ @@ -252,7 +252,7 @@ func NewIssueStorageCapConMigration( chainID: chainID, accountsCapabilities: storageDomainCapabilities, programs: programs, - mapping: capabilityMapping, + mapping: storageCapabilityMapping, logVerboseDiff: opts.LogVerboseDiff, verboseErrorOutput: opts.VerboseErrorOutput, errorMessageHandler: errorMessageHandler, @@ -384,7 +384,8 @@ func NewCadence1ValueMigrations( // Populated by CadenceLinkValueMigration, // used by CadenceCapabilityValueMigration - capabilityMapping := &capcons.CapabilityMapping{} + privatePublicCapabilityMapping := &capcons.PathCapabilityMapping{} + storageCapabilityMapping := &capcons.PathTypeCapabilityMapping{} // Populated by StorageCapMigration, // used by IssueStorageCapConMigration @@ -445,7 +446,7 @@ func NewCadence1ValueMigrations( opts.ChainID, storageDomainCapabilities, programs, - capabilityMapping, + storageCapabilityMapping, opts, ) return migration.name, migration @@ -456,7 +457,7 @@ func NewCadence1ValueMigrations( rwf, errorMessageHandler, programs, - capabilityMapping, + privatePublicCapabilityMapping, opts, ) return migration.name, migration @@ -466,7 +467,8 @@ func NewCadence1ValueMigrations( rwf, errorMessageHandler, programs, - capabilityMapping, + privatePublicCapabilityMapping, + storageCapabilityMapping, opts, ) return migration.name, migration diff --git a/cmd/util/ledger/migrations/cadence_values_migration.go b/cmd/util/ledger/migrations/cadence_values_migration.go index c484d34cb35..993b27da46b 100644 --- a/cmd/util/ledger/migrations/cadence_values_migration.go +++ b/cmd/util/ledger/migrations/cadence_values_migration.go @@ -324,7 +324,7 @@ func NewCadence1LinkValueMigration( rwf reporters.ReportWriterFactory, errorMessageHandler *errorMessageHandler, programs map[runtime.Location]*interpreter.Program, - capabilityMapping *capcons.CapabilityMapping, + capabilityMapping *capcons.PathCapabilityMapping, opts Options, ) *CadenceBaseMigration { var diffReporter reporters.ReportWriter @@ -380,7 +380,8 @@ func NewCadence1CapabilityValueMigration( rwf reporters.ReportWriterFactory, errorMessageHandler *errorMessageHandler, programs map[runtime.Location]*interpreter.Program, - capabilityMapping *capcons.CapabilityMapping, + privatePublicCapabilityMapping *capcons.PathCapabilityMapping, + storageCapabilityMapping *capcons.PathTypeCapabilityMapping, opts Options, ) *CadenceBaseMigration { var diffReporter reporters.ReportWriter @@ -402,8 +403,9 @@ func NewCadence1CapabilityValueMigration( ) []migrations.ValueMigration { return []migrations.ValueMigration{ &capcons.CapabilityValueMigration{ - CapabilityMapping: capabilityMapping, - Reporter: reporter, + PrivatePublicCapabilityMapping: privatePublicCapabilityMapping, + StorageCapabilityMapping: storageCapabilityMapping, + Reporter: reporter, }, } }, diff --git a/cmd/util/ledger/migrations/cadence_values_migration_test.go b/cmd/util/ledger/migrations/cadence_values_migration_test.go index 6bf3a3977b9..b31531627e0 100644 --- a/cmd/util/ledger/migrations/cadence_values_migration_test.go +++ b/cmd/util/ledger/migrations/cadence_values_migration_test.go @@ -15,6 +15,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/runtime/common" "github.com/onflow/cadence/runtime/interpreter" "github.com/onflow/cadence/runtime/sema" @@ -2162,16 +2163,47 @@ func TestStoragePathCapabilityMigration(t *testing.T) { addressB, err := common.HexToAddress("0xe5a8b7f23e8b548f") require.NoError(t, err) - runtime, err := NewInterpreterMigrationRuntime( + addressC, err := common.HexToAddress("0x1") + require.NoError(t, err) + + // Store a contract in `addressC`. + + const contractName = "Test" + contractAddress := addressC + + err = registersByAccount.Set( + string(contractAddress[:]), + flow.ContractKey(contractName), + []byte(` + pub contract Test { + access(all) resource R {} + } + `), + ) + require.NoError(t, err) + + encodedContractNames, err := environment.EncodeContractNames([]string{contractName}) + require.NoError(t, err) + + err = registersByAccount.Set( + string(contractAddress[:]), + flow.ContractNamesKey, + encodedContractNames, + ) + require.NoError(t, err) + + migrationRuntime, err := NewInterpreterMigrationRuntime( registersByAccount, chainID, InterpreterMigrationRuntimeConfig{}, ) require.NoError(t, err) - storage := runtime.Storage + storage := migrationRuntime.Storage storageDomain := common.PathDomainStorage.Identifier() + // Store a capability with storage path + storageMap := storage.GetStorageMap( addressA, storageDomain, @@ -2184,8 +2216,6 @@ func TestStoragePathCapabilityMigration(t *testing.T) { interpreter.PrimitiveStaticTypeAnyStruct, ) - // Store a capability with storage path - fooCapStorageMapKey := interpreter.StringStorageMapKey("fooCap") capabilityFoo := &interpreter.PathCapabilityValue{ @@ -2198,7 +2228,7 @@ func TestStoragePathCapabilityMigration(t *testing.T) { } storageMap.WriteValue( - runtime.Interpreter, + migrationRuntime.Interpreter, fooCapStorageMapKey, capabilityFoo, ) @@ -2216,16 +2246,47 @@ func TestStoragePathCapabilityMigration(t *testing.T) { } storageMap.WriteValue( - runtime.Interpreter, + migrationRuntime.Interpreter, barCapStorageMapKey, capabilityBar, ) - err = storage.NondeterministicCommit(runtime.Interpreter, false) + // Store a third capability with storage path, and with a broken type + + bazBorrowType := interpreter.NewReferenceStaticType( + nil, + interpreter.UnauthorizedAccess, + interpreter.NewCompositeStaticTypeComputeTypeID( + nil, + common.NewAddressLocation(nil, contractAddress, "Test"), + "Test.R", + ), + ) + + bazCapStorageMapKey := interpreter.StringStorageMapKey("bazCap") + + bazCapability := &interpreter.PathCapabilityValue{ + BorrowType: bazBorrowType, + Path: interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "baz"), + + // Important: Capability must be for a different address, + // compared to where the capability is stored. + Address: interpreter.AddressValue(addressB), + } + + storageMap.WriteValue( + migrationRuntime.Interpreter, + bazCapStorageMapKey, + bazCapability, + ) + + // Commit + + err = storage.NondeterministicCommit(migrationRuntime.Interpreter, false) require.NoError(t, err) // finalize the transaction - result, err := runtime.TransactionState.FinalizeMainTransaction() + result, err := migrationRuntime.TransactionState.FinalizeMainTransaction() require.NoError(t, err) // Merge the changes into the registers @@ -2275,18 +2336,35 @@ func TestStoragePathCapabilityMigration(t *testing.T) { reporter := rwf.reportWriters[capabilityValueMigrationReporterName] require.NotNil(t, reporter) - require.Len(t, reporter.entries, 3) + require.Len(t, reporter.entries, 5) require.Equal( t, []any{ - capabilityMissingCapabilityIDEntry{ + storageCapConsMissingBorrowTypeEntry{ AccountAddress: addressA, AddressPath: interpreter.AddressPath{ Address: addressB, Path: interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "bar"), }, }, + capabilityMigrationEntry{ + AccountAddress: addressA, + AddressPath: interpreter.AddressPath{ + Address: addressB, + Path: interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "baz"), + }, + BorrowType: bazBorrowType, + CapabilityID: 3, + }, + cadenceValueMigrationEntry{ + StorageKey: interpreter.StorageKey{ + Key: storageDomain, + Address: addressA, + }, + StorageMapKey: bazCapStorageMapKey, + Migration: "CapabilityValueMigration", + }, capabilityMigrationEntry{ AccountAddress: addressA, AddressPath: interpreter.AddressPath{ @@ -2294,7 +2372,7 @@ func TestStoragePathCapabilityMigration(t *testing.T) { Path: interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "foo"), }, BorrowType: borrowType, - CapabilityID: 3, + CapabilityID: 4, }, cadenceValueMigrationEntry{ StorageKey: interpreter.StorageKey{ @@ -2310,7 +2388,7 @@ func TestStoragePathCapabilityMigration(t *testing.T) { issueStorageCapConReporter := rwf.reportWriters[issueStorageCapConMigrationReporterName] require.NotNil(t, issueStorageCapConReporter) - require.Len(t, issueStorageCapConReporter.entries, 2) + require.Len(t, issueStorageCapConReporter.entries, 3) require.Equal( t, []any{ @@ -2321,6 +2399,15 @@ func TestStoragePathCapabilityMigration(t *testing.T) { Path: interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "bar"), }, }, + storageCapConIssuedEntry{ + AccountAddress: addressB, + AddressPath: interpreter.AddressPath{ + Address: addressB, + Path: interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "baz"), + }, + BorrowType: bazBorrowType, + CapabilityID: 3, + }, storageCapConIssuedEntry{ AccountAddress: addressB, AddressPath: interpreter.AddressPath{ @@ -2328,7 +2415,7 @@ func TestStoragePathCapabilityMigration(t *testing.T) { Path: interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "foo"), }, BorrowType: borrowType, - CapabilityID: 3, + CapabilityID: 4, }, }, issueStorageCapConReporter.entries, @@ -2347,7 +2434,7 @@ func TestStoragePathCapabilityMigration(t *testing.T) { let storage = getAuthAccount(%s).storage let fooCap = storage.copy(from: /storage/fooCap)! let barCap = storage.copy(from: /storage/barCap)! - assert(fooCap.id == 3) + assert(fooCap.id == 4) assert(barCap.id == 0) } `, @@ -2356,6 +2443,26 @@ func TestStoragePathCapabilityMigration(t *testing.T) { ) require.NoError(t, err) + // check the cap with the broken type + + _, err = runScript( + chainID, + registersByAccount, + fmt.Sprintf( + //language=Cadence + ` + access(all) + fun main() { + let storage = getAuthAccount(%s).storage + let bazCap = storage.copy(from: /storage/bazCap)! + } + `, + addressA.HexWithPrefix(), + ), + ) + require.Error(t, err) + require.ErrorAs(t, &runtime.ParsingCheckingError{}, &err) + // Check account B _, err = runScript( @@ -2369,7 +2476,7 @@ func TestStoragePathCapabilityMigration(t *testing.T) { let capabilities = getAuthAccount(%s).capabilities.storage let fooCapCons = capabilities.getControllers(forPath: /storage/foo) assert(fooCapCons.length == 1) - assert(fooCapCons[0].capabilityID == 3) + assert(fooCapCons[0].capabilityID == 4) } `, addressB.HexWithPrefix(), From edee8b7b4f2613d7b83e6ea7577a9345c598530d Mon Sep 17 00:00:00 2001 From: Yurii Oleksyshyn Date: Mon, 12 Aug 2024 20:36:18 +0300 Subject: [PATCH 3/5] Rename EpochCommitSafetyThreshold -> FinalizationSafetyThreshold --- .../protocol/protocol_state/kvstore/models.go | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/state/protocol/protocol_state/kvstore/models.go b/state/protocol/protocol_state/kvstore/models.go index ddc81590d0b..851200a08b3 100644 --- a/state/protocol/protocol_state/kvstore/models.go +++ b/state/protocol/protocol_state/kvstore/models.go @@ -54,9 +54,9 @@ func (model *UpgradableModel) GetVersionUpgrade() *protocol.ViewBasedActivator[u // with multiple supported KV model versions from the beginning. type Modelv0 struct { UpgradableModel - EpochStateID flow.Identifier - EpochExtensionViewCount uint64 - EpochCommitSafetyThreshold uint64 + EpochStateID flow.Identifier + EpochExtensionViewCount uint64 + FinalizationSafetyThreshold uint64 } var _ protocol_state.KVStoreAPI = (*Modelv0)(nil) @@ -121,11 +121,11 @@ func (model *Modelv0) SetEpochStateID(id flow.Identifier) { // Expected errors during normal operations: // - kvstore.ErrInvalidValue - if the view count is less than FinalizationSafetyThreshold*2. func (model *Modelv0) SetEpochExtensionViewCount(viewCount uint64) error { - // Strictly speaking it should be perfectly fine to use a value viewCount >= model.EpochCommitSafetyThreshold. + // Strictly speaking it should be perfectly fine to use a value viewCount >= model.FinalizationSafetyThreshold. // By using a sligtly higher value(factor of 2) we ensure that extension is big enough in practice to give operators a bigger // window in which a valid epoch recover event could be submitted. - if viewCount < model.EpochCommitSafetyThreshold*2 { - return fmt.Errorf("invalid view count %d, expect at least %d: %w", viewCount, model.EpochCommitSafetyThreshold*2, ErrInvalidValue) + if viewCount < model.FinalizationSafetyThreshold*2 { + return fmt.Errorf("invalid view count %d, expect at least %d: %w", viewCount, model.FinalizationSafetyThreshold*2, ErrInvalidValue) } model.EpochExtensionViewCount = viewCount return nil @@ -140,7 +140,7 @@ func (model *Modelv0) GetEpochExtensionViewCount() uint64 { } func (model *Modelv0) GetEpochCommitSafetyThreshold() uint64 { - return model.EpochCommitSafetyThreshold + return model.FinalizationSafetyThreshold } // Modelv1 is v1 of the Protocol State key-value store. @@ -208,9 +208,9 @@ func NewDefaultKVStore(finalizationSafetyThreshold, epochExtensionViewCount uint // version upgrades, from v0 to v1. func newKVStoreV0(finalizationSafetyThreshold, epochExtensionViewCount uint64, epochStateID flow.Identifier) (*Modelv0, error) { model := &Modelv0{ - UpgradableModel: UpgradableModel{}, - EpochStateID: epochStateID, - EpochCommitSafetyThreshold: finalizationSafetyThreshold, + UpgradableModel: UpgradableModel{}, + EpochStateID: epochStateID, + FinalizationSafetyThreshold: finalizationSafetyThreshold, } // use a setter to ensure the default value is valid and is not accidentally lower than the safety threshold. err := model.SetEpochExtensionViewCount(epochExtensionViewCount) From c2fa794e8c8265f5c1f724c93a57123d8fd0843d Mon Sep 17 00:00:00 2001 From: Supun Setunga Date: Mon, 12 Aug 2024 10:38:50 -0700 Subject: [PATCH 4/5] Update to cadence v1.0.0-preview.45 --- go.mod | 2 +- go.sum | 4 ++-- insecure/go.mod | 2 +- insecure/go.sum | 4 ++-- integration/go.mod | 2 +- integration/go.sum | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index ae57b143296..38adcf3d1e9 100644 --- a/go.mod +++ b/go.mod @@ -48,7 +48,7 @@ require ( github.com/multiformats/go-multiaddr-dns v0.3.1 github.com/multiformats/go-multihash v0.2.3 github.com/onflow/atree v0.8.0-rc.5 - github.com/onflow/cadence v1.0.0-preview.44 + github.com/onflow/cadence v1.0.0-preview.45 github.com/onflow/crypto v0.25.1 github.com/onflow/flow v0.3.4 github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1 diff --git a/go.sum b/go.sum index a228161f5cc..d2c9ca34fd6 100644 --- a/go.sum +++ b/go.sum @@ -2167,8 +2167,8 @@ github.com/onflow/atree v0.8.0-rc.5/go.mod h1:yccR+LR7xc1Jdic0mrjocbHvUD7lnVvg8/ 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 v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8= -github.com/onflow/cadence v1.0.0-preview.44 h1:APQ8DzIS6kX4FMZsaYoucbvF/PPwjHEerr+aGRDcPz4= -github.com/onflow/cadence v1.0.0-preview.44/go.mod h1:BCoenp1TYp+SmG7FGWStjehvvzcvNQ3xvpK5rkthq3Y= +github.com/onflow/cadence v1.0.0-preview.45 h1:vWX+HI1SvxaG47FL2XW80rxjAhV88oySLB5vAoOtnXI= +github.com/onflow/cadence v1.0.0-preview.45/go.mod h1:BCoenp1TYp+SmG7FGWStjehvvzcvNQ3xvpK5rkthq3Y= github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A= github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= diff --git a/insecure/go.mod b/insecure/go.mod index 1f367abeed7..5ca583528d5 100644 --- a/insecure/go.mod +++ b/insecure/go.mod @@ -202,7 +202,7 @@ require ( github.com/multiformats/go-varint v0.0.7 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/onflow/atree v0.8.0-rc.5 // indirect - github.com/onflow/cadence v1.0.0-preview.44 // indirect + github.com/onflow/cadence v1.0.0-preview.45 // indirect github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1 // indirect github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1 // indirect github.com/onflow/flow-ft/lib/go/contracts v1.0.0 // indirect diff --git a/insecure/go.sum b/insecure/go.sum index 453154bfcd3..d2fd62afe8c 100644 --- a/insecure/go.sum +++ b/insecure/go.sum @@ -2157,8 +2157,8 @@ github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f/go.mod h1:xvP61FoOs github.com/onflow/atree v0.8.0-rc.5 h1:1sU+c6UfDzq/EjM8nTw4EI8GvEMarcxkWkJKy6piFSY= github.com/onflow/atree v0.8.0-rc.5/go.mod h1:yccR+LR7xc1Jdic0mrjocbHvUD7lnVvg8/Ct1AA5zBo= github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8= -github.com/onflow/cadence v1.0.0-preview.44 h1:APQ8DzIS6kX4FMZsaYoucbvF/PPwjHEerr+aGRDcPz4= -github.com/onflow/cadence v1.0.0-preview.44/go.mod h1:BCoenp1TYp+SmG7FGWStjehvvzcvNQ3xvpK5rkthq3Y= +github.com/onflow/cadence v1.0.0-preview.45 h1:vWX+HI1SvxaG47FL2XW80rxjAhV88oySLB5vAoOtnXI= +github.com/onflow/cadence v1.0.0-preview.45/go.mod h1:BCoenp1TYp+SmG7FGWStjehvvzcvNQ3xvpK5rkthq3Y= github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A= github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= diff --git a/integration/go.mod b/integration/go.mod index 4303d3960bb..11b619df0cb 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-ds-pebble v0.3.1 github.com/libp2p/go-libp2p v0.32.2 - github.com/onflow/cadence v1.0.0-preview.44 + github.com/onflow/cadence v1.0.0-preview.45 github.com/onflow/crypto v0.25.1 github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1 github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1 diff --git a/integration/go.sum b/integration/go.sum index dff41fd195e..f1da82ef6cd 100644 --- a/integration/go.sum +++ b/integration/go.sum @@ -2141,8 +2141,8 @@ github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f/go.mod h1:xvP61FoOs github.com/onflow/atree v0.8.0-rc.5 h1:1sU+c6UfDzq/EjM8nTw4EI8GvEMarcxkWkJKy6piFSY= github.com/onflow/atree v0.8.0-rc.5/go.mod h1:yccR+LR7xc1Jdic0mrjocbHvUD7lnVvg8/Ct1AA5zBo= github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8= -github.com/onflow/cadence v1.0.0-preview.44 h1:APQ8DzIS6kX4FMZsaYoucbvF/PPwjHEerr+aGRDcPz4= -github.com/onflow/cadence v1.0.0-preview.44/go.mod h1:BCoenp1TYp+SmG7FGWStjehvvzcvNQ3xvpK5rkthq3Y= +github.com/onflow/cadence v1.0.0-preview.45 h1:vWX+HI1SvxaG47FL2XW80rxjAhV88oySLB5vAoOtnXI= +github.com/onflow/cadence v1.0.0-preview.45/go.mod h1:BCoenp1TYp+SmG7FGWStjehvvzcvNQ3xvpK5rkthq3Y= github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A= github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= From 5807882b8ca53d96d24de8db168c465fd1173b84 Mon Sep 17 00:00:00 2001 From: Supun Setunga Date: Mon, 12 Aug 2024 10:49:07 -0700 Subject: [PATCH 5/5] Add comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Müller --- cmd/util/ledger/migrations/cadence.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/util/ledger/migrations/cadence.go b/cmd/util/ledger/migrations/cadence.go index 463a6e30165..f091335b501 100644 --- a/cmd/util/ledger/migrations/cadence.go +++ b/cmd/util/ledger/migrations/cadence.go @@ -385,6 +385,8 @@ func NewCadence1ValueMigrations( // Populated by CadenceLinkValueMigration, // used by CadenceCapabilityValueMigration privatePublicCapabilityMapping := &capcons.PathCapabilityMapping{} + // Populated by IssueStorageCapConMigration + // used by CadenceCapabilityValueMigration storageCapabilityMapping := &capcons.PathTypeCapabilityMapping{} // Populated by StorageCapMigration,