Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Khalil/6959 Recover Epoch transaction args script #5576

Merged
merged 57 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
311115f
move reusable util funcs to common package
kc1116 Mar 22, 2024
7d09f47
generate tx args
kc1116 Mar 22, 2024
ffbd640
add happy path tests
kc1116 Mar 29, 2024
45fcead
Update cmd/bootstrap/cmd/keys.go
kc1116 Apr 1, 2024
18f7aec
Update keys.go
kc1116 Apr 1, 2024
c82ffbc
move NotEjected filter to filter package
kc1116 Apr 1, 2024
321da97
get subsets of internal collectors and partner collectors from snapshot
kc1116 Apr 1, 2024
9a4542d
Update cmd/util/cmd/epochs/cmd/recover.go
kc1116 Apr 2, 2024
91d6599
Update cmd/util/cmd/epochs/cmd/recover.go
kc1116 Apr 2, 2024
051629d
Update cmd/util/cmd/epochs/cmd/recover.go
kc1116 Apr 2, 2024
1399e18
Update cmd/util/cmd/epochs/cmd/recover.go
kc1116 Apr 2, 2024
2b9c152
Update recover.go
kc1116 Apr 2, 2024
3c8ee33
epoch counter should be an input
kc1116 Apr 2, 2024
d9db0eb
smart contract should generate random source with revertibleRandom
kc1116 Apr 2, 2024
f48b5a7
Update cmd/util/cmd/epochs/cmd/recover.go
kc1116 Apr 2, 2024
0cb7cae
Update cmd/util/cmd/epochs/cmd/recover.go
kc1116 Apr 2, 2024
884fdbf
add epoch-length and epoch-staking-phase-length
kc1116 Apr 2, 2024
6aacb01
use for range loop
kc1116 Apr 2, 2024
82c5803
dkg group key should be the first key in the array
kc1116 Apr 2, 2024
1d67790
Update cmd/util/cmd/common/clusters.go
kc1116 Apr 2, 2024
1c86a58
Merge branch 'khalil/6959-efm-recvery-epoch-data-generation' of githu…
kc1116 Apr 2, 2024
8d6611f
add godoc for ConstructRootQCsForClusters
kc1116 Apr 2, 2024
263974e
add godoc for *PartnerInfo util funcs
kc1116 Apr 2, 2024
c6a1989
document GetSnapshotAtEpochAndPhase arguments
kc1116 Apr 2, 2024
32df104
refactor fatal level logs
kc1116 Apr 2, 2024
4b3dae6
fix node ids in test root snapshot fixture
kc1116 Apr 2, 2024
3a8ec88
remove debug logs
kc1116 Apr 2, 2024
0060ce9
Update cmd/util/cmd/common/clusters.go
kc1116 Apr 3, 2024
3a2b99e
Update cmd/util/cmd/common/clusters.go
kc1116 Apr 3, 2024
fcb1006
Apply suggestions from code review
kc1116 Apr 3, 2024
340d3ab
Apply suggestions from code review
kc1116 Apr 3, 2024
6070f4e
add integration tests skeleton
kc1116 Apr 8, 2024
4b71333
Merge branch 'khalil/6959-efm-recvery-epoch-data-generation' of githu…
kc1116 Apr 8, 2024
b491179
Update service_events_fixtures.go
kc1116 Apr 8, 2024
fb3ec2c
lint fix
kc1116 Apr 8, 2024
a8cfa20
Update recover.go
kc1116 Apr 8, 2024
22511ab
fix lint
kc1116 Apr 8, 2024
2eb6b11
fix imports
kc1116 Apr 8, 2024
ad9cede
fix cmd unit tests add missing "wrote file" logs
kc1116 Apr 9, 2024
2701102
remove extra SN nodes
kc1116 Apr 9, 2024
e07c96a
Update recover_epoch_efm_test.go
kc1116 Apr 9, 2024
6bc838f
Merge branch 'master' into khalil/6959-efm-recvery-epoch-data-generation
kc1116 Apr 9, 2024
c27754f
Update integration/tests/epochs/base_suite.go
kc1116 Apr 15, 2024
47024da
use 0 as a default value force the user to provide values
kc1116 Apr 15, 2024
603d1da
Apply suggestions from code review
kc1116 Apr 15, 2024
b40197e
Update cmd/util/cmd/common/node_info.go
kc1116 Apr 15, 2024
6053858
Update cmd/util/cmd/common/node_info.go
kc1116 Apr 15, 2024
a7e6e2c
Apply suggestions from code review
kc1116 Apr 15, 2024
f823c45
Update cmd/util/cmd/common/node_info.go
kc1116 Apr 15, 2024
47361e2
Merge branch 'khalil/6959-efm-recvery-epoch-data-generation' of githu…
kc1116 Apr 15, 2024
5e3dffd
add sanity check ensure all node weights are equal when generating cl…
kc1116 Apr 15, 2024
897809d
Merge branch 'master' into khalil/6959-efm-recvery-epoch-data-generation
kc1116 Apr 15, 2024
a55fda1
Update node_info.go
kc1116 Apr 16, 2024
3ee695d
Merge branch 'khalil/6959-efm-recvery-epoch-data-generation' of githu…
kc1116 Apr 16, 2024
ab88472
Update clusters.go
kc1116 Apr 16, 2024
12e3534
Update clusters.go
kc1116 Apr 16, 2024
e64ad8a
Update clusters.go
kc1116 Apr 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions cmd/bootstrap/cmd/check_machine_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
sdk "github.com/onflow/flow-go-sdk"
client "github.com/onflow/flow-go-sdk/access/grpc"
"github.com/onflow/flow-go/cmd"
"github.com/onflow/flow-go/cmd/util/cmd/common"
model "github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/module/epochs"
)
Expand Down Expand Up @@ -44,7 +45,10 @@ func checkMachineAccountRun(_ *cobra.Command, _ []string) {

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

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

path := filepath.Join(flagOutdir, fmt.Sprintf(model.PathNodeMachineAccountInfoPriv, nodeID))
readJSON(path, &machineAccountInfo)
err := common.ReadJSON(path, &machineAccountInfo)
if err != nil {
log.Fatal().Err(err).Msg("failed to read json")
}

return machineAccountInfo
}
10 changes: 8 additions & 2 deletions cmd/bootstrap/cmd/db_encryption_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/spf13/cobra"

