diff --git a/.github/workflows/actions/test-monitor-process-results/action.yml b/.github/workflows/actions/test-monitor-process-results/action.yml index 08f1c16ab82..ea62e2f9c20 100644 --- a/.github/workflows/actions/test-monitor-process-results/action.yml +++ b/.github/workflows/actions/test-monitor-process-results/action.yml @@ -3,8 +3,11 @@ name: Test Monitor - Process Results description: Custom action that's used in multiple Flaky Test Monitor jobs to process test results and upload them to BigQuery inputs: - gcp_sa_key: - description: 'The GCP service account key for uploading to BigQuery' + service_account: + description: 'The GCP Service Account' + required: true + workload_identity_provider: + description: 'The GCP Workload Identity Provider' required: true runs: @@ -14,20 +17,30 @@ runs: id: commit_date run: echo "::set-output name=date::$(git show --no-patch --no-notes --pretty='%cI' $COMMIT_SHA)" shell: bash + - name: Get job run date id: job_run_date run: echo "::set-output name=date::$(TZ=":UTC" date -Iseconds)" shell: bash + - name: Process test results run: cat test-output | go run tools/test_monitor/level1/process_summary1_results.go env: JOB_STARTED: ${{ steps.job_run_date.outputs.date }} COMMIT_DATE: ${{ steps.commit_date.outputs.date }} shell: bash - - name: Set up Cloud SDK - uses: google-github-actions/setup-gcloud@v0 + + - name: Google auth + id: auth + uses: google-github-actions/auth@v2 with: - service_account_key: ${{ inputs.gcp_sa_key }} + service_account: ${{ inputs.service_account }} + token_format: 'access_token' + workload_identity_provider: ${{ inputs.workload_identity_provider }} + + - name: 'Set up Cloud SDK' + uses: 'google-github-actions/setup-gcloud@v2' + - name: Upload results to BigQuery (skipped tests) uses: nick-fields/retry@v2 with: diff --git a/.github/workflows/flaky-test-monitor.yml b/.github/workflows/flaky-test-monitor.yml index e9d55f75164..0df5c5d75fb 100644 --- a/.github/workflows/flaky-test-monitor.yml +++ b/.github/workflows/flaky-test-monitor.yml @@ -8,9 +8,12 @@ on: push: paths: - '.github/workflows/flaky-test-monitor.yml' +permissions: + id-token: write + contents: read env: - BIGQUERY_DATASET: production_src_flow_test_metrics + BIGQUERY_DATASET: dev_src_flow_test_metrics BIGQUERY_TABLE: skipped_tests BIGQUERY_TABLE2: test_results GO_VERSION: "1.22" @@ -73,7 +76,8 @@ jobs: TEST_CATEGORY: unit uses: ./.github/workflows/actions/test-monitor-process-results with: - gcp_sa_key: ${{ secrets.GCP_SA_KEY }} + service_account: ${{ secrets.FLAKY_TEST_SERVICE_ACCOUNT }} + workload_identity_provider: ${{ secrets.FLAKY_TEST_WORKLOAD_IDENTITY_PROVIDER }} unit-test-modules: name: Unit Tests (Modules) @@ -115,7 +119,8 @@ jobs: TEST_CATEGORY: ${{ matrix.test_category }} uses: ./.github/workflows/actions/test-monitor-process-results with: - gcp_sa_key: ${{ secrets.GCP_SA_KEY }} + service_account: ${{ secrets.FLAKY_TEST_SERVICE_ACCOUNT }} + workload_identity_provider: ${{ secrets.FLAKY_TEST_WORKLOAD_IDENTITY_PROVIDER }} integration-test: name: Integration Tests @@ -175,4 +180,6 @@ jobs: TEST_CATEGORY: ${{ matrix.test_category }} uses: ./.github/workflows/actions/test-monitor-process-results with: - gcp_sa_key: ${{ secrets.GCP_SA_KEY }} + service_account: ${{ secrets.FLAKY_TEST_SERVICE_ACCOUNT }} + workload_identity_provider: ${{ secrets.FLAKY_TEST_WORKLOAD_IDENTITY_PROVIDER }} + diff --git a/cmd/util/ledger/migrations/cadence.go b/cmd/util/ledger/migrations/cadence.go index 80e3725a1ad..139463e386d 100644 --- a/cmd/util/ledger/migrations/cadence.go +++ b/cmd/util/ledger/migrations/cadence.go @@ -236,6 +236,16 @@ func NewCadence1ValueMigrations( programs := make(map[common.Location]*interpreter.Program, 1000) migs = []NamedMigration{ + { + Name: "cleanup-contracts", + Migrate: NewAccountBasedMigration( + log, + opts.NWorker, + []AccountBasedMigration{ + NewContractCleanupMigration(rwf), + }, + ), + }, { Name: "check-contracts", Migrate: NewContractCheckingMigration( diff --git a/cmd/util/ledger/migrations/cadence_test.go b/cmd/util/ledger/migrations/cadence_test.go new file mode 100644 index 00000000000..7c6e02dccb7 --- /dev/null +++ b/cmd/util/ledger/migrations/cadence_test.go @@ -0,0 +1,69 @@ +package migrations + +import ( + "testing" + + "github.com/onflow/cadence/runtime/common" + "github.com/onflow/cadence/runtime/interpreter" + "github.com/rs/zerolog" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/onflow/flow-go/cmd/util/ledger/util/registers" + "github.com/onflow/flow-go/fvm/environment" + "github.com/onflow/flow-go/model/flow" +) + +func TestMigrateCadence1EmptyContract(t *testing.T) { + + t.Parallel() + + const chainID = flow.Testnet + + address, err := common.HexToAddress("0x4184b8bdf78db9eb") + require.NoError(t, err) + + const contractName = "FungibleToken" + + registersByAccount := registers.NewByAccount() + + err = registersByAccount.Set( + string(address[:]), + flow.ContractKey(contractName), + // some whitespace for testing purposes + []byte(" \t \n "), + ) + require.NoError(t, err) + + encodedContractNames, err := environment.EncodeContractNames([]string{contractName}) + require.NoError(t, err) + + err = registersByAccount.Set( + string(address[:]), + flow.ContractNamesKey, + encodedContractNames, + ) + require.NoError(t, err) + + programs := map[common.Location]*interpreter.Program{} + + rwf := &testReportWriterFactory{} + + // Run contract checking migration + + log := zerolog.Nop() + checkingMigration := NewContractCheckingMigration(log, rwf, chainID, false, programs) + + err = checkingMigration(registersByAccount) + require.NoError(t, err) + + reporter := rwf.reportWriters[contractCheckingReporterName] + assert.Empty(t, reporter.entries) + + // Initialize metrics collecting migration (used to run into unexpected error) + + metricsCollectingMigration := NewMetricsCollectingMigration(log, chainID, rwf, programs) + + err = metricsCollectingMigration.InitMigration(log, registersByAccount, 1) + require.NoError(t, err) +} diff --git a/cmd/util/ledger/migrations/contract_checking_migration.go b/cmd/util/ledger/migrations/contract_checking_migration.go index 3080d4bcb53..1442bdfb6c7 100644 --- a/cmd/util/ledger/migrations/contract_checking_migration.go +++ b/cmd/util/ledger/migrations/contract_checking_migration.go @@ -1,6 +1,7 @@ package migrations import ( + "bytes" "encoding/json" "fmt" "sort" @@ -78,6 +79,10 @@ func NewContractCheckingMigration( return err } + if len(bytes.TrimSpace(code)) == 0 { + continue + } + address := common.Address([]byte(owner)) location := common.AddressLocation{ Address: address, diff --git a/cmd/util/ledger/migrations/contract_cleanup_migration.go b/cmd/util/ledger/migrations/contract_cleanup_migration.go new file mode 100644 index 00000000000..bee3a8e49a4 --- /dev/null +++ b/cmd/util/ledger/migrations/contract_cleanup_migration.go @@ -0,0 +1,292 @@ +package migrations + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "sort" + + "github.com/rs/zerolog" + + "github.com/onflow/cadence/runtime/common" + + "github.com/onflow/flow-go/cmd/util/ledger/reporters" + "github.com/onflow/flow-go/cmd/util/ledger/util/registers" + "github.com/onflow/flow-go/fvm/environment" + "github.com/onflow/flow-go/model/flow" +) + +// ContractCleanupMigration normalized account's contract names and removes empty contracts. +type ContractCleanupMigration struct { + log zerolog.Logger + reporter reporters.ReportWriter +} + +const contractCleanupReporterName = "contract-cleanup" + +var _ AccountBasedMigration = &ContractCleanupMigration{} + +func NewContractCleanupMigration(rwf reporters.ReportWriterFactory) *ContractCleanupMigration { + return &ContractCleanupMigration{ + reporter: rwf.ReportWriter(contractCleanupReporterName), + } +} + +func (d *ContractCleanupMigration) InitMigration( + log zerolog.Logger, + _ *registers.ByAccount, + _ int, +) error { + d.log = log. + With(). + Str("migration", "ContractCleanupMigration"). + Logger() + + return nil +} + +func (d *ContractCleanupMigration) MigrateAccount( + _ context.Context, + address common.Address, + accountRegisters *registers.AccountRegisters, +) error { + + // Get the set of all contract names for the account. + + oldContractNames, err := d.getContractNames(accountRegisters) + if err != nil { + return fmt.Errorf( + "failed to get contract names for %s: %w", + address.HexWithPrefix(), + err, + ) + } + + contractNameSet := make(map[string]struct{}) + for _, contractName := range oldContractNames { + contractNameSet[contractName] = struct{}{} + } + + // Cleanup the code for each contract in the account. + // If the contract code is empty, the contract code register will be removed, + // and the contract name will be removed from the account's contract names. + + for contractName := range contractNameSet { + removed, err := d.cleanupContractCode( + address, + accountRegisters, + contractName, + ) + if err != nil { + return fmt.Errorf( + "failed to cleanup contract code for %s: %w", + address.HexWithPrefix(), + err, + ) + } + + if removed { + delete(contractNameSet, contractName) + } + } + + // Sort the contract names and set them back to the account. + + newContractNames := make([]string, 0, len(contractNameSet)) + for contractName := range contractNameSet { + newContractNames = append(newContractNames, contractName) + } + + sort.Strings(newContractNames) + + // NOTE: Always set the contract names back to the account, + // even if there are no contract names. + // This effectively clears the contract names register. + + err = d.setContractNames(accountRegisters, newContractNames) + if err != nil { + return fmt.Errorf( + "failed to set contract names for %s: %w", + address.HexWithPrefix(), + err, + ) + } + + if !stringSlicesEqual(newContractNames, oldContractNames) { + d.reporter.Write(contractNamesChanged{ + AccountAddress: address, + Old: oldContractNames, + New: newContractNames, + }) + } + + return nil +} + +func (d *ContractCleanupMigration) getContractNames( + accountRegisters *registers.AccountRegisters, +) ([]string, error) { + owner := accountRegisters.Owner() + + encodedContractNames, err := accountRegisters.Get(owner, flow.ContractNamesKey) + if err != nil { + return nil, fmt.Errorf( + "failed to get contract names: %w", + err, + ) + } + + if len(encodedContractNames) == 0 { + return nil, nil + } + + contractNames, err := environment.DecodeContractNames(encodedContractNames) + if err != nil { + return nil, fmt.Errorf( + "failed to decode contract names: %w", + err, + ) + } + + return contractNames, nil +} + +func (d *ContractCleanupMigration) setContractNames( + accountRegisters *registers.AccountRegisters, + contractNames []string, +) error { + owner := accountRegisters.Owner() + + var newEncodedContractNames []byte + var err error + + // Encode the new contract names, if there are any. + + if len(contractNames) > 0 { + newEncodedContractNames, err = environment.EncodeContractNames(contractNames) + if err != nil { + return fmt.Errorf( + "failed to encode contract names: %w", + err, + ) + } + } + + // NOTE: always set the contract names register, even if there are not contract names. + // This effectively clears the contract names register. + + err = accountRegisters.Set(owner, flow.ContractNamesKey, newEncodedContractNames) + if err != nil { + return fmt.Errorf( + "failed to set contract names: %w", + err, + ) + } + + return nil +} + +// cleanupContractCode removes the code for the contract if it is empty. +// Returns true if the contract code was removed. +func (d *ContractCleanupMigration) cleanupContractCode( + address common.Address, + accountRegisters *registers.AccountRegisters, + contractName string, +) (removed bool, err error) { + owner := accountRegisters.Owner() + + contractKey := flow.ContractKey(contractName) + + code, err := accountRegisters.Get(owner, contractKey) + if err != nil { + return false, fmt.Errorf( + "failed to get contract code for %s: %w", + contractName, + err, + ) + } + + // If the contract code is empty, remove the contract code register. + + if len(bytes.TrimSpace(code)) == 0 { + err = accountRegisters.Set(owner, contractKey, nil) + if err != nil { + return false, fmt.Errorf( + "failed to clear contract code for %s: %w", + contractName, + err, + ) + } + + d.reporter.Write(emptyContractRemoved{ + AccountAddress: address, + ContractName: contractName, + }) + + removed = true + } + + return removed, nil +} + +func (d *ContractCleanupMigration) Close() error { + d.reporter.Close() + + return nil +} + +type emptyContractRemoved struct { + AccountAddress common.Address + ContractName string +} + +var _ json.Marshaler = emptyContractRemoved{} + +func (e emptyContractRemoved) MarshalJSON() ([]byte, error) { + return json.Marshal(struct { + Kind string `json:"kind"` + AccountAddress string `json:"address"` + ContractName string `json:"name"` + }{ + Kind: "empty-contract-removed", + AccountAddress: e.AccountAddress.HexWithPrefix(), + ContractName: e.ContractName, + }) +} + +func stringSlicesEqual(a, b []string) bool { + if len(a) != len(b) { + return false + } + + for i := range a { + if a[i] != b[i] { + return false + } + } + + return true +} + +type contractNamesChanged struct { + AccountAddress common.Address `json:"address"` + Old []string `json:"old"` + New []string `json:"new"` +} + +var _ json.Marshaler = contractNamesChanged{} + +func (e contractNamesChanged) MarshalJSON() ([]byte, error) { + return json.Marshal(struct { + Kind string `json:"kind"` + AccountAddress string `json:"address"` + Old []string `json:"old"` + New []string `json:"new"` + }{ + Kind: "contract-names-changed", + AccountAddress: e.AccountAddress.HexWithPrefix(), + Old: e.Old, + New: e.New, + }) +} diff --git a/cmd/util/ledger/migrations/contract_cleanup_migration_test.go b/cmd/util/ledger/migrations/contract_cleanup_migration_test.go new file mode 100644 index 00000000000..ec57f9bb99e --- /dev/null +++ b/cmd/util/ledger/migrations/contract_cleanup_migration_test.go @@ -0,0 +1,277 @@ +package migrations + +import ( + "context" + "testing" + + "github.com/onflow/cadence/runtime/common" + "github.com/rs/zerolog" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/onflow/flow-go/cmd/util/ledger/util/registers" + "github.com/onflow/flow-go/fvm/environment" + "github.com/onflow/flow-go/model/flow" +) + +func TestContractCleanupMigration1(t *testing.T) { + + t.Parallel() + + // Arrange + + address, err := common.HexToAddress("0x4184b8bdf78db9eb") + require.NoError(t, err) + + flowAddress := flow.ConvertAddress(address) + owner := flow.AddressToRegisterOwner(flowAddress) + + const contractNameEmpty = "Foo" + const contractNameNonEmpty = "Bar" + + registersByAccount := registers.NewByAccount() + + err = registersByAccount.Set( + owner, + flow.ContractKey(contractNameEmpty), + // Some whitespace for testing purposes + []byte(" \t \n "), + ) + require.NoError(t, err) + + err = registersByAccount.Set( + owner, + flow.ContractKey(contractNameNonEmpty), + []byte(" \n \t access(all) contract Bar {} \n \n"), + ) + require.NoError(t, err) + + encodedContractNames, err := environment.EncodeContractNames([]string{ + // Unsorted and duplicates for testing purposes + contractNameEmpty, + contractNameNonEmpty, + contractNameEmpty, + contractNameNonEmpty, + contractNameEmpty, + contractNameEmpty, + contractNameNonEmpty, + }) + require.NoError(t, err) + + err = registersByAccount.Set( + owner, + flow.ContractNamesKey, + encodedContractNames, + ) + require.NoError(t, err) + + // Act + + rwf := &testReportWriterFactory{} + + cleanupMigration := NewContractCleanupMigration(rwf) + + log := zerolog.Nop() + + err = cleanupMigration.InitMigration(log, registersByAccount, 1) + require.NoError(t, err) + + accountRegisters := registersByAccount.AccountRegisters(owner) + + err = cleanupMigration.MigrateAccount( + context.Background(), + address, + accountRegisters, + ) + require.NoError(t, err) + + err = cleanupMigration.Close() + require.NoError(t, err) + + // Assert + + encodedContractNames, err = registersByAccount.Get( + owner, + flow.ContractNamesKey, + ) + require.NoError(t, err) + + contractNames, err := environment.DecodeContractNames(encodedContractNames) + require.NoError(t, err) + assert.Equal(t, + []string{ + contractNameNonEmpty, + }, + contractNames, + ) + + contractEmpty, err := registersByAccount.Get( + owner, + flow.ContractKey(contractNameEmpty), + ) + require.NoError(t, err) + assert.Nil(t, contractEmpty) + + contractNonEmpty, err := registersByAccount.Get( + owner, + flow.ContractKey(contractNameNonEmpty), + ) + require.NoError(t, err) + assert.NotEmpty(t, contractNonEmpty) + + reporter := rwf.reportWriters[contractCleanupReporterName] + require.NotNil(t, reporter) + + assert.Equal(t, + []any{ + emptyContractRemoved{ + AccountAddress: address, + ContractName: contractNameEmpty, + }, + contractNamesChanged{ + AccountAddress: address, + Old: []string{ + contractNameEmpty, + contractNameNonEmpty, + contractNameEmpty, + contractNameNonEmpty, + contractNameEmpty, + contractNameEmpty, + contractNameNonEmpty, + }, + New: []string{ + contractNameNonEmpty, + }, + }, + }, + reporter.entries, + ) +} + +func TestContractCleanupMigration2(t *testing.T) { + + t.Parallel() + + // Arrange + + address, err := common.HexToAddress("0x4184b8bdf78db9eb") + require.NoError(t, err) + + flowAddress := flow.ConvertAddress(address) + owner := flow.AddressToRegisterOwner(flowAddress) + + const contractNameEmpty1 = "Foo" + const contractNameEmpty2 = "Bar" + + registersByAccount := registers.NewByAccount() + + err = registersByAccount.Set( + owner, + flow.ContractKey(contractNameEmpty1), + // Some whitespace for testing purposes + []byte(" \t \n "), + ) + require.NoError(t, err) + + err = registersByAccount.Set( + owner, + flow.ContractKey(contractNameEmpty2), + []byte("\n \t \n \t"), + ) + require.NoError(t, err) + + encodedContractNames, err := environment.EncodeContractNames([]string{ + // Unsorted and duplicates for testing purposes + contractNameEmpty1, + contractNameEmpty2, + contractNameEmpty1, + contractNameEmpty2, + contractNameEmpty1, + contractNameEmpty1, + contractNameEmpty2, + }) + require.NoError(t, err) + + err = registersByAccount.Set( + owner, + flow.ContractNamesKey, + encodedContractNames, + ) + require.NoError(t, err) + + // Act + + rwf := &testReportWriterFactory{} + + cleanupMigration := NewContractCleanupMigration(rwf) + + log := zerolog.Nop() + + err = cleanupMigration.InitMigration(log, registersByAccount, 1) + require.NoError(t, err) + + accountRegisters := registersByAccount.AccountRegisters(owner) + + err = cleanupMigration.MigrateAccount( + context.Background(), + address, + accountRegisters, + ) + require.NoError(t, err) + + err = cleanupMigration.Close() + require.NoError(t, err) + + // Assert + + encodedContractNames, err = registersByAccount.Get( + owner, + flow.ContractNamesKey, + ) + require.NoError(t, err) + assert.Nil(t, encodedContractNames) + + contractEmpty1, err := registersByAccount.Get( + owner, + flow.ContractKey(contractNameEmpty1), + ) + require.NoError(t, err) + assert.Nil(t, contractEmpty1) + + contractEmpty2, err := registersByAccount.Get( + owner, + flow.ContractKey(contractNameEmpty2), + ) + require.NoError(t, err) + assert.Nil(t, contractEmpty2) + + reporter := rwf.reportWriters[contractCleanupReporterName] + require.NotNil(t, reporter) + + assert.Equal(t, + []any{ + emptyContractRemoved{ + AccountAddress: address, + ContractName: contractNameEmpty1, + }, + emptyContractRemoved{ + AccountAddress: address, + ContractName: contractNameEmpty2, + }, + contractNamesChanged{ + AccountAddress: address, + Old: []string{ + contractNameEmpty1, + contractNameEmpty2, + contractNameEmpty1, + contractNameEmpty2, + contractNameEmpty1, + contractNameEmpty1, + contractNameEmpty2, + }, + New: []string{}, + }, + }, + reporter.entries, + ) +} diff --git a/cmd/util/ledger/migrations/migration_metrics_collector.go b/cmd/util/ledger/migrations/migration_metrics_collector.go index cb558538bed..b6b62841203 100644 --- a/cmd/util/ledger/migrations/migration_metrics_collector.go +++ b/cmd/util/ledger/migrations/migration_metrics_collector.go @@ -67,7 +67,7 @@ func (m *MetricsCollectingMigration) InitMigration( // If the program is available, that means the associated contracts is compatible with Cadence 1.0. // i.e: the contract is either migrated to be compatible with 1.0 or existing contract already compatible. - for _, program := range m.programs { + for location, program := range m.programs { var nestedDecls *ast.Members contract := program.Program.SoleContractDeclaration() @@ -80,7 +80,16 @@ func (m *MetricsCollectingMigration) InitMigration( } else { contractInterface := program.Program.SoleContractInterfaceDeclaration() if contractInterface == nil { - panic(errors.NewUnreachableError()) + declarations := program.Program.Declarations() + declarationKinds := make([]common.DeclarationKind, 0, len(declarations)) + for _, declaration := range declarations { + declarationKinds = append(declarationKinds, declaration.DeclarationKind()) + } + panic(errors.NewUnexpectedError( + "invalid program %s: expected a sole contract or contract interface, got %s", + location, + declarationKinds, + )) } nestedDecls = contractInterface.Members diff --git a/fvm/fvm_signature_test.go b/fvm/fvm_signature_test.go index 870794001e9..b92e461e5e8 100644 --- a/fvm/fvm_signature_test.go +++ b/fvm/fvm_signature_test.go @@ -27,6 +27,12 @@ var createMessage = func(m string) (signableMessage []byte, message cadence.Arra return signableMessage, message } +var uint8ArrayArrayType = cadence.NewVariableSizedArrayType( + cadence.NewVariableSizedArrayType( + cadence.UInt8Type, + ), +) + func TestKeyListSignature(t *testing.T) { t.Parallel() @@ -552,12 +558,8 @@ func TestBLSMultiSignature(t *testing.T) { script := fvm.Script(code).WithArguments( jsoncdc.MustEncode(cadence.Array{ - Values: signatures, - ArrayType: &cadence.VariableSizedArrayType{ - ElementType: &cadence.VariableSizedArrayType{ - ElementType: cadence.UInt8Type, - }, - }, + Values: signatures, + ArrayType: uint8ArrayArrayType, }), ) @@ -584,12 +586,8 @@ func TestBLSMultiSignature(t *testing.T) { script := fvm.Script(code).WithArguments( jsoncdc.MustEncode(cadence.Array{ - Values: signatures, - ArrayType: &cadence.VariableSizedArrayType{ - ElementType: &cadence.VariableSizedArrayType{ - ElementType: cadence.UInt8Type, - }, - }, + Values: signatures, + ArrayType: uint8ArrayArrayType, }), ) @@ -607,12 +605,8 @@ func TestBLSMultiSignature(t *testing.T) { signatures := []cadence.Value{} script := fvm.Script(code).WithArguments( jsoncdc.MustEncode(cadence.Array{ - Values: signatures, - ArrayType: &cadence.VariableSizedArrayType{ - ElementType: &cadence.VariableSizedArrayType{ - ElementType: cadence.UInt8Type, - }, - }, + Values: signatures, + ArrayType: uint8ArrayArrayType, }), ) @@ -677,12 +671,8 @@ func TestBLSMultiSignature(t *testing.T) { script := fvm.Script(code(BLSSignatureAlgorithm)).WithArguments( jsoncdc.MustEncode(cadence.Array{ - Values: publicKeys, - ArrayType: &cadence.VariableSizedArrayType{ - ElementType: &cadence.VariableSizedArrayType{ - ElementType: cadence.UInt8Type, - }, - }, + Values: publicKeys, + ArrayType: uint8ArrayArrayType, }), ) @@ -711,12 +701,8 @@ func TestBLSMultiSignature(t *testing.T) { script := fvm.Script(code(signatureAlgorithm)).WithArguments( jsoncdc.MustEncode(cadence.Array{ - Values: publicKeys, - ArrayType: &cadence.VariableSizedArrayType{ - ElementType: &cadence.VariableSizedArrayType{ - ElementType: cadence.UInt8Type, - }, - }, + Values: publicKeys, + ArrayType: uint8ArrayArrayType, }), ) @@ -731,12 +717,8 @@ func TestBLSMultiSignature(t *testing.T) { var publicKeys []cadence.Value script := fvm.Script(code(BLSSignatureAlgorithm)).WithArguments( jsoncdc.MustEncode(cadence.Array{ - Values: publicKeys, - ArrayType: &cadence.VariableSizedArrayType{ - ElementType: &cadence.VariableSizedArrayType{ - ElementType: cadence.UInt8Type, - }, - }, + Values: publicKeys, + ArrayType: uint8ArrayArrayType, }), ) @@ -811,20 +793,12 @@ func TestBLSMultiSignature(t *testing.T) { script := fvm.Script(code).WithArguments( jsoncdc.MustEncode(cadence.Array{ // keys - Values: publicKeys, - ArrayType: &cadence.VariableSizedArrayType{ - ElementType: &cadence.VariableSizedArrayType{ - ElementType: cadence.UInt8Type, - }, - }, + Values: publicKeys, + ArrayType: uint8ArrayArrayType, }), jsoncdc.MustEncode(cadence.Array{ // signatures - Values: signatures, - ArrayType: &cadence.VariableSizedArrayType{ - ElementType: &cadence.VariableSizedArrayType{ - ElementType: cadence.UInt8Type, - }, - }, + Values: signatures, + ArrayType: uint8ArrayArrayType, }), jsoncdc.MustEncode(cadenceMessage), jsoncdc.MustEncode(cadence.String(tag)), diff --git a/fvm/transactionPayerBalanceChecker.go b/fvm/transactionPayerBalanceChecker.go index 280cf5e2ada..79edfff5804 100644 --- a/fvm/transactionPayerBalanceChecker.go +++ b/fvm/transactionPayerBalanceChecker.go @@ -16,23 +16,6 @@ const VerifyPayerBalanceResultTypeCanExecuteTransactionFieldName = "canExecuteTr const VerifyPayerBalanceResultTypeRequiredBalanceFieldName = "requiredBalance" const VerifyPayerBalanceResultTypeMaximumTransactionFeesFieldName = "maximumTransactionFees" -var VerifyPayerBalanceResultType = &cadence.StructType{ - Fields: []cadence.Field{ - { - Identifier: VerifyPayerBalanceResultTypeCanExecuteTransactionFieldName, - Type: cadence.BoolType, - }, - { - Identifier: VerifyPayerBalanceResultTypeRequiredBalanceFieldName, - Type: cadence.UFix64Type, - }, - { - Identifier: VerifyPayerBalanceResultTypeMaximumTransactionFeesFieldName, - Type: cadence.UFix64Type, - }, - }, -} - // decodeVerifyPayerBalanceResult decodes the VerifyPayerBalanceResult struct // https://github.com/onflow/flow-core-contracts/blob/7c70c6a1d33c2879b60c78e363fa68fc6fce13b9/contracts/FlowFees.cdc#L75 func decodeVerifyPayerBalanceResult(resultValue cadence.Value) ( diff --git a/fvm/transactionPayerBalanceChecker_test.go b/fvm/transactionPayerBalanceChecker_test.go index f03b03758d8..2dc3ca677b5 100644 --- a/fvm/transactionPayerBalanceChecker_test.go +++ b/fvm/transactionPayerBalanceChecker_test.go @@ -16,6 +16,28 @@ import ( "github.com/onflow/flow-go/model/flow" ) +var verifyPayerBalanceResultType = cadence.NewStructType( + // TODO: location + nil, + // TODO: qualified identifier + "", + []cadence.Field{ + { + Identifier: fvm.VerifyPayerBalanceResultTypeCanExecuteTransactionFieldName, + Type: cadence.BoolType, + }, + { + Identifier: fvm.VerifyPayerBalanceResultTypeRequiredBalanceFieldName, + Type: cadence.UFix64Type, + }, + { + Identifier: fvm.VerifyPayerBalanceResultTypeMaximumTransactionFeesFieldName, + Type: cadence.UFix64Type, + }, + }, + nil, +) + func TestTransactionPayerBalanceChecker(t *testing.T) { payer := flow.HexToAddress("1") t.Run("TransactionFeesEnabled == false disables the balance check", func(t *testing.T) { @@ -90,7 +112,7 @@ func TestTransactionPayerBalanceChecker(t *testing.T) { cadence.NewBool(true), cadence.UFix64(100), cadence.UFix64(100), - }).WithType(fvm.VerifyPayerBalanceResultType), + }).WithType(verifyPayerBalanceResultType), nil, ) @@ -119,7 +141,7 @@ func TestTransactionPayerBalanceChecker(t *testing.T) { cadence.NewBool(false), cadence.UFix64(100), cadence.UFix64(101), - }).WithType(fvm.VerifyPayerBalanceResultType), + }).WithType(verifyPayerBalanceResultType), nil, ) diff --git a/go.mod b/go.mod index 4478289e694..8ba431f0315 100644 --- a/go.mod +++ b/go.mod @@ -47,12 +47,12 @@ require ( github.com/multiformats/go-multiaddr-dns v0.3.1 github.com/multiformats/go-multihash v0.2.3 github.com/onflow/atree v0.7.0-rc.2 - github.com/onflow/cadence v1.0.0-preview.34 + github.com/onflow/cadence v1.0.0-preview.35 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.0 github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0 - github.com/onflow/flow-go-sdk v1.0.0-preview.36 + github.com/onflow/flow-go-sdk v1.0.0-preview.37 github.com/onflow/flow/protobuf/go/flow v0.4.4 github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 github.com/pierrec/lz4 v2.6.1+incompatible @@ -258,7 +258,7 @@ require ( github.com/onflow/flow-ft/lib/go/templates v1.0.0 // 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/sdks v0.5.1-0.20230912225508-b35402f12bba // indirect + github.com/onflow/sdks v0.6.0-preview.1 // indirect github.com/onsi/ginkgo/v2 v2.13.2 // indirect github.com/opencontainers/runtime-spec v1.1.0 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect diff --git a/go.sum b/go.sum index 7beb1e4191c..04e5310738d 100644 --- a/go.sum +++ b/go.sum @@ -2171,8 +2171,8 @@ github.com/onflow/atree v0.7.0-rc.2/go.mod h1:xvP61FoOs95K7IYdIYRnNcYQGf4nbF/uuJ 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.34 h1:MJSli75W6LJVUqSx/tq4MQe64H1+EcQBD/sNgpOO4jE= -github.com/onflow/cadence v1.0.0-preview.34/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmpdpNNAFxBsjMlrqVD0= +github.com/onflow/cadence v1.0.0-preview.35 h1:HZgt/9Foa6sCSH9SNaIFUSXK6q2ZxETg0ivsZbf+hhU= +github.com/onflow/cadence v1.0.0-preview.35/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmpdpNNAFxBsjMlrqVD0= 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= @@ -2187,8 +2187,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.36 h1:3g72MjmZPEEVAbtDATbjwqKoNSB7yHLWswUHSAB5zwQ= -github.com/onflow/flow-go-sdk v1.0.0-preview.36/go.mod h1:mjkXIluC+kseYyd8Z1aTq73IiffAUeoY5fuX/C2Z+1w= +github.com/onflow/flow-go-sdk v1.0.0-preview.37 h1:ujeIQheD+skzFt9+eOT9nXcc1rFxVLSCzwisEI3+2DA= +github.com/onflow/flow-go-sdk v1.0.0-preview.37/go.mod h1:2aSN7RdKzxWoCtCyOJz9W/ZNqkLgQDQS3hKLYwPlvGw= 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= @@ -2200,8 +2200,9 @@ github.com/onflow/go-ethereum v1.13.4 h1:iNO86fm8RbBbhZ87ZulblInqCdHnAQVY8okBrNs github.com/onflow/go-ethereum v1.13.4/go.mod h1:cE/gEUkAffhwbVmMJYz+t1dAfVNHNwZCgc3BWtZxBGY= github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 h1:sxyWLqGm/p4EKT6DUlQESDG1ZNMN9GjPCm1gTq7NGfc= github.com/onflow/nft-storefront/lib/go/contracts v1.0.0/go.mod h1:kMeq9zUwCrgrSojEbTUTTJpZ4WwacVm2pA7LVFr+glk= -github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba h1:rIehuhO6bj4FkwE4VzwEjX7MoAlOhUJENBJLqDqVxAo= github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU= +github.com/onflow/sdks v0.6.0-preview.1 h1:mb/cUezuqWEP1gFZNAgUI4boBltudv4nlfxke1KBp9k= +github.com/onflow/sdks v0.6.0-preview.1/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU= github.com/onflow/wal v1.0.2 h1:5bgsJVf2O3cfMNK12fiiTyYZ8cOrUiELt3heBJfHOhc= github.com/onflow/wal v1.0.2/go.mod h1:iMC8gkLqu4nkbkAla5HkSBb+FGyQOZiWz3DYm2wSXCk= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= diff --git a/insecure/go.mod b/insecure/go.mod index 653b5dddc0f..847f760e01c 100644 --- a/insecure/go.mod +++ b/insecure/go.mod @@ -199,17 +199,17 @@ require ( github.com/multiformats/go-varint v0.0.7 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/onflow/atree v0.7.0-rc.2 // indirect - github.com/onflow/cadence v1.0.0-preview.34 // indirect + github.com/onflow/cadence v1.0.0-preview.35 // indirect github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0 // indirect github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0 // 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.36 // indirect + github.com/onflow/flow-go-sdk v1.0.0-preview.37 // 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.4 // indirect github.com/onflow/go-ethereum v1.13.4 // indirect - github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba // indirect + github.com/onflow/sdks v0.6.0-preview.1 // indirect github.com/onflow/wal v1.0.2 // indirect github.com/onsi/ginkgo/v2 v2.13.2 // indirect github.com/opencontainers/runtime-spec v1.1.0 // indirect diff --git a/insecure/go.sum b/insecure/go.sum index 030ffa3f4cb..78e57537f8f 100644 --- a/insecure/go.sum +++ b/insecure/go.sum @@ -2160,8 +2160,8 @@ github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f/go.mod h1:xvP61FoOs github.com/onflow/atree v0.7.0-rc.2 h1:mZmVrl/zPlfI44EjV3FdR2QwIqT8nz1sCONUBFcML/U= github.com/onflow/atree v0.7.0-rc.2/go.mod h1:xvP61FoOs95K7IYdIYRnNcYQGf4nbF/uuJ0tHf4DRuM= github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8= -github.com/onflow/cadence v1.0.0-preview.34 h1:MJSli75W6LJVUqSx/tq4MQe64H1+EcQBD/sNgpOO4jE= -github.com/onflow/cadence v1.0.0-preview.34/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmpdpNNAFxBsjMlrqVD0= +github.com/onflow/cadence v1.0.0-preview.35 h1:HZgt/9Foa6sCSH9SNaIFUSXK6q2ZxETg0ivsZbf+hhU= +github.com/onflow/cadence v1.0.0-preview.35/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmpdpNNAFxBsjMlrqVD0= 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= @@ -2174,8 +2174,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.36 h1:3g72MjmZPEEVAbtDATbjwqKoNSB7yHLWswUHSAB5zwQ= -github.com/onflow/flow-go-sdk v1.0.0-preview.36/go.mod h1:mjkXIluC+kseYyd8Z1aTq73IiffAUeoY5fuX/C2Z+1w= +github.com/onflow/flow-go-sdk v1.0.0-preview.37 h1:ujeIQheD+skzFt9+eOT9nXcc1rFxVLSCzwisEI3+2DA= +github.com/onflow/flow-go-sdk v1.0.0-preview.37/go.mod h1:2aSN7RdKzxWoCtCyOJz9W/ZNqkLgQDQS3hKLYwPlvGw= 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= @@ -2185,8 +2185,9 @@ github.com/onflow/flow/protobuf/go/flow v0.4.4 h1:lD1owoZGFgLcvdLZDmP0Kc4GOuQeSU github.com/onflow/flow/protobuf/go/flow v0.4.4/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= github.com/onflow/go-ethereum v1.13.4 h1:iNO86fm8RbBbhZ87ZulblInqCdHnAQVY8okBrNsTevc= github.com/onflow/go-ethereum v1.13.4/go.mod h1:cE/gEUkAffhwbVmMJYz+t1dAfVNHNwZCgc3BWtZxBGY= -github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba h1:rIehuhO6bj4FkwE4VzwEjX7MoAlOhUJENBJLqDqVxAo= github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU= +github.com/onflow/sdks v0.6.0-preview.1 h1:mb/cUezuqWEP1gFZNAgUI4boBltudv4nlfxke1KBp9k= +github.com/onflow/sdks v0.6.0-preview.1/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU= github.com/onflow/wal v1.0.2 h1:5bgsJVf2O3cfMNK12fiiTyYZ8cOrUiELt3heBJfHOhc= github.com/onflow/wal v1.0.2/go.mod h1:iMC8gkLqu4nkbkAla5HkSBb+FGyQOZiWz3DYm2wSXCk= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= diff --git a/integration/benchmark/cmd/ci/main.go b/integration/benchmark/cmd/ci/main.go index 105ca023d2d..1f213cf74ce 100644 --- a/integration/benchmark/cmd/ci/main.go +++ b/integration/benchmark/cmd/ci/main.go @@ -64,7 +64,7 @@ func main() { gitRepoURLFlag := flag.String("git-repo-url", "https://github.com/onflow/flow-go.git", "git repo URL") bigQueryUpload := flag.Bool("bigquery-upload", true, "whether to upload results to BigQuery (true / false)") pushgateway := flag.String("pushgateway", "disabled", "host:port for pushgateway") - bigQueryProjectFlag := flag.String("bigquery-project", "dapperlabs-data", "project name for the bigquery uploader") + bigQueryProjectFlag := flag.String("bigquery-project", "ff-data-platform", "project name for the bigquery uploader") bigQueryDatasetFlag := flag.String("bigquery-dataset", "dev_src_flow_tps_metrics", "dataset name for the bigquery uploader") bigQueryRawTableFlag := flag.String("bigquery-raw-table", "rawResults", "table name for the bigquery raw results") flag.Parse() diff --git a/integration/go.mod b/integration/go.mod index ce66485b5a2..0f0c0531fe9 100644 --- a/integration/go.mod +++ b/integration/go.mod @@ -19,13 +19,13 @@ require ( github.com/ipfs/go-datastore v0.6.0 github.com/ipfs/go-ds-badger2 v0.1.3 github.com/libp2p/go-libp2p v0.32.2 - github.com/onflow/cadence v1.0.0-preview.34 + github.com/onflow/cadence v1.0.0-preview.35 github.com/onflow/crypto v0.25.1 github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0 github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0 github.com/onflow/flow-emulator v1.0.0-preview.24 github.com/onflow/flow-go v0.35.5-0.20240517202625-55f862b45dfd - github.com/onflow/flow-go-sdk v1.0.0-preview.36 + github.com/onflow/flow-go-sdk v1.0.0-preview.37 github.com/onflow/flow-go/insecure v0.0.0-00010101000000-000000000000 github.com/onflow/flow/protobuf/go/flow v0.4.4 github.com/onflow/go-ethereum v1.13.4 @@ -247,7 +247,7 @@ require ( github.com/onflow/flow-ft/lib/go/templates v1.0.0 // 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/sdks v0.5.1-0.20230912225508-b35402f12bba // indirect + github.com/onflow/sdks v0.6.0-preview.1 // indirect github.com/onflow/wal v1.0.2 // indirect github.com/onsi/ginkgo/v2 v2.13.2 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect diff --git a/integration/go.sum b/integration/go.sum index 821a5c27fd9..047b51801e7 100644 --- a/integration/go.sum +++ b/integration/go.sum @@ -2150,8 +2150,8 @@ github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f/go.mod h1:xvP61FoOs github.com/onflow/atree v0.7.0-rc.2 h1:mZmVrl/zPlfI44EjV3FdR2QwIqT8nz1sCONUBFcML/U= github.com/onflow/atree v0.7.0-rc.2/go.mod h1:xvP61FoOs95K7IYdIYRnNcYQGf4nbF/uuJ0tHf4DRuM= github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8= -github.com/onflow/cadence v1.0.0-preview.34 h1:MJSli75W6LJVUqSx/tq4MQe64H1+EcQBD/sNgpOO4jE= -github.com/onflow/cadence v1.0.0-preview.34/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmpdpNNAFxBsjMlrqVD0= +github.com/onflow/cadence v1.0.0-preview.35 h1:HZgt/9Foa6sCSH9SNaIFUSXK6q2ZxETg0ivsZbf+hhU= +github.com/onflow/cadence v1.0.0-preview.35/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmpdpNNAFxBsjMlrqVD0= 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= @@ -2166,8 +2166,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.36 h1:3g72MjmZPEEVAbtDATbjwqKoNSB7yHLWswUHSAB5zwQ= -github.com/onflow/flow-go-sdk v1.0.0-preview.36/go.mod h1:mjkXIluC+kseYyd8Z1aTq73IiffAUeoY5fuX/C2Z+1w= +github.com/onflow/flow-go-sdk v1.0.0-preview.37 h1:ujeIQheD+skzFt9+eOT9nXcc1rFxVLSCzwisEI3+2DA= +github.com/onflow/flow-go-sdk v1.0.0-preview.37/go.mod h1:2aSN7RdKzxWoCtCyOJz9W/ZNqkLgQDQS3hKLYwPlvGw= 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= @@ -2177,8 +2177,9 @@ github.com/onflow/flow/protobuf/go/flow v0.4.4 h1:lD1owoZGFgLcvdLZDmP0Kc4GOuQeSU github.com/onflow/flow/protobuf/go/flow v0.4.4/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= github.com/onflow/go-ethereum v1.13.4 h1:iNO86fm8RbBbhZ87ZulblInqCdHnAQVY8okBrNsTevc= github.com/onflow/go-ethereum v1.13.4/go.mod h1:cE/gEUkAffhwbVmMJYz+t1dAfVNHNwZCgc3BWtZxBGY= -github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba h1:rIehuhO6bj4FkwE4VzwEjX7MoAlOhUJENBJLqDqVxAo= github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU= +github.com/onflow/sdks v0.6.0-preview.1 h1:mb/cUezuqWEP1gFZNAgUI4boBltudv4nlfxke1KBp9k= +github.com/onflow/sdks v0.6.0-preview.1/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU= github.com/onflow/wal v1.0.2 h1:5bgsJVf2O3cfMNK12fiiTyYZ8cOrUiELt3heBJfHOhc= github.com/onflow/wal v1.0.2/go.mod h1:iMC8gkLqu4nkbkAla5HkSBb+FGyQOZiWz3DYm2wSXCk= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= diff --git a/model/convert/service_event.go b/model/convert/service_event.go index 292fb62be11..386356fff8d 100644 --- a/model/convert/service_event.go +++ b/model/convert/service_event.go @@ -682,11 +682,14 @@ func invalidCadenceTypeError( fieldName string, actualType, expectedType cadence.Value, ) error { + // NOTE: This error is reported if the Go-types are different (not if Cadence types are different). + // Therefore, print the Go-type instead of cadence type. + // Cadence type can be `nil`, since the `expectedType` is always the zero-value of the Go type. return fmt.Errorf( - "invalid Cadence type for field %s (got=%s, expected=%s)", + "invalid Cadence type for field %s (got=%T, expected=%T)", fieldName, - actualType.Type().ID(), - expectedType.Type().ID(), + actualType, + expectedType, ) } diff --git a/module/state_synchronization/indexer/util_test.go b/module/state_synchronization/indexer/util_test.go index c7c66970e84..612e858e6ed 100644 --- a/module/state_synchronization/indexer/util_test.go +++ b/module/state_synchronization/indexer/util_test.go @@ -58,10 +58,10 @@ func TestFindContractUpdates(t *testing.T) { } func contractUpdatedFixture(t *testing.T, address common.Address, contractName string) flow.Event { - contractUpdateEventType := &cadence.EventType{ - Location: stdlib.AccountContractAddedEventType.Location, - QualifiedIdentifier: stdlib.AccountContractAddedEventType.QualifiedIdentifier(), - Fields: []cadence.Field{ + contractUpdateEventType := cadence.NewEventType( + stdlib.AccountContractAddedEventType.Location, + stdlib.AccountContractAddedEventType.QualifiedIdentifier(), + []cadence.Field{ { Identifier: "address", Type: cadence.AddressType, @@ -75,7 +75,8 @@ func contractUpdatedFixture(t *testing.T, address common.Address, contractName s Type: cadence.StringType, }, }, - } + nil, + ) contractString, err := cadence.NewString(contractName) require.NoError(t, err) diff --git a/utils/unittest/generator/events.go b/utils/unittest/generator/events.go index 63a0904fb72..8ea969c1240 100644 --- a/utils/unittest/generator/events.go +++ b/utils/unittest/generator/events.go @@ -55,10 +55,10 @@ func (g *Events) New() flow.Event { identifier := fmt.Sprintf("TestContract.FooEvent%d", g.count) typeID := location.TypeID(nil, identifier) - testEventType := &cadence.EventType{ - Location: location, - QualifiedIdentifier: identifier, - Fields: []cadence.Field{ + testEventType := cadence.NewEventType( + location, + identifier, + []cadence.Field{ { Identifier: "a", Type: cadence.IntType, @@ -68,7 +68,8 @@ func (g *Events) New() flow.Event { Type: cadence.StringType, }, }, - } + nil, + ) fooString, err := cadence.NewString("foo") if err != nil { @@ -123,16 +124,18 @@ func GenerateAccountCreateEvent(t *testing.T, address flow.Address) flow.Event { cadenceEvent := cadence.NewEvent( []cadence.Value{ cadence.NewAddress(address), - }).WithType(&cadence.EventType{ - Location: stdlib.FlowLocation{}, - QualifiedIdentifier: "AccountCreated", - Fields: []cadence.Field{ - { - Identifier: "address", - Type: cadence.AddressType, + }). + WithType(cadence.NewEventType( + stdlib.FlowLocation{}, + "AccountCreated", + []cadence.Field{ + { + Identifier: "address", + Type: cadence.AddressType, + }, }, - }, - }) + nil, + )) payload, err := ccf.Encode(cadenceEvent) require.NoError(t, err) @@ -162,24 +165,26 @@ func GenerateAccountContractEvent(t *testing.T, qualifiedIdentifier string, addr testutils.ConvertToCadence([]byte{111, 43, 164, 202, 220, 174, 148, 17, 253, 161, 9, 124, 237, 83, 227, 75, 115, 149, 141, 83, 129, 145, 252, 68, 122, 137, 80, 155, 89, 233, 136, 213}), ).WithType(cadence.NewConstantSizedArrayType(32, cadence.UInt8Type)), contractName, - }).WithType(&cadence.EventType{ - Location: stdlib.FlowLocation{}, - QualifiedIdentifier: qualifiedIdentifier, - Fields: []cadence.Field{ - { - Identifier: "address", - Type: cadence.AddressType, + }). + WithType(cadence.NewEventType( + stdlib.FlowLocation{}, + qualifiedIdentifier, + []cadence.Field{ + { + Identifier: "address", + Type: cadence.AddressType, + }, + { + Identifier: "codeHash", + Type: cadence.NewConstantSizedArrayType(32, cadence.UInt8Type), + }, + { + Identifier: "contract", + Type: cadence.StringType, + }, }, - { - Identifier: "codeHash", - Type: cadence.NewConstantSizedArrayType(32, cadence.UInt8Type), - }, - { - Identifier: "contract", - Type: cadence.StringType, - }, - }, - }) + nil, + )) payload, err := ccf.Encode(cadenceEvent) require.NoError(t, err) diff --git a/utils/unittest/service_events_fixtures.go b/utils/unittest/service_events_fixtures.go index f92923f6f18..11088635809 100644 --- a/utils/unittest/service_events_fixtures.go +++ b/utils/unittest/service_events_fixtures.go @@ -736,10 +736,10 @@ func newFlowClusterQCVoteStructType() cadence.Type { address, _ := common.HexToAddress("01cf0e2f2f715450") location := common.NewAddressLocation(nil, address, "FlowClusterQC") - return &cadence.StructType{ - Location: location, - QualifiedIdentifier: "FlowClusterQC.Vote", - Fields: []cadence.Field{ + return cadence.NewStructType( + location, + "FlowClusterQC.Vote", + []cadence.Field{ { Identifier: "nodeID", Type: cadence.StringType, @@ -761,7 +761,8 @@ func newFlowClusterQCVoteStructType() cadence.Type { Type: cadence.UInt64Type, }, }, - } + nil, + ) } func newFlowIDTableStakingNodeInfoStructType() *cadence.StructType { @@ -771,10 +772,10 @@ func newFlowIDTableStakingNodeInfoStructType() *cadence.StructType { address, _ := common.HexToAddress("01cf0e2f2f715450") location := common.NewAddressLocation(nil, address, "FlowIDTableStaking") - return &cadence.StructType{ - Location: location, - QualifiedIdentifier: "FlowIDTableStaking.NodeInfo", - Fields: []cadence.Field{ + return cadence.NewStructType( + location, + "FlowIDTableStaking.NodeInfo", + []cadence.Field{ { Identifier: "id", Type: cadence.StringType, @@ -832,7 +833,8 @@ func newFlowIDTableStakingNodeInfoStructType() *cadence.StructType { Type: cadence.UInt64Type, }, }, - } + nil, + ) } func newFlowEpochEpochSetupEventType() *cadence.EventType { @@ -842,10 +844,10 @@ func newFlowEpochEpochSetupEventType() *cadence.EventType { address, _ := common.HexToAddress("01cf0e2f2f715450") location := common.NewAddressLocation(nil, address, "FlowEpoch") - return &cadence.EventType{ - Location: location, - QualifiedIdentifier: "FlowEpoch.EpochSetup", - Fields: []cadence.Field{ + return cadence.NewEventType( + location, + "FlowEpoch.EpochSetup", + []cadence.Field{ { Identifier: "counter", Type: cadence.UInt64Type, @@ -891,7 +893,8 @@ func newFlowEpochEpochSetupEventType() *cadence.EventType { Type: cadence.UInt64Type, }, }, - } + nil, + ) } func newFlowEpochEpochCommitEventType() *cadence.EventType { @@ -901,10 +904,10 @@ func newFlowEpochEpochCommitEventType() *cadence.EventType { address, _ := common.HexToAddress("01cf0e2f2f715450") location := common.NewAddressLocation(nil, address, "FlowEpoch") - return &cadence.EventType{ - Location: location, - QualifiedIdentifier: "FlowEpoch.EpochCommitted", - Fields: []cadence.Field{ + return cadence.NewEventType( + location, + "FlowEpoch.EpochCommitted", + []cadence.Field{ { Identifier: "counter", Type: cadence.UInt64Type, @@ -918,7 +921,8 @@ func newFlowEpochEpochCommitEventType() *cadence.EventType { Type: cadence.NewVariableSizedArrayType(cadence.StringType), }, }, - } + nil, + ) } func newFlowClusterQCClusterQCStructType() *cadence.StructType { @@ -928,10 +932,10 @@ func newFlowClusterQCClusterQCStructType() *cadence.StructType { address, _ := common.HexToAddress("01cf0e2f2f715450") location := common.NewAddressLocation(nil, address, "FlowClusterQC") - return &cadence.StructType{ - Location: location, - QualifiedIdentifier: "FlowClusterQC.ClusterQC", - Fields: []cadence.Field{ + return cadence.NewStructType( + location, + "FlowClusterQC.ClusterQC", + []cadence.Field{ { Identifier: "index", Type: cadence.UInt16Type, @@ -949,7 +953,8 @@ func newFlowClusterQCClusterQCStructType() *cadence.StructType { Type: cadence.NewVariableSizedArrayType(cadence.StringType), }, }, - } + nil, + ) } func NewNodeVersionBeaconVersionBeaconEventType() *cadence.EventType { @@ -959,10 +964,10 @@ func NewNodeVersionBeaconVersionBeaconEventType() *cadence.EventType { address, _ := common.HexToAddress("01cf0e2f2f715450") location := common.NewAddressLocation(nil, address, "NodeVersionBeacon") - return &cadence.EventType{ - Location: location, - QualifiedIdentifier: "NodeVersionBeacon.VersionBeacon", - Fields: []cadence.Field{ + return cadence.NewEventType( + location, + "NodeVersionBeacon.VersionBeacon", + []cadence.Field{ { Identifier: "versionBoundaries", Type: cadence.NewVariableSizedArrayType(NewNodeVersionBeaconVersionBoundaryStructType()), @@ -972,7 +977,8 @@ func NewNodeVersionBeaconVersionBeaconEventType() *cadence.EventType { Type: cadence.UInt64Type, }, }, - } + nil, + ) } func NewNodeVersionBeaconVersionBoundaryStructType() *cadence.StructType { @@ -982,10 +988,10 @@ func NewNodeVersionBeaconVersionBoundaryStructType() *cadence.StructType { address, _ := common.HexToAddress("01cf0e2f2f715450") location := common.NewAddressLocation(nil, address, "NodeVersionBeacon") - return &cadence.StructType{ - Location: location, - QualifiedIdentifier: "NodeVersionBeacon.VersionBoundary", - Fields: []cadence.Field{ + return cadence.NewStructType( + location, + "NodeVersionBeacon.VersionBoundary", + []cadence.Field{ { Identifier: "blockHeight", Type: cadence.UInt64Type, @@ -995,7 +1001,8 @@ func NewNodeVersionBeaconVersionBoundaryStructType() *cadence.StructType { Type: NewNodeVersionBeaconSemverStructType(), }, }, - } + nil, + ) } func NewNodeVersionBeaconSemverStructType() *cadence.StructType { @@ -1005,10 +1012,10 @@ func NewNodeVersionBeaconSemverStructType() *cadence.StructType { address, _ := common.HexToAddress("01cf0e2f2f715450") location := common.NewAddressLocation(nil, address, "NodeVersionBeacon") - return &cadence.StructType{ - Location: location, - QualifiedIdentifier: "NodeVersionBeacon.Semver", - Fields: []cadence.Field{ + return cadence.NewStructType( + location, + "NodeVersionBeacon.Semver", + []cadence.Field{ { Identifier: "major", Type: cadence.UInt8Type, @@ -1026,7 +1033,8 @@ func NewNodeVersionBeaconSemverStructType() *cadence.StructType { Type: cadence.NewOptionalType(cadence.StringType), }, }, - } + nil, + ) } func NewProtocolStateVersionUpgradeEventType() *cadence.EventType { @@ -1036,10 +1044,10 @@ func NewProtocolStateVersionUpgradeEventType() *cadence.EventType { address, _ := common.HexToAddress("01cf0e2f2f715450") location := common.NewAddressLocation(nil, address, "ProtocolStateVersionUpgrade") - return &cadence.EventType{ - Location: location, - QualifiedIdentifier: "NodeVersionBeacon.ProtocolStateVersionUpgrade", - Fields: []cadence.Field{ + return cadence.NewEventType( + location, + "NodeVersionBeacon.ProtocolStateVersionUpgrade", + []cadence.Field{ { Identifier: "newProtocolVersion", Type: cadence.UInt64Type, @@ -1049,7 +1057,8 @@ func NewProtocolStateVersionUpgradeEventType() *cadence.EventType { Type: cadence.UInt64Type, }, }, - } + nil, + ) } func ufix64FromString(s string) cadence.UFix64 { @@ -1152,10 +1161,10 @@ func NewFlowClusterQCClusterStructType() *cadence.StructType { address, _ := common.HexToAddress("01cf0e2f2f715450") location := common.NewAddressLocation(nil, address, "FlowClusterQC") - return &cadence.StructType{ - Location: location, - QualifiedIdentifier: "FlowClusterQC.Cluster", - Fields: []cadence.Field{ + return cadence.NewStructType( + location, + "FlowClusterQC.Cluster", + []cadence.Field{ { Identifier: "index", Type: cadence.UInt16Type, @@ -1177,5 +1186,6 @@ func NewFlowClusterQCClusterStructType() *cadence.StructType { Type: cadence.NewDictionaryType(cadence.StringType, cadence.UInt64Type), }, }, - } + nil, + ) }