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

Migration to add keys to service accounts for testing #6969

Merged
4 changes: 3 additions & 1 deletion cmd/util/cmd/execution-state-extract/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func run(*cobra.Command, []string) {
}

// Validate chain ID
_ = flow.ChainID(flagChain).Chain()
chain := flow.ChainID(flagChain).Chain()

if flagNoReport {
log.Warn().Msgf("--no-report flag is deprecated")
Expand Down Expand Up @@ -422,6 +422,8 @@ func run(*cobra.Command, []string) {
var migs []migrations.NamedMigration

switch flagMigration {
case "add-keys":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
case "add-keys":
case "add-migrationnetwork-keys":

maybe making the purpose a bit more clear and specific.

migs = append(migs, addKeysMigration(log.Logger, flagOutputDir, flagNWorker, chain.ChainID())...)
default:
log.Fatal().Msgf("unknown migration: %s", flagMigration)
}
Expand Down
36 changes: 36 additions & 0 deletions cmd/util/cmd/execution-state-extract/execution_state_extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"github.com/rs/zerolog/log"
"golang.org/x/sync/errgroup"

"github.com/onflow/flow-go-sdk/crypto"

Check failure on line 13 in cmd/util/cmd/execution-state-extract/execution_state_extract.go

View workflow job for this annotation

GitHub Actions / Lint (./)

File is not properly formatted (goimports)
migrators "github.com/onflow/flow-go/cmd/util/ledger/migrations"
"github.com/onflow/flow-go/cmd/util/ledger/reporters"
"github.com/onflow/flow-go/cmd/util/ledger/util"
"github.com/onflow/flow-go/ledger"
"github.com/onflow/flow-go/ledger/common/hash"
Expand Down Expand Up @@ -356,3 +358,37 @@

return newTrie, nil
}

func addKeysMigration(
log zerolog.Logger,
outputDir string,
workerCount int,
chainID flow.ChainID,
) []migrators.NamedMigration {

log.Info().Msg("initializing add-keys migrations ...")

rwf := reporters.NewReportFileWriterFactory(outputDir, log)

key, err := crypto.DecodePublicKeyHex(crypto.ECDSA_P256, "711d4cd9930d695ef5c79b668d321f92ba00ed8280fded52c0fa2b15501411d026fe6fb4be3ec894facd3a00f04e32e2db5f5696d3b2b3419e4fba89fb95dca8")
if err != nil {
panic("failed to decode key")
}

namedMigrations := []migrators.NamedMigration{
{
Name: "account-usage-migration",
Migrate: migrators.NewAccountBasedMigration(
log,
workerCount,
[]migrators.AccountBasedMigration{
migrators.NewAddKeyMigration(chainID, key, rwf),
},
),
},
}

log.Info().Msg("initialized migrations")

return namedMigrations
}
Loading
Loading