-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Aptos LOOP setup #14076
Aptos LOOP setup #14076
Changes from all commits
8a6a50e
2b009a6
d0cabfd
0ca4038
19a797e
c7bd4ee
b1ba73d
7e117d4
e913686
7d04627
86397c2
58538d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ import ( | |
solcfg "github.com/smartcontractkit/chainlink-solana/pkg/solana/config" | ||
pkgstarknet "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink" | ||
starkchain "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/chain" | ||
"github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/config" | ||
starkcfg "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/config" | ||
"github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" | ||
coreconfig "github.com/smartcontractkit/chainlink/v2/core/config" | ||
"github.com/smartcontractkit/chainlink/v2/core/config/env" | ||
|
@@ -171,12 +171,12 @@ func (r *RelayerFactory) NewSolana(ks keystore.Solana, chainCfgs solcfg.TOMLConf | |
|
||
type StarkNetFactoryConfig struct { | ||
Keystore keystore.StarkNet | ||
config.TOMLConfigs | ||
starkcfg.TOMLConfigs | ||
} | ||
|
||
// TODO BCF-2606 consider consolidating the driving logic with that of NewSolana above via generics | ||
// perhaps when we implement a Cosmos LOOP | ||
func (r *RelayerFactory) NewStarkNet(ks keystore.StarkNet, chainCfgs config.TOMLConfigs) (map[types.RelayID]loop.Relayer, error) { | ||
func (r *RelayerFactory) NewStarkNet(ks keystore.StarkNet, chainCfgs starkcfg.TOMLConfigs) (map[types.RelayID]loop.Relayer, error) { | ||
starknetRelayers := make(map[types.RelayID]loop.Relayer) | ||
|
||
var ( | ||
|
@@ -205,7 +205,7 @@ func (r *RelayerFactory) NewStarkNet(ks keystore.StarkNet, chainCfgs config.TOML | |
if cmdName := env.StarknetPlugin.Cmd.Get(); cmdName != "" { | ||
// setup the starknet relayer to be a LOOP | ||
cfgTOML, err := toml.Marshal(struct { | ||
Starknet config.TOMLConfig | ||
Starknet starkcfg.TOMLConfig | ||
}{Starknet: *chainCfg}) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to marshal StarkNet configs: %w", err) | ||
|
@@ -301,3 +301,65 @@ func (r *RelayerFactory) NewCosmos(config CosmosFactoryConfig) (map[types.RelayI | |
} | ||
return relayers, nil | ||
} | ||
|
||
type AptosFactoryConfig struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [non-blocking discussion] We should also ideally get Beholder integrated and configured in the core Node itself, and then inject it here to make it available to the LOOP as a common core service. @mathewdgardner wdyt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Draft in progress here to follow beholder client PR: smartcontractkit/chainlink-common#696 |
||
Keystore keystore.Aptos | ||
TOMLConfigs RawConfigs | ||
} | ||
|
||
func (r *RelayerFactory) NewAptos(ks keystore.Aptos, chainCfgs RawConfigs) (map[types.RelayID]loop.Relayer, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: shouldn't we use the |
||
plugin := env.NewPlugin("aptos") | ||
loopKs := &keystore.AptosLooppSigner{Aptos: ks} | ||
return r.NewLOOPRelayer("Aptos", corerelay.NetworkAptos, plugin, loopKs, chainCfgs) | ||
} | ||
|
||
func (r *RelayerFactory) NewLOOPRelayer(name string, network string, plugin env.Plugin, ks coretypes.Keystore, chainCfgs RawConfigs) (map[types.RelayID]loop.Relayer, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: consider grouping the keystore, config, and capRegistry in a type like PluginContext |
||
relayers := make(map[types.RelayID]loop.Relayer) | ||
lggr := r.Logger.Named(name) | ||
|
||
unique := make(map[string]struct{}) | ||
// create one relayer per chain id | ||
for _, chainCfg := range chainCfgs { | ||
relayID := types.RelayID{Network: network, ChainID: chainCfg.ChainID()} | ||
if _, alreadyExists := unique[relayID.Name()]; alreadyExists { | ||
return nil, fmt.Errorf("duplicate chain definitions for %s", relayID.Name()) | ||
} | ||
unique[relayID.Name()] = struct{}{} | ||
|
||
// skip disabled chains from further processing | ||
if !chainCfg.IsEnabled() { | ||
lggr.Warnw("Skipping disabled chain", "id", relayID.ChainID) | ||
continue | ||
} | ||
|
||
lggr2 := lggr.Named(relayID.ChainID) | ||
|
||
cmdName := plugin.Cmd.Get() | ||
if cmdName == "" { | ||
return nil, fmt.Errorf("plugin not defined: %s", "") | ||
} | ||
|
||
// setup the relayer as a LOOP | ||
cfgTOML, err := toml.Marshal(chainCfg) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to marshal configs: %w", err) | ||
} | ||
|
||
envVars, err := plugins.ParseEnvFile(plugin.Env.Get()) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to parse env file: %w", err) | ||
} | ||
cmdFn, err := plugins.NewCmdFactory(r.Register, plugins.CmdConfig{ | ||
ID: relayID.Name(), | ||
Cmd: cmdName, | ||
Env: envVars, | ||
}) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to create LOOP command: %w", err) | ||
} | ||
// the relayer service has a delicate keystore dependency. the value that is passed to NewRelayerService must | ||
// be compatible with instantiating a starknet transaction manager KeystoreAdapter within the LOOPp executable. | ||
relayers[relayID] = loop.NewRelayerService(lggr2, r.GRPCOpts, cmdFn, string(cfgTOML), ks, r.CapabilitiesRegistry) | ||
} | ||
return relayers, nil | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unfortunately not so simple, because we also support passing multiple files that override one another. I can't think of a simple short-term fix, but this will have to be solved another way eventually regardless 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you concat the files together, then only do the parse once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plain concat only works in special cases. We could write logic to crawl through the maps and set individual fields, but I'm not sure how easy that will be 🤔