-
Notifications
You must be signed in to change notification settings - Fork 2
Family Agnostic Standalone Executor #1038
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2df606d
chainaccess: introduce ExecutorConfig and DestinationChainConfig over…
winder 879626a
chainaccess: Add some placeholders for new interfaces
winder c58d522
Initialize the destination reader.
winder 514aead
chainaccess: Add ContractTransmitter construction.
winder eb55662
Comments
winder d682635
Lint fix
winder c0ab535
poke
winder 8981f1c
Use the registry in the standalone executor.
winder 86a5970
Revert executor main.go.
winder 841161f
Fix lint.
winder f28e4be
Make source reader optional.
winder 99c70a5
Use the registry.
winder 56b427f
Not sure why this was added.
winder 5ffa885
Treat dest reader and contract transmitter as a tuple.
winder 6cac85e
Return errors if the objects are not initialized.
winder 48c31ac
Fix lint
winder 43daeb4
Add changelog.
winder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Use Registry in Standalone Executor | ||
|
|
||
| ## Summary | ||
|
|
||
| ### Standalone executor is now family agnostic. | ||
|
|
||
| `cmd/executor/standalone/main.go` now uses `chainaccess.NewRegistry` to build | ||
| chain accessors instead of constructing EVM readers and transmitters directly. | ||
| The chain init loop calls `accessor.DestinationReader()` and | ||
| `accessor.ContractTransmitter()`, and skips any chain where either returns an | ||
| error. | ||
|
|
||
| ### `chainaccess.Accessor` getter signatures changed | ||
|
|
||
| Two new getters were added to `chainaccess.Accessor` and the existing getter was modified. | ||
| They return an error when the capability is not available for the chain, rather than returning nil: | ||
|
|
||
| ```go | ||
| // Before | ||
| SourceReader() SourceReader | ||
|
|
||
| // After | ||
| SourceReader() (SourceReader, error) | ||
| DestinationReader() (DestinationReader, error) | ||
| ContractTransmitter() (ContractTransmitter, error) | ||
| ``` | ||
|
|
||
| Callers must check the error before using the returned value. | ||
|
|
||
| ### `GetAccessor` should succeeds even when capabilities are partially unavailable | ||
|
|
||
| `AccessorFactory.GetAccessor` should returns a valid `Accessor` whenever the | ||
| chain selector is recognized, even if one or more of its capabilities | ||
| (e.g. `SourceReader` when `on_ramp_addresses` is absent) could not be constructed. | ||
| Missing capabilities are reported as errors only when the corresponding getter is called. | ||
|
|
||
| Previously, the GetAccessor call would fail because there was only a single capability. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,6 @@ import ( | |
| "time" | ||
|
|
||
| "github.com/BurntSushi/toml" | ||
| "github.com/ethereum/go-ethereum/common" | ||
| "github.com/grafana/pyroscope-go" | ||
| "go.uber.org/zap/zapcore" | ||
|
|
||
|
|
@@ -20,12 +19,10 @@ import ( | |
| x "github.com/smartcontractkit/chainlink-ccv/executor/pkg/executor" | ||
| "github.com/smartcontractkit/chainlink-ccv/executor/pkg/leaderelector" | ||
| "github.com/smartcontractkit/chainlink-ccv/executor/pkg/monitoring" | ||
| "github.com/smartcontractkit/chainlink-ccv/integration/pkg/accessors/evm" | ||
| _ "github.com/smartcontractkit/chainlink-ccv/integration/pkg/accessors/evm" | ||
| "github.com/smartcontractkit/chainlink-ccv/integration/pkg/backofftimeprovider" | ||
| "github.com/smartcontractkit/chainlink-ccv/integration/pkg/ccvstreamer" | ||
| "github.com/smartcontractkit/chainlink-ccv/integration/pkg/contracttransmitter" | ||
| "github.com/smartcontractkit/chainlink-ccv/integration/pkg/cursechecker" | ||
| "github.com/smartcontractkit/chainlink-ccv/integration/pkg/destinationreader" | ||
| "github.com/smartcontractkit/chainlink-ccv/pkg/chainaccess" | ||
| "github.com/smartcontractkit/chainlink-ccv/protocol" | ||
| "github.com/smartcontractkit/chainlink-ccv/protocol/common/logging" | ||
|
|
@@ -35,7 +32,6 @@ import ( | |
|
|
||
| const ( | ||
| configPathEnvVar = "EXECUTOR_CONFIG_PATH" | ||
| privateKeyEnvVar = "EXECUTOR_TRANSMITTER_PRIVATE_KEY" | ||
| // indexerPollingInterval describes how frequently we ask indexer for new messages. | ||
| // This should be kept at 1s for consistent behavior across all executors. | ||
| indexerPollingInterval = 1 * time.Second | ||
|
|
@@ -71,7 +67,7 @@ func main() { | |
| } | ||
| lggr = logger.Named(lggr, "executor") | ||
|
|
||
| executorConfig, blockchainInfo, err := loadConfiguration(configPath) | ||
| executorConfig, registry, err := loadConfiguration(lggr, configPath) | ||
| if err != nil { | ||
| lggr.Errorw("Failed to load configuration", "path", configPath, "error", err) | ||
| os.Exit(1) | ||
|
|
@@ -99,7 +95,6 @@ func main() { | |
| protocol.InitChainSelectorCache() | ||
|
|
||
| lggr.Infow("Executor configuration", "config", executorConfig) | ||
| lggr.Infow("Blockchain information", "blockchainInfo", blockchainInfo) | ||
|
|
||
| // | ||
| // Setup OTEL Monitoring (via beholder) | ||
|
|
@@ -159,53 +154,30 @@ func main() { | |
| destReaders := make(map[protocol.ChainSelector]chainaccess.DestinationReader) | ||
| enabledDestChains := make([]protocol.ChainSelector, 0) | ||
| rmnReaders := make(map[protocol.ChainSelector]chainaccess.RMNCurseReader) | ||
| for selector, chain := range blockchainInfo.GetAllInfos() { | ||
| strSel := strconv.FormatUint(uint64(selector), 10) | ||
| chainConfig := executorConfig.ChainConfiguration[strSel] | ||
|
|
||
| chainClient, err := evm.CreateMultiNodeClientFromInfo(ctx, chain, lggr) | ||
| for strSel := range executorConfig.ChainConfiguration { | ||
| selectorUint, err := strconv.ParseUint(strSel, 10, 64) | ||
| if err != nil { | ||
| lggr.Errorw("Failed to create chain client", "error", err, "chainSelector", strSel) | ||
| lggr.Errorw("Invalid chain selector in configuration", "error", err, "chainSelector", strSel) | ||
| continue | ||
| } | ||
| dr, err := destinationreader.NewEvmDestinationReader( | ||
| destinationreader.Params{ | ||
| Lggr: lggr, | ||
| ChainSelector: selector, | ||
| ChainClient: chainClient, | ||
| OfframpAddress: chainConfig.OffRampAddress, | ||
| RmnRemoteAddress: chainConfig.RmnAddress, | ||
| ExecutionVisabilityWindow: executorConfig.MaxRetryDuration, | ||
| Monitoring: executorMonitoring, | ||
| }) | ||
| selector := protocol.ChainSelector(selectorUint) | ||
|
|
||
| accessor, err := registry.GetAccessor(ctx, selector) | ||
| if err != nil { | ||
| lggr.Errorw("Failed to create destination reader", "error", err, "chainSelector", strSel) | ||
| chainClient.Close() | ||
| lggr.Errorw("Failed to get accessor for chain", "error", err, "chainSelector", strSel) | ||
| continue | ||
| } | ||
|
|
||
| pk := os.Getenv(privateKeyEnvVar) | ||
| if pk == "" { | ||
| lggr.Errorf("Environment variable %s is not set", privateKeyEnvVar) | ||
| os.Exit(1) | ||
| } | ||
| dr, drErr := accessor.DestinationReader() | ||
| ct, ctErr := accessor.ContractTransmitter() | ||
|
|
||
| ct, err := contracttransmitter.NewEVMContractTransmitterFromRPC( | ||
| ctx, | ||
| lggr, | ||
| selector, | ||
| chain.Nodes[0].InternalHTTPUrl, | ||
| pk, | ||
| common.HexToAddress(chainConfig.OffRampAddress), | ||
| ) | ||
| if err != nil { | ||
| lggr.Errorw("Failed to create contract transmitter", "error", err) | ||
| os.Exit(1) | ||
| } | ||
| if dr != nil { | ||
| destReaders[selector] = dr | ||
| rmnReaders[selector] = dr | ||
| if drErr != nil || ctErr != nil { | ||
| lggr.Warnw("Skipping chain: missing DestinationReader or ContractTransmitter", "chainSelector", strSel, "destReaderErr", drErr, "transmitterErr", ctErr) | ||
| continue | ||
| } | ||
|
|
||
| destReaders[selector] = dr | ||
| rmnReaders[selector] = dr | ||
| contractTransmitters[selector] = ct | ||
| enabledDestChains = append(enabledDestChains, selector) | ||
| } | ||
|
|
@@ -346,15 +318,25 @@ func main() { | |
| lggr.Infow("Execution service stopped gracefully") | ||
| } | ||
|
|
||
| func loadConfiguration(filepath string) (*executor.Configuration, *chainaccess.Infos[evm.Info], error) { | ||
| var config executor.ConfigWithBlockchainInfo[evm.Info] | ||
| if _, err := toml.DecodeFile(filepath, &config); err != nil { | ||
| func loadConfiguration(lggr logger.Logger, filepath string) (*executor.Configuration, *chainaccess.Registry, error) { | ||
| content, err := os.ReadFile(filepath) // #nosec G304 -- config file path is operator-controlled | ||
| if err != nil { | ||
| return nil, nil, err | ||
| } | ||
|
|
||
| var config executor.ConfigWithBlockchainInfo[any] | ||
| if _, err := toml.Decode(string(content), &config); err != nil { | ||
| return nil, nil, err | ||
| } | ||
| normalizedConfig, err := config.GetNormalizedConfig() | ||
| if err != nil { | ||
| return nil, nil, err | ||
| } | ||
| return normalizedConfig, &config.BlockchainInfos, nil | ||
|
|
||
| registry, err := chainaccess.NewRegistry(lggr, string(content)) | ||
| if err != nil { | ||
| return nil, nil, err | ||
| } | ||
|
Comment on lines
+336
to
+339
Collaborator
Author
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. The main change. Create the registry, then use it in place of the other constructor calls that used to be in this file. |
||
|
|
||
| return normalizedConfig, registry, nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There should be a better way to inject this into the executor.
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.
In the bootstrap approach this would be provided by the keystore