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

(feat): Update Functions core/scripts oracle.toml template #10409

Merged
merged 3 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 7 additions & 3 deletions core/scripts/functions/src/generate_jobspecs_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ func (g *generateJobSpecs) Run(args []string) {
donID := fs.String("donid", "", "don id string")
routerAddress := fs.String("contract", "", "router contract address")
truncateHostname := fs.Bool("truncateboothostname", false, "truncate host name to first segment (needed for staging DONs)")
gatewayID := fs.String("gatewayid", "", "gateway id string")
gatewayURL := fs.String("gatewayurl", "", "gateway url string")
Copy link
Contributor

Choose a reason for hiding this comment

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

soon we will be moving to a config file... due to lots of variables.

err := fs.Parse(args)
if err != nil || nodesFile == nil || *nodesFile == "" || routerAddress == nil || *routerAddress == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

check for nil here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it actually a required field?
I was going off of since we aren't checking things like donID.. but looks like that might just be out of date and we should require that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think everything that is in latest oracle.toml should be required.

fs.Usage()
Expand All @@ -45,7 +47,7 @@ func (g *generateJobSpecs) Run(args []string) {
helpers.PanicErr(err)

bootHost := nodes[0].url.Host
lines = replacePlaceholders(lines, *donID, *chainID, *p2pPort, *routerAddress, bootHost, &bootstrapNode, &bootstrapNode, *truncateHostname)
lines = replacePlaceholders(lines, *donID, *chainID, *p2pPort, *routerAddress, bootHost, &bootstrapNode, &bootstrapNode, *truncateHostname, *gatewayID, *gatewayURL)
outputPath := filepath.Join(artefactsDir, bootHost+".toml")
err = writeLines(lines, outputPath)
helpers.PanicErr(err)
Expand All @@ -54,15 +56,15 @@ func (g *generateJobSpecs) Run(args []string) {
lines, err = readLines(filepath.Join(templatesDir, oracleSpecTemplate))
helpers.PanicErr(err)
for i := 1; i < len(nodes); i++ {
oracleLines := replacePlaceholders(lines, *donID, *chainID, *p2pPort, *routerAddress, bootHost, &bootstrapNode, &nca[i], *truncateHostname)
oracleLines := replacePlaceholders(lines, *donID, *chainID, *p2pPort, *routerAddress, bootHost, &bootstrapNode, &nca[i], *truncateHostname, *gatewayID, *gatewayURL)
outputPath := filepath.Join(artefactsDir, nodes[i].url.Host+".toml")
err = writeLines(oracleLines, outputPath)
helpers.PanicErr(err)
fmt.Println("Saved oracle node jobspec:", outputPath)
}
}

func replacePlaceholders(lines []string, donID string, chainID, p2pPort int64, routerAddress, bootHost string, boot *NodeKeys, node *NodeKeys, truncateHostname bool) (output []string) {
func replacePlaceholders(lines []string, donID string, chainID, p2pPort int64, routerAddress, bootHost string, boot *NodeKeys, node *NodeKeys, truncateHostname bool, gatewayID string, gatewayURL string) (output []string) {
chainIDStr := strconv.FormatInt(chainID, 10)
if truncateHostname {
bootHost = bootHost[:strings.IndexByte(bootHost, '.')]
Expand All @@ -77,6 +79,8 @@ func replacePlaceholders(lines []string, donID string, chainID, p2pPort int64, r
l = strings.Replace(l, "{{p2p_bootstrapper}}", bootstrapper, 1)
l = strings.Replace(l, "{{timestamp}}", ts, 1)
l = strings.Replace(l, "{{don_id}}", donID, 1)
l = strings.Replace(l, "{{gateway_id}}", gatewayID, 1)
l = strings.Replace(l, "{{gateway_url}}", gatewayURL, 1)
output = append(output, l)
}
return
Expand Down
6 changes: 5 additions & 1 deletion core/scripts/functions/templates/oracle.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,8 @@ maxSecretsSizesList = [10_240, 20_480, 51_200, 102_400, 307_200, 512_000, 1_048_
NodeAddress = "{{node_eth_address}}"

[pluginConfig.gatewayConnectorConfig.WsClientConfig]
HandshakeTimeoutMillis = 1_000
HandshakeTimeoutMillis = 1_000

[[pluginConfig.gatewayConnectorConfig.Gateways]]
Id = "{{gateway_id}}"
URL = "{{gateway_url}}"
Loading