Skip to content

Commit

Permalink
Add additional logging around node sets and key fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryNguyen5 committed Nov 1, 2024
1 parent a9d485c commit edbf331
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/scripts/keystone/src/01_provision_keystone.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func (g *provisionKeystone) Run(args []string) {
/// when it comes to nodesets
err = os.RemoveAll(*nodeSetsPath)
PanicErr(err)
fmt.Println("Collecting node sets...")
nodeSets := downloadNodeSets(*chainID, *nodeSetsPath, *nodeSetSize)

if *clean {
Expand Down
9 changes: 5 additions & 4 deletions core/scripts/keystone/src/99_fetch_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func mustFetchNodeKeys(chainID int64, nodes []NodeWthCreds, createAptosKeys bool
for _, n := range nodes {
api := newNodeAPI(n)
// Get eth key
fmt.Printf("Fetching ETH keys for node %s\n", n.ServiceName)
eKey := api.mustExec(api.methods.ListETHKeys)
ethKeys := mustJSON[[]presenters.ETHKeyResource](eKey)
ethAddress, err := findFirstGoodEthKeyAddress(chainID, *ethKeys)
Expand All @@ -121,6 +122,7 @@ func mustFetchNodeKeys(chainID int64, nodes []NodeWthCreds, createAptosKeys bool
}

// Get p2p key
fmt.Printf("Fetching P2P key for node %s\n", n.ServiceName)
p2pKeys := api.mustExec(api.methods.ListP2PKeys)
p2pKey := mustJSON[[]presenters.P2PKeyResource](p2pKeys)
if len(*p2pKey) != 1 {
Expand All @@ -135,6 +137,7 @@ func mustFetchNodeKeys(chainID int64, nodes []NodeWthCreds, createAptosKeys bool
expectedBundleLen := 1

// evm key bundles
fmt.Printf("Fetching OCR2 EVM key bundles for node %s\n", n.ServiceName)
ocr2EvmBundles := getTrimmedEVMOCR2KBs(*ocr2Bundles)
evmBundleLen := len(ocr2EvmBundles)
if evmBundleLen < expectedBundleLen {
Expand All @@ -150,9 +153,11 @@ func mustFetchNodeKeys(chainID int64, nodes []NodeWthCreds, createAptosKeys bool
// aptos key bundles
var ocr2AptosBundles []OCR2AptosKBTrimmed
if createAptosKeys {
fmt.Printf("Fetching OCR2 Aptos key bundles for node %s\n", n.ServiceName)
ocr2AptosBundles = createAptosOCR2KB(ocr2Bundles, expectedBundleLen, api)
}

fmt.Printf("Fetching CSA keys for node %s\n", n.ServiceName)
csaKeys := api.mustExec(api.methods.ListCSAKeys)
csaKeyResources := mustJSON[[]presenters.CSAKeyResource](csaKeys)
csaPubKey, err := findFirstCSAPublicKey(*csaKeyResources)
Expand Down Expand Up @@ -237,7 +242,6 @@ func getOrCreateAptosKey(api *nodeAPI) string {
PanicErr(errors.New("node must have single aptos key"))
}

fmt.Printf("Node has aptos account %s\n", aptosKeys[0].Account)
aptosAccount := aptosKeys[0].Account
api.output.Reset()

Expand Down Expand Up @@ -274,9 +278,6 @@ func findFirstCSAPublicKey(csaKeyResources []presenters.CSAKeyResource) (string,
func findFirstGoodEthKeyAddress(chainID int64, ethKeys []presenters.ETHKeyResource) (string, error) {
for _, ethKey := range ethKeys {
if ethKey.EVMChainID.Equal(ubig.NewI(chainID)) && !ethKey.Disabled {
if ethKey.EthBalance == nil || ethKey.EthBalance.IsZero() {
fmt.Println("WARN: selected ETH address has zero balance", ethKey.Address)
}
return ethKey.Address, nil
}
}
Expand Down

0 comments on commit edbf331

Please sign in to comment.