diff --git a/.github/workflows/ci-core.yml b/.github/workflows/ci-core.yml index cc934ecf9b6..c731bf5fa87 100644 --- a/.github/workflows/ci-core.yml +++ b/.github/workflows/ci-core.yml @@ -55,7 +55,7 @@ jobs: golangci: # We don't directly merge dependabot PRs, so let's not waste the resources - if: ${{ github.event_name == 'pull_request' || github.event_name == 'schedule' && github.actor != 'dependabot[bot]' }} + if: ${{ (github.event_name == 'pull_request' || github.event_name == 'schedule') && github.actor != 'dependabot[bot]' }} name: lint runs-on: ubuntu22.04-8cores-32GB needs: [filter] diff --git a/core/scripts/functions/main.go b/core/scripts/functions/main.go index 2bf35828c91..cf496542b05 100644 --- a/core/scripts/functions/main.go +++ b/core/scripts/functions/main.go @@ -19,6 +19,7 @@ func main() { src.NewGenerateJobSpecsCommand(), src.NewDeployJobSpecsCommand(), src.NewDeleteJobsCommand(), + src.NewFetchKeysCommand(), } commandsList := func(commands []command) string { diff --git a/core/scripts/functions/src/fetch_keys.go b/core/scripts/functions/src/fetch_keys.go new file mode 100644 index 00000000000..4c3b11a7e28 --- /dev/null +++ b/core/scripts/functions/src/fetch_keys.go @@ -0,0 +1,44 @@ +package src + +import ( + "encoding/json" + "flag" + "fmt" + "os" +) + +type fetchKeys struct { +} + +func NewFetchKeysCommand() *fetchKeys { + return &fetchKeys{} +} + +func (g *fetchKeys) Name() string { + return "fetch-keys" +} + +func (g *fetchKeys) Run(args []string) { + fs := flag.NewFlagSet(g.Name(), flag.ContinueOnError) + nodesFile := fs.String("nodes", "", "a file containing nodes urls, logins and passwords") + chainID := fs.Int64("chainid", 80001, "chain id") + if err := fs.Parse(args); err != nil || *nodesFile == "" || *chainID == 0 { + fs.Usage() + os.Exit(1) + } + + nodes := mustReadNodesList(*nodesFile) + nca := mustFetchNodesKeys(*chainID, nodes) + + nodePublicKeys, err := json.MarshalIndent(nca, "", " ") + if err != nil { + panic(err) + } + filepath := "PublicKeys.json" + err = os.WriteFile(filepath, nodePublicKeys, 0600) + if err != nil { + panic(err) + } + fmt.Println("Functions OCR2 public keys have been saved to:", filepath) + +}