Executor service refactor and bootstrap#870
Conversation
|
Code coverage report:
WARNING: go tool cover failed for coverage_target.out |
|
Needs more edits around documentation and configuration |
makramkd
left a comment
There was a problem hiding this comment.
Excellent start! Main points:
- Do we still need the legacy mode? I noticed that main.go didn't switch to use bootstrap.Run, is that for another PR?
- Key generation is still happening manually in devenv, I think we should switch that to use the keystore like the verifier
- Some common code can probably be factored out
| case chainsel.FamilyStellar: | ||
| return serializeExtraArgsV3(opts) |
There was a problem hiding this comment.
Haha, another point of registration needed? 🤔
There was a problem hiding this comment.
We have it on 1.6 and it'd be nice to bring over: https://github.com/smartcontractkit/chainlink-ccip/blob/28f9affca9218f1c594b0ae0ef26523811841032/deployment/testadapters/adapters.go#L108-L112
The ExtraArgOpt approach is a bit clunky though since each implementation ends up with a loop like this so cciptestinterfaces.MessageOptions seems nicer: https://github.com/smartcontractkit/chainlink-ccip/blob/28f9affca9218f1c594b0ae0ef26523811841032/chains/evm/deployment/v1_6_0/testadapter/test_adapter.go#L258-L272
https://github.com/smartcontractkit/chainlink-ccip/blob/28f9affca9218f1c594b0ae0ef26523811841032/chains/solana/deployment/v1_6_0/testadapter/test_adapter.go#L388-L405
(note that on 1.6 it's source chain encoded so there's more code)
There was a problem hiding this comment.
Something like this?
GetExtraArgs(receiver []byte, opts cciptestinterfaces.MessageOptions) ([]byte, error)
Receiver leaks through because solana needs to derive some custom accounts based on it
| // TransmitterPrivateKey is used in standalone mode for transaction signing. | ||
| TransmitterPrivateKey string `toml:"transmitter_private_key"` |
There was a problem hiding this comment.
Is this still being used even after bootstrapping? We should rely on a key generated by the keystore instead if so.
|
|
||
| // GenerateConfigWithBlockchainInfos combines the pre-generated config with blockchain infos | ||
| // for standalone mode deployment. | ||
| func (v *Input) GenerateConfigWithBlockchainInfos(blockchainInfos map[string]*blockchain.Info) ([]byte, error) { |
| // NewStandalone creates a standalone executor (legacy mode, no bootstrap/JD). | ||
| func NewStandalone(in *Input, blockchainOutputs []*ctfblockchain.Output) (*Output, error) { |
There was a problem hiding this comment.
Is there a reason you think we should keep this around?
| func generateTransmitterPrivateKey() (string, error) { | ||
| // TODO: not chain agnostic. | ||
| pk, err := crypto.GenerateKey() | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| return hex.EncodeToString(crypto.FromECDSA(pk)), nil | ||
| } | ||
|
|
||
| // SetTransmitterPrivateKey sets the transmitter private key for the provided execs array. | ||
| func SetTransmitterPrivateKey(execs []*Input) ([]*Input, error) { | ||
| for _, exec := range execs { | ||
| pk, err := generateTransmitterPrivateKey() | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to generate transmitter private key: %w", err) | ||
| } | ||
| exec.TransmitterPrivateKey = pk | ||
| } | ||
| return execs, nil | ||
| } |
There was a problem hiding this comment.
IMO we should remove these
| # Then copy the rest of the source and build | ||
| COPY . . | ||
| WORKDIR /cmd/executor | ||
| WORKDIR /cmd/executor/standalone |
There was a problem hiding this comment.
Ditto here, don't need standalone suffix
| # Then copy the rest of the source | ||
| COPY . . | ||
| WORKDIR /app/cmd/executor | ||
| WORKDIR /app/cmd/executor/standalone |
There was a problem hiding this comment.
Don't need standalone suffix
| // LoadConfigWithBlockchainInfos decodes the executor config from the job spec | ||
| // into a strongly-typed map[string]*T. The type T is chosen by the caller (e.g. | ||
| // blockchain.Info for EVM). Strict decode is applied: any unknown key in the | ||
| // config (including under blockchain_infos.<selector>) causes an error. | ||
| // The returned Configuration has defaults applied via GetNormalizedConfig. | ||
| func LoadConfigWithBlockchainInfos[T any](spec JobSpec) (*Configuration, map[string]*T, error) { |
There was a problem hiding this comment.
This dups what we have for commit verifier right? I guess the only difference is the return value Configuration instead of Config.
Maybe we can factor out a common method, we'll need to add a second generic type param for the return value though, wdyt?
type cfgWithBlockchainInfos[T any, U any] struct {
U
BlockchainInfos map[string]*T `toml:"blockchain_infos"`
}
func LoadConfigWithBlockchainInfos[T any, U any](spec JobSpec) (*U, map[string]*T, error) {
| normalized, err := decodeTarget.GetNormalizedConfig() | ||
| if err != nil { | ||
| return nil, nil, fmt.Errorf("failed to normalize executor config: %w", err) | ||
| } |
There was a problem hiding this comment.
Ah I just realized that this is executor specific, hmm...
Only thing I can think of is that we can call this after we decode, doesn't seem like it has to be part of decoding, but not too caught up on it.
There was a problem hiding this comment.
Also, were you thinking of adding the bootstrapped version in a follow up PR?
There was a problem hiding this comment.
The current setup here wraps this (standalone) as a bootstrapped version. In Stellar, it's being setup with bootstrap.Run (like this) just like the verifier
There was a problem hiding this comment.
ah nvm, I just realized this was about the the main.go in here
This PR adds a
devenvservice bootstrap path for the executor. This matches what has been done for the verifier.