Skip to content

Commit 9c4c4a3

Browse files
authored
Merge pull request #5576 from onflow/khalil/6959-efm-recvery-epoch-data-generation
Khalil/6959 Recover Epoch transaction args script
2 parents 2d8f653 + e64ad8a commit 9c4c4a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1661
-926
lines changed

cmd/access/node_builder/access_node_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ func (builder *FlowAccessNodeBuilder) InitIDProviders() {
13151315
filter.And(
13161316
filter.HasRole[flow.Identity](flow.RoleConsensus),
13171317
filter.Not(filter.HasNodeID[flow.Identity](node.Me.NodeID())),
1318-
underlay.NotEjectedFilter,
1318+
filter.NotEjectedFilter,
13191319
),
13201320
builder.IdentityProvider,
13211321
)

cmd/bootstrap/cmd/check_machine_account.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
sdk "github.com/onflow/flow-go-sdk"
1414
client "github.com/onflow/flow-go-sdk/access/grpc"
1515
"github.com/onflow/flow-go/cmd"
16+
"github.com/onflow/flow-go/cmd/util/cmd/common"
1617
model "github.com/onflow/flow-go/model/bootstrap"
1718
"github.com/onflow/flow-go/module/epochs"
1819
)
@@ -44,7 +45,10 @@ func checkMachineAccountRun(_ *cobra.Command, _ []string) {
4445

4546
// read the private node information - used to get the role
4647
var nodeInfoPriv model.NodeInfoPriv
47-
readJSON(filepath.Join(flagOutdir, fmt.Sprintf(model.PathNodeInfoPriv, nodeID)), &nodeInfoPriv)
48+
err = common.ReadJSON(filepath.Join(flagOutdir, fmt.Sprintf(model.PathNodeInfoPriv, nodeID)), &nodeInfoPriv)
49+
if err != nil {
50+
log.Fatal().Err(err).Msg("failed to read json")
51+
}
4852

4953
// read the machine account info file
5054
machineAccountInfo := readMachineAccountInfo(nodeID)
@@ -97,7 +101,10 @@ func readMachineAccountInfo(nodeID string) model.NodeMachineAccountInfo {
97101
var machineAccountInfo model.NodeMachineAccountInfo
98102

99103
path := filepath.Join(flagOutdir, fmt.Sprintf(model.PathNodeMachineAccountInfoPriv, nodeID))
100-
readJSON(path, &machineAccountInfo)
104+
err := common.ReadJSON(path, &machineAccountInfo)
105+
if err != nil {
106+
log.Fatal().Err(err).Msg("failed to read json")
107+
}
101108

102109
return machineAccountInfo
103110
}

cmd/bootstrap/cmd/clusters.go

Lines changed: 0 additions & 125 deletions
This file was deleted.

cmd/bootstrap/cmd/db_encryption_key.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/spf13/cobra"
88

99
"github.com/onflow/flow-go/cmd/bootstrap/utils"
10+
"github.com/onflow/flow-go/cmd/util/cmd/common"
1011
model "github.com/onflow/flow-go/model/bootstrap"
1112
)
1213

@@ -35,7 +36,7 @@ func dbEncryptionKeyRun(_ *cobra.Command, _ []string) {
3536
log = log.With().Str("path", dbEncryptionKeyPath).Logger()
3637

3738
// check if the key already exists
38-
exists, err := pathExists(path.Join(flagOutdir, dbEncryptionKeyPath))
39+
exists, err := common.PathExists(path.Join(flagOutdir, dbEncryptionKeyPath))
3940
if err != nil {
4041
log.Fatal().Err(err).Msg("could not check if db encryption key already exists")
4142
}
@@ -50,5 +51,10 @@ func dbEncryptionKeyRun(_ *cobra.Command, _ []string) {
5051
}
5152
log.Info().Msg("generated db encryption key")
5253

53-
writeText(dbEncryptionKeyPath, dbEncryptionKey)
54+
err = common.WriteText(dbEncryptionKeyPath, flagOutdir, dbEncryptionKey)
55+
if err != nil {
56+
log.Fatal().Err(err).Msg("failed to write file")
57+
}
58+
59+
log.Info().Msgf("wrote file %s/%s", flagOutdir, dbEncryptionKeyPath)
5460
}

