-
Notifications
You must be signed in to change notification settings - Fork 49
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
Removing chain dependencies from NewCommitServices construct #1361
Conversation
…ed out ContractReader config
…rds using ChainReader
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.
let's wait for flaky tests to be resolved before merging
This reverts commit b323a8b.
This PR tests https://github.com/smartcontractkit/ccip/pull/1361/files without changes made to integration-tests/docker/test_env/cl_node.go --------- Co-authored-by: Patrick <[email protected]>
var priceGetter ccip.AllTokensPriceGetter | ||
withPipeline := strings.Trim(pluginJobSpecConfig.TokenPricesUSDPipeline, "\n\t ") != "" | ||
if withPipeline { | ||
priceGetter, err = ccip.NewPipelineGetter(pluginJobSpecConfig.TokenPricesUSDPipeline, d.pipelineRunner, jb.ID, jb.ExternalJobID, jb.Name.ValueOrZero(), lggr) | ||
if err != nil { | ||
return nil, fmt.Errorf("creating pipeline price getter: %w", err) | ||
} | ||
} else { | ||
// Use dynamic price getter. | ||
if pluginJobSpecConfig.PriceGetterConfig == nil { | ||
return nil, fmt.Errorf("priceGetterConfig is nil") | ||
} | ||
|
||
// Configure contract readers for all chains specified in the aggregator configurations. | ||
// Some lanes (e.g. Wemix/Kroma) requires other clients than source and destination, since they use feeds from other chains. | ||
aggregatorChainsToContracts := make(map[uint64][]common.Address) | ||
for _, aggCfg := range pluginJobSpecConfig.PriceGetterConfig.AggregatorPrices { | ||
if _, ok := aggregatorChainsToContracts[aggCfg.ChainID]; !ok { | ||
aggregatorChainsToContracts[aggCfg.ChainID] = make([]common.Address, 0) | ||
} | ||
|
||
aggregatorChainsToContracts[aggCfg.ChainID] = append(aggregatorChainsToContracts[aggCfg.ChainID], aggCfg.AggregatorContractAddress) | ||
} | ||
|
||
contractReaders := map[uint64]types.ContractReader{} | ||
|
||
for chainID, aggregatorContracts := range aggregatorChainsToContracts { | ||
relayID := types.RelayID{Network: spec.Relay, ChainID: strconv.FormatUint(chainID, 10)} | ||
relay, rerr := d.RelayGetter.Get(relayID) | ||
if rerr != nil { | ||
return nil, fmt.Errorf("get relay by id=%v: %w", relayID, err) | ||
} | ||
|
||
contractsConfig := make(map[string]evmrelaytypes.ChainContractReader, len(aggregatorContracts)) | ||
for i := range aggregatorContracts { | ||
contractsConfig[fmt.Sprintf("%v_%v", ccip.OFFCHAIN_AGGREGATOR, i)] = evmrelaytypes.ChainContractReader{ | ||
ContractABI: ccip.OffChainAggregatorABI, | ||
Configs: map[string]*evmrelaytypes.ChainReaderDefinition{ | ||
"decimals": { // CR consumers choose an alias | ||
ChainSpecificName: "decimals", | ||
}, | ||
"latestRoundData": { | ||
ChainSpecificName: "latestRoundData", | ||
}, | ||
}, | ||
} | ||
} | ||
contractReaderConfig := evmrelaytypes.ChainReaderConfig{ | ||
Contracts: contractsConfig, | ||
} | ||
|
||
contractReaderConfigJsonBytes, jerr := json.Marshal(contractReaderConfig) | ||
if jerr != nil { | ||
return nil, fmt.Errorf("marshal contract reader config: %w", jerr) | ||
} | ||
|
||
contractReader, cerr := relay.NewContractReader(ctx, contractReaderConfigJsonBytes) | ||
if cerr != nil { | ||
return nil, fmt.Errorf("new ccip commit contract reader %w", cerr) | ||
} | ||
|
||
contractReaders[chainID] = contractReader | ||
} | ||
|
||
priceGetter, err = ccip.NewDynamicPriceGetter(*pluginJobSpecConfig.PriceGetterConfig, contractReaders) | ||
if err != nil { | ||
return nil, fmt.Errorf("creating dynamic price getter: %w", err) | ||
} | ||
} |
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.
It would be nice to wrap this in a function similar to d.ccipCommitGetDstProvider
and d.ccipCommitGetSrcProvider
above.
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.
const OFFCHAIN_AGGREGATOR = "OffchainAggregator" | ||
const DECIMALS_METHOD_NAME = "decimals" | ||
const LATEST_ROUND_DATA_METHOD_NAME = "latestRoundData" |
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.
All caps is not idiomatic (stdlib uses UpperCamelCase, i.e. math.MaxUint64
). They were also private before. So two requests:
- Can it be private?
- Please rename to
DecimalsMethodName
ordecimalsMethodName
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.
These specific vars are not exported anywhere else, since they live in a package that is defined behind in a leaf of aninternal
path. Will rename to UpperCamelCase, thanks for the stdlib callout.
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.
.PHONY: install-chainlink-delve | ||
install-chainlink-delve: operator-ui ## Install the chainlink binary. | ||
go install $(GOFLAGS) -gcflags "all=-N -l" . |
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.
What is this? It doesn't seem to have anything to do with delve
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.
The -gcflags "all=-N -l"
portion of this compiles the binary in a way that allows a debugger to step through.
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.
Approved, but hoping for a followup to address the nits
Quality Gate failedFailed conditions |
## Motivation LOOP-ify ## Solution --------- Co-authored-by: Bartek Tofel <[email protected]> Co-authored-by: lukaszcl <[email protected]>
## Motivation Quick follow ups to #1361
Motivation
LOOP-ify
Solution