diff --git a/cmd/bootstrap/utils/key_generation.go b/cmd/bootstrap/utils/key_generation.go index fd4c8c53444..6cb662be21c 100644 --- a/cmd/bootstrap/utils/key_generation.go +++ b/cmd/bootstrap/utils/key_generation.go @@ -13,6 +13,7 @@ import ( sdk "github.com/onflow/flow-go-sdk" sdkcrypto "github.com/onflow/flow-go-sdk/crypto" + "github.com/onflow/flow-go/fvm/systemcontracts" "github.com/onflow/flow-go/model/bootstrap" model "github.com/onflow/flow-go/model/bootstrap" diff --git a/cmd/collection/main.go b/cmd/collection/main.go index c3d1496918a..1a241ba703b 100644 --- a/cmd/collection/main.go +++ b/cmd/collection/main.go @@ -9,6 +9,7 @@ import ( client "github.com/onflow/flow-go-sdk/access/grpc" sdkcrypto "github.com/onflow/flow-go-sdk/crypto" + "github.com/onflow/flow-go/admin/commands" collectionCommands "github.com/onflow/flow-go/admin/commands/collection" storageCommands "github.com/onflow/flow-go/admin/commands/storage" diff --git a/cmd/consensus/main.go b/cmd/consensus/main.go index 874385b2b3f..616e7657d10 100644 --- a/cmd/consensus/main.go +++ b/cmd/consensus/main.go @@ -12,6 +12,7 @@ import ( client "github.com/onflow/flow-go-sdk/access/grpc" "github.com/onflow/flow-go-sdk/crypto" + "github.com/onflow/flow-go/cmd" "github.com/onflow/flow-go/cmd/util/cmd/common" "github.com/onflow/flow-go/consensus" diff --git a/cmd/util/cmd/common/snapshot.go b/cmd/util/cmd/common/snapshot.go index 6e940237ea1..83b568b71b8 100644 --- a/cmd/util/cmd/common/snapshot.go +++ b/cmd/util/cmd/common/snapshot.go @@ -9,9 +9,10 @@ import ( "github.com/rs/zerolog" "github.com/sethvargo/go-retry" + "github.com/onflow/flow-go-sdk/access/grpc" + "github.com/onflow/flow-go/utils/logging" - "github.com/onflow/flow-go-sdk/access/grpc" "github.com/onflow/flow-go/model/flow" "github.com/onflow/flow-go/state/protocol" "github.com/onflow/flow-go/state/protocol/inmem" diff --git a/cmd/util/ledger/migrations/account_based_migration_test.go b/cmd/util/ledger/migrations/account_based_migration_test.go index bd2b59b6ee6..c06a6a7f090 100644 --- a/cmd/util/ledger/migrations/account_based_migration_test.go +++ b/cmd/util/ledger/migrations/account_based_migration_test.go @@ -3,7 +3,6 @@ package migrations import ( "context" "fmt" - "testing" "github.com/onflow/cadence/common" diff --git a/cmd/util/ledger/migrations/migrator_runtime.go b/cmd/util/ledger/migrations/migrator_runtime.go index ab051393bed..35e35b065d3 100644 --- a/cmd/util/ledger/migrations/migrator_runtime.go +++ b/cmd/util/ledger/migrations/migrator_runtime.go @@ -16,6 +16,7 @@ import ( "github.com/onflow/flow-go/fvm/evm" evmStdlib "github.com/onflow/flow-go/fvm/evm/stdlib" "github.com/onflow/flow-go/fvm/storage/state" + "github.com/onflow/flow-go/fvm/systemcontracts" "github.com/onflow/flow-go/model/flow" ) @@ -111,8 +112,11 @@ func (c InterpreterMigrationRuntimeConfig) NewRuntimeInterface( } } + sc := systemcontracts.SystemContractsForChain(chainID) + return util.NewMigrationRuntimeInterface( chainID, + common.Address(sc.Crypto.Address), getCodeFunc, getContractNames, getOrLoadProgram, diff --git a/cmd/util/ledger/util/migration_runtime_interface.go b/cmd/util/ledger/util/migration_runtime_interface.go index 1043fd03ce5..12142eb15b4 100644 --- a/cmd/util/ledger/util/migration_runtime_interface.go +++ b/cmd/util/ledger/util/migration_runtime_interface.go @@ -38,6 +38,7 @@ type GerOrLoadProgramListenerFunc func( type MigrationRuntimeInterface struct { runtime.EmptyRuntimeInterface chainID flow.ChainID + CryptoContractAddress common.Address GetContractCodeFunc GetContractCodeFunc GetContractNamesFunc GetContractNamesFunc GetOrLoadProgramFunc GetOrLoadProgramFunc @@ -48,6 +49,7 @@ var _ runtime.Interface = &MigrationRuntimeInterface{} func NewMigrationRuntimeInterface( chainID flow.ChainID, + cryptoContractAddress common.Address, getCodeFunc GetContractCodeFunc, getContractNamesFunc GetContractNamesFunc, getOrLoadProgramFunc GetOrLoadProgramFunc, @@ -55,6 +57,7 @@ func NewMigrationRuntimeInterface( ) *MigrationRuntimeInterface { return &MigrationRuntimeInterface{ chainID: chainID, + CryptoContractAddress: cryptoContractAddress, GetContractCodeFunc: getCodeFunc, GetContractNamesFunc: getContractNamesFunc, GetOrLoadProgramFunc: getOrLoadProgramFunc, @@ -67,65 +70,12 @@ func (m *MigrationRuntimeInterface) ResolveLocation( location runtime.Location, ) ([]runtime.ResolvedLocation, error) { - addressLocation, isAddress := location.(common.AddressLocation) - - // if the location is not an address location, e.g. an identifier location (`import Crypto`), - // then return a single resolved location which declares all identifiers. - if !isAddress { - return []runtime.ResolvedLocation{ - { - Location: location, - Identifiers: identifiers, - }, - }, nil - } - - // if the location is an address, - // and no specific identifiers where requested in the import statement, - // then fetch all identifiers at this address - if len(identifiers) == 0 { - address := flow.Address(addressLocation.Address) - - getContractNames := m.GetContractNamesFunc - if getContractNames == nil { - return nil, errors.New("GetContractNamesFunc missing") - } - - contractNames, err := getContractNames(address) - if err != nil { - return nil, fmt.Errorf("ResolveLocation failed: %w", err) - } - - // if there are no contractNames deployed, - // then return no resolved locations - if len(contractNames) == 0 { - return nil, nil - } - - identifiers = make([]runtime.Identifier, len(contractNames)) - - for i := range identifiers { - identifiers[i] = runtime.Identifier{ - Identifier: contractNames[i], - } - } - } - - // return one resolved location per identifier. - // each resolved location is an address contract location - resolvedLocations := make([]runtime.ResolvedLocation, len(identifiers)) - for i := range resolvedLocations { - identifier := identifiers[i] - resolvedLocations[i] = runtime.ResolvedLocation{ - Location: common.AddressLocation{ - Address: addressLocation.Address, - Name: identifier.Identifier, - }, - Identifiers: []runtime.Identifier{identifier}, - } - } - - return resolvedLocations, nil + return environment.ResolveLocation( + identifiers, + location, + m.GetContractNamesFunc, + m.CryptoContractAddress, + ) } func (m *MigrationRuntimeInterface) GetCode(location runtime.Location) ([]byte, error) { diff --git a/consensus/hotstuff/verification/common.go b/consensus/hotstuff/verification/common.go index 4febede7412..04c355f4390 100644 --- a/consensus/hotstuff/verification/common.go +++ b/consensus/hotstuff/verification/common.go @@ -1,6 +1,7 @@ package verification import ( + "encoding/binary" "fmt" "github.com/onflow/crypto" @@ -8,8 +9,6 @@ import ( "github.com/onflow/flow-go/consensus/hotstuff/model" "github.com/onflow/flow-go/model/flow" - - "encoding/binary" ) // MakeVoteMessage generates the message we have to sign in order to be able diff --git a/engine/execution/state/bootstrap/bootstrap_test.go b/engine/execution/state/bootstrap/bootstrap_test.go index 96457ebda93..5a7a99dc417 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("edc0ffd7e797e2383bc68b694645e6b62b0d996498bcff9b492bf4d426798ec5") + expectedStateCommitmentBytes, _ := hex.DecodeString("543fa7112081094b66871692c5a7784f40a9e5cdb9cfda10d1d9b81653966409") expectedStateCommitment, err := flow.ToStateCommitment(expectedStateCommitmentBytes) require.NoError(t, err) diff --git a/fvm/bootstrap.go b/fvm/bootstrap.go index 5c7e09d31ed..0f3526c8d83 100644 --- a/fvm/bootstrap.go +++ b/fvm/bootstrap.go @@ -351,6 +351,7 @@ func (b *bootstrapExecutor) Execute() error { b.deployViewResolver(service, &env) b.deployBurner(service, &env) + b.deployCrypto(service, &env) err = expectAccounts(1) if err != nil { @@ -523,6 +524,22 @@ func (b *bootstrapExecutor) deployBurner(deployTo flow.Address, env *templates.E panicOnMetaInvokeErrf("failed to deploy burner contract: %s", txError, err) } +func (b *bootstrapExecutor) deployCrypto(deployTo flow.Address, env *templates.Environment) { + contract := contracts.Crypto() + + txError, err := b.invokeMetaTransaction( + b.ctx, + Transaction( + blueprints.DeployContractTransaction( + deployTo, + contract, + "Crypto"), + 0), + ) + env.CryptoAddress = deployTo.String() + panicOnMetaInvokeErrf("failed to deploy crypto contract: %s", txError, err) +} + func (b *bootstrapExecutor) deployMetadataViews(fungibleToken, nonFungibleToken flow.Address, env *templates.Environment) { mvContract := contracts.MetadataViews(*env) diff --git a/fvm/crypto/hash_test.go b/fvm/crypto/hash_test.go index 29eeb7ec09c..6c8ba0354c8 100644 --- a/fvm/crypto/hash_test.go +++ b/fvm/crypto/hash_test.go @@ -2,10 +2,9 @@ package crypto_test import ( "crypto/rand" - "testing" - "crypto/sha256" "crypto/sha512" + "testing" "github.com/onflow/crypto/hash" "github.com/stretchr/testify/assert" diff --git a/fvm/environment/contract_reader.go b/fvm/environment/contract_reader.go index e3c868ee2e9..5c8aba5cc25 100644 --- a/fvm/environment/contract_reader.go +++ b/fvm/environment/contract_reader.go @@ -6,6 +6,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/runtime" + "github.com/onflow/cadence/stdlib" "github.com/onflow/flow-go/fvm/errors" "github.com/onflow/flow-go/fvm/tracing" @@ -15,21 +16,23 @@ import ( // ContractReader provide read access to contracts. type ContractReader struct { - tracer tracing.TracerSpan - meter Meter - - accounts Accounts + tracer tracing.TracerSpan + meter Meter + accounts Accounts + cryptoContractAddress common.Address } func NewContractReader( tracer tracing.TracerSpan, meter Meter, accounts Accounts, + cryptoContractAddress common.Address, ) *ContractReader { return &ContractReader{ - tracer: tracer, - meter: meter, - accounts: accounts, + tracer: tracer, + meter: meter, + accounts: accounts, + cryptoContractAddress: cryptoContractAddress, } } @@ -69,12 +72,37 @@ func (reader *ContractReader) ResolveLocation( return nil, fmt.Errorf("resolve location failed: %w", err) } + return ResolveLocation( + identifiers, + location, + reader.accounts.GetContractNames, + reader.cryptoContractAddress, + ) +} + +func ResolveLocation( + identifiers []ast.Identifier, + location common.Location, + getContractNames func(flow.Address) ([]string, error), + cryptoContractAddress common.Address, +) ([]runtime.ResolvedLocation, error) { + addressLocation, isAddress := location.(common.AddressLocation) // if the location is not an address location, e.g. an identifier location - // (`import Crypto`), then return a single resolved location which declares - // all identifiers. + // then return a single resolved location which declares all identifiers. if !isAddress { + + // if the location is the Crypto contract, + // translate it to the address of the Crypto contract on the chain + + if location == stdlib.CryptoContractLocation { + location = common.AddressLocation{ + Address: cryptoContractAddress, + Name: string(stdlib.CryptoContractLocation), + } + } + return []runtime.ResolvedLocation{ { Location: location, @@ -87,9 +115,13 @@ func (reader *ContractReader) ResolveLocation( // and no specific identifiers where requested in the import statement, // then fetch all identifiers at this address if len(identifiers) == 0 { + if getContractNames == nil { + return nil, fmt.Errorf("no identifiers provided") + } + address := flow.ConvertAddress(addressLocation.Address) - contractNames, err := reader.accounts.GetContractNames(address) + contractNames, err := getContractNames(address) if err != nil { return nil, fmt.Errorf("resolving location failed: %w", err) } diff --git a/fvm/environment/facade_env.go b/fvm/environment/facade_env.go index 2f101b9aa9d..67e20e02394 100644 --- a/fvm/environment/facade_env.go +++ b/fvm/environment/facade_env.go @@ -11,6 +11,7 @@ import ( "github.com/onflow/flow-go/fvm/storage" "github.com/onflow/flow-go/fvm/storage/snapshot" "github.com/onflow/flow-go/fvm/storage/state" + "github.com/onflow/flow-go/fvm/systemcontracts" "github.com/onflow/flow-go/fvm/tracing" ) @@ -63,12 +64,15 @@ func newFacadeEnvironment( accounts := NewAccounts(txnState) logger := NewProgramLogger(tracer, params.ProgramLoggerParams) runtime := NewRuntime(params.RuntimeParams) + chain := params.Chain systemContracts := NewSystemContracts( - params.Chain, + chain, tracer, logger, runtime) + sc := systemcontracts.SystemContractsForChain(chain.ChainID()) + env := &facadeEnvironment{ Runtime: runtime, @@ -130,6 +134,7 @@ func newFacadeEnvironment( tracer, meter, accounts, + common.Address(sc.Crypto.Address), ), ContractUpdater: NoContractUpdater{}, Programs: NewPrograms( diff --git a/fvm/evm/stdlib/checking.go b/fvm/evm/stdlib/checking.go index 03819737de1..81faed8c298 100644 --- a/fvm/evm/stdlib/checking.go +++ b/fvm/evm/stdlib/checking.go @@ -1,11 +1,11 @@ package stdlib import ( - "fmt" - "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/runtime" + + "github.com/onflow/flow-go/fvm/environment" ) // checkingInterface is a runtime.Interface implementation @@ -13,68 +13,41 @@ import ( // It is not suitable for execution. type checkingInterface struct { runtime.EmptyRuntimeInterface - SystemContractCodes map[common.AddressLocation][]byte - Programs map[runtime.Location]*interpreter.Program + SystemContractCodes map[common.Location][]byte + Programs map[runtime.Location]*interpreter.Program + cryptoContractAddress common.Address } var _ runtime.Interface = &checkingInterface{} -func (*checkingInterface) ResolveLocation( +func (i *checkingInterface) ResolveLocation( identifiers []runtime.Identifier, location runtime.Location, ) ( []runtime.ResolvedLocation, error, ) { - - addressLocation, isAddress := location.(common.AddressLocation) - - // if the location is not an address location, e.g. an identifier location - // (`import Crypto`), then return a single resolved location which declares - // all identifiers. - if !isAddress { - return []runtime.ResolvedLocation{ - { - Location: location, - Identifiers: identifiers, - }, - }, nil - } - - if len(identifiers) == 0 { - return nil, fmt.Errorf("no identifiers provided") - } - - // return one resolved location per identifier. - // each resolved location is an address contract location - resolvedLocations := make([]runtime.ResolvedLocation, len(identifiers)) - for i := range resolvedLocations { - identifier := identifiers[i] - resolvedLocations[i] = runtime.ResolvedLocation{ - Location: common.AddressLocation{ - Address: addressLocation.Address, - Name: identifier.Identifier, - }, - Identifiers: []runtime.Identifier{identifier}, - } - } - - return resolvedLocations, nil + return environment.ResolveLocation( + identifiers, + location, + nil, + i.cryptoContractAddress, + ) } -func (r *checkingInterface) GetOrLoadProgram( +func (i *checkingInterface) GetOrLoadProgram( location runtime.Location, load func() (*interpreter.Program, error), ) ( program *interpreter.Program, err error, ) { - if r.Programs == nil { - r.Programs = map[runtime.Location]*interpreter.Program{} + if i.Programs == nil { + i.Programs = map[runtime.Location]*interpreter.Program{} } var ok bool - program, ok = r.Programs[location] + program, ok = i.Programs[location] if ok { return } @@ -84,11 +57,15 @@ func (r *checkingInterface) GetOrLoadProgram( // NOTE: important: still set empty program, // even if error occurred - r.Programs[location] = program + i.Programs[location] = program return } -func (r *checkingInterface) GetAccountContractCode(location common.AddressLocation) (code []byte, err error) { - return r.SystemContractCodes[location], nil +func (i *checkingInterface) GetCode(location common.Location) ([]byte, error) { + return i.SystemContractCodes[location], nil +} + +func (i *checkingInterface) GetAccountContractCode(location common.AddressLocation) (code []byte, err error) { + return i.SystemContractCodes[location], nil } diff --git a/fvm/evm/stdlib/contract.cdc b/fvm/evm/stdlib/contract.cdc index 986313c50df..618f9b0b9fa 100644 --- a/fvm/evm/stdlib/contract.cdc +++ b/fvm/evm/stdlib/contract.cdc @@ -74,7 +74,7 @@ contract EVM { /// This data helps to replay the transactions without the need to /// have access to the full cadence state data. precompiledCalls: [UInt8], - /// stateUpdateChecksum provides a mean to validate + /// stateUpdateChecksum provides a mean to validate /// the updates to the storage when re-executing a transaction off-chain. stateUpdateChecksum: [UInt8; 4] ) diff --git a/fvm/evm/stdlib/contract_test.go b/fvm/evm/stdlib/contract_test.go index 619e8d7a63f..bdffe56846b 100644 --- a/fvm/evm/stdlib/contract_test.go +++ b/fvm/evm/stdlib/contract_test.go @@ -30,6 +30,26 @@ import ( "github.com/onflow/flow-go/model/flow" ) +func newLocationResolver( + cryptoContractAddress flow.Address, +) func( + identifiers []runtime.Identifier, + location runtime.Location, +) ([]runtime.ResolvedLocation, error) { + cryptoContractAddress2 := common.Address(cryptoContractAddress) + return func( + identifiers []runtime.Identifier, + location runtime.Location, + ) ([]runtime.ResolvedLocation, error) { + return environment.ResolveLocation( + identifiers, + location, + nil, + cryptoContractAddress2, + ) + } +} + type testContractHandler struct { flowTokenAddress common.Address evmContractAddress common.Address @@ -222,6 +242,7 @@ func deployContracts( NonFungibleTokenAddress: contractsAddressHex, MetadataViewsAddress: contractsAddressHex, FungibleTokenMetadataViewsAddress: contractsAddressHex, + CryptoAddress: contractsAddressHex, } contracts := []struct { @@ -229,6 +250,10 @@ func deployContracts( code []byte deployTx []byte }{ + { + name: "Crypto", + code: coreContracts.Crypto(), + }, { name: "ViewResolver", code: coreContracts.ViewResolver(), @@ -373,7 +398,7 @@ func TestEVMEncodeABI(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -474,7 +499,7 @@ func TestEVMEncodeABIByteTypes(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -921,7 +946,7 @@ func TestEVMEncodeABIBytesRoundtrip(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -1279,7 +1304,7 @@ func TestEVMEncodeABIComputation(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -1374,7 +1399,7 @@ func TestEVMEncodeABIComputationEmptyDynamicVariables(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -1478,7 +1503,7 @@ func TestEVMEncodeABIComputationDynamicVariablesAboveChunkSize(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -1576,7 +1601,7 @@ func TestEVMDecodeABI(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -1709,7 +1734,7 @@ func TestEVMDecodeABIComputation(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -1786,7 +1811,7 @@ func TestEVMEncodeDecodeABIRoundtripForUintIntTypes(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -2252,7 +2277,7 @@ func TestEVMEncodeDecodeABIRoundtrip(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -2330,7 +2355,7 @@ func TestEVMEncodeDecodeABIErrors(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -2416,7 +2441,7 @@ func TestEVMEncodeDecodeABIErrors(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -2501,7 +2526,7 @@ func TestEVMEncodeDecodeABIErrors(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -2587,7 +2612,7 @@ func TestEVMEncodeDecodeABIErrors(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -2673,7 +2698,7 @@ func TestEVMEncodeDecodeABIErrors(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -2769,7 +2794,7 @@ func TestEVMEncodeDecodeABIErrors(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -2855,7 +2880,7 @@ func TestEVMEncodeDecodeABIErrors(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -2941,7 +2966,7 @@ func TestEVMEncodeDecodeABIErrors(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -3027,7 +3052,7 @@ func TestEVMEncodeDecodeABIErrors(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -3113,7 +3138,7 @@ func TestEVMEncodeDecodeABIErrors(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -3199,7 +3224,7 @@ func TestEVMEncodeDecodeABIErrors(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -3315,7 +3340,7 @@ func TestEVMEncodeABIWithSignature(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -3448,7 +3473,7 @@ func TestEVMDecodeABIWithSignature(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -3568,7 +3593,7 @@ func TestEVMDecodeABIWithSignatureMismatch(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -3671,7 +3696,7 @@ func TestEVMAddressConstructionAndReturn(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -3773,7 +3798,7 @@ func TestEVMAddressSerializationAndDeserialization(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -3950,7 +3975,7 @@ func TestBalanceConstructionAndReturn(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -4080,7 +4105,7 @@ func TestEVMRun(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -4197,7 +4222,7 @@ func TestEVMDryRun(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -4336,7 +4361,7 @@ func TestEVMBatchRun(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -4436,7 +4461,7 @@ func TestEVMCreateCadenceOwnedAccount(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -4592,7 +4617,7 @@ func TestCadenceOwnedAccountCall(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -4711,7 +4736,7 @@ func TestEVMAddressDeposit(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -4824,7 +4849,7 @@ func TestCOADeposit(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -4995,7 +5020,7 @@ func TestCadenceOwnedAccountWithdraw(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -5148,7 +5173,7 @@ func TestCadenceOwnedAccountDeploy(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -5223,7 +5248,7 @@ func RunEVMScript( OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -5461,7 +5486,7 @@ func TestEVMValidateCOAOwnershipProof(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil @@ -5609,7 +5634,7 @@ func TestInternalEVMAccess(t *testing.T) { OnGetSigningAccounts: func() ([]runtime.Address, error) { return []runtime.Address{runtime.Address(contractsAddress)}, nil }, - OnResolveLocation: LocationResolver, + OnResolveLocation: newLocationResolver(contractsAddress), OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { accountCodes[location] = code return nil diff --git a/fvm/evm/stdlib/type.go b/fvm/evm/stdlib/type.go index ed3c1825f16..5ad44909bb4 100644 --- a/fvm/evm/stdlib/type.go +++ b/fvm/evm/stdlib/type.go @@ -32,8 +32,11 @@ func newContractType(chainID flow.ChainID) *sema.CompositeType { templatesEnv := contracts.AsTemplateEnv() + cryptoContractLocation := contracts.Crypto.Location() + runtimeInterface := &checkingInterface{ - SystemContractCodes: map[common.AddressLocation][]byte{ + cryptoContractAddress: cryptoContractLocation.Address, + SystemContractCodes: map[common.Location][]byte{ contracts.ViewResolver.Location(): coreContracts.ViewResolver(), contracts.Burner.Location(): coreContracts.Burner(), contracts.FungibleToken.Location(): coreContracts.FungibleToken(templatesEnv), @@ -41,6 +44,7 @@ func newContractType(chainID flow.ChainID) *sema.CompositeType { contracts.MetadataViews.Location(): coreContracts.MetadataViews(templatesEnv), contracts.FlowToken.Location(): coreContracts.FlowToken(templatesEnv), contracts.FungibleTokenMetadataViews.Location(): coreContracts.FungibleTokenMetadataViews(templatesEnv), + cryptoContractLocation: coreContracts.Crypto(), }, } diff --git a/fvm/evm/testutils/cadence.go b/fvm/evm/testutils/cadence.go index 3af633e74d7..12f4889a428 100644 --- a/fvm/evm/testutils/cadence.go +++ b/fvm/evm/testutils/cadence.go @@ -5,64 +5,10 @@ import ( "testing" "github.com/onflow/cadence" - "github.com/onflow/cadence/ast" - "github.com/onflow/cadence/common" "github.com/onflow/cadence/encoding/json" - "github.com/onflow/cadence/runtime" - "github.com/onflow/cadence/sema" "github.com/stretchr/testify/require" ) -// LocationResolver is a location Cadence runtime interface location resolver -// very similar to ContractReader.ResolveLocation, -// but it does not look up available contract names -func LocationResolver( - identifiers []ast.Identifier, - location common.Location, -) ( - result []sema.ResolvedLocation, - err error, -) { - addressLocation, isAddress := location.(common.AddressLocation) - - // if the location is not an address location, e.g. an identifier location - // (`import Crypto`), then return a single resolved location which declares - // all identifiers. - if !isAddress { - return []runtime.ResolvedLocation{ - { - Location: location, - Identifiers: identifiers, - }, - }, nil - } - - // if the location is an address, - // and no specific identifiers where requested in the import statement, - // then assume the imported identifier is the address location's identifier (the contract) - if len(identifiers) == 0 { - identifiers = []ast.Identifier{ - {Identifier: addressLocation.Name}, - } - } - - // return one resolved location per identifier. - // each resolved location is an address contract location - resolvedLocations := make([]runtime.ResolvedLocation, len(identifiers)) - for i := range resolvedLocations { - identifier := identifiers[i] - resolvedLocations[i] = runtime.ResolvedLocation{ - Location: common.AddressLocation{ - Address: addressLocation.Address, - Name: identifier.Identifier, - }, - Identifiers: []runtime.Identifier{identifier}, - } - } - - return resolvedLocations, nil -} - func EncodeArgs(argValues []cadence.Value) [][]byte { args := make([][]byte, len(argValues)) for i, arg := range argValues { diff --git a/fvm/fvm_bench_test.go b/fvm/fvm_bench_test.go index 33ff347a6f1..566cf81653a 100644 --- a/fvm/fvm_bench_test.go +++ b/fvm/fvm_bench_test.go @@ -23,7 +23,7 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - flow2 "github.com/onflow/flow-go-sdk" + flowsdk "github.com/onflow/flow-go-sdk" "github.com/onflow/flow-go-sdk/templates" "github.com/onflow/flow-go/engine/execution" @@ -315,13 +315,13 @@ func (b *BasicBlockExecutor) SetupAccounts(tb testing.TB, privateKeys []flow.Acc serviceAddress := b.Chain(tb).ServiceAddress() for _, privateKey := range privateKeys { - accountKey := flow2.NewAccountKey(). + accountKey := flowsdk.NewAccountKey(). FromPrivateKey(privateKey.PrivateKey). SetWeight(fvm.AccountKeyWeightThreshold). SetHashAlgo(privateKey.HashAlgo). SetSigAlgo(privateKey.SignAlgo) - sdkTX, err := templates.CreateAccount([]*flow2.AccountKey{accountKey}, []templates.Contract{}, flow2.BytesToAddress(serviceAddress.Bytes())) + sdkTX, err := templates.CreateAccount([]*flowsdk.AccountKey{accountKey}, []templates.Contract{}, flowsdk.BytesToAddress(serviceAddress.Bytes())) require.NoError(tb, err) txBody := flow.NewTransactionBody(). diff --git a/fvm/fvm_test.go b/fvm/fvm_test.go index 2fc6c9ccd2d..cb0d270f725 100644 --- a/fvm/fvm_test.go +++ b/fvm/fvm_test.go @@ -9,7 +9,10 @@ import ( "strings" "testing" - stdlib2 "github.com/onflow/cadence/stdlib" + cadenceStdlib "github.com/onflow/cadence/stdlib" + + flowsdk "github.com/onflow/flow-go-sdk" + "github.com/onflow/flow-go-sdk/test" envMock "github.com/onflow/flow-go/fvm/environment/mock" "github.com/onflow/flow-go/fvm/evm/events" @@ -971,7 +974,7 @@ func TestTransactionFeeDeduction(t *testing.T) { address := flow.ConvertAddress( cadence.SearchFieldByName( data.(cadence.Event), - stdlib2.AccountEventAddressParameter.Identifier, + cadenceStdlib.AccountEventAddressParameter.Identifier, ).(cadence.Address), ) @@ -1528,17 +1531,17 @@ func TestSettingExecutionWeights(t *testing.T) { SetScript([]byte(fmt.Sprintf(` import FungibleToken from 0x%s import FlowToken from 0x%s - + transaction() { let sentVault: @{FungibleToken.Vault} - + prepare(signer: auth(BorrowValue) &Account) { let vaultRef = signer.storage.borrow(from: /storage/flowTokenVault) ?? panic("Could not borrow reference to the owner's Vault!") - + self.sentVault <- vaultRef.withdraw(amount: 5.0) } - + execute { let recipient1 = getAccount(%s) let recipient2 = getAccount(%s) @@ -1556,7 +1559,7 @@ func TestSettingExecutionWeights(t *testing.T) { ?? panic("Could not borrow receiver reference to the recipient's Vault") let receiverRef5 = recipient5.capabilities.borrow<&{FungibleToken.Receiver}>(/public/flowTokenReceiver) ?? panic("Could not borrow receiver reference to the recipient's Vault") - + receiverRef1.deposit(from: <-self.sentVault.withdraw(amount: 1.0)) receiverRef2.deposit(from: <-self.sentVault.withdraw(amount: 1.0)) receiverRef3.deposit(from: <-self.sentVault.withdraw(amount: 1.0)) @@ -2332,7 +2335,7 @@ func TestInteractionLimit(t *testing.T) { address = flow.ConvertAddress( cadence.SearchFieldByName( data.(cadence.Event), - stdlib2.AccountEventAddressParameter.Identifier, + cadenceStdlib.AccountEventAddressParameter.Identifier, ).(cadence.Address), ) @@ -2916,7 +2919,7 @@ func TestEVM(t *testing.T) { sc := systemcontracts.SystemContractsForChain(chain.ChainID()) script := fvm.Script([]byte(fmt.Sprintf(` import EVM from %s - + access(all) fun main() { let bal = EVM.Balance(attoflow: 1000000000000000000) let acc <- EVM.createCadenceOwnedAccount() @@ -2979,7 +2982,7 @@ func TestEVM(t *testing.T) { script := fvm.Script([]byte(fmt.Sprintf(` import EVM from %s - + access(all) fun main() { destroy <- EVM.createCadenceOwnedAccount() @@ -3011,7 +3014,7 @@ func TestEVM(t *testing.T) { txBody := flow.NewTransactionBody(). SetScript([]byte(fmt.Sprintf(` import FungibleToken from %s - import FlowToken from %s + import FlowToken from %s import EVM from %s transaction() { @@ -3029,7 +3032,7 @@ func TestEVM(t *testing.T) { acc.deposit(from: <- amount) destroy acc - // commit blocks + // commit blocks evmHeartbeat.heartbeat() } }`, @@ -3229,3 +3232,175 @@ func TestAccountCapabilitiesPublishEntitledRejection(t *testing.T) { }), ) } + +func TestCrypto(t *testing.T) { + t.Parallel() + + const chainID = flow.Testnet + + test := func(t *testing.T, importDecl string) { + + chain, vm := createChainAndVm(chainID) + + ctx := fvm.NewContext( + fvm.WithChain(chain), + fvm.WithCadenceLogging(true), + ) + + script := []byte(fmt.Sprintf( + ` + %s + + access(all) + fun main( + rawPublicKeys: [String], + weights: [UFix64], + domainSeparationTag: String, + signatures: [String], + toAddress: Address, + fromAddress: Address, + amount: UFix64 + ): Bool { + let keyList = Crypto.KeyList() + + var i = 0 + for rawPublicKey in rawPublicKeys { + keyList.add( + PublicKey( + publicKey: rawPublicKey.decodeHex(), + signatureAlgorithm: SignatureAlgorithm.ECDSA_P256 + ), + hashAlgorithm: HashAlgorithm.SHA3_256, + weight: weights[i], + ) + i = i + 1 + } + + let signatureSet: [Crypto.KeyListSignature] = [] + + var j = 0 + for signature in signatures { + signatureSet.append( + Crypto.KeyListSignature( + keyIndex: j, + signature: signature.decodeHex() + ) + ) + j = j + 1 + } + + // assemble the same message in cadence + let message = toAddress.toBytes() + .concat(fromAddress.toBytes()) + .concat(amount.toBigEndianBytes()) + + return keyList.verify( + signatureSet: signatureSet, + signedData: message, + domainSeparationTag: domainSeparationTag + ) + } + `, + importDecl, + )) + + accountKeys := test.AccountKeyGenerator() + + // create the keys + keyAlice, signerAlice := accountKeys.NewWithSigner() + keyBob, signerBob := accountKeys.NewWithSigner() + + // create the message that will be signed + addresses := test.AddressGenerator() + + toAddress := cadence.Address(addresses.New()) + fromAddress := cadence.Address(addresses.New()) + + amount, err := cadence.NewUFix64("100.00") + require.NoError(t, err) + + var message []byte + message = append(message, toAddress.Bytes()...) + message = append(message, fromAddress.Bytes()...) + message = append(message, amount.ToBigEndianBytes()...) + + // sign the message with Alice and Bob + signatureAlice, err := flowsdk.SignUserMessage(signerAlice, message) + require.NoError(t, err) + + signatureBob, err := flowsdk.SignUserMessage(signerBob, message) + require.NoError(t, err) + + publicKeys := cadence.NewArray([]cadence.Value{ + cadence.String(hex.EncodeToString(keyAlice.PublicKey.Encode())), + cadence.String(hex.EncodeToString(keyBob.PublicKey.Encode())), + }) + + // each signature has half weight + weightAlice, err := cadence.NewUFix64("0.5") + require.NoError(t, err) + + weightBob, err := cadence.NewUFix64("0.5") + require.NoError(t, err) + + weights := cadence.NewArray([]cadence.Value{ + weightAlice, + weightBob, + }) + + signatures := cadence.NewArray([]cadence.Value{ + cadence.String(hex.EncodeToString(signatureAlice)), + cadence.String(hex.EncodeToString(signatureBob)), + }) + + domainSeparationTag := cadence.String("FLOW-V0.0-user") + + arguments := []cadence.Value{ + publicKeys, + weights, + domainSeparationTag, + signatures, + toAddress, + fromAddress, + amount, + } + + encodedArguments := make([][]byte, 0, len(arguments)) + for _, argument := range arguments { + encodedArguments = append(encodedArguments, jsoncdc.MustEncode(argument)) + } + + snapshotTree := testutil.RootBootstrappedLedger(vm, ctx) + + _, output, err := vm.Run( + ctx, + fvm.Script(script). + WithArguments(encodedArguments...), + snapshotTree) + require.NoError(t, err) + + require.NoError(t, output.Err) + + result := output.Value + + assert.Equal(t, + cadence.NewBool(true), + result, + ) + } + + t.Run("identifier location", func(t *testing.T) { + t.Parallel() + + test(t, "import Crypto") + }) + + t.Run("address location", func(t *testing.T) { + t.Parallel() + + sc := systemcontracts.SystemContractsForChain(chainID) + cryptoContractAddress := sc.Crypto.Address.HexWithPrefix() + + test(t, fmt.Sprintf("import Crypto from %s", cryptoContractAddress)) + }) +} diff --git a/fvm/systemcontracts/system_contracts.go b/fvm/systemcontracts/system_contracts.go index 233c8bd0fb0..3760044698e 100644 --- a/fvm/systemcontracts/system_contracts.go +++ b/fvm/systemcontracts/system_contracts.go @@ -43,6 +43,7 @@ const ( ContractNameViewResolver = "ViewResolver" ContractNameEVM = "EVM" ContractNameBurner = "Burner" + ContractNameCrypto = "Crypto" // AccountNameEVMStorage is not a contract, but a special account that is used to store EVM state AccountNameEVMStorage = "EVMStorageAccount" @@ -171,6 +172,7 @@ type SystemContracts struct { // Utility contracts Burner SystemContract + Crypto SystemContract } // AsTemplateEnv returns a template environment with all system contracts filled in. @@ -198,6 +200,7 @@ func (c SystemContracts) AsTemplateEnv() templates.Environment { ViewResolverAddress: c.ViewResolver.Address.Hex(), BurnerAddress: c.Burner.Address.Hex(), + CryptoAddress: c.Crypto.Address.Hex(), } } @@ -228,6 +231,7 @@ func (c SystemContracts) All() []SystemContract { // EVMStorage is not included here, since it is not a contract c.Burner, + c.Crypto, } } @@ -365,6 +369,7 @@ func init() { AccountNameEVMStorage: evmStorageEVMFunc, ContractNameBurner: burnerAddressFunc, + ContractNameCrypto: serviceAddressFunc, } getSystemContractsForChain := func(chainID flow.ChainID) *SystemContracts { @@ -420,6 +425,7 @@ func init() { EVMStorage: addressOfAccount(AccountNameEVMStorage), Burner: addressOfContract(ContractNameBurner), + Crypto: addressOfContract(ContractNameCrypto), } return contracts diff --git a/go.mod b/go.mod index 8ac883df3aa..c9beac7c5b5 100644 --- a/go.mod +++ b/go.mod @@ -48,12 +48,12 @@ 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 - github.com/onflow/cadence v1.1.0 + github.com/onflow/cadence v1.2.1 github.com/onflow/crypto v0.25.2 github.com/onflow/flow v0.3.4 - github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2 - github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2 - github.com/onflow/flow-go-sdk v1.1.0 + github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 + github.com/onflow/flow-core-contracts/lib/go/templates v1.4.0 + github.com/onflow/flow-go-sdk v1.2.2 github.com/onflow/flow/protobuf/go/flow v0.4.7 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 79da2652571..036ed5849f6 100644 --- a/go.sum +++ b/go.sum @@ -913,22 +913,22 @@ github.com/onflow/atree v0.8.0 h1:qg5c6J1gVDNObughpEeWm8oxqhPGdEyGrda121GM4u0= github.com/onflow/atree v0.8.0/go.mod h1:yccR+LR7xc1Jdic0mrjocbHvUD7lnVvg8/Ct1AA5zBo= 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.1.0 h1:wPg86IX1kRv6DWjdETxKa4tv6A3iAwJVzzKAwaGdtDA= -github.com/onflow/cadence v1.1.0/go.mod h1:fJxxOAp1wnWDfOHT8GOc1ypsU0RR5E3z51AhG8Yf5jg= +github.com/onflow/cadence v1.2.1 h1:hmSsgX3rTsp2E5qTSl1JXINt8qepdRrHTwDSYqN5Nxs= +github.com/onflow/cadence v1.2.1/go.mod h1:fJxxOAp1wnWDfOHT8GOc1ypsU0RR5E3z51AhG8Yf5jg= github.com/onflow/crypto v0.25.2 h1:GjHunqVt+vPcdqhxxhAXiMIF3YiLX7gTuTR5O+VG2ns= github.com/onflow/crypto v0.25.2/go.mod h1:fY7eLqUdMKV8EGOw301unP8h7PvLVy8/6gVR++/g0BY= github.com/onflow/flow v0.3.4 h1:FXUWVdYB90f/rjNcY0Owo30gL790tiYff9Pb/sycXYE= github.com/onflow/flow v0.3.4/go.mod h1:lzyAYmbu1HfkZ9cfnL5/sjrrsnJiUU8fRL26CqLP7+c= -github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2 h1:My0EZLNXlzjN5tT81wD+wNb+PSqfOLJKHA1crXBNu5U= -github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac= -github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2 h1:YNHTonFhPSCuPJFYhIYZ1okSZmXEeQ07eKaoryrjHQI= -github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64= +github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 h1:R86HaOuk6vpuECZnriEUE7bw9inC2AtdSn8lL/iwQLQ= +github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac= +github.com/onflow/flow-core-contracts/lib/go/templates v1.4.0 h1:u2DAG8pk0xFH7TwS70t1gSZ/FtIIZWMSNyiu4SeXBYg= +github.com/onflow/flow-core-contracts/lib/go/templates v1.4.0/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64= github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3SsEftzXG2JlmSe24= github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A= github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM= github.com/onflow/flow-ft/lib/go/templates v1.0.1/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE= -github.com/onflow/flow-go-sdk v1.1.0 h1:DT8P3B3oAicOOXugdev4s1IEKHsiLS9T7MovFcTzB2s= -github.com/onflow/flow-go-sdk v1.1.0/go.mod h1:21g1pqP9Wy8RBXdenNsjzADwbtWNOViUCnfNZwr3trM= +github.com/onflow/flow-go-sdk v1.2.2 h1:F78Sq/VaExgtaQv739k06gnx2aIyLF5wVE0XwxFpmsc= +github.com/onflow/flow-go-sdk v1.2.2/go.mod h1:yhQ5+Sp2xWoCQ1fuRDswawTDQ0ng0z5nTkFVH82xL7E= github.com/onflow/flow-nft/lib/go/contracts v1.2.2 h1:XFERNVUDGbZ4ViZjt7P1cGD80mO1PzUJYPfdhXFsGbQ= github.com/onflow/flow-nft/lib/go/contracts v1.2.2/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY= github.com/onflow/flow-nft/lib/go/templates v1.2.1 h1:SAALMZPDw9Eb9p5kSLnmnFxjyig1MLiT4JUlLp0/bSE= diff --git a/insecure/go.mod b/insecure/go.mod index 33d8e855071..f6381343701 100644 --- a/insecure/go.mod +++ b/insecure/go.mod @@ -203,12 +203,12 @@ require ( github.com/nxadm/tail v1.4.8 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/onflow/atree v0.8.0 // indirect - github.com/onflow/cadence v1.1.0 // indirect - github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2 // indirect - github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2 // indirect + github.com/onflow/cadence v1.2.1 // indirect + github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 // indirect + github.com/onflow/flow-core-contracts/lib/go/templates v1.4.0 // indirect github.com/onflow/flow-ft/lib/go/contracts v1.0.1 // indirect github.com/onflow/flow-ft/lib/go/templates v1.0.1 // indirect - github.com/onflow/flow-go-sdk v1.1.0 // indirect + github.com/onflow/flow-go-sdk v1.2.2 // indirect github.com/onflow/flow-nft/lib/go/contracts v1.2.2 // indirect github.com/onflow/flow-nft/lib/go/templates v1.2.1 // indirect github.com/onflow/flow/protobuf/go/flow v0.4.7 // indirect diff --git a/insecure/go.sum b/insecure/go.sum index 27949c5063a..11976c45d95 100644 --- a/insecure/go.sum +++ b/insecure/go.sum @@ -856,20 +856,20 @@ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onflow/atree v0.8.0 h1:qg5c6J1gVDNObughpEeWm8oxqhPGdEyGrda121GM4u0= github.com/onflow/atree v0.8.0/go.mod h1:yccR+LR7xc1Jdic0mrjocbHvUD7lnVvg8/Ct1AA5zBo= -github.com/onflow/cadence v1.1.0 h1:wPg86IX1kRv6DWjdETxKa4tv6A3iAwJVzzKAwaGdtDA= -github.com/onflow/cadence v1.1.0/go.mod h1:fJxxOAp1wnWDfOHT8GOc1ypsU0RR5E3z51AhG8Yf5jg= +github.com/onflow/cadence v1.2.1 h1:hmSsgX3rTsp2E5qTSl1JXINt8qepdRrHTwDSYqN5Nxs= +github.com/onflow/cadence v1.2.1/go.mod h1:fJxxOAp1wnWDfOHT8GOc1ypsU0RR5E3z51AhG8Yf5jg= github.com/onflow/crypto v0.25.2 h1:GjHunqVt+vPcdqhxxhAXiMIF3YiLX7gTuTR5O+VG2ns= github.com/onflow/crypto v0.25.2/go.mod h1:fY7eLqUdMKV8EGOw301unP8h7PvLVy8/6gVR++/g0BY= -github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2 h1:My0EZLNXlzjN5tT81wD+wNb+PSqfOLJKHA1crXBNu5U= -github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac= -github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2 h1:YNHTonFhPSCuPJFYhIYZ1okSZmXEeQ07eKaoryrjHQI= -github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64= +github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 h1:R86HaOuk6vpuECZnriEUE7bw9inC2AtdSn8lL/iwQLQ= +github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac= +github.com/onflow/flow-core-contracts/lib/go/templates v1.4.0 h1:u2DAG8pk0xFH7TwS70t1gSZ/FtIIZWMSNyiu4SeXBYg= +github.com/onflow/flow-core-contracts/lib/go/templates v1.4.0/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64= github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3SsEftzXG2JlmSe24= github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A= github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM= github.com/onflow/flow-ft/lib/go/templates v1.0.1/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE= -github.com/onflow/flow-go-sdk v1.1.0 h1:DT8P3B3oAicOOXugdev4s1IEKHsiLS9T7MovFcTzB2s= -github.com/onflow/flow-go-sdk v1.1.0/go.mod h1:21g1pqP9Wy8RBXdenNsjzADwbtWNOViUCnfNZwr3trM= +github.com/onflow/flow-go-sdk v1.2.2 h1:F78Sq/VaExgtaQv739k06gnx2aIyLF5wVE0XwxFpmsc= +github.com/onflow/flow-go-sdk v1.2.2/go.mod h1:yhQ5+Sp2xWoCQ1fuRDswawTDQ0ng0z5nTkFVH82xL7E= github.com/onflow/flow-nft/lib/go/contracts v1.2.2 h1:XFERNVUDGbZ4ViZjt7P1cGD80mO1PzUJYPfdhXFsGbQ= github.com/onflow/flow-nft/lib/go/contracts v1.2.2/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY= github.com/onflow/flow-nft/lib/go/templates v1.2.1 h1:SAALMZPDw9Eb9p5kSLnmnFxjyig1MLiT4JUlLp0/bSE= diff --git a/integration/benchmark/account/account_provider.go b/integration/benchmark/account/account_provider.go index cdbd743d025..d46ecd42dbe 100644 --- a/integration/benchmark/account/account_provider.go +++ b/integration/benchmark/account/account_provider.go @@ -10,9 +10,11 @@ import ( "golang.org/x/sync/errgroup" flowsdk "github.com/onflow/flow-go-sdk" + "github.com/onflow/flow-go/module/util" "github.com/onflow/flow-go-sdk/crypto" + "github.com/onflow/flow-go/fvm/blueprints" "github.com/onflow/flow-go/fvm/systemcontracts" "github.com/onflow/flow-go/integration/benchmark/common" diff --git a/integration/benchmark/contLoadGenerator.go b/integration/benchmark/contLoadGenerator.go index 2ca1cee974c..7f1c31562cf 100644 --- a/integration/benchmark/contLoadGenerator.go +++ b/integration/benchmark/contLoadGenerator.go @@ -12,6 +12,7 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/onflow/flow-go-sdk/access" "github.com/onflow/flow-go-sdk/crypto" + "github.com/onflow/flow-go/fvm/systemcontracts" "github.com/onflow/flow-go/integration/benchmark/account" "github.com/onflow/flow-go/integration/benchmark/common" diff --git a/integration/benchmark/follower.go b/integration/benchmark/follower.go index 746c5b17b40..0681570b491 100644 --- a/integration/benchmark/follower.go +++ b/integration/benchmark/follower.go @@ -10,6 +10,7 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/onflow/flow-go-sdk/access" + "github.com/onflow/flow-go/module/metrics" "github.com/rs/zerolog" diff --git a/integration/benchmark/follower_test.go b/integration/benchmark/follower_test.go index 1b5b942e497..8ae218a6885 100644 --- a/integration/benchmark/follower_test.go +++ b/integration/benchmark/follower_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/require" flowsdk "github.com/onflow/flow-go-sdk" + mockClient "github.com/onflow/flow-go/integration/benchmark/mock" "github.com/onflow/flow-go/utils/unittest" ) diff --git a/integration/benchmark/load/common.go b/integration/benchmark/load/common.go index 93882d96757..4ce4e589fc8 100644 --- a/integration/benchmark/load/common.go +++ b/integration/benchmark/load/common.go @@ -7,6 +7,7 @@ import ( "github.com/rs/zerolog" flowsdk "github.com/onflow/flow-go-sdk" + "github.com/onflow/flow-go/integration/benchmark/common" "github.com/onflow/flow-go/integration/benchmark/account" diff --git a/integration/benchmark/load/simple_load.go b/integration/benchmark/load/simple_load.go index e10927d5493..b1b05cf9005 100644 --- a/integration/benchmark/load/simple_load.go +++ b/integration/benchmark/load/simple_load.go @@ -7,6 +7,7 @@ import ( "github.com/rs/zerolog" flowsdk "github.com/onflow/flow-go-sdk" + "github.com/onflow/flow-go/fvm/blueprints" "github.com/onflow/flow-go/integration/benchmark/account" ) diff --git a/integration/benchmark/load/token_transfer_load.go b/integration/benchmark/load/token_transfer_load.go index e382c58611f..703b013900b 100644 --- a/integration/benchmark/load/token_transfer_load.go +++ b/integration/benchmark/load/token_transfer_load.go @@ -5,6 +5,7 @@ import ( "github.com/rs/zerolog" flowsdk "github.com/onflow/flow-go-sdk" + "github.com/onflow/flow-go/fvm/errors" "github.com/onflow/flow-go/fvm/systemcontracts" "github.com/onflow/flow-go/integration/benchmark/account" diff --git a/integration/benchmark/load/token_transfer_multiple_load.go b/integration/benchmark/load/token_transfer_multiple_load.go index 3e7ab6930a1..05bd4d6ca5b 100644 --- a/integration/benchmark/load/token_transfer_multiple_load.go +++ b/integration/benchmark/load/token_transfer_multiple_load.go @@ -9,6 +9,7 @@ import ( "github.com/onflow/flow-go/model/flow" flowsdk "github.com/onflow/flow-go-sdk" + "github.com/onflow/flow-go/fvm/systemcontracts" "github.com/onflow/flow-go/integration/benchmark/account" "github.com/onflow/flow-go/integration/benchmark/scripts" diff --git a/integration/benchmark/scripts/scripts.go b/integration/benchmark/scripts/scripts.go index 105b5285c1f..b21b564ee20 100644 --- a/integration/benchmark/scripts/scripts.go +++ b/integration/benchmark/scripts/scripts.go @@ -8,6 +8,7 @@ import ( "github.com/onflow/cadence" flowsdk "github.com/onflow/flow-go-sdk" + "github.com/onflow/flow-go/model/flow" ) diff --git a/integration/dkg/node.go b/integration/dkg/node.go index cbea2b7f44a..5c16acba499 100644 --- a/integration/dkg/node.go +++ b/integration/dkg/node.go @@ -8,6 +8,7 @@ import ( sdk "github.com/onflow/flow-go-sdk" sdkcrypto "github.com/onflow/flow-go-sdk/crypto" + "github.com/onflow/flow-go/engine/consensus/dkg" testmock "github.com/onflow/flow-go/engine/testutil/mock" "github.com/onflow/flow-go/model/bootstrap" diff --git a/integration/go.mod b/integration/go.mod index 8e5e807dc01..92956116a7e 100644 --- a/integration/go.mod +++ b/integration/go.mod @@ -20,13 +20,13 @@ require ( github.com/ipfs/go-ds-badger2 v0.1.3 github.com/ipfs/go-ds-pebble v0.3.1-0.20240828032824-d745b9d3200b github.com/libp2p/go-libp2p v0.32.2 - github.com/onflow/cadence v1.1.0 + github.com/onflow/cadence v1.2.1 github.com/onflow/crypto v0.25.2 - github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2 - github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2 - github.com/onflow/flow-emulator v1.0.2-0.20241018193523-2601797fe0f2 - github.com/onflow/flow-go v0.38.0-preview.0.0.20241018193026-4b778232480b - github.com/onflow/flow-go-sdk v1.1.0 + github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 + github.com/onflow/flow-core-contracts/lib/go/templates v1.4.0 + github.com/onflow/flow-emulator v1.0.2-0.20241021223526-a545558d37a2 + github.com/onflow/flow-go v0.38.0-preview.0.0.20241021221952-af9cd6e99de1 + github.com/onflow/flow-go-sdk v1.2.2 github.com/onflow/flow-go/insecure v0.0.0-00010101000000-000000000000 github.com/onflow/flow/protobuf/go/flow v0.4.7 github.com/onflow/go-ethereum v1.14.7 diff --git a/integration/go.sum b/integration/go.sum index 7033bc72121..7e114711f03 100644 --- a/integration/go.sum +++ b/integration/go.sum @@ -742,22 +742,22 @@ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onflow/atree v0.8.0 h1:qg5c6J1gVDNObughpEeWm8oxqhPGdEyGrda121GM4u0= github.com/onflow/atree v0.8.0/go.mod h1:yccR+LR7xc1Jdic0mrjocbHvUD7lnVvg8/Ct1AA5zBo= -github.com/onflow/cadence v1.1.0 h1:wPg86IX1kRv6DWjdETxKa4tv6A3iAwJVzzKAwaGdtDA= -github.com/onflow/cadence v1.1.0/go.mod h1:fJxxOAp1wnWDfOHT8GOc1ypsU0RR5E3z51AhG8Yf5jg= +github.com/onflow/cadence v1.2.1 h1:hmSsgX3rTsp2E5qTSl1JXINt8qepdRrHTwDSYqN5Nxs= +github.com/onflow/cadence v1.2.1/go.mod h1:fJxxOAp1wnWDfOHT8GOc1ypsU0RR5E3z51AhG8Yf5jg= github.com/onflow/crypto v0.25.2 h1:GjHunqVt+vPcdqhxxhAXiMIF3YiLX7gTuTR5O+VG2ns= github.com/onflow/crypto v0.25.2/go.mod h1:fY7eLqUdMKV8EGOw301unP8h7PvLVy8/6gVR++/g0BY= -github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2 h1:My0EZLNXlzjN5tT81wD+wNb+PSqfOLJKHA1crXBNu5U= -github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac= -github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2 h1:YNHTonFhPSCuPJFYhIYZ1okSZmXEeQ07eKaoryrjHQI= -github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64= -github.com/onflow/flow-emulator v1.0.2-0.20241018193523-2601797fe0f2 h1:bCp07I6BKfDGu8CFiWS0OY7FiqELAZNbeZ2M70o1gXY= -github.com/onflow/flow-emulator v1.0.2-0.20241018193523-2601797fe0f2/go.mod h1:QMKsUPYQh4PPvSF3ryYzkbL6HzWAhoRr55FtbKCC5Jc= +github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 h1:R86HaOuk6vpuECZnriEUE7bw9inC2AtdSn8lL/iwQLQ= +github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac= +github.com/onflow/flow-core-contracts/lib/go/templates v1.4.0 h1:u2DAG8pk0xFH7TwS70t1gSZ/FtIIZWMSNyiu4SeXBYg= +github.com/onflow/flow-core-contracts/lib/go/templates v1.4.0/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64= +github.com/onflow/flow-emulator v1.0.2-0.20241021223526-a545558d37a2 h1:zs3/ctgI1KNFTcA1HpkDmyNuUybY/oFXDE1S+cYR9lU= +github.com/onflow/flow-emulator v1.0.2-0.20241021223526-a545558d37a2/go.mod h1:HgcZT9TZVOqmNGqN3fX+QqoiVovIHfLwqbXwuaEJiXE= github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3SsEftzXG2JlmSe24= github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A= github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM= github.com/onflow/flow-ft/lib/go/templates v1.0.1/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE= -github.com/onflow/flow-go-sdk v1.1.0 h1:DT8P3B3oAicOOXugdev4s1IEKHsiLS9T7MovFcTzB2s= -github.com/onflow/flow-go-sdk v1.1.0/go.mod h1:21g1pqP9Wy8RBXdenNsjzADwbtWNOViUCnfNZwr3trM= +github.com/onflow/flow-go-sdk v1.2.2 h1:F78Sq/VaExgtaQv739k06gnx2aIyLF5wVE0XwxFpmsc= +github.com/onflow/flow-go-sdk v1.2.2/go.mod h1:yhQ5+Sp2xWoCQ1fuRDswawTDQ0ng0z5nTkFVH82xL7E= github.com/onflow/flow-nft/lib/go/contracts v1.2.2 h1:XFERNVUDGbZ4ViZjt7P1cGD80mO1PzUJYPfdhXFsGbQ= github.com/onflow/flow-nft/lib/go/contracts v1.2.2/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY= github.com/onflow/flow-nft/lib/go/templates v1.2.1 h1:SAALMZPDw9Eb9p5kSLnmnFxjyig1MLiT4JUlLp0/bSE= diff --git a/integration/testnet/network.go b/integration/testnet/network.go index bc5fdc2f48b..51c1a7db899 100644 --- a/integration/testnet/network.go +++ b/integration/testnet/network.go @@ -31,6 +31,7 @@ import ( "github.com/onflow/cadence" "github.com/onflow/flow-go-sdk/crypto" + "github.com/onflow/flow-go/cmd/bootstrap/dkg" "github.com/onflow/flow-go/cmd/bootstrap/run" "github.com/onflow/flow-go/cmd/bootstrap/utils" diff --git a/integration/tests/access/cohort2/observer_indexer_enabled_test.go b/integration/tests/access/cohort2/observer_indexer_enabled_test.go index 43f784669bc..cc2709f9780 100644 --- a/integration/tests/access/cohort2/observer_indexer_enabled_test.go +++ b/integration/tests/access/cohort2/observer_indexer_enabled_test.go @@ -17,6 +17,7 @@ import ( sdk "github.com/onflow/flow-go-sdk" sdkcrypto "github.com/onflow/flow-go-sdk/crypto" "github.com/onflow/flow-go-sdk/templates" + "github.com/onflow/flow-go/engine/access/rpc/backend" "github.com/onflow/flow-go/engine/common/rpc/convert" "github.com/onflow/flow-go/integration/testnet" diff --git a/integration/tests/access/cohort3/access_circuit_breaker_test.go b/integration/tests/access/cohort3/access_circuit_breaker_test.go index 772a56e6c8c..8cb745bd569 100644 --- a/integration/tests/access/cohort3/access_circuit_breaker_test.go +++ b/integration/tests/access/cohort3/access_circuit_breaker_test.go @@ -16,6 +16,7 @@ import ( sdk "github.com/onflow/flow-go-sdk" sdkcrypto "github.com/onflow/flow-go-sdk/crypto" "github.com/onflow/flow-go-sdk/templates" + "github.com/onflow/flow-go/integration/testnet" "github.com/onflow/flow-go/integration/tests/lib" "github.com/onflow/flow-go/model/flow" diff --git a/integration/tests/collection/recovery_test.go b/integration/tests/collection/recovery_test.go index 6d1309df18c..d1812e83c7a 100644 --- a/integration/tests/collection/recovery_test.go +++ b/integration/tests/collection/recovery_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/suite" client "github.com/onflow/flow-go-sdk/access/grpc" + "github.com/onflow/flow-go/integration/convert" "github.com/onflow/flow-go/model/flow" "github.com/onflow/flow-go/utils/unittest" diff --git a/integration/utils/emulator_client.go b/integration/utils/emulator_client.go index 8d42e1388fd..1af763e6cff 100644 --- a/integration/utils/emulator_client.go +++ b/integration/utils/emulator_client.go @@ -12,6 +12,7 @@ import ( sdk "github.com/onflow/flow-go-sdk" "github.com/onflow/flow-go-sdk/templates" + "github.com/onflow/flow-go/model/flow" ) diff --git a/ledger/common/bitutils/utils_test.go b/ledger/common/bitutils/utils_test.go index d8f23dfd1a4..f168c058ffa 100644 --- a/ledger/common/bitutils/utils_test.go +++ b/ledger/common/bitutils/utils_test.go @@ -5,9 +5,8 @@ import ( "math/big" "math/bits" "math/rand" - "time" - "testing" + "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/module/epochs/base_client.go b/module/epochs/base_client.go index 5b372d80141..a0b845fd19a 100644 --- a/module/epochs/base_client.go +++ b/module/epochs/base_client.go @@ -12,6 +12,7 @@ import ( sdk "github.com/onflow/flow-go-sdk" sdkcrypto "github.com/onflow/flow-go-sdk/crypto" + "github.com/onflow/flow-go/network" "github.com/onflow/flow-go/module" diff --git a/module/epochs/qc_client.go b/module/epochs/qc_client.go index 8bdf32d6a57..4f891361063 100644 --- a/module/epochs/qc_client.go +++ b/module/epochs/qc_client.go @@ -13,6 +13,7 @@ import ( sdk "github.com/onflow/flow-go-sdk" sdkcrypto "github.com/onflow/flow-go-sdk/crypto" + "github.com/onflow/flow-go/network" "github.com/onflow/flow-go/consensus/hotstuff/model" diff --git a/storage/badger/payloads_test.go b/storage/badger/payloads_test.go index cb11074f88b..d92a593526e 100644 --- a/storage/badger/payloads_test.go +++ b/storage/badger/payloads_test.go @@ -2,7 +2,6 @@ package badger_test import ( "errors" - "testing" "github.com/dgraph-io/badger/v2" diff --git a/utils/unittest/execution_state.go b/utils/unittest/execution_state.go index 425527670dc..7265fb895fa 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 = "d2a7db1fa0cc1eee36e8769c11095fbaa440ab7916e5923afa10e760fd5eae2b" +const GenesisStateCommitmentHex = "b921d979dd58c55c43f8918cf653578697ec75d8cc2782a0c447b8ee0c39b544" var GenesisStateCommitment flow.StateCommitment @@ -87,10 +87,10 @@ func genesisCommitHexByChainID(chainID flow.ChainID) string { return GenesisStateCommitmentHex } if chainID == flow.Testnet { - return "719c12f8e28a40d822e43873d8a188daa7a3f81dc530c4c61f4141d76985bd46" + return "042170743acd6c7e8d14bb91b7296719cb61448c222a30163feb108d9994fd58" } if chainID == flow.Sandboxnet { return "e1c08b17f9e5896f03fe28dd37ca396c19b26628161506924fbf785834646ea1" } - return "5efd4c97fa23bd76769ab891a2681a839f8bdd0a2be0e07ab841f51b2e3a2f51" + return "c67d4b16a38b4bf0d9d5b6c5f75c55079af969b847538ceec87bc00af1c50516" } diff --git a/utils/unittest/fixtures.go b/utils/unittest/fixtures.go index 0bce5e99b41..9c3f9784493 100644 --- a/utils/unittest/fixtures.go +++ b/utils/unittest/fixtures.go @@ -19,6 +19,7 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/onflow/flow-go-sdk" + hotstuff "github.com/onflow/flow-go/consensus/hotstuff/model" "github.com/onflow/flow-go/engine" "github.com/onflow/flow-go/engine/access/rest/util"