Skip to content

Commit

Permalink
chore: script to generate local ocr3 config
Browse files Browse the repository at this point in the history
  • Loading branch information
agparadiso committed Dec 27, 2024
1 parent 06a4445 commit aa4de36
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/scripts/keystone/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func main() {
src.NewDeployAndInitializeCapabilitiesRegistryCommand(),
src.NewDeployWorkflowsCommand(),
src.NewDeleteWorkflowsCommand(),
src.NewGenerateLocalOCR3ConfigCommand(),
}

commandsList := func(commands []command) string {
Expand Down
117 changes: 117 additions & 0 deletions core/scripts/keystone/src/generate_ocr3_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package src

import (
"encoding/json"
"os"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/keystone"
ksdeploy "github.com/smartcontractkit/chainlink/deployment/keystone"
)

type generateLocalOCR3Config struct{}

func NewGenerateLocalOCR3ConfigCommand() *generateLocalOCR3Config {
return &generateLocalOCR3Config{}
}

func (g *generateLocalOCR3Config) Name() string {
return "generate-local-ocr3-config"
}

func (g *generateLocalOCR3Config) Run(args []string) {
publicKeys := []byte(`[
{
"EthAddress": "0x562Fb5bEB2195eFB63a897cd8E56812203D57425",
"P2PPeerID": "12D3KooWBWNYzGEDJWL28S7m3pKfoNNZcVoxFmWy3bViQwKaoEDB",
"OCR2BundleID": "7321d9d5354d213cb151b1d441667db5f3920dd9c1ca7f1aa2a44ac8b5800181",
"OCR2OnchainPublicKey": "c2f219a8108892acf6b19abcb8cfd0db84cd4944",
"OCR2OffchainPublicKey": "7435cf08d8b51ed7b06009dc5bee1a9f55356e2b12e35643b92703175cbe61b8",
"OCR2ConfigPublicKey": "6d28e38b2247862899c5b980cb452bcb3f70e205ebbcc29e4160618e4b773073",
"CSAPublicKey": "csa_2a5dc332b7a57a0791733338bdc4b92327d4b75618c9bbc590b776c170828dba"
},
{
"EthAddress": "0x93039932B12ef661246807E72842701F85841121",
"P2PPeerID": "12D3KooWLV8XD6rdR2JBDtQ3JMdMD9sT9YBPVXP2hv3NmDyvir8A",
"OCR2BundleID": "ade8e16d038352098ec7df13e950f73f232db8eb80ff6393310ae2e019fccba6",
"OCR2OnchainPublicKey": "5008946f5edc82cbe0dad08c8969941b367c4ab0",
"OCR2OffchainPublicKey": "7c22530085a9e46d6e60a1c2ef4e592e68c3409ced283dc076ffef1c1bd3ae79",
"OCR2ConfigPublicKey": "caf89c07e24ddc61bf5039b351c48d39748b86f8eec5e9d65932e9bf30d4925b",
"CSAPublicKey": "csa_8867d2dc3246eb332b9c496177d0723c1f5703fdaa5edb1d67b14b49e28fc928"
},
{
"EthAddress": "0x328ed819a3080cf7890073E8d1De37D604d19930",
"P2PPeerID": "12D3KooWHUxfya9Y47ngEFvkuBqxuriuxUQxSTzugUsiQrFpn2jG",
"OCR2BundleID": "2a04702dfa7d091d7dbcaa7137c68661fcfed7f049340e19f579d3c6ea5c082a",
"OCR2OnchainPublicKey": "f0ac550f06fd4a7d79e818fc25b50061cd298baf",
"OCR2OffchainPublicKey": "9d8ef6fc381d59610f71836531d0adedb7e3bc8b7266eb5507dbc3e220a90330",
"OCR2ConfigPublicKey": "eb5e1531eb160e050cbf746a1f0ff9c5e417d880c531f7ba419024e4895db86b",
"CSAPublicKey": "csa_f7a6d71a3c1f3ea22228544a77f6e2ebc990eedd8729770c7d6e670a47675551"
},
{
"EthAddress": "0x23d082e64A17aA3afd629227Ff005b40D757cdE3",
"P2PPeerID": "12D3KooWCMTrMr4wAGTpTPrBouAH45BgmvrPZhBCbNVgZX6SuP5v",
"OCR2BundleID": "2d38534a02caac02dbead64d3d16b297323d10f1b62ad27c75472c0b1f46b3e0",
"OCR2OnchainPublicKey": "b149ebc05ba7952bedf8b8c112a2cc9b0664f586",
"OCR2OffchainPublicKey": "f4db9a461004567e8388a25ff2326dcc02a6d8fe524e1678733431e44338597f",
"OCR2ConfigPublicKey": "c3d4b8ddd441e46e07c911b1427b21cc8d9bdb328988a96570300c3420d41943",
"CSAPublicKey": "csa_5594bc4bcccf6f0c0f9b430033ff6f353a03dce3bf00f35cbe8e9e787371239f"
},
{
"EthAddress": "0x19111364C2F25c4efFfABfedeA3aFa770E229BD5",
"P2PPeerID": "12D3KooWLiHtrWGmX2YeiYyDRQ8ZiffseRk7Vjnm1Zp8EwVRwKez",
"OCR2BundleID": "1b7eba957da13a94a0325f49328d6b94a5cde993bb0938eb5bc980c969684f36",
"OCR2OnchainPublicKey": "ccf7768128eff05b142d10dbb1487422e512c62e",
"OCR2OffchainPublicKey": "f473ec18217edb0712d4c5a6140eb658705465025ecd00b5cffac33ad4d2e301",
"OCR2ConfigPublicKey": "a2f3b256fa2eb033b04c5eacd1fe1f9a130a533c6da045953a0e71e1a9adaf21",
"CSAPublicKey": "csa_a86dceb6516d64dd0d7029463e86fb67c880b049291e153c1121f3ceea894fc9"
}
]`)

var pubKeys []ksdeploy.NodeKeys
err := json.Unmarshal(publicKeys, &pubKeys)
if err != nil {
panic(err)
}

config := []byte(`{
"MaxQueryLengthBytes": 1000000,
"MaxObservationLengthBytes": 1000000,
"MaxReportLengthBytes": 1000000,
"MaxRequestBatchSize": 1000,
"UniqueReports": true,
"DeltaProgressMillis": 5000,
"DeltaResendMillis": 5000,
"DeltaInitialMillis": 5000,
"DeltaRoundMillis": 2000,
"DeltaGraceMillis": 500,
"DeltaCertifiedCommitRequestMillis": 1000,
"DeltaStageMillis": 30000,
"MaxRoundsPerEpoch": 10,
"TransmissionSchedule": [4],
"MaxDurationQueryMillis": 1000,
"MaxDurationObservationMillis": 1000,
"MaxDurationReportMillis": 1000,
"MaxDurationAcceptMillis": 1000,
"MaxDurationTransmitMillis": 1000,
"MaxFaultyOracles": 1}`)
var cfg keystone.OracleConfig
err = json.Unmarshal(config, &cfg)
if err != nil {
panic(err)
}

ocrConfig, err := ksdeploy.GenerateOCR3Config(cfg, pubKeys, deployment.XXXGenerateTestOCRSecrets())

Check failure on line 104 in core/scripts/keystone/src/generate_ocr3_config.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint (core/scripts)

ineffectual assignment to err (ineffassign)

// Convert to JSON
jsonData, err := json.MarshalIndent(ocrConfig, "", " ")
if err != nil {
panic(err)
}

// Generate a json file in `./testdata/OCR3Config.json`
err = os.WriteFile("./OCR3LocalConfig.json", jsonData, 0644)

Check failure on line 113 in core/scripts/keystone/src/generate_ocr3_config.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint (core/scripts)

G306: Expect WriteFile permissions to be 0600 or less (gosec)
if err != nil {
panic(err)
}
}

0 comments on commit aa4de36

Please sign in to comment.