Skip to content

Commit

Permalink
Merge branch 'master' into access-cohort3-integration-tests-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriiDiachuk authored May 28, 2024
2 parents 280a223 + 778a287 commit 8a03502
Show file tree
Hide file tree
Showing 56 changed files with 1,672 additions and 701 deletions.
5 changes: 3 additions & 2 deletions cmd/bootstrap/cmd/partner_infos.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/encodable"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/grpcclient"
)

const (
Expand Down Expand Up @@ -117,12 +118,12 @@ func getFlowClient() *client.Client {
insecureClient = false
}

config, err := common.NewFlowClientConfig(flagANAddress, strings.TrimPrefix(flagANNetworkKey, "0x"), flow.ZeroID, insecureClient)
config, err := grpcclient.NewFlowClientConfig(flagANAddress, strings.TrimPrefix(flagANNetworkKey, "0x"), flow.ZeroID, insecureClient)
if err != nil {
log.Fatal().Err(err).Msgf("could not get flow client config with address (%s) and network key (%s)", flagANAddress, flagANNetworkKey)
}

flowClient, err := common.FlowClient(config)
flowClient, err := grpcclient.FlowClient(config)
if err != nil {
log.Fatal().Err(err).Msgf("could not get flow client with address (%s) and network key (%s)", flagANAddress, flagANNetworkKey)
}
Expand Down
11 changes: 6 additions & 5 deletions cmd/collection/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
modulecompliance "github.com/onflow/flow-go/module/compliance"
"github.com/onflow/flow-go/module/epochs"
confinalizer "github.com/onflow/flow-go/module/finalizer/consensus"
"github.com/onflow/flow-go/module/grpcclient"
"github.com/onflow/flow-go/module/mempool"
epochpool "github.com/onflow/flow-go/module/mempool/epochs"
"github.com/onflow/flow-go/module/mempool/herocache"
Expand Down Expand Up @@ -98,7 +99,7 @@ func main() {

// epoch qc contract client
machineAccountInfo *bootstrap.NodeMachineAccountInfo
flowClientConfigs []*common.FlowClientConfig
flowClientConfigs []*grpcclient.FlowClientConfig
insecureAccessAPI bool
accessNodeIDS []string
apiRatelimits map[string]int
Expand Down Expand Up @@ -284,7 +285,7 @@ func main() {
return fmt.Errorf("failed to validate flag --access-node-ids %w", err)
}

flowClientConfigs, err = common.FlowClientConfigs(anIDS, insecureAccessAPI, node.State.Sealed())
flowClientConfigs, err = grpcclient.FlowClientConfigs(anIDS, insecureAccessAPI, node.State.Sealed())
if err != nil {
return fmt.Errorf("failed to prepare flow client connection configs for each access node id %w", err)
}
Expand All @@ -293,7 +294,7 @@ func main() {
}).
Component("machine account config validator", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
// @TODO use fallback logic for flowClient similar to DKG/QC contract clients
flowClient, err := common.FlowClient(flowClientConfigs[0])
flowClient, err := grpcclient.FlowClient(flowClientConfigs[0])
if err != nil {
return nil, fmt.Errorf("failed to get flow client connection option for access node (0): %s %w", flowClientConfigs[0].AccessAddress, err)
}
Expand Down Expand Up @@ -682,11 +683,11 @@ func createQCContractClient(node *cmd.NodeConfig, machineAccountInfo *bootstrap.
}

// createQCContractClients creates priority ordered array of QCContractClient
func createQCContractClients(node *cmd.NodeConfig, machineAccountInfo *bootstrap.NodeMachineAccountInfo, flowClientOpts []*common.FlowClientConfig) ([]module.QCContractClient, error) {
func createQCContractClients(node *cmd.NodeConfig, machineAccountInfo *bootstrap.NodeMachineAccountInfo, flowClientOpts []*grpcclient.FlowClientConfig) ([]module.QCContractClient, error) {
qcClients := make([]module.QCContractClient, 0)

for _, opt := range flowClientOpts {
flowClient, err := common.FlowClient(opt)
flowClient, err := grpcclient.FlowClient(opt)
if err != nil {
return nil, fmt.Errorf("failed to create flow client for qc contract client with options: %s %w", flowClientOpts, err)
}
Expand Down
11 changes: 6 additions & 5 deletions cmd/consensus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
dkgmodule "github.com/onflow/flow-go/module/dkg"
"github.com/onflow/flow-go/module/epochs"
finalizer "github.com/onflow/flow-go/module/finalizer/consensus"
"github.com/onflow/flow-go/module/grpcclient"
"github.com/onflow/flow-go/module/mempool"
consensusMempools "github.com/onflow/flow-go/module/mempool/consensus"
"github.com/onflow/flow-go/module/mempool/stdmap"
Expand Down Expand Up @@ -99,7 +100,7 @@ func main() {

// DKG contract client
machineAccountInfo *bootstrap.NodeMachineAccountInfo
flowClientConfigs []*common.FlowClientConfig
flowClientConfigs []*grpcclient.FlowClientConfig
insecureAccessAPI bool
accessNodeIDS []string

Expand Down Expand Up @@ -408,7 +409,7 @@ func main() {
return fmt.Errorf("failed to validate flag --access-node-ids %w", err)
}

flowClientConfigs, err = common.FlowClientConfigs(anIDS, insecureAccessAPI, node.State.Sealed())
flowClientConfigs, err = grpcclient.FlowClientConfigs(anIDS, insecureAccessAPI, node.State.Sealed())
if err != nil {
return fmt.Errorf("failed to prepare flow client connection configs for each access node id %w", err)
}
Expand All @@ -417,7 +418,7 @@ func main() {
}).
Component("machine account config validator", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
// @TODO use fallback logic for flowClient similar to DKG/QC contract clients
flowClient, err := common.FlowClient(flowClientConfigs[0])
flowClient, err := grpcclient.FlowClient(flowClientConfigs[0])
if err != nil {
return nil, fmt.Errorf("failed to get flow client connection option for access node (0): %s %w", flowClientConfigs[0].AccessAddress, err)
}
Expand Down Expand Up @@ -981,11 +982,11 @@ func createDKGContractClient(node *cmd.NodeConfig, machineAccountInfo *bootstrap
}

// createDKGContractClients creates an array dkgContractClient that is sorted by retry fallback priority
func createDKGContractClients(node *cmd.NodeConfig, machineAccountInfo *bootstrap.NodeMachineAccountInfo, flowClientOpts []*common.FlowClientConfig) ([]module.DKGContractClient, error) {
func createDKGContractClients(node *cmd.NodeConfig, machineAccountInfo *bootstrap.NodeMachineAccountInfo, flowClientOpts []*grpcclient.FlowClientConfig) ([]module.DKGContractClient, error) {
dkgClients := make([]module.DKGContractClient, 0)

for _, opt := range flowClientOpts {
flowClient, err := common.FlowClient(opt)
flowClient, err := grpcclient.FlowClient(opt)
if err != nil {
return nil, fmt.Errorf("failed to create flow client for dkg contract client with options: %s %w", flowClientOpts, err)
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/dynamic_startup.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/onflow/flow-go/cmd/util/cmd/common"
"github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/grpcclient"
"github.com/onflow/flow-go/state/protocol"
badgerstate "github.com/onflow/flow-go/state/protocol/badger"
utilsio "github.com/onflow/flow-go/utils/io"
Expand Down Expand Up @@ -92,11 +93,11 @@ func DynamicStartPreInit(nodeConfig *NodeConfig) error {
// CASE 2.2: Use Dynamic Startup to bootstrap.

// get flow client with secure client connection to download protocol snapshot from access node
config, err := common.NewFlowClientConfig(nodeConfig.DynamicStartupANAddress, nodeConfig.DynamicStartupANPubkey, flow.ZeroID, false)
config, err := grpcclient.NewFlowClientConfig(nodeConfig.DynamicStartupANAddress, nodeConfig.DynamicStartupANPubkey, flow.ZeroID, false)
if err != nil {
return fmt.Errorf("failed to create flow client config for node dynamic startup pre-init: %w", err)
}
flowClient, err := common.FlowClient(config)
flowClient, err := grpcclient.FlowClient(config)
if err != nil {
return fmt.Errorf("failed to create flow client for node dynamic startup pre-init: %w", err)
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/util/cmd/common/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/grpcclient"
"github.com/onflow/flow-go/state/protocol"
)

Expand Down Expand Up @@ -31,7 +32,7 @@ func validateFlags(accessNodeIDS []string, snapshot protocol.Snapshot) ([]flow.I
}

if accessNodeIDS[0] == "*" {
anIDS, err := DefaultAccessNodeIDS(snapshot)
anIDS, err := grpcclient.DefaultAccessNodeIDS(snapshot)
if err != nil {
return nil, fmt.Errorf("failed to get default access node ids %w", err)
}
Expand Down Expand Up @@ -59,7 +60,7 @@ func validateFlagsMainNet(accessNodeIDS []string) ([]flow.Identifier, error) {

// convertIDS converts a list of access node id hex strings to flow.Identifier
func convertIDS(accessNodeIDS []string) ([]flow.Identifier, error) {
anIDS, err := FlowIDFromHexString(accessNodeIDS...)
anIDS, err := grpcclient.FlowIDFromHexString(accessNodeIDS...)
if err != nil {
return nil, fmt.Errorf("failed to convert access node ID(s) into flow identifier(s) %w", err)
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/util/cmd/epochs/cmd/recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
epochcmdutil "github.com/onflow/flow-go/cmd/util/cmd/epochs/utils"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/model/flow/filter"
"github.com/onflow/flow-go/module/grpcclient"
"github.com/onflow/flow-go/state/protocol/inmem"
)

Expand Down Expand Up @@ -90,12 +91,12 @@ func addGenerateRecoverEpochTxArgsCmdFlags() error {

func getSnapshot() *inmem.Snapshot {
// get flow client with secure client connection to download protocol snapshot from access node
config, err := common.NewFlowClientConfig(flagAnAddress, flagAnPubkey, flow.ZeroID, false)
config, err := grpcclient.NewFlowClientConfig(flagAnAddress, flagAnPubkey, flow.ZeroID, false)
if err != nil {
log.Fatal().Err(err).Msg("failed to create flow client config")
}

flowClient, err := common.FlowClient(config)
flowClient, err := grpcclient.FlowClient(config)
if err != nil {
log.Fatal().Err(err).Msg("failed to create flow client")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/util/ledger/migrations/account_based_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func MigrateGroupConcurrently(
continue
}

for m, migration := range migrations {
for migrationIndex, migration := range migrations {

select {
case <-ctx.Done():
Expand All @@ -194,7 +194,7 @@ func MigrateGroupConcurrently(
if err != nil {
log.Error().
Err(err).
Int("migration_index", m).
Int("migration_index", migrationIndex).
Type("migration", migration).
Hex("address", address[:]).
Msg("could not migrate account")
Expand Down
Loading

0 comments on commit 8a03502

Please sign in to comment.