Skip to content
Open
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
46 changes: 36 additions & 10 deletions node/cmd/guardiand/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,11 @@ var (
accountantNttKeyPath *string
accountantNttKeyPassPhrase *string

aptosRPC *string
aptosAccount *string
aptosHandle *string
aptosRPC *string
aptosAccount *string
aptosHandle *string
aptosIndexerRPC *string
aptosIndexerToken *string

movementRPC *string
movementAccount *string
Expand Down Expand Up @@ -389,6 +391,8 @@ func init() {
aptosRPC = node.RegisterFlagWithValidationOrFail(NodeCmd, "aptosRPC", "Aptos RPC URL", "http://aptos:8080", []string{"http", "https"})
aptosAccount = NodeCmd.Flags().String("aptosAccount", "", "aptos account")
aptosHandle = NodeCmd.Flags().String("aptosHandle", "", "aptos handle")
aptosIndexerRPC = node.RegisterFlagWithValidationOrFail(NodeCmd, "aptosIndexerRPC", "Aptos Indexer RPC URL", "", []string{"http", "https"})
aptosIndexerToken = NodeCmd.Flags().String("aptosIndexerToken", "", "Aptos Indexer access token")

movementRPC = node.RegisterFlagWithValidationOrFail(NodeCmd, "movementRPC", "Movement RPC URL", "", []string{"http", "https"})
movementAccount = NodeCmd.Flags().String("movementAccount", "", "movement account")
Expand Down Expand Up @@ -925,8 +929,24 @@ func runNode(cmd *cobra.Command, args []string) {
logger.Fatal("Both --nearContract and --nearRPC must be set or both unset")
}

if !argsConsistent([]string{*aptosAccount, *aptosRPC, *aptosHandle}) {
logger.Fatal("Either --aptosAccount, --aptosRPC and --aptosHandle must all be set or all unset")
// Validate Aptos configuration - support both legacy and indexer modes
aptosBasic := []string{*aptosRPC, *aptosAccount, *aptosHandle}

if !argsConsistent(aptosBasic) {
logger.Fatal("Either --aptosRPC, --aptosAccount, and --aptosHandle must all be set together or all unset")
}

// If Aptos is enabled, validate indexer configuration
if *aptosRPC != "" {
// Only aptosIndexerRPC is required for indexer mode, token is optional
useIndexerMode := *aptosIndexerRPC != ""

// Log which mode will be used
Copy link
Contributor

Choose a reason for hiding this comment

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

nice, this will be critical to debugging. do you think this is worth a (really short) feature flag in the heartbeat as well?

if useIndexerMode {
logger.Info("Aptos watcher will run in indexer mode (GraphQL + REST)")
} else {
logger.Info("Aptos watcher will run in legacy mode (REST API only)")
}
}

if !argsConsistent([]string{*movementAccount, *movementRPC, *movementHandle}) {
Expand Down Expand Up @@ -1658,12 +1678,18 @@ func runNode(cmd *cobra.Command, args []string) {
}

if shouldStart(aptosRPC) {
// Determine if we should use indexer mode (only aptosIndexerRPC required)
useIndexer := *aptosIndexerRPC != ""

wc := &aptos.WatcherConfig{
NetworkID: "aptos",
ChainID: vaa.ChainIDAptos,
Rpc: *aptosRPC,
Account: *aptosAccount,
Handle: *aptosHandle,
NetworkID: "aptos",
ChainID: vaa.ChainIDAptos,
Rpc: *aptosRPC,
Account: *aptosAccount,
Handle: *aptosHandle,
IndexerRpc: *aptosIndexerRPC,
IndexerToken: *aptosIndexerToken,
UseIndexer: useIndexer,
}
watcherConfigs = append(watcherConfigs, wc)
}
Expand Down
15 changes: 9 additions & 6 deletions node/pkg/watchers/aptos/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ import (
)

type WatcherConfig struct {
NetworkID watchers.NetworkID // human readable name
ChainID vaa.ChainID // ChainID
Rpc string
Account string
Handle string
NetworkID watchers.NetworkID // human readable name
ChainID vaa.ChainID // ChainID
Rpc string
Account string
Handle string
IndexerRpc string
IndexerToken string
UseIndexer bool // true for indexer mode, false for legacy mode
}

func (wc *WatcherConfig) GetNetworkID() watchers.NetworkID {
Expand All @@ -35,5 +38,5 @@ func (wc *WatcherConfig) Create(
_ chan<- *common.GuardianSet,
_ common.Environment,
) (supervisor.Runnable, interfaces.Reobserver, error) {
return NewWatcher(wc.ChainID, wc.NetworkID, wc.Rpc, wc.Account, wc.Handle, msgC, obsvReqC).Run, nil, nil
return NewWatcher(wc.ChainID, wc.NetworkID, wc.Rpc, wc.Account, wc.Handle, wc.IndexerRpc, wc.IndexerToken, wc.UseIndexer, msgC, obsvReqC).Run, nil, nil
}
Loading
Loading