diff --git a/README.md b/README.md index 2a99195b..0ec1ac4e 100644 --- a/README.md +++ b/README.md @@ -139,9 +139,9 @@ The relayer is configured via a JSON file, the path to which is passed in via th - The address of the destination account that will receive the Warp message. -`"source-subnets": []SourceSubnets` +`"source-blockchains": []SourceBlockchains` -- The list of source subnets to support. Each `SourceSubnet` has the following configuration: +- The list of source subnets to support. Each `SourceBlockchain` has the following configuration: `"subnet-id": string` @@ -175,9 +175,9 @@ The relayer is configured via a JSON file, the path to which is passed in via th - The block height at which to back-process transactions from the source subnet. If the database already contains a later block height for the source subnet, then that will be used instead. Must be non-zero. -`"destination-subnets": []DestinationSubnets` +`"destination-blockchains": []DestinationBlockchains` -- The list of destination subnets to support. Each `DestinationSubnet` has the following configuration: +- The list of destination subnets to support. Each `DestinationBlockchain` has the following configuration: `"subnet-id": string` diff --git a/config/config.go b/config/config.go index 87a85f03..4dba303a 100644 --- a/config/config.go +++ b/config/config.go @@ -55,7 +55,7 @@ type ManualWarpMessage struct { destinationAddress common.Address } -type SourceSubnet struct { +type SourceBlockchain struct { SubnetID string `mapstructure:"subnet-id" json:"subnet-id"` BlockchainID string `mapstructure:"blockchain-id" json:"blockchain-id"` VM string `mapstructure:"vm" json:"vm"` @@ -69,7 +69,7 @@ type SourceSubnet struct { supportedDestinations set.Set[ids.ID] } -type DestinationSubnet struct { +type DestinationBlockchain struct { SubnetID string `mapstructure:"subnet-id" json:"subnet-id"` BlockchainID string `mapstructure:"blockchain-id" json:"blockchain-id"` VM string `mapstructure:"vm" json:"vm"` @@ -86,14 +86,14 @@ type WarpQuorum struct { } type Config struct { - LogLevel string `mapstructure:"log-level" json:"log-level"` - PChainAPIURL string `mapstructure:"p-chain-api-url" json:"p-chain-api-url"` - InfoAPIURL string `mapstructure:"info-api-url" json:"info-api-url"` - StorageLocation string `mapstructure:"storage-location" json:"storage-location"` - SourceSubnets []*SourceSubnet `mapstructure:"source-subnets" json:"source-subnets"` - DestinationSubnets []*DestinationSubnet `mapstructure:"destination-subnets" json:"destination-subnets"` - ProcessMissedBlocks bool `mapstructure:"process-missed-blocks" json:"process-missed-blocks"` - ManualWarpMessages []*ManualWarpMessage `mapstructure:"manual-warp-messages" json:"manual-warp-messages"` + LogLevel string `mapstructure:"log-level" json:"log-level"` + PChainAPIURL string `mapstructure:"p-chain-api-url" json:"p-chain-api-url"` + InfoAPIURL string `mapstructure:"info-api-url" json:"info-api-url"` + StorageLocation string `mapstructure:"storage-location" json:"storage-location"` + SourceBlockchains []*SourceBlockchain `mapstructure:"source-blockchains" json:"source-blockchains"` + DestinationBlockchains []*DestinationBlockchain `mapstructure:"destination-blockchains" json:"destination-blockchains"` + ProcessMissedBlocks bool `mapstructure:"process-missed-blocks" json:"process-missed-blocks"` + ManualWarpMessages []*ManualWarpMessage `mapstructure:"manual-warp-messages" json:"manual-warp-messages"` // convenience fields to access the source subnet and chain IDs after initialization sourceSubnetIDs []ids.ID @@ -136,10 +136,10 @@ func BuildConfig(v *viper.Viper) (Config, bool, error) { if err := v.UnmarshalKey(ManualWarpMessagesKey, &cfg.ManualWarpMessages); err != nil { return Config{}, false, fmt.Errorf("failed to unmarshal manual warp messages: %w", err) } - if err := v.UnmarshalKey(DestinationSubnetsKey, &cfg.DestinationSubnets); err != nil { + if err := v.UnmarshalKey(DestinationBlockchainsKey, &cfg.DestinationBlockchains); err != nil { return Config{}, false, fmt.Errorf("failed to unmarshal destination subnets: %w", err) } - if err := v.UnmarshalKey(SourceSubnetsKey, &cfg.SourceSubnets); err != nil { + if err := v.UnmarshalKey(SourceBlockchainsKey, &cfg.SourceBlockchains); err != nil { return Config{}, false, fmt.Errorf("failed to unmarshal source subnets: %w", err) } @@ -150,19 +150,19 @@ func BuildConfig(v *viper.Viper) (Config, bool, error) { accountPrivateKey := v.GetString(AccountPrivateKeyKey) if accountPrivateKey != "" { optionOverwritten = true - for i := range cfg.DestinationSubnets { - cfg.DestinationSubnets[i].AccountPrivateKey = utils.SanitizeHexString(accountPrivateKey) + for i := range cfg.DestinationBlockchains { + cfg.DestinationBlockchains[i].AccountPrivateKey = utils.SanitizeHexString(accountPrivateKey) } } else { // Otherwise, check for private keys suffixed with the chain ID and set it for that subnet // Since the key is dynamic, this is only possible through environment variables - for i, subnet := range cfg.DestinationSubnets { + for i, subnet := range cfg.DestinationBlockchains { subnetAccountPrivateKey := os.Getenv(fmt.Sprintf("%s_%s", accountPrivateKeyEnvVarName, subnet.BlockchainID)) if subnetAccountPrivateKey != "" { optionOverwritten = true - cfg.DestinationSubnets[i].AccountPrivateKey = utils.SanitizeHexString(subnetAccountPrivateKey) + cfg.DestinationBlockchains[i].AccountPrivateKey = utils.SanitizeHexString(subnetAccountPrivateKey) } else { - cfg.DestinationSubnets[i].AccountPrivateKey = utils.SanitizeHexString(cfg.DestinationSubnets[i].AccountPrivateKey) + cfg.DestinationBlockchains[i].AccountPrivateKey = utils.SanitizeHexString(cfg.DestinationBlockchains[i].AccountPrivateKey) } } } @@ -178,10 +178,10 @@ func BuildConfig(v *viper.Viper) (Config, bool, error) { // Does not modify the public fields as derived from the configuration passed to the application, // but does initialize private fields available through getters func (c *Config) Validate() error { - if len(c.SourceSubnets) == 0 { + if len(c.SourceBlockchains) == 0 { return errors.New("relayer not configured to relay from any subnets. A list of source subnets must be provided in the configuration file") } - if len(c.DestinationSubnets) == 0 { + if len(c.DestinationBlockchains) == 0 { return errors.New("relayer not configured to relay to any subnets. A list of destination subnets must be provided in the configuration file") } if _, err := url.ParseRequestURI(c.PChainAPIURL); err != nil { @@ -192,8 +192,8 @@ func (c *Config) Validate() error { } // Validate the destination chains - destinationChains := set.NewSet[string](len(c.DestinationSubnets)) - for _, s := range c.DestinationSubnets { + destinationChains := set.NewSet[string](len(c.DestinationBlockchains)) + for _, s := range c.DestinationBlockchains { if err := s.Validate(); err != nil { return err } @@ -204,10 +204,10 @@ func (c *Config) Validate() error { } // Validate the source chains and store the source subnet and chain IDs for future use - sourceBlockchains := set.NewSet[string](len(c.SourceSubnets)) + sourceBlockchains := set.NewSet[string](len(c.SourceBlockchains)) var sourceSubnetIDs []ids.ID var sourceBlockchainIDs []ids.ID - for _, s := range c.SourceSubnets { + for _, s := range c.SourceBlockchains { // Validate configuration if err := s.Validate(&destinationChains); err != nil { return err @@ -359,7 +359,7 @@ func getWarpQuorum( func (c *Config) InitializeWarpQuorums() error { // Fetch the Warp quorum values for each destination subnet. - for _, destinationSubnet := range c.DestinationSubnets { + for _, destinationSubnet := range c.DestinationBlockchains { err := destinationSubnet.initializeWarpQuorum() if err != nil { return fmt.Errorf("failed to initialize Warp quorum for destination subnet %s: %w", destinationSubnet.SubnetID, err) @@ -369,14 +369,14 @@ func (c *Config) InitializeWarpQuorums() error { return nil } -func (s *SourceSubnet) GetSupportedDestinations() set.Set[ids.ID] { +func (s *SourceBlockchain) GetSupportedDestinations() set.Set[ids.ID] { return s.supportedDestinations } // Validates the source subnet configuration, including verifying that the supported destinations are present in destinationBlockchainIDs // Does not modify the public fields as derived from the configuration passed to the application, // but does initialize private fields available through getters -func (s *SourceSubnet) Validate(destinationBlockchainIDs *set.Set[string]) error { +func (s *SourceBlockchain) Validate(destinationBlockchainIDs *set.Set[string]) error { if _, err := ids.FromString(s.SubnetID); err != nil { return fmt.Errorf("invalid subnetID in source subnet configuration. Provided ID: %s", s.SubnetID) } @@ -441,7 +441,7 @@ func (s *SourceSubnet) Validate(destinationBlockchainIDs *set.Set[string]) error } // Validatees the destination subnet configuration -func (s *DestinationSubnet) Validate() error { +func (s *DestinationBlockchain) Validate() error { if _, err := ids.FromString(s.SubnetID); err != nil { return fmt.Errorf("invalid subnetID in source subnet configuration. Provided ID: %s", s.SubnetID) } @@ -469,7 +469,7 @@ func (s *DestinationSubnet) Validate() error { return nil } -func (s *DestinationSubnet) initializeWarpQuorum() error { +func (s *DestinationBlockchain) initializeWarpQuorum() error { blockchainID, err := ids.FromString(s.BlockchainID) if err != nil { return fmt.Errorf("invalid blockchainID in configuration. error: %w", err) @@ -494,7 +494,7 @@ func (s *DestinationSubnet) initializeWarpQuorum() error { } // Get the private key and derive the wallet address from a relayer's configured private key for a given destination subnet. -func (s *DestinationSubnet) GetRelayerAccountInfo() (*ecdsa.PrivateKey, common.Address, error) { +func (s *DestinationBlockchain) GetRelayerAccountInfo() (*ecdsa.PrivateKey, common.Address, error) { pk, err := crypto.HexToECDSA(s.AccountPrivateKey) if err != nil { return nil, common.Address{}, err @@ -513,7 +513,7 @@ func (c *Config) GetSourceIDs() ([]ids.ID, []ids.ID) { } func (c *Config) GetWarpQuorum(blockchainID ids.ID) (WarpQuorum, error) { - for _, s := range c.DestinationSubnets { + for _, s := range c.DestinationBlockchains { if blockchainID.String() == s.BlockchainID { return s.warpQuorum, nil } diff --git a/config/config_test.go b/config/config_test.go index 130c47e1..2f9c0c4e 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -33,7 +33,7 @@ var ( LogLevel: "info", PChainAPIURL: "http://test.avax.network", InfoAPIURL: "http://test.avax.network", - SourceSubnets: []*SourceSubnet{ + SourceBlockchains: []*SourceBlockchain{ { RPCEndpoint: fmt.Sprintf("http://test.avax.network/ext/bc/%s/rpc", testBlockchainID), WSEndpoint: fmt.Sprintf("ws://test.avax.network/ext/bc/%s/ws", testBlockchainID), @@ -47,7 +47,7 @@ var ( }, }, }, - DestinationSubnets: []*DestinationSubnet{ + DestinationBlockchains: []*DestinationBlockchain{ { RPCEndpoint: fmt.Sprintf("http://test.avax.network/ext/bc/%s/rpc", testBlockchainID), BlockchainID: testBlockchainID, @@ -70,12 +70,12 @@ func TestGetRelayerAccountInfo(t *testing.T) { testCases := []struct { name string - s DestinationSubnet + s DestinationBlockchain expectedResult retStruct }{ { name: "valid", - s: DestinationSubnet{ + s: DestinationBlockchain{ AccountPrivateKey: "56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027", }, expectedResult: retStruct{ @@ -88,7 +88,7 @@ func TestGetRelayerAccountInfo(t *testing.T) { }, { name: "invalid 0x prefix", - s: DestinationSubnet{ + s: DestinationBlockchain{ AccountPrivateKey: "0x56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027", }, expectedResult: retStruct{ @@ -101,7 +101,7 @@ func TestGetRelayerAccountInfo(t *testing.T) { }, { name: "invalid private key", - s: DestinationSubnet{ + s: DestinationBlockchain{ AccountPrivateKey: "invalid56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027", }, expectedResult: retStruct{ @@ -168,9 +168,9 @@ func TestGetRelayerAccountPrivateKey_set_pk_in_config(t *testing.T) { expectedOverwritten: false, resultVerifier: func(c Config) bool { // All destination subnets should have the default private key - for i, subnet := range c.DestinationSubnets { - if subnet.AccountPrivateKey != utils.SanitizeHexString(testValidConfig.DestinationSubnets[i].AccountPrivateKey) { - fmt.Printf("expected: %s, got: %s\n", utils.SanitizeHexString(testValidConfig.DestinationSubnets[i].AccountPrivateKey), subnet.AccountPrivateKey) + for i, subnet := range c.DestinationBlockchains { + if subnet.AccountPrivateKey != utils.SanitizeHexString(testValidConfig.DestinationBlockchains[i].AccountPrivateKey) { + fmt.Printf("expected: %s, got: %s\n", utils.SanitizeHexString(testValidConfig.DestinationBlockchains[i].AccountPrivateKey), subnet.AccountPrivateKey) return false } } @@ -185,26 +185,26 @@ func TestGetRelayerAccountPrivateKey_set_pk_with_subnet_env(t *testing.T) { baseConfig: testValidConfig, configModifier: func(c Config) Config { // Add a second destination subnet. This PK should NOT be overwritten - newSubnet := *c.DestinationSubnets[0] + newSubnet := *c.DestinationBlockchains[0] newSubnet.BlockchainID = testBlockchainID2 newSubnet.AccountPrivateKey = testPk1 - c.DestinationSubnets = append(c.DestinationSubnets, &newSubnet) + c.DestinationBlockchains = append(c.DestinationBlockchains, &newSubnet) return c }, envSetter: func() { // Overwrite the PK for the first subnet using an env var - varName := fmt.Sprintf("%s_%s", accountPrivateKeyEnvVarName, testValidConfig.DestinationSubnets[0].BlockchainID) + varName := fmt.Sprintf("%s_%s", accountPrivateKeyEnvVarName, testValidConfig.DestinationBlockchains[0].BlockchainID) t.Setenv(varName, testPk2) }, expectedOverwritten: true, resultVerifier: func(c Config) bool { // All destination subnets should have testPk1 - if c.DestinationSubnets[0].AccountPrivateKey != utils.SanitizeHexString(testPk2) { - fmt.Printf("expected: %s, got: %s\n", utils.SanitizeHexString(testPk2), c.DestinationSubnets[0].AccountPrivateKey) + if c.DestinationBlockchains[0].AccountPrivateKey != utils.SanitizeHexString(testPk2) { + fmt.Printf("expected: %s, got: %s\n", utils.SanitizeHexString(testPk2), c.DestinationBlockchains[0].AccountPrivateKey) return false } - if c.DestinationSubnets[1].AccountPrivateKey != utils.SanitizeHexString(testPk1) { - fmt.Printf("expected: %s, got: %s\n", utils.SanitizeHexString(testPk1), c.DestinationSubnets[1].AccountPrivateKey) + if c.DestinationBlockchains[1].AccountPrivateKey != utils.SanitizeHexString(testPk1) { + fmt.Printf("expected: %s, got: %s\n", utils.SanitizeHexString(testPk1), c.DestinationBlockchains[1].AccountPrivateKey) return false } return true @@ -217,10 +217,10 @@ func TestGetRelayerAccountPrivateKey_set_pk_with_global_env(t *testing.T) { baseConfig: testValidConfig, configModifier: func(c Config) Config { // Add a second destination subnet. This PK SHOULD be overwritten - newSubnet := *c.DestinationSubnets[0] + newSubnet := *c.DestinationBlockchains[0] newSubnet.BlockchainID = testBlockchainID2 newSubnet.AccountPrivateKey = testPk1 - c.DestinationSubnets = append(c.DestinationSubnets, &newSubnet) + c.DestinationBlockchains = append(c.DestinationBlockchains, &newSubnet) return c }, envSetter: func() { @@ -230,7 +230,7 @@ func TestGetRelayerAccountPrivateKey_set_pk_with_global_env(t *testing.T) { expectedOverwritten: true, resultVerifier: func(c Config) bool { // All destination subnets should have testPk2 - for _, subnet := range c.DestinationSubnets { + for _, subnet := range c.DestinationBlockchains { if subnet.AccountPrivateKey != utils.SanitizeHexString(testPk2) { fmt.Printf("expected: %s, got: %s\n", utils.SanitizeHexString(testPk2), subnet.AccountPrivateKey) return false @@ -253,7 +253,7 @@ func TestGetRelayerAccountInfoSkipChainConfigCheckCompatible(t *testing.T) { accountPrivateKey := "56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027" expectedAddress := "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC" - info := DestinationSubnet{ + info := DestinationBlockchain{ AccountPrivateKey: accountPrivateKey, } _, address, err := info.GetRelayerAccountInfo() @@ -388,8 +388,8 @@ func TestGetWarpQuorum(t *testing.T) { } } -func TestValidateSourceSubnet(t *testing.T) { - validSourceCfg := SourceSubnet{ +func TestValidateSourceBlockchain(t *testing.T) { + validSourceCfg := SourceBlockchain{ BlockchainID: testBlockchainID, RPCEndpoint: fmt.Sprintf("http://test.avax.network/ext/bc/%s/rpc", testBlockchainID), WSEndpoint: fmt.Sprintf("ws://test.avax.network/ext/bc/%s/ws", testBlockchainID), @@ -404,21 +404,21 @@ func TestValidateSourceSubnet(t *testing.T) { } testCases := []struct { name string - sourceSubnet func() SourceSubnet + sourceSubnet func() SourceBlockchain destinationBlockchainIDs []string expectError bool expectedSupportedDestinations []string }{ { name: "valid source subnet; explicitly supported destination", - sourceSubnet: func() SourceSubnet { return validSourceCfg }, + sourceSubnet: func() SourceBlockchain { return validSourceCfg }, destinationBlockchainIDs: []string{testBlockchainID}, expectError: false, expectedSupportedDestinations: []string{testBlockchainID}, }, { name: "valid source subnet; implicitly supported destination", - sourceSubnet: func() SourceSubnet { + sourceSubnet: func() SourceBlockchain { cfg := validSourceCfg cfg.SupportedDestinations = nil return cfg @@ -429,14 +429,14 @@ func TestValidateSourceSubnet(t *testing.T) { }, { name: "valid source subnet; partially supported destinations", - sourceSubnet: func() SourceSubnet { return validSourceCfg }, + sourceSubnet: func() SourceBlockchain { return validSourceCfg }, destinationBlockchainIDs: []string{testBlockchainID, testBlockchainID2}, expectError: false, expectedSupportedDestinations: []string{testBlockchainID}, }, { name: "valid source subnet; unsupported destinations", - sourceSubnet: func() SourceSubnet { return validSourceCfg }, + sourceSubnet: func() SourceBlockchain { return validSourceCfg }, destinationBlockchainIDs: []string{testBlockchainID2}, expectError: true, expectedSupportedDestinations: []string{}, diff --git a/config/keys.go b/config/keys.go index b51ce8d5..274ec6cb 100644 --- a/config/keys.go +++ b/config/keys.go @@ -5,14 +5,14 @@ package config // Top-level configuration keys const ( - ConfigFileKey = "config-file" - LogLevelKey = "log-level" - PChainAPIURLKey = "p-chain-api-url" - InfoAPIURLKey = "info-api-url" - SourceSubnetsKey = "source-subnets" - DestinationSubnetsKey = "destination-subnets" - AccountPrivateKeyKey = "account-private-key" - StorageLocationKey = "storage-location" - ProcessMissedBlocksKey = "process-missed-blocks" - ManualWarpMessagesKey = "manual-warp-messages" + ConfigFileKey = "config-file" + LogLevelKey = "log-level" + PChainAPIURLKey = "p-chain-api-url" + InfoAPIURLKey = "info-api-url" + SourceBlockchainsKey = "source-blockchains" + DestinationBlockchainsKey = "destination-blockchains" + AccountPrivateKeyKey = "account-private-key" + StorageLocationKey = "storage-location" + ProcessMissedBlocksKey = "process-missed-blocks" + ManualWarpMessagesKey = "manual-warp-messages" ) diff --git a/main/main.go b/main/main.go index 49036011..4a816856 100644 --- a/main/main.go +++ b/main/main.go @@ -189,7 +189,7 @@ func main() { // Create relayers for each of the subnets configured as a source errGroup, ctx := errgroup.WithContext(context.Background()) - for _, s := range cfg.SourceSubnets { + for _, s := range cfg.SourceBlockchains { blockchainID, err := ids.FromString(s.BlockchainID) if err != nil { logger.Error( @@ -236,7 +236,7 @@ func runRelayer( logger logging.Logger, metrics *relayer.MessageRelayerMetrics, db database.RelayerDatabase, - sourceSubnetInfo config.SourceSubnet, + sourceSubnetInfo config.SourceBlockchain, pChainClient platformvm.Client, network *peers.AppRequestNetwork, responseChan chan message.InboundMessage, diff --git a/relayer/relayer.go b/relayer/relayer.go index 586273e8..e3a8825a 100644 --- a/relayer/relayer.go +++ b/relayer/relayer.go @@ -68,7 +68,7 @@ func NewRelayer( logger logging.Logger, metrics *MessageRelayerMetrics, db database.RelayerDatabase, - sourceSubnetInfo config.SourceSubnet, + sourceSubnetInfo config.SourceBlockchain, pChainClient platformvm.Client, network *peers.AppRequestNetwork, responseChan chan message.InboundMessage, diff --git a/tests/basic_relay.go b/tests/basic_relay.go index 3d33f0c9..89c09f1f 100644 --- a/tests/basic_relay.go +++ b/tests/basic_relay.go @@ -163,7 +163,7 @@ func BasicRelay(network interfaces.LocalNetwork) { // StartBlockHeight to the block height of the *third* message, we expect the relayer to skip // the first two messages on startup, but process the third. modifiedRelayerConfig := relayerConfig - modifiedRelayerConfig.SourceSubnets[0].StartBlockHeight = currHeight + modifiedRelayerConfig.SourceBlockchains[0].StartBlockHeight = currHeight modifiedRelayerConfig.ProcessMissedBlocks = true relayerConfigPath = writeRelayerConfig(modifiedRelayerConfig) diff --git a/tests/utils/utils.go b/tests/utils/utils.go index 88296c27..be3000ef 100644 --- a/tests/utils/utils.go +++ b/tests/utils/utils.go @@ -94,13 +94,13 @@ func CreateDefaultRelayerConfig( "Setting up relayer config", ) // Construct the config values for each subnet - sources := make([]*config.SourceSubnet, len(subnetsInfo)) - destinations := make([]*config.DestinationSubnet, len(subnetsInfo)) + sources := make([]*config.SourceBlockchain, len(subnetsInfo)) + destinations := make([]*config.DestinationBlockchain, len(subnetsInfo)) for i, subnetInfo := range subnetsInfo { host, port, err := teleporterTestUtils.GetURIHostAndPort(subnetInfo.NodeURIs[0]) Expect(err).Should(BeNil()) - sources[i] = &config.SourceSubnet{ + sources[i] = &config.SourceBlockchain{ SubnetID: subnetInfo.SubnetID.String(), BlockchainID: subnetInfo.BlockchainID.String(), VM: config.EVM.String(), @@ -123,7 +123,7 @@ func CreateDefaultRelayerConfig( }, } - destinations[i] = &config.DestinationSubnet{ + destinations[i] = &config.DestinationBlockchain{ SubnetID: subnetInfo.SubnetID.String(), BlockchainID: subnetInfo.BlockchainID.String(), VM: config.EVM.String(), @@ -141,13 +141,13 @@ func CreateDefaultRelayerConfig( } return config.Config{ - LogLevel: logging.Info.LowerString(), - PChainAPIURL: subnetsInfo[0].NodeURIs[0], - InfoAPIURL: subnetsInfo[0].NodeURIs[0], - StorageLocation: RelayerStorageLocation(), - ProcessMissedBlocks: false, - SourceSubnets: sources, - DestinationSubnets: destinations, + LogLevel: logging.Info.LowerString(), + PChainAPIURL: subnetsInfo[0].NodeURIs[0], + InfoAPIURL: subnetsInfo[0].NodeURIs[0], + StorageLocation: RelayerStorageLocation(), + ProcessMissedBlocks: false, + SourceBlockchains: sources, + DestinationBlockchains: destinations, } } diff --git a/vms/contract_message.go b/vms/contract_message.go index a3cf1794..f7331171 100644 --- a/vms/contract_message.go +++ b/vms/contract_message.go @@ -15,7 +15,7 @@ type ContractMessage interface { UnpackWarpMessage(unsignedMsgBytes []byte) (*warp.UnsignedMessage, error) } -func NewContractMessage(logger logging.Logger, subnetInfo config.SourceSubnet) ContractMessage { +func NewContractMessage(logger logging.Logger, subnetInfo config.SourceBlockchain) ContractMessage { switch config.ParseVM(subnetInfo.VM) { case config.EVM: return evm.NewContractMessage(logger, subnetInfo) diff --git a/vms/destination_client.go b/vms/destination_client.go index c8352367..bed8a808 100644 --- a/vms/destination_client.go +++ b/vms/destination_client.go @@ -34,7 +34,7 @@ type DestinationClient interface { DestinationBlockchainID() ids.ID } -func NewDestinationClient(logger logging.Logger, subnetInfo config.DestinationSubnet) (DestinationClient, error) { +func NewDestinationClient(logger logging.Logger, subnetInfo config.DestinationBlockchain) (DestinationClient, error) { switch config.ParseVM(subnetInfo.VM) { case config.EVM: return evm.NewDestinationClient(logger, subnetInfo) @@ -46,7 +46,7 @@ func NewDestinationClient(logger logging.Logger, subnetInfo config.DestinationSu // CreateDestinationClients creates destination clients for all subnets configured as destinations func CreateDestinationClients(logger logging.Logger, relayerConfig config.Config) (map[ids.ID]DestinationClient, error) { destinationClients := make(map[ids.ID]DestinationClient) - for _, subnetInfo := range relayerConfig.DestinationSubnets { + for _, subnetInfo := range relayerConfig.DestinationBlockchains { blockchainID, err := ids.FromString(subnetInfo.BlockchainID) if err != nil { logger.Error( diff --git a/vms/evm/contract_message.go b/vms/evm/contract_message.go index ce5dcbc7..49ace169 100644 --- a/vms/evm/contract_message.go +++ b/vms/evm/contract_message.go @@ -17,7 +17,7 @@ type contractMessage struct { logger logging.Logger } -func NewContractMessage(logger logging.Logger, subnetInfo config.SourceSubnet) *contractMessage { +func NewContractMessage(logger logging.Logger, subnetInfo config.SourceBlockchain) *contractMessage { return &contractMessage{ logger: logger, } diff --git a/vms/evm/contract_message_test.go b/vms/evm/contract_message_test.go index 269c4e56..cff0ec97 100644 --- a/vms/evm/contract_message_test.go +++ b/vms/evm/contract_message_test.go @@ -51,7 +51,7 @@ func TestUnpack(t *testing.T) { logging.JSON.ConsoleEncoder(), ), ) - m := NewContractMessage(logger, config.SourceSubnet{}) + m := NewContractMessage(logger, config.SourceBlockchain{}) testCases := []struct { name string diff --git a/vms/evm/destination_client.go b/vms/evm/destination_client.go index 9c6f4647..0be4a735 100644 --- a/vms/evm/destination_client.go +++ b/vms/evm/destination_client.go @@ -48,7 +48,7 @@ type destinationClient struct { logger logging.Logger } -func NewDestinationClient(logger logging.Logger, subnetInfo config.DestinationSubnet) (*destinationClient, error) { +func NewDestinationClient(logger logging.Logger, subnetInfo config.DestinationBlockchain) (*destinationClient, error) { // Dial the destination RPC endpoint client, err := ethclient.Dial(subnetInfo.RPCEndpoint) if err != nil { diff --git a/vms/evm/destination_client_test.go b/vms/evm/destination_client_test.go index a80a7244..c7be3413 100644 --- a/vms/evm/destination_client_test.go +++ b/vms/evm/destination_client_test.go @@ -17,7 +17,7 @@ import ( "go.uber.org/mock/gomock" ) -var destinationSubnet = config.DestinationSubnet{ +var destinationSubnet = config.DestinationBlockchain{ SubnetID: "2TGBXcnwx5PqiXWiqxAKUaNSqDguXNh1mxnp82jui68hxJSZAx", BlockchainID: "S4mMqUXe7vHsGiRAma6bv3CKnyaLssyAxmQ2KvFpX1KEvfFCD", VM: config.EVM.String(), diff --git a/vms/evm/subscriber.go b/vms/evm/subscriber.go index 760a3c4d..432c8df9 100644 --- a/vms/evm/subscriber.go +++ b/vms/evm/subscriber.go @@ -61,7 +61,7 @@ type subscriber struct { } // NewSubscriber returns a subscriber -func NewSubscriber(logger logging.Logger, subnetInfo config.SourceSubnet) *subscriber { +func NewSubscriber(logger logging.Logger, subnetInfo config.SourceBlockchain) *subscriber { blockchainID, err := ids.FromString(subnetInfo.BlockchainID) if err != nil { logger.Error( diff --git a/vms/evm/subscriber_test.go b/vms/evm/subscriber_test.go index e873b1de..e46aed84 100644 --- a/vms/evm/subscriber_test.go +++ b/vms/evm/subscriber_test.go @@ -15,7 +15,7 @@ import ( ) func makeSubscriberWithMockEthClient(t *testing.T) (*subscriber, *mock_ethclient.MockClient) { - sourceSubnet := config.SourceSubnet{ + sourceSubnet := config.SourceBlockchain{ SubnetID: "2TGBXcnwx5PqiXWiqxAKUaNSqDguXNh1mxnp82jui68hxJSZAx", BlockchainID: "S4mMqUXe7vHsGiRAma6bv3CKnyaLssyAxmQ2KvFpX1KEvfFCD", VM: config.EVM.String(), diff --git a/vms/subscriber.go b/vms/subscriber.go index 3dbc6362..3a25199b 100644 --- a/vms/subscriber.go +++ b/vms/subscriber.go @@ -37,7 +37,7 @@ type Subscriber interface { } // NewSubscriber returns a concrete Subscriber according to the VM specified by [subnetInfo] -func NewSubscriber(logger logging.Logger, subnetInfo config.SourceSubnet) Subscriber { +func NewSubscriber(logger logging.Logger, subnetInfo config.SourceBlockchain) Subscriber { switch config.ParseVM(subnetInfo.VM) { case config.EVM: return evm.NewSubscriber(logger, subnetInfo)