diff --git a/.golangci.yml b/.golangci.yml index c6ca2c8b46a..73ea0875b70 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -33,7 +33,6 @@ linters: - -ST1012 # error var factoryError should have name of the form errFoo" were hidden - -ST1016 # methods on the same type should have the same receiver name (seen 45x "db", 4x "s") (staticcheck) - -ST1017 # don't use Yoda conditions" were hidden - - -ST1019 # other import of \"github.com/onflow/flow-go/model/bootstrap\"" were hidden - -ST1023 # should omit type flow.IdentifierList from declaration; it will be inferred from the right-hand side" were hidden custom: structwrite: diff --git a/cmd/bootstrap/cmd/finalize.go b/cmd/bootstrap/cmd/finalize.go index 4de0a5f167a..5f3acd5211c 100644 --- a/cmd/bootstrap/cmd/finalize.go +++ b/cmd/bootstrap/cmd/finalize.go @@ -19,7 +19,6 @@ import ( hotstuff "github.com/onflow/flow-go/consensus/hotstuff/model" "github.com/onflow/flow-go/fvm" "github.com/onflow/flow-go/model/bootstrap" - model "github.com/onflow/flow-go/model/bootstrap" "github.com/onflow/flow-go/model/dkg" "github.com/onflow/flow-go/model/flow" "github.com/onflow/flow-go/module/epochs" @@ -148,8 +147,8 @@ func finalize(cmd *cobra.Command, args []string) { rootQC := constructRootQC( block, votes, - model.FilterByRole(stakingNodes, flow.RoleConsensus), - model.FilterByRole(internalNodes, flow.RoleConsensus), + bootstrap.FilterByRole(stakingNodes, flow.RoleConsensus), + bootstrap.FilterByRole(internalNodes, flow.RoleConsensus), dkgData, ) log.Info().Msg("") @@ -200,15 +199,15 @@ func finalize(cmd *cobra.Command, args []string) { } // write snapshot to disk - err = common.WriteJSON(model.PathRootProtocolStateSnapshot, flagOutdir, snapshot.Encodable()) + err = common.WriteJSON(bootstrap.PathRootProtocolStateSnapshot, flagOutdir, snapshot.Encodable()) if err != nil { log.Fatal().Err(err).Msg("failed to write json") } - log.Info().Msgf("wrote file %s/%s", flagOutdir, model.PathRootProtocolStateSnapshot) + log.Info().Msgf("wrote file %s/%s", flagOutdir, bootstrap.PathRootProtocolStateSnapshot) log.Info().Msg("") // read snapshot and verify consistency - rootSnapshot, err := loadRootProtocolSnapshot(model.PathRootProtocolStateSnapshot) + rootSnapshot, err := loadRootProtocolSnapshot(bootstrap.PathRootProtocolStateSnapshot) if err != nil { log.Fatal().Err(err).Msg("unable to load serialized root protocol") } @@ -249,7 +248,7 @@ func finalize(cmd *cobra.Command, args []string) { log.Info().Str("private_dir", flagInternalNodePrivInfoDir).Str("output_dir", flagOutdir).Msg("attempting to copy private key files") if flagInternalNodePrivInfoDir != flagOutdir { log.Info().Msg("copying internal private keys to output folder") - err := io.CopyDirectory(flagInternalNodePrivInfoDir, filepath.Join(flagOutdir, model.DirPrivateRoot)) + err := io.CopyDirectory(flagInternalNodePrivInfoDir, filepath.Join(flagOutdir, bootstrap.DirPrivateRoot)) if err != nil { log.Error().Err(err).Msg("could not copy private key files") } @@ -278,7 +277,7 @@ func readRootBlockVotes() []*hotstuff.Vote { } for _, f := range files { // skip files that do not include node-infos - if !strings.Contains(f, model.FilenameRootBlockVotePrefix) { + if !strings.Contains(f, bootstrap.FilenameRootBlockVotePrefix) { continue } @@ -300,7 +299,7 @@ func readRootBlockVotes() []*hotstuff.Vote { // // IMPORTANT: node infos are returned in the canonical ordering, meaning this // is safe to use as the input to the DKG and protocol state. -func mergeNodeInfos(internalNodes, partnerNodes []model.NodeInfo) ([]model.NodeInfo, error) { +func mergeNodeInfos(internalNodes, partnerNodes []bootstrap.NodeInfo) ([]bootstrap.NodeInfo, error) { nodes := append(internalNodes, partnerNodes...) // test for duplicate Addresses @@ -322,7 +321,7 @@ func mergeNodeInfos(internalNodes, partnerNodes []model.NodeInfo) ([]model.NodeI } // sort nodes using the canonical ordering - nodes = model.Sort(nodes, flow.Canonical[flow.Identity]) + nodes = bootstrap.Sort(nodes, flow.Canonical[flow.Identity]) return nodes, nil } @@ -410,7 +409,7 @@ func generateEmptyExecutionState( } commit, err = run.GenerateExecutionState( - filepath.Join(flagOutdir, model.DirnameExecutionState), + filepath.Join(flagOutdir, bootstrap.DirnameExecutionState), serviceAccountPublicKey, rootBlock.ChainID.Chain(), fvm.WithRootBlock(rootBlock), diff --git a/cmd/bootstrap/cmd/machine_account_key_test.go b/cmd/bootstrap/cmd/machine_account_key_test.go index dfd93fcd5f6..b7c14f18384 100644 --- a/cmd/bootstrap/cmd/machine_account_key_test.go +++ b/cmd/bootstrap/cmd/machine_account_key_test.go @@ -13,7 +13,6 @@ import ( "github.com/onflow/flow-go/cmd/util/cmd/common" "github.com/onflow/flow-go/model/bootstrap" - model "github.com/onflow/flow-go/model/bootstrap" ioutils "github.com/onflow/flow-go/utils/io" "github.com/onflow/flow-go/utils/unittest" ) @@ -45,11 +44,11 @@ func TestMachineAccountKeyFileExists(t *testing.T) { nodeID := strings.TrimSpace(string(b)) // make sure file exists - machineKeyFilePath := filepath.Join(flagOutdir, fmt.Sprintf(model.PathNodeMachineAccountPrivateKey, nodeID)) + machineKeyFilePath := filepath.Join(flagOutdir, fmt.Sprintf(bootstrap.PathNodeMachineAccountPrivateKey, nodeID)) require.FileExists(t, machineKeyFilePath) // read file priv key file before command - var machineAccountPrivBefore model.NodeMachineAccountKey + var machineAccountPrivBefore bootstrap.NodeMachineAccountKey require.NoError(t, common.ReadJSON(machineKeyFilePath, &machineAccountPrivBefore)) // run command with flags @@ -59,7 +58,7 @@ func TestMachineAccountKeyFileExists(t *testing.T) { require.Regexp(t, keyFileExistsRegex, hook.logs.String()) // read machine account key file again - var machineAccountPrivAfter model.NodeMachineAccountKey + var machineAccountPrivAfter bootstrap.NodeMachineAccountKey require.NoError(t, common.ReadJSON(machineKeyFilePath, &machineAccountPrivAfter)) // check if key was modified @@ -99,7 +98,7 @@ func TestMachineAccountKeyFileCreated(t *testing.T) { nodeID := strings.TrimSpace(string(b)) // delete machine account key file - machineKeyFilePath := filepath.Join(flagOutdir, fmt.Sprintf(model.PathNodeMachineAccountPrivateKey, nodeID)) + machineKeyFilePath := filepath.Join(flagOutdir, fmt.Sprintf(bootstrap.PathNodeMachineAccountPrivateKey, nodeID)) err = os.Remove(machineKeyFilePath) require.NoError(t, err) diff --git a/cmd/bootstrap/cmd/machine_account_test.go b/cmd/bootstrap/cmd/machine_account_test.go index 27631a3bddc..ff97e73064f 100644 --- a/cmd/bootstrap/cmd/machine_account_test.go +++ b/cmd/bootstrap/cmd/machine_account_test.go @@ -13,7 +13,6 @@ import ( "github.com/onflow/flow-go/cmd/util/cmd/common" "github.com/onflow/flow-go/model/bootstrap" - model "github.com/onflow/flow-go/model/bootstrap" "github.com/onflow/flow-go/model/flow" ioutils "github.com/onflow/flow-go/utils/io" "github.com/onflow/flow-go/utils/unittest" @@ -55,11 +54,11 @@ func TestMachineAccountHappyPath(t *testing.T) { nodeID := strings.TrimSpace(string(b)) // make sure key file exists (sanity check) - machineKeyFilePath := filepath.Join(flagOutdir, fmt.Sprintf(model.PathNodeMachineAccountPrivateKey, nodeID)) + machineKeyFilePath := filepath.Join(flagOutdir, fmt.Sprintf(bootstrap.PathNodeMachineAccountPrivateKey, nodeID)) require.FileExists(t, machineKeyFilePath) // sanity check if machine account info file exists - machineInfoFilePath := filepath.Join(flagOutdir, fmt.Sprintf(model.PathNodeMachineAccountInfoPriv, nodeID)) + machineInfoFilePath := filepath.Join(flagOutdir, fmt.Sprintf(bootstrap.PathNodeMachineAccountInfoPriv, nodeID)) require.NoFileExists(t, machineInfoFilePath) // make sure regex matches and file was created @@ -102,11 +101,11 @@ func TestMachineAccountInfoFileExists(t *testing.T) { nodeID := strings.TrimSpace(string(b)) // make sure key file exists (sanity check) - machineKeyFilePath := filepath.Join(flagOutdir, fmt.Sprintf(model.PathNodeMachineAccountPrivateKey, nodeID)) + machineKeyFilePath := filepath.Join(flagOutdir, fmt.Sprintf(bootstrap.PathNodeMachineAccountPrivateKey, nodeID)) require.FileExists(t, machineKeyFilePath) // sanity check if machine account info file exists - machineInfoFilePath := filepath.Join(flagOutdir, fmt.Sprintf(model.PathNodeMachineAccountInfoPriv, nodeID)) + machineInfoFilePath := filepath.Join(flagOutdir, fmt.Sprintf(bootstrap.PathNodeMachineAccountInfoPriv, nodeID)) require.NoFileExists(t, machineInfoFilePath) // run machine account to create info file @@ -115,14 +114,14 @@ func TestMachineAccountInfoFileExists(t *testing.T) { hook.logs.Reset() // read in info file - var machineAccountInfoBefore model.NodeMachineAccountInfo + var machineAccountInfoBefore bootstrap.NodeMachineAccountInfo require.NoError(t, common.ReadJSON(machineInfoFilePath, &machineAccountInfoBefore)) // run again and make sure info file was not changed machineAccountRun(nil, nil) require.Regexp(t, regex, hook.logs.String()) - var machineAccountInfoAfter model.NodeMachineAccountInfo + var machineAccountInfoAfter bootstrap.NodeMachineAccountInfo require.NoError(t, common.ReadJSON(machineInfoFilePath, &machineAccountInfoAfter)) assert.Equal(t, machineAccountInfoBefore, machineAccountInfoAfter) @@ -160,11 +159,11 @@ func TestMachineAccountWrongFlowAddressFormat(t *testing.T) { nodeID := strings.TrimSpace(string(b)) // make sure key file exists (sanity check) - machineKeyFilePath := filepath.Join(flagOutdir, fmt.Sprintf(model.PathNodeMachineAccountPrivateKey, nodeID)) + machineKeyFilePath := filepath.Join(flagOutdir, fmt.Sprintf(bootstrap.PathNodeMachineAccountPrivateKey, nodeID)) require.FileExists(t, machineKeyFilePath) // sanity check if machine account info file exists - machineInfoFilePath := filepath.Join(flagOutdir, fmt.Sprintf(model.PathNodeMachineAccountInfoPriv, nodeID)) + machineInfoFilePath := filepath.Join(flagOutdir, fmt.Sprintf(bootstrap.PathNodeMachineAccountInfoPriv, nodeID)) require.NoFileExists(t, machineInfoFilePath) // run machine account command diff --git a/cmd/bootstrap/run/epochs.go b/cmd/bootstrap/run/epochs.go index ed695af2b07..4dad518d71b 100644 --- a/cmd/bootstrap/run/epochs.go +++ b/cmd/bootstrap/run/epochs.go @@ -13,7 +13,6 @@ import ( hotstuff "github.com/onflow/flow-go/consensus/hotstuff/model" "github.com/onflow/flow-go/fvm/systemcontracts" "github.com/onflow/flow-go/model/bootstrap" - model "github.com/onflow/flow-go/model/bootstrap" "github.com/onflow/flow-go/model/cluster" "github.com/onflow/flow-go/model/flow" "github.com/onflow/flow-go/model/flow/filter" @@ -163,7 +162,7 @@ func GenerateRecoverTxArgsWithDKG( // Filter internalNodes so it only contains nodes which are valid for inclusion in the epoch // This is a safety measure: just in case subsequent functions don't properly account for additional nodes, // we proactively remove them from consideration here. - internalNodes = slices.DeleteFunc(slices.Clone(internalNodes), func(info model.NodeInfo) bool { + internalNodes = slices.DeleteFunc(slices.Clone(internalNodes), func(info bootstrap.NodeInfo) bool { _, isCurrentEligibleEpochParticipant := internalNodesMap[info.NodeID] return !isCurrentEligibleEpochParticipant }) @@ -364,11 +363,11 @@ func ConstructClusterRootQCsFromVotes(log zerolog.Logger, clusterList flow.Clust // Filters a list of nodes to include only nodes that will sign the QC for the // given cluster. The resulting list of nodes is only nodes that are in the // given cluster AND are not partner nodes (ie. we have the private keys). -func filterClusterSigners(cluster flow.IdentitySkeletonList, nodeInfos []model.NodeInfo) []model.NodeInfo { - var filtered []model.NodeInfo +func filterClusterSigners(cluster flow.IdentitySkeletonList, nodeInfos []bootstrap.NodeInfo) []bootstrap.NodeInfo { + var filtered []bootstrap.NodeInfo for _, node := range nodeInfos { _, isInCluster := cluster.ByNodeID(node.NodeID) - isPrivateKeyAvailable := node.Type() == model.NodeInfoTypePrivate + isPrivateKeyAvailable := node.Type() == bootstrap.NodeInfoTypePrivate if isInCluster && isPrivateKeyAvailable { filtered = append(filtered, node) diff --git a/cmd/bootstrap/run/execution_state.go b/cmd/bootstrap/run/execution_state.go index c1896668c38..ab76c4e036b 100644 --- a/cmd/bootstrap/run/execution_state.go +++ b/cmd/bootstrap/run/execution_state.go @@ -10,7 +10,6 @@ import ( "github.com/onflow/flow-go/engine/execution/state/bootstrap" "github.com/onflow/flow-go/fvm" "github.com/onflow/flow-go/ledger/common/pathfinder" - "github.com/onflow/flow-go/ledger/complete" ledger "github.com/onflow/flow-go/ledger/complete" "github.com/onflow/flow-go/ledger/complete/mtrie/trie" "github.com/onflow/flow-go/ledger/complete/wal" @@ -43,7 +42,7 @@ func GenerateExecutionState( return flow.DummyStateCommitment, err } - compactor, err := complete.NewCompactor(ledgerStorage, diskWal, zerolog.Nop(), capacity, checkpointDistance, checkpointsToKeep, atomic.NewBool(false), metricsCollector) + compactor, err := ledger.NewCompactor(ledgerStorage, diskWal, zerolog.Nop(), capacity, checkpointDistance, checkpointsToKeep, atomic.NewBool(false), metricsCollector) if err != nil { return flow.DummyStateCommitment, err } diff --git a/cmd/bootstrap/transit/cmd/pull.go b/cmd/bootstrap/transit/cmd/pull.go index 9eb0a9861b5..6ccd0fbf1a7 100644 --- a/cmd/bootstrap/transit/cmd/pull.go +++ b/cmd/bootstrap/transit/cmd/pull.go @@ -16,7 +16,6 @@ import ( "github.com/onflow/flow-go/cmd/bootstrap/gcs" "github.com/onflow/flow-go/cmd/bootstrap/utils" "github.com/onflow/flow-go/model/bootstrap" - model "github.com/onflow/flow-go/model/bootstrap" "github.com/onflow/flow-go/model/flow" ) @@ -130,7 +129,7 @@ func pull(cmd *cobra.Command, args []string) { if role == flow.RoleExecution { // root.checkpoint* is downloaded to /public-root-information after a pull - localPublicRootInfoDir := filepath.Join(flagBootDir, model.DirnamePublicBootstrap) + localPublicRootInfoDir := filepath.Join(flagBootDir, bootstrap.DirnamePublicBootstrap) // move the root.checkpoint, root.checkpoint.0, root.checkpoint.1 etc. files to the bootstrap/execution-state dir err = filepath.WalkDir(localPublicRootInfoDir, func(srcPath string, rootCheckpointFile fs.DirEntry, err error) error { @@ -139,9 +138,9 @@ func pull(cmd *cobra.Command, args []string) { } // if rootCheckpointFile is a file whose name starts with "root.checkpoint", then move it - if !rootCheckpointFile.IsDir() && strings.HasPrefix(rootCheckpointFile.Name(), model.FilenameWALRootCheckpoint) { + if !rootCheckpointFile.IsDir() && strings.HasPrefix(rootCheckpointFile.Name(), bootstrap.FilenameWALRootCheckpoint) { - dstPath := filepath.Join(flagBootDir, model.DirnameExecutionState, rootCheckpointFile.Name()) + dstPath := filepath.Join(flagBootDir, bootstrap.DirnameExecutionState, rootCheckpointFile.Name()) log.Info().Str("src", srcPath).Str("destination", dstPath).Msgf("moving file") err = moveFile(srcPath, dstPath) if err != nil { @@ -165,7 +164,7 @@ func pull(cmd *cobra.Command, args []string) { } // calculate SHA256 of rootsnapshot - rootFile := filepath.Join(flagBootDir, model.PathRootProtocolStateSnapshot) + rootFile := filepath.Join(flagBootDir, bootstrap.PathRootProtocolStateSnapshot) rootSHA256, err := getFileSHA256(rootFile) if err != nil { log.Fatal().Err(err).Str("file", rootFile).Msg("failed to calculate SHA256 of root file") diff --git a/cmd/bootstrap/utils/key_generation.go b/cmd/bootstrap/utils/key_generation.go index 7d82109309d..658656b9222 100644 --- a/cmd/bootstrap/utils/key_generation.go +++ b/cmd/bootstrap/utils/key_generation.go @@ -16,7 +16,6 @@ import ( "github.com/onflow/flow-go/fvm/systemcontracts" "github.com/onflow/flow-go/model/bootstrap" - model "github.com/onflow/flow-go/model/bootstrap" "github.com/onflow/flow-go/model/encodable" "github.com/onflow/flow-go/model/flow" ) @@ -310,9 +309,9 @@ func WriteStakingNetworkingKeyFiles(nodeInfos []bootstrap.NodeInfo, write WriteJ // WriteNodeInternalPubInfos writes the `node-internal-infos.pub.json` file. // In a nutshell, this file contains the Role, address and weight for all authorized nodes. func WriteNodeInternalPubInfos(nodeInfos []bootstrap.NodeInfo, write WriteJSONFileFunc) error { - configs := make([]model.NodeConfig, len(nodeInfos)) + configs := make([]bootstrap.NodeConfig, len(nodeInfos)) for i, nodeInfo := range nodeInfos { - configs[i] = model.NodeConfig{ + configs[i] = bootstrap.NodeConfig{ Role: nodeInfo.Role, Address: nodeInfo.Address, Weight: nodeInfo.Weight, diff --git a/cmd/execution_builder.go b/cmd/execution_builder.go index e79a8a4aea8..2dbca1b15d9 100644 --- a/cmd/execution_builder.go +++ b/cmd/execution_builder.go @@ -67,7 +67,6 @@ import ( "github.com/onflow/flow-go/ledger/common/pathfinder" ledger "github.com/onflow/flow-go/ledger/complete" "github.com/onflow/flow-go/ledger/complete/wal" - bootstrapFilenames "github.com/onflow/flow-go/model/bootstrap" modelbootstrap "github.com/onflow/flow-go/model/bootstrap" "github.com/onflow/flow-go/model/flow" "github.com/onflow/flow-go/model/flow/filter" @@ -78,7 +77,6 @@ import ( exedataprovider "github.com/onflow/flow-go/module/executiondatasync/provider" "github.com/onflow/flow-go/module/executiondatasync/pruner" edstorage "github.com/onflow/flow-go/module/executiondatasync/storage" - execdatastorage "github.com/onflow/flow-go/module/executiondatasync/storage" "github.com/onflow/flow-go/module/executiondatasync/tracker" "github.com/onflow/flow-go/module/finalizedreader" finalizer "github.com/onflow/flow-go/module/finalizer/consensus" @@ -168,7 +166,7 @@ type ExecutionNode struct { executionDataStore execution_data.ExecutionDataStore toTriggerCheckpoint *atomic.Bool // create the checkpoint trigger to be controlled by admin tool, and listened by the compactor stopControl *stop.StopControl // stop the node at given block height - executionDataDatastore execdatastorage.DatastoreManager + executionDataDatastore edstorage.DatastoreManager executionDataPruner *pruner.Pruner executionDataBlobstore blobs.Blobstore executionDataTracker tracker.Storage @@ -1409,8 +1407,8 @@ func (exeNode *ExecutionNode) LoadBootstrapper(node *NodeConfig) error { err := wal.CheckpointHasRootHash( node.Logger, - path.Join(node.BootstrapDir, bootstrapFilenames.DirnameExecutionState), - bootstrapFilenames.FilenameWALRootCheckpoint, + path.Join(node.BootstrapDir, modelbootstrap.DirnameExecutionState), + modelbootstrap.FilenameWALRootCheckpoint, ledgerpkg.RootHash(node.RootSeal.FinalState), ) if err != nil { @@ -1488,18 +1486,18 @@ func copyBootstrapState(dir, trie string) error { firstCheckpointFilename := "00000000" fileExists := func(fileName string) bool { - _, err := os.Stat(filepath.Join(dir, bootstrapFilenames.DirnameExecutionState, fileName)) + _, err := os.Stat(filepath.Join(dir, modelbootstrap.DirnameExecutionState, fileName)) return err == nil } // if there is a root checkpoint file, then copy that file over - if fileExists(bootstrapFilenames.FilenameWALRootCheckpoint) { - filename = bootstrapFilenames.FilenameWALRootCheckpoint + if fileExists(modelbootstrap.FilenameWALRootCheckpoint) { + filename = modelbootstrap.FilenameWALRootCheckpoint } else if fileExists(firstCheckpointFilename) { // else if there is a checkpoint file, then copy that file over filename = firstCheckpointFilename } else { - filePath := filepath.Join(dir, bootstrapFilenames.DirnameExecutionState, firstCheckpointFilename) + filePath := filepath.Join(dir, modelbootstrap.DirnameExecutionState, firstCheckpointFilename) // include absolute path of the missing file in the error message absPath, err := filepath.Abs(filePath) @@ -1511,7 +1509,7 @@ func copyBootstrapState(dir, trie string) error { } // copy from the bootstrap folder to the execution state folder - from, to := path.Join(dir, bootstrapFilenames.DirnameExecutionState), trie + from, to := path.Join(dir, modelbootstrap.DirnameExecutionState), trie log.Info().Str("dir", dir).Str("trie", trie). Msgf("linking checkpoint file %v from directory: %v, to: %v", filename, from, to) diff --git a/cmd/verification_builder.go b/cmd/verification_builder.go index 976814b1e06..c4441b740f4 100644 --- a/cmd/verification_builder.go +++ b/cmd/verification_builder.go @@ -16,7 +16,6 @@ import ( "github.com/onflow/flow-go/consensus/hotstuff/verification" recoveryprotocol "github.com/onflow/flow-go/consensus/recovery/protocol" "github.com/onflow/flow-go/engine/common/follower" - followereng "github.com/onflow/flow-go/engine/common/follower" commonsync "github.com/onflow/flow-go/engine/common/synchronization" "github.com/onflow/flow-go/engine/execution/computation" "github.com/onflow/flow-go/engine/verification/assigner" @@ -390,7 +389,7 @@ func (v *VerificationNodeBuilder) LoadComponentsAndModules() { heroCacheCollector = metrics.FollowerCacheMetrics(node.MetricsRegisterer) } - core, err := followereng.NewComplianceCore( + core, err := follower.NewComplianceCore( node.Logger, node.Metrics.Mempool, heroCacheCollector, @@ -405,7 +404,7 @@ func (v *VerificationNodeBuilder) LoadComponentsAndModules() { return nil, fmt.Errorf("could not create follower core: %w", err) } - followerEng, err = followereng.NewComplianceLayer( + followerEng, err = follower.NewComplianceLayer( node.Logger, node.EngineRegistry, node.Me, diff --git a/consensus/hotstuff/votecollector/combined_vote_processor_v2_test.go b/consensus/hotstuff/votecollector/combined_vote_processor_v2_test.go index 6a77caf8704..8a4d67b375e 100644 --- a/consensus/hotstuff/votecollector/combined_vote_processor_v2_test.go +++ b/consensus/hotstuff/votecollector/combined_vote_processor_v2_test.go @@ -22,7 +22,6 @@ import ( "github.com/onflow/flow-go/consensus/hotstuff/model" "github.com/onflow/flow-go/consensus/hotstuff/safetyrules" "github.com/onflow/flow-go/consensus/hotstuff/signature" - hsig "github.com/onflow/flow-go/consensus/hotstuff/signature" hotstuffvalidator "github.com/onflow/flow-go/consensus/hotstuff/validator" "github.com/onflow/flow-go/consensus/hotstuff/verification" "github.com/onflow/flow-go/model/encodable" @@ -30,7 +29,6 @@ import ( "github.com/onflow/flow-go/module" "github.com/onflow/flow-go/module/local" modulemock "github.com/onflow/flow-go/module/mock" - mSig "github.com/onflow/flow-go/module/signature" msig "github.com/onflow/flow-go/module/signature" "github.com/onflow/flow-go/state/protocol/inmem" storagemock "github.com/onflow/flow-go/storage/mock" @@ -825,7 +823,7 @@ func TestCombinedVoteProcessorV2_BuildVerifyQC(t *testing.T) { // there is no Random Beacon key for this epoch keys.On("RetrieveMyBeaconPrivateKey", epochCounter).Return(nil, false, nil) - beaconSignerStore := hsig.NewEpochAwareRandomBeaconKeyStore(epochLookup, keys) + beaconSignerStore := signature.NewEpochAwareRandomBeaconKeyStore(epochLookup, keys) me, err := local.New(identity.IdentitySkeleton, stakingPriv) require.NoError(t, err) @@ -848,7 +846,7 @@ func TestCombinedVoteProcessorV2_BuildVerifyQC(t *testing.T) { // there is Random Beacon key for this epoch keys.On("RetrieveMyBeaconPrivateKey", epochCounter).Return(dkgKey, true, nil) - beaconSignerStore := hsig.NewEpochAwareRandomBeaconKeyStore(epochLookup, keys) + beaconSignerStore := signature.NewEpochAwareRandomBeaconKeyStore(epochLookup, keys) me, err := local.New(identity.IdentitySkeleton, stakingPriv) require.NoError(t, err) @@ -906,7 +904,7 @@ func TestCombinedVoteProcessorV2_BuildVerifyQC(t *testing.T) { qcCreated := false onQCCreated := func(qc *flow.QuorumCertificate) { - packer := hsig.NewConsensusSigDataPacker(committee) + packer := signature.NewConsensusSigDataPacker(committee) // create verifier that will do crypto checks of created QC verifier := verification.NewCombinedVerifier(committee, packer) @@ -1033,7 +1031,7 @@ func TestCombinedVoteProcessorV2_DoubleVoting(t *testing.T) { // create and sign proposal leaderVote, err := rbSigner.CreateVote(block) - require.Equal(t, 2*mSig.SigLen, len(leaderVote.SigData), "sanity check failed: need a compound staking + beacon signature in the vote for this test") + require.Equal(t, 2*msig.SigLen, len(leaderVote.SigData), "sanity check failed: need a compound staking + beacon signature in the vote for this test") require.NoError(t, err) proposal := helper.MakeSignedProposal(helper.WithProposal(helper.MakeProposal(helper.WithBlock(block))), helper.WithSigData(leaderVote.SigData)) @@ -1057,7 +1055,7 @@ func TestCombinedVoteProcessorV2_DoubleVoting(t *testing.T) { baseFactory := &combinedVoteProcessorFactoryBaseV2{ committee: committee, onQCCreated: onQCCreated, - packer: hsig.NewConsensusSigDataPacker(committee), + packer: signature.NewConsensusSigDataPacker(committee), } voteProcessorFactory := &VoteProcessorFactory{ baseFactory: baseFactory.Create, diff --git a/engine/access/rest/http/routes/transactions_test.go b/engine/access/rest/http/routes/transactions_test.go index 333055d456a..b06201bb656 100644 --- a/engine/access/rest/http/routes/transactions_test.go +++ b/engine/access/rest/http/routes/transactions_test.go @@ -17,10 +17,8 @@ import ( "google.golang.org/grpc/status" "github.com/onflow/flow/protobuf/go/flow/entities" - entitiesproto "github.com/onflow/flow/protobuf/go/flow/entities" "github.com/onflow/flow-go/access/mock" - "github.com/onflow/flow-go/engine/access/rest/common/models" commonmodels "github.com/onflow/flow-go/engine/access/rest/common/models" mockcommonmodels "github.com/onflow/flow-go/engine/access/rest/common/models/mock" "github.com/onflow/flow-go/engine/access/rest/router" @@ -299,22 +297,22 @@ func TestGetTransactionResult(t *testing.T) { testVectors := map[*accessmodel.TransactionResult]string{{ Status: flow.TransactionStatusExpired, ErrorMessage: "", - }: string(models.FAILURE_RESULT), { + }: string(commonmodels.FAILURE_RESULT), { Status: flow.TransactionStatusSealed, ErrorMessage: "cadence runtime exception", - }: string(models.FAILURE_RESULT), { + }: string(commonmodels.FAILURE_RESULT), { Status: flow.TransactionStatusFinalized, ErrorMessage: "", - }: string(models.PENDING_RESULT), { + }: string(commonmodels.PENDING_RESULT), { Status: flow.TransactionStatusPending, ErrorMessage: "", - }: string(models.PENDING_RESULT), { + }: string(commonmodels.PENDING_RESULT), { Status: flow.TransactionStatusExecuted, ErrorMessage: "", - }: string(models.PENDING_RESULT), { + }: string(commonmodels.PENDING_RESULT), { Status: flow.TransactionStatusSealed, ErrorMessage: "", - }: string(models.SUCCESS_RESULT)} + }: string(commonmodels.SUCCESS_RESULT)} for txResult, err := range testVectors { txResult.BlockID = bid @@ -387,7 +385,7 @@ func TestGetScheduledTransactions(t *testing.T) { Return(tx, nil). Once() backend. - On("GetScheduledTransactionResult", mocks.Anything, scheduledTxID, entitiesproto.EventEncodingVersion_JSON_CDC_V0). + On("GetScheduledTransactionResult", mocks.Anything, scheduledTxID, entities.EventEncodingVersion_JSON_CDC_V0). Return(txr, nil). Once() @@ -397,14 +395,14 @@ func TestGetScheduledTransactions(t *testing.T) { }) t.Run("get result by scheduled transaction ID", func(t *testing.T) { - var expectedTxResult models.TransactionResult + var expectedTxResult commonmodels.TransactionResult expectedTxResult.Build(txr, txID, link) expectedResult, err := json.Marshal(expectedTxResult) require.NoError(t, err) backend := mock.NewAPI(t) backend. - On("GetScheduledTransactionResult", mocks.Anything, scheduledTxID, entitiesproto.EventEncodingVersion_JSON_CDC_V0). + On("GetScheduledTransactionResult", mocks.Anything, scheduledTxID, entities.EventEncodingVersion_JSON_CDC_V0). Return(txr, nil). Once() @@ -435,7 +433,7 @@ func TestGetScheduledTransactions(t *testing.T) { Return(tx, nil). Once() backend. - On("GetTransactionResult", mocks.Anything, txID, flow.ZeroID, flow.ZeroID, entitiesproto.EventEncodingVersion_JSON_CDC_V0). + On("GetTransactionResult", mocks.Anything, txID, flow.ZeroID, flow.ZeroID, entities.EventEncodingVersion_JSON_CDC_V0). Return(txr, nil). Once() @@ -582,7 +580,7 @@ func scheduledTransactionFixture(t *testing.T, g *fixtures.GeneratorSuite, sched // expectedTransactionResponse constructs the expected json transaction response for the given // transaction body and transaction result. func expectedTransactionResponse(t *testing.T, tx *flow.TransactionBody, txr *accessmodel.TransactionResult, link commonmodels.LinkGenerator) string { - var expectedTxWithoutResult models.Transaction + var expectedTxWithoutResult commonmodels.Transaction expectedTxWithoutResult.Build(tx, txr, link) expected, err := json.Marshal(expectedTxWithoutResult) diff --git a/engine/access/rest/websockets/data_providers/models/event.go b/engine/access/rest/websockets/data_providers/models/event.go index c3db39bb559..b8e289e7674 100644 --- a/engine/access/rest/websockets/data_providers/models/event.go +++ b/engine/access/rest/websockets/data_providers/models/event.go @@ -3,15 +3,14 @@ package models import ( "strconv" - "github.com/onflow/flow-go/engine/access/rest/common/models" commonmodels "github.com/onflow/flow-go/engine/access/rest/common/models" "github.com/onflow/flow-go/engine/access/state_stream/backend" ) // EventResponse is the response message for 'events' topic. type EventResponse struct { - models.BlockEvents // Embed BlockEvents struct to reuse its fields - MessageIndex uint64 `json:"message_index"` + commonmodels.BlockEvents // Embed BlockEvents struct to reuse its fields + MessageIndex uint64 `json:"message_index"` } // NewEventResponse creates EventResponse instance. diff --git a/engine/access/rpc/backend/scripts/executor/execution_node.go b/engine/access/rpc/backend/scripts/executor/execution_node.go index d6c58e35b43..ba727f18361 100644 --- a/engine/access/rpc/backend/scripts/executor/execution_node.go +++ b/engine/access/rpc/backend/scripts/executor/execution_node.go @@ -12,7 +12,6 @@ import ( "github.com/onflow/flow-go/engine/access/rpc/backend/node_communicator" "github.com/onflow/flow-go/engine/access/rpc/connection" - "github.com/onflow/flow-go/engine/common/rpc" commonrpc "github.com/onflow/flow-go/engine/common/rpc" "github.com/onflow/flow-go/model/flow" "github.com/onflow/flow-go/module" @@ -96,7 +95,7 @@ func (e *ENScriptExecutor) Execute(ctx context.Context, request *Request) ([]byt e.metrics.ScriptExecutionErrorOnExecutionNode() e.log.Error().Err(errToReturn).Msg("script execution failed for execution node internal reasons") } - return nil, execDuration, rpc.ConvertError(errToReturn, "failed to execute script on execution nodes", codes.Internal) + return nil, execDuration, commonrpc.ConvertError(errToReturn, "failed to execute script on execution nodes", codes.Internal) } return result, execDuration, nil diff --git a/engine/access/rpc/backend/transactions/transactions_functional_test.go b/engine/access/rpc/backend/transactions/transactions_functional_test.go index aa3c1061778..f43834e4ea5 100644 --- a/engine/access/rpc/backend/transactions/transactions_functional_test.go +++ b/engine/access/rpc/backend/transactions/transactions_functional_test.go @@ -15,7 +15,6 @@ import ( "google.golang.org/grpc/status" "github.com/onflow/flow/protobuf/go/flow/entities" - "github.com/onflow/flow/protobuf/go/flow/execution" execproto "github.com/onflow/flow/protobuf/go/flow/execution" "github.com/onflow/flow-go/access/validator" @@ -30,7 +29,6 @@ import ( "github.com/onflow/flow-go/engine/common/rpc/convert" "github.com/onflow/flow-go/fvm/blueprints" "github.com/onflow/flow-go/fvm/systemcontracts" - "github.com/onflow/flow-go/model/access" accessmodel "github.com/onflow/flow-go/model/access" "github.com/onflow/flow-go/model/access/systemcollection" "github.com/onflow/flow-go/model/flow" @@ -347,7 +345,7 @@ func scheduledTransactionFromEvents( ) (*flow.TransactionBody, error) { systemCollection, err := systemcollection.Default(chainID). ByHeight(blockHeight). - SystemCollection(chainID.Chain(), access.StaticEventProvider(events)) + SystemCollection(chainID.Chain(), accessmodel.StaticEventProvider(events)) if err != nil { return nil, err } @@ -523,7 +521,7 @@ func (s *TransactionsFunctionalSuite) TestTransactionsByBlockID_Local() { versionedSystemCollection := systemcollection.Default(s.g.ChainID()) systemCollection, err := versionedSystemCollection. ByHeight(block.Height). - SystemCollection(s.g.ChainID().Chain(), access.StaticEventProvider(s.tf.ExpectedEvents)) + SystemCollection(s.g.ChainID().Chain(), accessmodel.StaticEventProvider(s.tf.ExpectedEvents)) s.Require().NoError(err) expectedTransactions = append(expectedTransactions, systemCollection.Transactions...) @@ -594,7 +592,7 @@ func (s *TransactionsFunctionalSuite) TestTransactionResult_ExecutionNode() { txID := s.tf.ExpectedResults[1].TransactionID accessResponse := convert.TransactionResultToMessage(s.expectedResultForIndex(1, entities.EventEncodingVersion_CCF_V0)) - nodeResponse := &execution.GetTransactionResultResponse{ + nodeResponse := &execproto.GetTransactionResultResponse{ StatusCode: accessResponse.StatusCode, ErrorMessage: accessResponse.ErrorMessage, Events: accessResponse.Events, @@ -624,7 +622,7 @@ func (s *TransactionsFunctionalSuite) TestTransactionResultByIndex_ExecutionNode blockID := s.tf.Block.ID() accessResponse := convert.TransactionResultToMessage(s.expectedResultForIndex(1, entities.EventEncodingVersion_CCF_V0)) - nodeResponse := &execution.GetTransactionResultResponse{ + nodeResponse := &execproto.GetTransactionResultResponse{ StatusCode: accessResponse.StatusCode, ErrorMessage: accessResponse.ErrorMessage, Events: accessResponse.Events, @@ -681,10 +679,10 @@ func (s *TransactionsFunctionalSuite) TestTransactionResultsByBlockID_ExecutionN blockID := s.tf.Block.ID() expectedResults := make([]*accessmodel.TransactionResult, len(s.tf.ExpectedResults)) - nodeResults := make([]*execution.GetTransactionResultResponse, len(s.tf.ExpectedResults)) + nodeResults := make([]*execproto.GetTransactionResultResponse, len(s.tf.ExpectedResults)) for i := range s.tf.ExpectedResults { accessResponse := convert.TransactionResultToMessage(s.expectedResultForIndex(i, entities.EventEncodingVersion_CCF_V0)) - nodeResults[i] = &execution.GetTransactionResultResponse{ + nodeResults[i] = &execproto.GetTransactionResultResponse{ StatusCode: accessResponse.StatusCode, ErrorMessage: accessResponse.ErrorMessage, Events: accessResponse.Events, @@ -692,7 +690,7 @@ func (s *TransactionsFunctionalSuite) TestTransactionResultsByBlockID_ExecutionN expectedResults[i] = s.expectedResultForIndex(i, entities.EventEncodingVersion_JSON_CDC_V0) } - nodeResponse := &execution.GetTransactionResultsResponse{ + nodeResponse := &execproto.GetTransactionResultsResponse{ TransactionResults: nodeResults, EventEncodingVersion: entities.EventEncodingVersion_CCF_V0, } @@ -726,7 +724,7 @@ func (s *TransactionsFunctionalSuite) TestTransactionsByBlockID_ExecutionNode() versionedSystemCollection := systemcollection.Default(s.g.ChainID()) systemCollection, err := versionedSystemCollection. ByHeight(block.Height). - SystemCollection(s.g.ChainID().Chain(), access.StaticEventProvider(s.tf.ExpectedEvents)) + SystemCollection(s.g.ChainID().Chain(), accessmodel.StaticEventProvider(s.tf.ExpectedEvents)) s.Require().NoError(err) expectedTransactions = append(expectedTransactions, systemCollection.Transactions...) @@ -745,8 +743,8 @@ func (s *TransactionsFunctionalSuite) TestTransactionsByBlockID_ExecutionNode() } } - nodeResponse := &execution.GetEventsForBlockIDsResponse{ - Results: []*execution.GetEventsForBlockIDsResponse_Result{ + nodeResponse := &execproto.GetEventsForBlockIDsResponse{ + Results: []*execproto.GetEventsForBlockIDsResponse_Result{ { BlockId: blockID[:], BlockHeight: block.Height, diff --git a/engine/collection/synchronization/engine_test.go b/engine/collection/synchronization/engine_test.go index 9b9fbf50015..80203ef8aed 100644 --- a/engine/collection/synchronization/engine_test.go +++ b/engine/collection/synchronization/engine_test.go @@ -20,7 +20,6 @@ import ( "github.com/onflow/flow-go/model/flow/filter" "github.com/onflow/flow-go/model/messages" "github.com/onflow/flow-go/module/chainsync" - synccore "github.com/onflow/flow-go/module/chainsync" "github.com/onflow/flow-go/module/metrics" module "github.com/onflow/flow-go/module/mock" netint "github.com/onflow/flow-go/network" @@ -502,7 +501,7 @@ func (ss *SyncSuite) TestPollHeight() { // check that we send to three nodes from our total list others := ss.participants.Filter(filter.HasNodeID[flow.Identity](ss.participants[1:].NodeIDs()...)) - ss.con.On("Multicast", mock.Anything, synccore.DefaultPollNodes, others[0].NodeID, others[1].NodeID).Return(nil).Run( + ss.con.On("Multicast", mock.Anything, chainsync.DefaultPollNodes, others[0].NodeID, others[1].NodeID).Return(nil).Run( func(args mock.Arguments) { req := args.Get(0).(*messages.SyncRequest) require.Equal(ss.T(), ss.head.Height, req.Height, "request should contain finalized height") @@ -520,7 +519,7 @@ func (ss *SyncSuite) TestSendRequests() { batches := unittest.BatchListFixture(1) // should submit and mark requested all ranges - ss.con.On("Multicast", mock.AnythingOfType("*messages.RangeRequest"), synccore.DefaultBlockRequestNodes, mock.Anything, mock.Anything).Return(nil).Run( + ss.con.On("Multicast", mock.AnythingOfType("*messages.RangeRequest"), chainsync.DefaultBlockRequestNodes, mock.Anything, mock.Anything).Return(nil).Run( func(args mock.Arguments) { req := args.Get(0).(*messages.RangeRequest) ss.Assert().Equal(ranges[0].From, req.FromHeight) @@ -530,7 +529,7 @@ func (ss *SyncSuite) TestSendRequests() { ss.core.On("RangeRequested", ranges[0]) // should submit and mark requested all batches - ss.con.On("Multicast", mock.AnythingOfType("*messages.BatchRequest"), synccore.DefaultBlockRequestNodes, mock.Anything, mock.Anything, mock.Anything).Return(nil).Run( + ss.con.On("Multicast", mock.AnythingOfType("*messages.BatchRequest"), chainsync.DefaultBlockRequestNodes, mock.Anything, mock.Anything, mock.Anything).Return(nil).Run( func(args mock.Arguments) { req := args.Get(0).(*messages.BatchRequest) ss.Assert().Equal(batches[0].BlockIDs, req.BlockIDs) diff --git a/engine/execution/provider/engine_test.go b/engine/execution/provider/engine_test.go index d1c441521cf..b2b0ebe87a6 100644 --- a/engine/execution/provider/engine_test.go +++ b/engine/execution/provider/engine_test.go @@ -8,7 +8,6 @@ import ( "time" "github.com/stretchr/testify/assert" - _ "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/engine/testutil/nodes.go b/engine/testutil/nodes.go index 6dbb9f33f3c..65b007235c4 100644 --- a/engine/testutil/nodes.go +++ b/engine/testutil/nodes.go @@ -30,7 +30,6 @@ import ( "github.com/onflow/flow-go/engine" "github.com/onflow/flow-go/engine/collection/epochmgr" "github.com/onflow/flow-go/engine/collection/epochmgr/factories" - "github.com/onflow/flow-go/engine/collection/ingest" collectioningest "github.com/onflow/flow-go/engine/collection/ingest" mockcollection "github.com/onflow/flow-go/engine/collection/mock" "github.com/onflow/flow-go/engine/collection/pusher" @@ -51,7 +50,6 @@ import ( "github.com/onflow/flow-go/engine/execution/ingestion/uploader" executionprovider "github.com/onflow/flow-go/engine/execution/provider" executionState "github.com/onflow/flow-go/engine/execution/state" - bootstrapexec "github.com/onflow/flow-go/engine/execution/state/bootstrap" esbootstrap "github.com/onflow/flow-go/engine/execution/state/bootstrap" "github.com/onflow/flow-go/engine/execution/storehouse" testmock "github.com/onflow/flow-go/engine/testutil/mock" @@ -303,7 +301,7 @@ func CollectionNode(t *testing.T, hub *stub.Hub, identity bootstrap.NodeInfo, ro clusterPayloads := store.NewClusterPayloads(node.Metrics, db) ingestionEngine, err := collectioningest.New(node.Log, node.Net, node.State, node.Metrics, node.Metrics, node.Metrics, node.Me, node.ChainID.Chain(), pools, collectioningest.DefaultConfig(), - ingest.NewAddressRateLimiter(rate.Limit(1), 10)) // 10 tps + collectioningest.NewAddressRateLimiter(rate.Limit(1), 10)) // 10 tps require.NoError(t, err) selector := filter.HasRole[flow.Identity](flow.RoleAccess, flow.RoleVerification) @@ -603,7 +601,7 @@ func ExecutionNode(t *testing.T, hub *stub.Hub, identity bootstrap.NodeInfo, ide genesisHead, err := node.State.Final().Head() require.NoError(t, err) - bootstrapper := bootstrapexec.NewBootstrapper(node.Log) + bootstrapper := esbootstrap.NewBootstrapper(node.Log) commit, err := bootstrapper.BootstrapLedger( ls, unittest.ServiceAccountPublicKey, diff --git a/engine/verification/verifier/engine_test.go b/engine/verification/verifier/engine_test.go index 627ca29cdbb..3bf01b3cbf7 100644 --- a/engine/verification/verifier/engine_test.go +++ b/engine/verification/verifier/engine_test.go @@ -9,7 +9,6 @@ import ( "github.com/ipfs/go-cid" "github.com/jordanschalm/lockctx" "github.com/stretchr/testify/mock" - testifymock "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -69,11 +68,11 @@ func (suite *VerifierEngineTestSuite) SetupTest() { suite.approvals = mockstorage.NewResultApprovals(suite.T()) suite.chunkVerifier = mockmodule.NewChunkVerifier(suite.T()) - suite.net.On("Register", channels.PushApprovals, testifymock.Anything). + suite.net.On("Register", channels.PushApprovals, mock.Anything). Return(suite.pushCon, nil). Once() - suite.net.On("Register", channels.ProvideApprovalsByChunk, testifymock.Anything). + suite.net.On("Register", channels.ProvideApprovalsByChunk, mock.Anything). Return(suite.pullCon, nil). Once() @@ -128,7 +127,7 @@ func (suite *VerifierEngineTestSuite) TestVerifyHappyPath() { eng := suite.getTestNewEngine() consensusNodes := unittest.IdentityListFixture(1, unittest.WithRole(flow.RoleConsensus)) - suite.ss.On("Identities", testifymock.Anything).Return(consensusNodes, nil) + suite.ss.On("Identities", mock.Anything).Return(consensusNodes, nil) vChunk, _ := unittest.VerifiableChunkDataFixture(uint64(0)) @@ -183,9 +182,9 @@ func (suite *VerifierEngineTestSuite) TestVerifyHappyPath() { Once() suite.pushCon. - On("Publish", testifymock.Anything, testifymock.Anything). + On("Publish", mock.Anything, mock.Anything). Return(nil). - Run(func(args testifymock.Arguments) { + Run(func(args mock.Arguments) { // check that the approval matches the input execution result ra, ok := args[0].(*messages.ResultApproval) suite.Require().True(ok) diff --git a/fvm/evm/emulator/state/base.go b/fvm/evm/emulator/state/base.go index a0e85fee22e..3ae602e9c00 100644 --- a/fvm/evm/emulator/state/base.go +++ b/fvm/evm/emulator/state/base.go @@ -3,7 +3,6 @@ package state import ( "fmt" - "github.com/ethereum/go-ethereum/common" gethCommon "github.com/ethereum/go-ethereum/common" gethTypes "github.com/ethereum/go-ethereum/core/types" gethCrypto "github.com/ethereum/go-ethereum/crypto" @@ -178,7 +177,7 @@ func (v *BaseView) GetState(sk types.SlotAddress) (gethCommon.Hash, error) { // if account doesn't exist we return empty hash // if account exist but not a smart contract we return EmptyRootHash // if is a contract we return the hash of the root slab content (some sort of commitment). -func (v *BaseView) GetStorageRoot(addr common.Address) (common.Hash, error) { +func (v *BaseView) GetStorageRoot(addr gethCommon.Address) (gethCommon.Hash, error) { account, err := v.getAccount(addr) if err != nil { return gethCommon.Hash{}, err diff --git a/fvm/evm/emulator/state/stateDB.go b/fvm/evm/emulator/state/stateDB.go index 6411c205d27..08a60146751 100644 --- a/fvm/evm/emulator/state/stateDB.go +++ b/fvm/evm/emulator/state/stateDB.go @@ -9,7 +9,6 @@ import ( gethCommon "github.com/ethereum/go-ethereum/common" gethState "github.com/ethereum/go-ethereum/core/state" gethStateless "github.com/ethereum/go-ethereum/core/stateless" - "github.com/ethereum/go-ethereum/core/tracing" gethTracing "github.com/ethereum/go-ethereum/core/tracing" gethTypes "github.com/ethereum/go-ethereum/core/types" gethParams "github.com/ethereum/go-ethereum/params" @@ -227,7 +226,7 @@ func (db *StateDB) GetCodeSize(addr gethCommon.Address) int { func (db *StateDB) SetCode( addr gethCommon.Address, code []byte, - reason tracing.CodeChangeReason, + reason gethTracing.CodeChangeReason, ) (prev []byte) { prev = db.GetCode(addr) err := db.latestView().SetCode(addr, code) diff --git a/model/flow/service_event_test.go b/model/flow/service_event_test.go index 02877d068a7..c0776fba1fd 100644 --- a/model/flow/service_event_test.go +++ b/model/flow/service_event_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/fxamacker/cbor/v2" - "github.com/google/go-cmp/cmp" gocmp "github.com/google/go-cmp/cmp" "github.com/onflow/crypto" "github.com/stretchr/testify/require" @@ -26,9 +25,9 @@ func TestEncodeDecode(t *testing.T) { setEpochExtensionViewCount := &flow.SetEpochExtensionViewCount{Value: uint64(rand.Uint32())} ejectionEvent := &flow.EjectNode{NodeID: unittest.IdentifierFixture()} - comparePubKey := cmp.FilterValues(func(a, b crypto.PublicKey) bool { + comparePubKey := gocmp.FilterValues(func(a, b crypto.PublicKey) bool { return true - }, cmp.Comparer(func(a, b crypto.PublicKey) bool { + }, gocmp.Comparer(func(a, b crypto.PublicKey) bool { if a == nil { return b == nil } diff --git a/network/p2p/libp2pNode.go b/network/p2p/libp2pNode.go index e38342aacb7..0b18eb4d091 100644 --- a/network/p2p/libp2pNode.go +++ b/network/p2p/libp2pNode.go @@ -15,7 +15,6 @@ import ( "github.com/onflow/flow-go/module/component" "github.com/onflow/flow-go/module/irrecoverable" "github.com/onflow/flow-go/network" - flownet "github.com/onflow/flow-go/network" "github.com/onflow/flow-go/network/channels" "github.com/onflow/flow-go/network/p2p/unicast/protocols" ) @@ -117,7 +116,7 @@ type PubSub interface { // Unsubscribe cancels the subscriber and closes the topic. Unsubscribe(topic channels.Topic) error // Publish publishes the given payload on the topic. - Publish(ctx context.Context, messageScope flownet.OutgoingMessageScope) error + Publish(ctx context.Context, messageScope network.OutgoingMessageScope) error // SetPubSub sets the node's pubsub implementation. // SetPubSub may be called at most once. SetPubSub(ps PubSubAdapter) diff --git a/state/protocol/badger/mutator_test.go b/state/protocol/badger/mutator_test.go index 47055894268..eb9c7a2df07 100644 --- a/state/protocol/badger/mutator_test.go +++ b/state/protocol/badger/mutator_test.go @@ -19,7 +19,6 @@ import ( "github.com/onflow/flow-go/model/flow" "github.com/onflow/flow-go/model/flow/filter" "github.com/onflow/flow-go/module" - "github.com/onflow/flow-go/module/metrics" mmetrics "github.com/onflow/flow-go/module/metrics" mockmodule "github.com/onflow/flow-go/module/mock" "github.com/onflow/flow-go/module/signature" @@ -86,7 +85,7 @@ func TestBootstrapValid(t *testing.T) { func TestExtendValid(t *testing.T) { unittest.RunWithPebbleDB(t, func(pdb *pebble.DB) { lockManager := storage.NewTestingLockManager() - metrics := metrics.NewNoopCollector() + metrics := mmetrics.NewNoopCollector() tracer := trace.NewNoopTracer() db := pebbleimpl.ToDB(pdb) log := zerolog.Nop() @@ -257,7 +256,7 @@ func TestSealedIndex(t *testing.T) { err = state.Finalize(context.Background(), b4.ID()) require.NoError(t, err) - metrics := metrics.NewNoopCollector() + metrics := mmetrics.NewNoopCollector() seals := store.NewSeals(metrics, db) // can only find seal for G @@ -2799,7 +2798,7 @@ func TestEpochTargetDuration(t *testing.T) { func TestExtendInvalidSealsInBlock(t *testing.T) { unittest.RunWithPebbleDB(t, func(pdb *pebble.DB) { lockManager := storage.NewTestingLockManager() - metrics := metrics.NewNoopCollector() + metrics := mmetrics.NewNoopCollector() tracer := trace.NewNoopTracer() log := zerolog.Nop() db := pebbleimpl.ToDB(pdb) @@ -3463,7 +3462,7 @@ func TestCacheAtomicity(t *testing.T) { func TestHeaderInvalidTimestamp(t *testing.T) { unittest.RunWithPebbleDB(t, func(pdb *pebble.DB) { lockManager := storage.NewTestingLockManager() - metrics := metrics.NewNoopCollector() + metrics := mmetrics.NewNoopCollector() tracer := trace.NewNoopTracer() log := zerolog.Nop() db := pebbleimpl.ToDB(pdb) diff --git a/state/protocol/badger/state_test.go b/state/protocol/badger/state_test.go index cc9c024d3e6..83c05b1e40c 100644 --- a/state/protocol/badger/state_test.go +++ b/state/protocol/badger/state_test.go @@ -17,7 +17,6 @@ import ( bprotocol "github.com/onflow/flow-go/state/protocol/badger" "github.com/onflow/flow-go/state/protocol/inmem" "github.com/onflow/flow-go/state/protocol/util" - protoutil "github.com/onflow/flow-go/state/protocol/util" "github.com/onflow/flow-go/storage" "github.com/onflow/flow-go/storage/operation/pebbleimpl" "github.com/onflow/flow-go/storage/store" @@ -34,7 +33,7 @@ func TestBootstrapAndOpen(t *testing.T) { block.ParentID = unittest.IdentifierFixture() }) - protoutil.RunWithBootstrapState(t, rootSnapshot, func(db storage.DB, _ *bprotocol.State) { + util.RunWithBootstrapState(t, rootSnapshot, func(db storage.DB, _ *bprotocol.State) { lockManager := storage.NewTestingLockManager() // expect the final view metric to be set to current epoch's final view epoch, err := rootSnapshot.Epochs().Current() @@ -111,7 +110,7 @@ func TestBootstrapAndOpen_EpochCommitted(t *testing.T) { } }) - protoutil.RunWithBootstrapState(t, committedPhaseSnapshot, func(db storage.DB, _ *bprotocol.State) { + util.RunWithBootstrapState(t, committedPhaseSnapshot, func(db storage.DB, _ *bprotocol.State) { lockManager := storage.NewTestingLockManager() complianceMetrics := new(mock.ComplianceMetrics) @@ -879,7 +878,7 @@ func bootstrap(t *testing.T, rootSnapshot protocol.Snapshot, f func(*bprotocol.S // from non-root states. func snapshotAfter(t *testing.T, rootSnapshot protocol.Snapshot, f func(*bprotocol.FollowerState, protocol.MutableProtocolState) protocol.Snapshot) protocol.Snapshot { var after protocol.Snapshot - protoutil.RunWithFullProtocolStateAndMutator(t, rootSnapshot, func(_ storage.DB, state *bprotocol.ParticipantState, mutableState protocol.MutableProtocolState) { + util.RunWithFullProtocolStateAndMutator(t, rootSnapshot, func(_ storage.DB, state *bprotocol.ParticipantState, mutableState protocol.MutableProtocolState) { snap := f(state.FollowerState, mutableState) var err error after, err = inmem.FromSnapshot(snap) diff --git a/state/protocol/util/testing.go b/state/protocol/util/testing.go index 220fb2d41bb..cc0ba5f0a79 100644 --- a/state/protocol/util/testing.go +++ b/state/protocol/util/testing.go @@ -10,7 +10,6 @@ import ( "github.com/onflow/flow-go/model/flow" "github.com/onflow/flow-go/module" - "github.com/onflow/flow-go/module/metrics" mmetrics "github.com/onflow/flow-go/module/metrics" modulemock "github.com/onflow/flow-go/module/mock" "github.com/onflow/flow-go/module/trace" @@ -70,7 +69,7 @@ func RunWithBootstrapState(t testing.TB, rootSnapshot protocol.Snapshot, f func( unittest.RunWithPebbleDB(t, func(pdb *pebble.DB) { lockManager := storage.NewTestingLockManager() db := pebbleimpl.ToDB(pdb) - metrics := metrics.NewNoopCollector() + metrics := mmetrics.NewNoopCollector() all := store.InitAll(metrics, db) state, err := pbadger.Bootstrap( metrics, @@ -97,7 +96,7 @@ func RunWithFullProtocolState(t testing.TB, rootSnapshot protocol.Snapshot, f fu unittest.RunWithPebbleDB(t, func(pdb *pebble.DB) { lockManager := storage.NewTestingLockManager() db := pebbleimpl.ToDB(pdb) - metrics := metrics.NewNoopCollector() + metrics := mmetrics.NewNoopCollector() tracer := trace.NewNoopTracer() log := zerolog.Nop() consumer := events.NewNoop() @@ -187,7 +186,7 @@ func RunWithFullProtocolStateAndValidator(t testing.TB, rootSnapshot protocol.Sn unittest.RunWithPebbleDB(t, func(pdb *pebble.DB) { lockManager := storage.NewTestingLockManager() db := pebbleimpl.ToDB(pdb) - metrics := metrics.NewNoopCollector() + metrics := mmetrics.NewNoopCollector() tracer := trace.NewNoopTracer() log := zerolog.Nop() consumer := events.NewNoop() @@ -231,7 +230,7 @@ func RunWithFollowerProtocolState(t testing.TB, rootSnapshot protocol.Snapshot, unittest.RunWithPebbleDB(t, func(pdb *pebble.DB) { lockManager := storage.NewTestingLockManager() db := pebbleimpl.ToDB(pdb) - metrics := metrics.NewNoopCollector() + metrics := mmetrics.NewNoopCollector() tracer := trace.NewNoopTracer() log := zerolog.Nop() consumer := events.NewNoop() @@ -272,7 +271,7 @@ func RunWithFullProtocolStateAndConsumer(t testing.TB, rootSnapshot protocol.Sna unittest.RunWithPebbleDB(t, func(pdb *pebble.DB) { lockManager := storage.NewTestingLockManager() db := pebbleimpl.ToDB(pdb) - metrics := metrics.NewNoopCollector() + metrics := mmetrics.NewNoopCollector() tracer := trace.NewNoopTracer() log := zerolog.Nop() all := store.InitAll(metrics, db) @@ -369,7 +368,7 @@ func RunWithFollowerProtocolStateAndHeaders(t testing.TB, rootSnapshot protocol. unittest.RunWithPebbleDB(t, func(pdb *pebble.DB) { lockManager := storage.NewTestingLockManager() db := pebbleimpl.ToDB(pdb) - metrics := metrics.NewNoopCollector() + metrics := mmetrics.NewNoopCollector() tracer := trace.NewNoopTracer() log := zerolog.Nop() consumer := events.NewNoop() @@ -410,7 +409,7 @@ func RunWithFullProtocolStateAndMutator(t testing.TB, rootSnapshot protocol.Snap unittest.RunWithPebbleDB(t, func(pdb *pebble.DB) { lockManager := storage.NewTestingLockManager() db := pebbleimpl.ToDB(pdb) - metrics := metrics.NewNoopCollector() + metrics := mmetrics.NewNoopCollector() tracer := trace.NewNoopTracer() log := zerolog.Nop() consumer := events.NewNoop()