cmd/bootstrap/cmd/dkg.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/onflow/crypto"
77

88
bootstrapDKG "github.com/onflow/flow-go/cmd/bootstrap/dkg"
9+
"github.com/onflow/flow-go/cmd/util/cmd/common"
910
model "github.com/onflow/flow-go/model/bootstrap"
1011
"github.com/onflow/flow-go/model/dkg"
1112
"github.com/onflow/flow-go/model/encodable"
@@ -38,17 +39,25 @@ func runBeaconKG(nodes []model.NodeInfo) dkg.DKGData {
3839
encKey := encodable.RandomBeaconPrivKey{PrivateKey: privKey}
3940
privKeyShares = append(privKeyShares, encKey)
4041

41-
writeJSON(fmt.Sprintf(model.PathRandomBeaconPriv, nodeID), encKey)
42+
err = common.WriteJSON(fmt.Sprintf(model.PathRandomBeaconPriv, nodeID), flagOutdir, encKey)
43+
if err != nil {
44+
log.Fatal().Err(err).Msg("failed to write json")
45+
}
46+
log.Info().Msgf("wrote file %s/%s", flagOutdir, fmt.Sprintf(model.PathRandomBeaconPriv, nodeID))
4247
}
4348

4449
// write full DKG info that will be used to construct QC
45-
writeJSON(model.PathRootDKGData, inmem.EncodableFullDKG{
50+
err = common.WriteJSON(model.PathRootDKGData, flagOutdir, inmem.EncodableFullDKG{
4651
GroupKey: encodable.RandomBeaconPubKey{
4752
PublicKey: dkgData.PubGroupKey,
4853
},
4954
PubKeyShares: pubKeyShares,
5055
PrivKeyShares: privKeyShares,
5156
})
57+
if err != nil {
58+
log.Fatal().Err(err).Msg("failed to write json")
59+
}
60+
log.Info().Msgf("wrote file %s/%s", flagOutdir, model.PathRootDKGData)
5261

5362
return dkgData
5463
}

cmd/bootstrap/cmd/final_list.go

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package cmd
22

33
import (
4+
"fmt"
5+
46
"github.com/spf13/cobra"
57

68
"github.com/onflow/flow-go/cmd"
9+
"github.com/onflow/flow-go/cmd/util/cmd/common"
710
model "github.com/onflow/flow-go/model/bootstrap"
811
"github.com/onflow/flow-go/model/flow"
912
)
@@ -65,7 +68,11 @@ func finalList(cmd *cobra.Command, args []string) {
6568
validateNodes(localNodes, registeredNodes)
6669

6770
// write node-config.json with the new list of nodes to be used for the `finalize` command
68-
writeJSON(model.PathFinallist, model.ToPublicNodeInfoList(localNodes))
71+
err := common.WriteJSON(model.PathFinallist, flagOutdir, model.ToPublicNodeInfoList(localNodes))
72+
if err != nil {
73+
log.Fatal().Err(err).Msg("failed to write json")
74+
}
75+
log.Info().Msgf("wrote file %s/%s", flagOutdir, model.PathFinallist)
6976
}
7077

7178
func validateNodes(localNodes []model.NodeInfo, registeredNodes []model.NodeInfo) {
@@ -229,18 +236,25 @@ func checkMismatchingNodes(localNodes []model.NodeInfo, registeredNodes []model.
229236
}
230237

231238
func assembleInternalNodesWithoutWeight() []model.NodeInfo {
232-
privInternals := readInternalNodes()
239+
privInternals, err := common.ReadInternalNodeInfos(flagInternalNodePrivInfoDir)
240+
if err != nil {
241+
log.Fatal().Err(err).Msg("failed to read internal node infos")
242+
}
233243
log.Info().Msgf("read %v internal private node-info files", len(privInternals))
234244

235245
var nodes []model.NodeInfo
236246
for _, internal := range privInternals {
237247
// check if address is valid format
238-
validateAddressFormat(internal.Address)
248+
common.ValidateAddressFormat(log, internal.Address)
239249

240250
// validate every single internal node
241-
nodeID := validateNodeID(internal.NodeID)
251+
err := common.ValidateNodeID(internal.NodeID)
252+
if err != nil {
253+
log.Fatal().Err(err).Msg(fmt.Sprintf("invalid node ID: %s", internal.NodeID))
254+
}
255+
242256
node := model.NewPrivateNodeInfo(
243-
nodeID,
257+
internal.NodeID,
244258
internal.Role,
245259
internal.Address,
246260
flow.DefaultInitialWeight,
@@ -255,35 +269,50 @@ func assembleInternalNodesWithoutWeight() []model.NodeInfo {
255269
}
256270

257271
func assemblePartnerNodesWithoutWeight() []model.NodeInfo {
258-
partners := readPartnerNodes()
272+
partners, err := common.ReadPartnerNodeInfos(flagPartnerNodeInfoDir)
273+
if err != nil {
274+
log.Fatal().Err(err).Msg("failed to read partner node infos")
275+
}
259276
log.Info().Msgf("read %v partner node configuration files", len(partners))
260277
return createPublicNodeInfo(partners)
261278
}
262279

263280
func readStakingContractDetails() []model.NodeInfo {
264281
var stakingNodes []model.NodeInfoPub
265-
readJSON(flagStakingNodesPath, &stakingNodes)
282+
err := common.ReadJSON(flagStakingNodesPath, &stakingNodes)
283+
if err != nil {
284+
log.Fatal().Err(err).Msg("failed to read json")
285+
}
266286
return createPublicNodeInfo(stakingNodes)
267287
}
268288

269289
func createPublicNodeInfo(nodes []model.NodeInfoPub) []model.NodeInfo {
270290
var publicInfoNodes []model.NodeInfo
271291
for _, n := range nodes {
272-
validateAddressFormat(n.Address)
292+
common.ValidateAddressFormat(log, n.Address)
273293

274294
// validate every single partner node
275-
nodeID := validateNodeID(n.NodeID)
276-
networkPubKey := validateNetworkPubKey(n.NetworkPubKey)
277-
stakingPubKey := validateStakingPubKey(n.StakingPubKey)
295+
err := common.ValidateNodeID(n.NodeID)
296+
if err != nil {
297+
log.Fatal().Err(err).Msg(fmt.Sprintf("invalid node ID: %s", n.NodeID))
298+
}
299+
err = common.ValidateNetworkPubKey(n.NetworkPubKey)
300+
if err != nil {
301+
log.Fatal().Err(err).Msg(fmt.Sprintf("invalid network public key: %s", n.NetworkPubKey))
302+
}
303+
err = common.ValidateStakingPubKey(n.StakingPubKey)
304+
if err != nil {
305+
log.Fatal().Err(err).Msg(fmt.Sprintf("invalid staking public key: %s", n.StakingPubKey))
306+
}
278307

279-
// all nodes should have equal weight
308+
// all nodes should have equal weight (this might change in the future)
280309
node := model.NewPublicNodeInfo(
281-
nodeID,
310+
n.NodeID,
282311
n.Role,
283312
n.Address,
284313
flow.DefaultInitialWeight,
285-
networkPubKey,
286-
stakingPubKey,
314+
n.NetworkPubKey,
315+
n.StakingPubKey,
287316
)
288317

289318
publicInfoNodes = append(publicInfoNodes, node)

0 commit comments

Comments
 (0)