Skip to content

Commit

Permalink
Merge branch 'ccip-develop' into fix/onramp-allowlist-race-condition
Browse files Browse the repository at this point in the history
  • Loading branch information
0xsuryansh authored Oct 3, 2024
2 parents a39272f + 5aee339 commit 46d641b
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 120 deletions.
2 changes: 1 addition & 1 deletion contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ TokenAdminRegistry_setPool:test_setPool_ZeroAddressRemovesPool_Success() (gas: 3
TokenAdminRegistry_transferAdminRole:test_transferAdminRole_OnlyAdministrator_Revert() (gas: 18103)
TokenAdminRegistry_transferAdminRole:test_transferAdminRole_Success() (gas: 49438)
TokenPoolAndProxy:test_lockOrBurn_burnMint_Success() (gas: 5586499)
TokenPoolAndProxy:test_lockOrBurn_burnWithFromMint_Success() (gas: 5617969)
TokenPoolAndProxy:test_lockOrBurn_burnWithFromMint_Success() (gas: 5618769)
TokenPoolAndProxy:test_lockOrBurn_lockRelease_Success() (gas: 5793246)
TokenPoolAndProxy:test_setPreviousPool_Success() (gas: 3070731)
TokenPoolAndProxyMigration:test_tokenPoolMigration_Success_1_2() (gas: 6434801)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {SafeERC20} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/tok
contract BurnWithFromMintTokenPoolAndProxy is ITypeAndVersion, LegacyPoolWrapper {
using SafeERC20 for IBurnMintERC20;

string public constant override typeAndVersion = "BurnFromMintTokenPoolAndProxy 1.5.0";
string public constant override typeAndVersion = "BurnWithFromMintTokenPoolAndProxy 1.5.0";

constructor(
IBurnMintERC20 token,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ burn_from_mint_token_pool: ../../../contracts/solc/v0.8.24/BurnFromMintTokenPool
burn_mint_token_pool: ../../../contracts/solc/v0.8.24/BurnMintTokenPool/BurnMintTokenPool.abi ../../../contracts/solc/v0.8.24/BurnMintTokenPool/BurnMintTokenPool.bin 3e8e3358f0bb520af069a7d37ea625940a88461a54418b1d5925eabced8c74df
burn_mint_token_pool_and_proxy: ../../../contracts/solc/v0.8.24/BurnMintTokenPoolAndProxy/BurnMintTokenPoolAndProxy.abi ../../../contracts/solc/v0.8.24/BurnMintTokenPoolAndProxy/BurnMintTokenPoolAndProxy.bin 717c079d5d13300cf3c3ee871c6e5bf9af904411f204fb081a9f3b263cca1391
burn_with_from_mint_token_pool: ../../../contracts/solc/v0.8.24/BurnWithFromMintTokenPool/BurnWithFromMintTokenPool.abi ../../../contracts/solc/v0.8.24/BurnWithFromMintTokenPool/BurnWithFromMintTokenPool.bin 6333d0314d0bd29e75ea5e05fe62a4516ade0c6db91c30b6f93645035db52ed8
burn_with_from_mint_token_pool_and_proxy: ../../../contracts/solc/v0.8.24/BurnWithFromMintTokenPoolAndProxy/BurnWithFromMintTokenPoolAndProxy.abi ../../../contracts/solc/v0.8.24/BurnWithFromMintTokenPoolAndProxy/BurnWithFromMintTokenPoolAndProxy.bin 08ed1235dda921ce8841b26aa18d0c0f36db4884779dd7670857159801b6d597
burn_with_from_mint_token_pool_and_proxy: ../../../contracts/solc/v0.8.24/BurnWithFromMintTokenPoolAndProxy/BurnWithFromMintTokenPoolAndProxy.abi ../../../contracts/solc/v0.8.24/BurnWithFromMintTokenPoolAndProxy/BurnWithFromMintTokenPoolAndProxy.bin 1ed5c299f928529081dc01b7a46db2b5e6728001767863495a7675d8db99a9e2
ccip_encoding_utils: ../../../contracts/solc/v0.8.24/ICCIPEncodingUtils/ICCIPEncodingUtils.abi ../../../contracts/solc/v0.8.24/ICCIPEncodingUtils/ICCIPEncodingUtils.bin 2e6fa009821d30a24efdc9f9d14b2269fb9a51cb7d536ea8b2d29d97dd8b591c
ccip_home: ../../../contracts/solc/v0.8.24/CCIPHome/CCIPHome.abi ../../../contracts/solc/v0.8.24/CCIPHome/CCIPHome.bin 87de30d71a511f936bdeecb01a88a70ad3f323117202ebb17cdbdc84d65a3857
ccip_reader_tester: ../../../contracts/solc/v0.8.24/CCIPReaderTester/CCIPReaderTester.abi ../../../contracts/solc/v0.8.24/CCIPReaderTester/CCIPReaderTester.bin 32916b41e0070cb6853d558bbff06ab367324fa52cac59893065e8f616ff14f0
Expand Down
13 changes: 10 additions & 3 deletions core/services/ocr2/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,15 @@ func (d *Delegate) newServicesCCIPCommit(ctx context.Context, lggr logger.Sugare
MetricsRegisterer: prometheus.WrapRegistererWith(map[string]string{"job_name": jb.Name.ValueOrZero()}, prometheus.DefaultRegisterer),
}

var priceGetter ccip.AllTokensPriceGetter
priceGetter, err := d.ccipCommitPriceGetter(ctx, lggr, pluginJobSpecConfig, jb)
if err != nil {
return nil, fmt.Errorf("failed to create price getter: %w", err)
}
return ccipcommit.NewCommitServices(ctx, d.ds, srcProvider, dstProvider, priceGetter, jb, lggr, d.pipelineRunner, oracleArgsNoPlugin, d.isNewlyCreatedJob, int64(srcChainID), dstChainID, logError)
}

func (d *Delegate) ccipCommitPriceGetter(ctx context.Context, lggr logger.SugaredLogger, pluginJobSpecConfig ccipconfig.CommitPluginJobSpecConfig, jb job.Job) (priceGetter ccip.AllTokensPriceGetter, err error) {
spec := jb.OCR2OracleSpec
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)
Expand Down Expand Up @@ -1685,8 +1693,7 @@ func (d *Delegate) newServicesCCIPCommit(ctx context.Context, lggr logger.Sugare
return nil, fmt.Errorf("creating dynamic price getter: %w", err)
}
}

return ccipcommit.NewCommitServices(ctx, d.ds, srcProvider, dstProvider, priceGetter, jb, lggr, d.pipelineRunner, oracleArgsNoPlugin, d.isNewlyCreatedJob, int64(srcChainID), dstChainID, logError)
return priceGetter, nil
}