"github.com/onflow/flow-go/cmd/bootstrap/utils"
"github.com/onflow/flow-go/cmd/util/cmd/common"
model "github.com/onflow/flow-go/model/bootstrap"
)

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

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

writeText(dbEncryptionKeyPath, dbEncryptionKey)
err = common.WriteText(dbEncryptionKeyPath, flagOutdir, dbEncryptionKey)
if err != nil {
log.Fatal().Err(err).Msg("failed to write file")
}

log.Info().Msgf("wrote file %v", dbEncryptionKeyPath)
}
11 changes: 9 additions & 2 deletions cmd/bootstrap/cmd/dkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/onflow/crypto"

bootstrapDKG "github.com/onflow/flow-go/cmd/bootstrap/dkg"
"github.com/onflow/flow-go/cmd/util/cmd/common"
model "github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/dkg"
"github.com/onflow/flow-go/model/encodable"
Expand Down Expand Up @@ -38,17 +39,23 @@ func runBeaconKG(nodes []model.NodeInfo) dkg.DKGData {
encKey := encodable.RandomBeaconPrivKey{PrivateKey: privKey}
privKeyShares = append(privKeyShares, encKey)

writeJSON(fmt.Sprintf(model.PathRandomBeaconPriv, nodeID), encKey)
err = common.WriteJSON(fmt.Sprintf(model.PathRandomBeaconPriv, nodeID), flagOutdir, encKey)
if err != nil {
log.Fatal().Err(err).Msg("failed to write json")
}
}

// write full DKG info that will be used to construct QC
writeJSON(model.PathRootDKGData, inmem.EncodableFullDKG{
err = common.WriteJSON(model.PathRootDKGData, flagOutdir, inmem.EncodableFullDKG{
GroupKey: encodable.RandomBeaconPubKey{
PublicKey: dkgData.PubGroupKey,
},
PubKeyShares: pubKeyShares,
PrivKeyShares: privKeyShares,
})
if err != nil {
log.Fatal().Err(err).Msg("failed to write json")
}

return dkgData
}
27 changes: 17 additions & 10 deletions cmd/bootstrap/cmd/final_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/spf13/cobra"

"github.com/onflow/flow-go/cmd"
"github.com/onflow/flow-go/cmd/util/cmd/common"
model "github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/flow"
)
Expand Down Expand Up @@ -65,7 +66,10 @@ func finalList(cmd *cobra.Command, args []string) {
validateNodes(localNodes, registeredNodes)

// write node-config.json with the new list of nodes to be used for the `finalize` command
writeJSON(model.PathFinallist, model.ToPublicNodeInfoList(localNodes))
err := common.WriteJSON(model.PathFinallist, flagOutdir, model.ToPublicNodeInfoList(localNodes))
if err != nil {
log.Fatal().Err(err).Msg("failed to write json")
}
}

func validateNodes(localNodes []model.NodeInfo, registeredNodes []model.NodeInfo) {
Expand Down Expand Up @@ -229,16 +233,16 @@ func checkMismatchingNodes(localNodes []model.NodeInfo, registeredNodes []model.
}

func assembleInternalNodesWithoutWeight() []model.NodeInfo {
privInternals := readInternalNodes()
privInternals := common.ReadInternalNodes(log, flagInternalNodePrivInfoDir)
log.Info().Msgf("read %v internal private node-info files", len(privInternals))

var nodes []model.NodeInfo
for _, internal := range privInternals {
// check if address is valid format
validateAddressFormat(internal.Address)
common.ValidateAddressFormat(log, internal.Address)

// validate every single internal node
nodeID := validateNodeID(internal.NodeID)
nodeID := ValidateNodeID(internal.NodeID)
node := model.NewPrivateNodeInfo(
nodeID,
internal.Role,
Expand All @@ -255,26 +259,29 @@ func assembleInternalNodesWithoutWeight() []model.NodeInfo {
}

func assemblePartnerNodesWithoutWeight() []model.NodeInfo {
partners := readPartnerNodes()
partners := common.ReadPartnerNodes(log, flagPartnerNodeInfoDir)
log.Info().Msgf("read %v partner node configuration files", len(partners))
return createPublicNodeInfo(partners)
}

func readStakingContractDetails() []model.NodeInfo {
var stakingNodes []model.NodeInfoPub
readJSON(flagStakingNodesPath, &stakingNodes)
err := common.ReadJSON(flagStakingNodesPath, &stakingNodes)
if err != nil {
log.Fatal().Err(err).Msg("failed to read json")
}
return createPublicNodeInfo(stakingNodes)
}

func createPublicNodeInfo(nodes []model.NodeInfoPub) []model.NodeInfo {
var publicInfoNodes []model.NodeInfo
for _, n := range nodes {
validateAddressFormat(n.Address)
common.ValidateAddressFormat(log, n.Address)

// validate every single partner node
nodeID := validateNodeID(n.NodeID)
networkPubKey := validateNetworkPubKey(n.NetworkPubKey)
stakingPubKey := validateStakingPubKey(n.StakingPubKey)
nodeID := ValidateNodeID(n.NodeID)
networkPubKey := ValidateNetworkPubKey(n.NetworkPubKey)
stakingPubKey := ValidateStakingPubKey(n.StakingPubKey)

// all nodes should have equal weight
kc1116 marked this conversation as resolved.
Show resolved Hide resolved
node := model.NewPublicNodeInfo(
Expand Down
Loading
Loading