func newCCIPCommitPluginBytes(isSourceProvider bool, sourceStartBlock uint64, destStartBlock uint64) config.CommitPluginConfig {
Expand Down
34 changes: 17 additions & 17 deletions core/services/ocr2/plugins/ccip/internal/pricegetter/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/rpclib"
)

const OFFCHAIN_AGGREGATOR = "OffchainAggregator"
const DECIMALS_METHOD_NAME = "decimals"
const LATEST_ROUND_DATA_METHOD_NAME = "latestRoundData"
const OffchainAggregator = "OffchainAggregator"
const DecimalsMethodName = "decimals"
const LatestRoundDataMethodName = "latestRoundData"

func init() {
// Ensure existence of latestRoundData method on the Aggregator contract.
aggregatorABI, err := abi.JSON(strings.NewReader(offchainaggregator.OffchainAggregatorABI))
if err != nil {
panic(err)
}
ensureMethodOnContract(aggregatorABI, DECIMALS_METHOD_NAME)
ensureMethodOnContract(aggregatorABI, LATEST_ROUND_DATA_METHOD_NAME)
ensureMethodOnContract(aggregatorABI, DecimalsMethodName)
ensureMethodOnContract(aggregatorABI, LatestRoundDataMethodName)
}

func ensureMethodOnContract(abi abi.ABI, methodName string) {
Expand Down Expand Up @@ -159,7 +159,7 @@ func (d *DynamicPriceGetter) performBatchCall(ctx context.Context, chainID uint6
for i, call := range batchCalls.decimalCalls {
bindings = append(bindings, types.BoundContract{
Address: string(ccipcalc.EvmAddrToGeneric(call.ContractAddress())),
Name: fmt.Sprintf("%v_%v", OFFCHAIN_AGGREGATOR, i),
Name: fmt.Sprintf("%v_%v", OffchainAggregator, i),
})
}

Expand All @@ -172,15 +172,15 @@ func (d *DynamicPriceGetter) performBatchCall(ctx context.Context, chainID uint6
var decimalsReq uint8
batchGetLatestValuesRequest := make(map[string]types.ContractBatch)
for i, call := range batchCalls.decimalCalls {
contractName := fmt.Sprintf("%v_%v", OFFCHAIN_AGGREGATOR, i)
contractName := fmt.Sprintf("%v_%v", OffchainAggregator, i)
batchGetLatestValuesRequest[contractName] = append(batchGetLatestValuesRequest[contractName], types.BatchRead{
ReadName: call.MethodName(),
ReturnVal: &decimalsReq,
})
}

for i, call := range batchCalls.latestRoundDataCalls {
contractName := fmt.Sprintf("%v_%v", OFFCHAIN_AGGREGATOR, i)
contractName := fmt.Sprintf("%v_%v", OffchainAggregator, i)
batchGetLatestValuesRequest[contractName] = append(batchGetLatestValuesRequest[contractName], types.BatchRead{
ReadName: call.MethodName(),
ReturnVal: &aggregator_v3_interface.LatestRoundData{},
Expand All @@ -200,26 +200,26 @@ func (d *DynamicPriceGetter) performBatchCall(ctx context.Context, chainID uint6
latestRoundCR := make([]aggregator_v3_interface.LatestRoundData, 0, nbDecimalCalls)
var respErr error
for j := range nbCalls {
contractName := fmt.Sprintf("%v_%v", OFFCHAIN_AGGREGATOR, j)
contractName := fmt.Sprintf("%v_%v", OffchainAggregator, j)
offchainAggregatorRespSlice := result[contractName]

for i, read := range offchainAggregatorRespSlice {
for _, read := range offchainAggregatorRespSlice {
val, readErr := read.GetResult()
if readErr != nil {
respErr = multierr.Append(respErr, fmt.Errorf("error with method call %v: %w", batchCalls.decimalCalls[i].MethodName(), readErr))
respErr = multierr.Append(respErr, fmt.Errorf("error with contract reader readName %v: %w", read.ReadName, readErr))
continue
}
if read.ReadName == DECIMALS_METHOD_NAME {
if read.ReadName == DecimalsMethodName {
decimal, ok := val.(*uint8)
if !ok {
return fmt.Errorf("expected type uint8 for method call %v on contract %v: %w", batchCalls.decimalCalls[i].MethodName(), batchCalls.decimalCalls[i].ContractAddress(), readErr)
return fmt.Errorf("expected type uint8 for method call %v on contract %v: %w", batchCalls.decimalCalls[j].MethodName(), batchCalls.decimalCalls[j].ContractAddress(), readErr)
}

decimalsCR = append(decimalsCR, *decimal)
} else if read.ReadName == LATEST_ROUND_DATA_METHOD_NAME {
} else if read.ReadName == LatestRoundDataMethodName {
latestRoundDataRes, ok := val.(*aggregator_v3_interface.LatestRoundData)
if !ok {
return fmt.Errorf("expected type latestRoundDataConfig for method call %v on contract %v: %w", batchCalls.latestRoundDataCalls[i/2].MethodName(), batchCalls.latestRoundDataCalls[i/2].ContractAddress(), readErr)
return fmt.Errorf("expected type latestRoundDataConfig for method call %v on contract %v: %w", batchCalls.latestRoundDataCalls[j].MethodName(), batchCalls.latestRoundDataCalls[j].ContractAddress(), readErr)
}

latestRoundCR = append(latestRoundCR, *latestRoundDataRes)
Expand Down Expand Up @@ -271,12 +271,12 @@ func (d *DynamicPriceGetter) preparePricesAndBatchCallsPerChain(tokens []cciptyp
chainCalls := batchCallsPerChain[aggCfg.ChainID]
chainCalls.decimalCalls = append(chainCalls.decimalCalls, rpclib.NewEvmCall(
d.aggregatorAbi,
DECIMALS_METHOD_NAME,
DecimalsMethodName,
aggCfg.AggregatorContractAddress,
))
chainCalls.latestRoundDataCalls = append(chainCalls.latestRoundDataCalls, rpclib.NewEvmCall(
d.aggregatorAbi,
LATEST_ROUND_DATA_METHOD_NAME,
LatestRoundDataMethodName,
aggCfg.AggregatorContractAddress,
))
chainCalls.tokenOrder = append(chainCalls.tokenOrder, tk)
Expand Down
Loading

0 comments on commit 46d641b

Please sign in to comment.