Skip to content

Commit

Permalink
Post merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-sekara committed Jan 10, 2025
1 parent 7ea7b6d commit f04214d
Show file tree
Hide file tree
Showing 90 changed files with 403 additions and 474 deletions.
8 changes: 8 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -490,12 +490,20 @@ packages:
PriceRegistryReader:
config:
filename: price_registry_reader_mock.go
FeeEstimatorConfigReader:
config:
filename: fee_estimator_config_mock.go
TokenPoolReader:
config:
filename: token_pool_reader_mock.go
USDCReader:
config:
filename: usdc_reader_mock.go
github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/estimatorconfig:
interfaces:
GasPriceInterceptor:
config:
filename: gas_price_interceptor_mock.go
github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/batchreader:
config:
filename: token_pool_batched_reader_mock.go
Expand Down
3 changes: 3 additions & 0 deletions core/chains/evm/client/config_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ func TestClientConfigBuilder(t *testing.T) {
require.Equal(t, deathDeclarationDelay, nodePool.DeathDeclarationDelay())
require.Equal(t, pollInterval, nodePool.FinalizedBlockPollInterval())
require.Equal(t, newHeadsPollInterval, nodePool.NewHeadsPollInterval())

// Validate node configs
require.Equal(t, *nodeConfigs[0].Name, *nodes[0].Name)
require.Equal(t, *nodeConfigs[0].WSURL, (*nodes[0].WSURL).String())
require.Equal(t, *nodeConfigs[0].HTTPURL, (*nodes[0].HTTPURL).String())

// Validate chain config
Expand Down
38 changes: 19 additions & 19 deletions core/chains/evm/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ func TestChainScopedConfig_GasEstimator(t *testing.T) {
assert.Equal(t, assets.GWei(20), ge.PriceDefault())
assert.Equal(t, assets.GWei(500), ge.PriceMax())
assert.Equal(t, assets.GWei(1), ge.PriceMin())
assert.Equal(t, uint64(8_000_000), ge.LimitDefault())
assert.Equal(t, uint64(8_000_000), ge.LimitMax())
assert.Equal(t, uint64(500000), ge.LimitDefault())
assert.Equal(t, uint64(500000), ge.LimitMax())
assert.Equal(t, float32(1), ge.LimitMultiplier())
assert.Equal(t, uint64(21000), ge.LimitTransfer())
assert.Equal(t, assets.GWei(5), ge.BumpMin())
Expand Down Expand Up @@ -305,23 +305,23 @@ func TestChainScopedConfig_Profiles(t *testing.T) {
expectedGasLimitDefault uint64
expectedMinimumContractPayment string
}{
{"default", 0, 8_000_000, "0.00001"},
{"mainnet", 1, 8_000_000, "0.1"},
{"kovan", 42, 8_000_000, "0.1"},

{"optimism", 10, 8_000_000, "0.00001"},
{"optimism", 69, 8_000_000, "0.00001"},
{"optimism", 420, 8_000_000, "0.00001"},

{"bscMainnet", 56, 8_000_000, "0.00001"},
{"hecoMainnet", 128, 8_000_000, "0.00001"},
{"fantomMainnet", 250, 8_000_000, "0.00001"},
{"fantomTestnet", 4002, 8_000_000, "0.00001"},
{"polygonMatic", 800001, 8_000_000, "0.00001"},
{"harmonyMainnet", 1666600000, 8_000_000, "0.00001"},
{"harmonyTestnet", 1666700000, 8_000_000, "0.00001"},

{"gnosisMainnet", 100, 8_000_000, "0.00001"},
{"default", 0, 500000, "0.00001"},
{"mainnet", 1, 500000, "0.1"},
{"kovan", 42, 500000, "0.1"},

{"optimism", 10, 500000, "0.00001"},
{"optimism", 69, 500000, "0.00001"},
{"optimism", 420, 500000, "0.00001"},

{"bscMainnet", 56, 500000, "0.00001"},
{"hecoMainnet", 128, 500000, "0.00001"},
{"fantomMainnet", 250, 500000, "0.00001"},
{"fantomTestnet", 4002, 500000, "0.00001"},
{"polygonMatic", 800001, 500000, "0.00001"},
{"harmonyMainnet", 1666600000, 500000, "0.00001"},
{"harmonyTestnet", 1666700000, 500000, "0.00001"},

{"gnosisMainnet", 100, 500000, "0.00001"},
}
for _, test := range tests {
tt := test
Expand Down
6 changes: 0 additions & 6 deletions core/chains/evm/gas/block_history_estimator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1453,12 +1453,6 @@ func TestBlockHistoryEstimator_IsUsable(t *testing.T) {
assert.Equal(t, false, bhe.IsUsable(tx, block, chaintype.ChainWeMix, geCfg.PriceMin(), logger.Test(t)))
})

t.Run("returns false if transaction is of type 0x16 only on WeMix", func(t *testing.T) {
cfg.ChainTypeF = "wemix"
tx := evmtypes.Transaction{Type: 0x16, GasPrice: assets.NewWeiI(10), GasLimit: 42, Hash: utils.NewHash()}
assert.Equal(t, false, bhe.IsUsable(tx, block, cfg.ChainType(), geCfg.PriceMin(), logger.Test(t)))
})

t.Run("returns false if transaction has base fee higher than the gas price only on Celo", func(t *testing.T) {
tx := evmtypes.Transaction{Type: 0x0, GasPrice: assets.NewWeiI(10), GasLimit: 42, Hash: utils.NewHash()}
assert.Equal(t, false, bhe.IsUsable(tx, block, chaintype.ChainCelo, geCfg.PriceMin(), logger.Test(t)))
Expand Down
1 change: 0 additions & 1 deletion core/chains/evm/gas/chain_specific.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func chainSpecificIsUsable(tx evmtypes.Transaction, baseFee *assets.Wei, chainTy
return false
}
}

if chainType == chaintype.ChainZkSync {
// zKSync specific type for contract deployment & priority transactions
// https://era.zksync.io/docs/reference/concepts/transactions.html#eip-712-0x71
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/gas/rollups/l1_oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func NewL1GasOracle(lggr logger.Logger, ethClient l1OracleClient, chainType chai

switch chainType {
// FIXME Merge conflict, is it still valid?
//case chaintype.ChainOptimismBedrock, chaintype.ChainKroma, chaintype.ChainScroll, chaintype.ChainMantle, chaintype.ChainZircuit:
// case chaintype.ChainOptimismBedrock, chaintype.ChainKroma, chaintype.ChainScroll, chaintype.ChainMantle, chaintype.ChainZircuit:
// l1Oracle, err = NewOpStackL1GasOracle(lggr, ethClient, chainType)
case chaintype.ChainArbitrum:
l1Oracle, err = NewArbitrumL1GasOracle(lggr, ethClient)
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/gas/rollups/op_l1_oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

// Reads L2-specific precompiles and caches the l1GasPrice set by the L2.
//
//nolint:unused
// nolint:unused backported from CCIP
type optimismL1Oracle struct {
services.StateMachine
client l1OracleClient
Expand Down
4 changes: 2 additions & 2 deletions core/chains/evm/logpoller/disabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ func (disabled) Name() string { return "disabledLogPoller" }

func (disabled) Start(ctx context.Context) error { return ErrDisabled }

func (disabled) Close() error { return ErrDisabled }

func (disabled) Healthy() error {
return ErrDisabled
}

func (disabled) Close() error { return ErrDisabled }

func (disabled) Ready() error { return ErrDisabled }

func (disabled) HealthReport() map[string]error {
Expand Down
36 changes: 0 additions & 36 deletions core/chains/evm/logpoller/observability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package logpoller

import (
"fmt"
"math"
"math/big"
"testing"
"time"
Expand Down Expand Up @@ -149,41 +148,6 @@ func TestCountersAreProperlyPopulatedForWrites(t *testing.T) {
assert.Equal(t, float64(2), testutil.ToFloat64(orm.blocksInserted.WithLabelValues("420")))
}

func TestCounterAreProperlyPopulatedForDeletes(t *testing.T) {
ctx := testutils.Context(t)
orm := createObservedORM(t, 420)
logs := generateRandomLogs(420, 20)

for _, log := range logs {
err := orm.InsertLogsWithBlock(ctx, []Log{log}, NewLogPollerBlock(utils.RandomBytes32(), log.BlockNumber, time.Now(), 0))
require.NoError(t, err)
}

// Delete 5 logs
removed, err := orm.DeleteBlocksBefore(ctx, logs[4].BlockNumber, 100)
require.NoError(t, err)
assert.Equal(t, int64(5), removed)
assert.Equal(t, float64(5), testutil.ToFloat64(orm.datasetSize.WithLabelValues("420", "DeleteBlocksBefore", "delete")))

// Delete 1 more log
removed, err = orm.DeleteBlocksBefore(ctx, logs[5].BlockNumber, 100)
require.NoError(t, err)
assert.Equal(t, int64(1), removed)
assert.Equal(t, float64(1), testutil.ToFloat64(orm.datasetSize.WithLabelValues("420", "DeleteBlocksBefore", "delete")))

// Delete all
removed, err = orm.DeleteBlocksBefore(ctx, logs[len(logs)-1].BlockNumber, 0)
require.NoError(t, err)
assert.Equal(t, int64(14), removed)
assert.Equal(t, float64(14), testutil.ToFloat64(orm.datasetSize.WithLabelValues("420", "DeleteBlocksBefore", "delete")))

// Nothing to be deleted
removed, err = orm.DeleteBlocksBefore(ctx, math.MaxInt, 0)
require.NoError(t, err)
assert.Equal(t, int64(0), removed)
assert.Equal(t, float64(0), testutil.ToFloat64(orm.datasetSize.WithLabelValues("420", "DeleteBlocksBefore", "delete")))
}

func generateRandomLogs(chainId, count int) []Log {
logs := make([]Log, count)
for i := range logs {
Expand Down
1 change: 0 additions & 1 deletion core/chains/evm/txmgr/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ func (c *evmTxmClient) BatchGetReceipts(ctx context.Context, attempts []TxAttemp
for _, req := range reqs {
txErr = append(txErr, req.Error)
}

return txReceipt, txErr, nil
}

Expand Down
19 changes: 1 addition & 18 deletions core/chains/evm/txmgr/stuck_tx_detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func TestStuckTxDetector_DetectStuckTransactionsZircuit(t *testing.T) {
feeEstimator := gasmocks.NewEvmFeeEstimator(t)
// Return 10 gwei as market gas price
marketGasPrice := tenGwei
fee := gas.EvmFee{Legacy: marketGasPrice}
fee := gas.EvmFee{GasPrice: marketGasPrice}
feeEstimator.On("GetFee", mock.Anything, []byte{}, uint64(0), mock.Anything, mock.Anything, mock.Anything).Return(fee, uint64(0), nil)
ethClient := testutils.NewEthClientMockWithDefaultChain(t)
autoPurgeThreshold := uint32(5)
Expand Down Expand Up @@ -563,23 +563,6 @@ func mustInsertUnconfirmedTxWithBroadcastAttemptsContainsEmptyBroadcastBeforeBlo
return etx
}

// helper function for edge case where broadcast attempt contains empty pointer
func mustInsertUnconfirmedTxWithBroadcastAttemptsContainsEmptyBroadcastBeforeBlockNum(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress common.Address, numAttempts uint32, latestGasPrice *assets.Wei) txmgr.Tx {
ctx := tests.Context(t)
etx := cltest.MustInsertUnconfirmedEthTx(t, txStore, nonce, fromAddress)
// Insert attempts from oldest to newest
for i := int64(numAttempts - 1); i >= 0; i-- {
attempt := cltest.NewLegacyEthTxAttempt(t, etx.ID)
attempt.State = txmgrtypes.TxAttemptBroadcast
attempt.BroadcastBeforeBlockNum = nil
attempt.TxFee = gas.EvmFee{Legacy: latestGasPrice.Sub(assets.NewWeiI(i))}
require.NoError(t, txStore.InsertTxAttempt(ctx, &attempt))
}
etx, err := txStore.FindTxWithAttempts(ctx, etx.ID)
require.NoError(t, err)
return etx
}

func mustInsertFatalErrorTxWithError(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress common.Address, blockNum int64) txmgr.Tx {
etx := cltest.NewEthTx(fromAddress)
etx.State = txmgrcommon.TxFatalError
Expand Down
8 changes: 4 additions & 4 deletions core/chains/evm/types/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ func TestBlock_UnmarshalJSON(t *testing.T) {
t.Run("unmarshals geth block", func(t *testing.T) {
b := new(evmtypes.Block)
err := b.UnmarshalJSON([]byte(gethSampleBlock))
assert.NoError(t, err)
require.NoError(t, err)

assert.Equal(t, int64(15051090), b.Number)
assert.Equal(t, "0x45eb0a650b6b0b9fd1ee676b870e43fa7614f1034f7404070327a332faed05c0", b.Hash.Hex())
Expand All @@ -966,14 +966,14 @@ func TestBlock_UnmarshalJSON(t *testing.T) {
t.Run("handles empty result", func(t *testing.T) {
b := new(evmtypes.Block)
err := b.UnmarshalJSON([]byte("null"))
assert.Error(t, err)
require.Error(t, err)
assert.Equal(t, pkgerrors.Cause(err), evmtypes.ErrMissingBlock)
assert.True(t, pkgerrors.Is(err, evmtypes.ErrMissingBlock))
})
t.Run("unmarshals EIP-4844 block", func(t *testing.T) {
b := new(evmtypes.Block)
err := b.UnmarshalJSON([]byte(eip4844Block))
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, int64(5300694), b.Number)
assert.Equal(t, "0x3edd900025edab70dde26a52377c3d0a9474c3f540bd0131d58f508711272590", b.Hash.Hex())
assert.Equal(t, "0x077c1d68b52f8203cb90a71759a09b11c2a6577f97ea1fd4a8686a387fbedac8", b.ParentHash.Hex())
Expand All @@ -984,7 +984,7 @@ func TestBlock_UnmarshalJSON(t *testing.T) {
t.Run("unmarshals EIP-4844 block", func(t *testing.T) {
b := new(evmtypes.Block)
err := b.UnmarshalJSON([]byte(eip4844Block))
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, int64(5300694), b.Number)
assert.Equal(t, "0x3edd900025edab70dde26a52377c3d0a9474c3f540bd0131d58f508711272590", b.Hash.Hex())
assert.Equal(t, "0x077c1d68b52f8203cb90a71759a09b11c2a6577f97ea1fd4a8686a387fbedac8", b.ParentHash.Hex())
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/utils/ethabi.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func ABIEncode(abiStr string, values ...interface{}) ([]byte, error) {
return res[4:], nil
}

// ABIDecode is the equivalent of abi.decode.
// ABIEncode is the equivalent of abi.decode.
// See a full set of examples https://github.com/ethereum/go-ethereum/blob/420b78659bef661a83c5c442121b13f13288c09f/accounts/abi/packing_test.go#L31
func ABIDecode(abiStr string, data []byte) ([]interface{}, error) {
inDef := fmt.Sprintf(`[{ "name" : "method", "type": "function", "outputs": %s}]`, abiStr)
Expand Down
3 changes: 0 additions & 3 deletions core/gethwrappers/go_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ package gethwrappers
//go:generate go generate ./liquiditymanager
//go:generate go generate ./workflow

// CCIP
//go:generate go generate ./ccip

// Mocks that contain only events and functions to emit them
// These contracts are used in testing Atlas flows. The contracts contain no logic, only events, structures, and functions to emit them.
// The flow is as follows:
Expand Down
1 change: 0 additions & 1 deletion core/services/blockheaderfeeder/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"go.uber.org/multierr"

"github.com/smartcontractkit/chainlink-common/pkg/services"

"github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm"
"github.com/smartcontractkit/chainlink/v2/core/config"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/batch_blockhash_store"
Expand Down
1 change: 1 addition & 0 deletions core/services/chainlink/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/bridges"
"github.com/smartcontractkit/chainlink/v2/core/build"
"github.com/smartcontractkit/chainlink/v2/core/capabilities"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip"
gatewayconnector "github.com/smartcontractkit/chainlink/v2/core/capabilities/gateway_connector"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/remote"
remotetypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/remote/types"
Expand Down
4 changes: 0 additions & 4 deletions core/services/chainlink/config_feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ func (f *featureConfig) UICSAKeys() bool {
return *f.c.UICSAKeys
}

func (f *featureConfig) CCIP() bool {
return *f.c.CCIP
}

func (f *featureConfig) MultiFeedsManagers() bool {
return *f.c.MultiFeedsManagers
}
4 changes: 2 additions & 2 deletions core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ func TestConfig_Marshal(t *testing.T) {
LogBackfillBatchSize: ptr[uint32](17),
LogPollInterval: &minute,
LogKeepBlocksDepth: ptr[uint32](100000),
LogPrunePageSize: ptr[uint32](10000),
LogPrunePageSize: ptr[uint32](0),
BackupLogPollerBlockDelay: ptr[uint64](532),
MinContractPayment: commonassets.NewLinkFromJuels(math.MaxInt64),
MinIncomingConfirmations: ptr[uint32](13),
Expand Down Expand Up @@ -1106,7 +1106,7 @@ LinkContractAddress = '0x538aAaB4ea120b2bC2fe5D296852D948F07D849e'
LogBackfillBatchSize = 17
LogPollInterval = '1m0s'
LogKeepBlocksDepth = 100000
LogPrunePageSize = 10000
LogPrunePageSize = 0
BackupLogPollerBlockDelay = 532
MinIncomingConfirmations = 13
MinContractPayment = '9.223372036854775807 link'
Expand Down
2 changes: 1 addition & 1 deletion core/services/chainlink/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ LinkContractAddress = '0x538aAaB4ea120b2bC2fe5D296852D948F07D849e'
LogBackfillBatchSize = 17
LogPollInterval = '1m0s'
LogKeepBlocksDepth = 100000
LogPrunePageSize = 10000
LogPrunePageSize = 0
BackupLogPollerBlockDelay = 532
MinIncomingConfirmations = 13
MinContractPayment = '9.223372036854775807 link'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ LinkContractAddress = '0x514910771AF9Ca656af840dff83E8264EcF986CA'
LogBackfillBatchSize = 1000
LogPollInterval = '15s'
LogKeepBlocksDepth = 100000
LogPrunePageSize = 10000
LogPrunePageSize = 0
BackupLogPollerBlockDelay = 100
MinIncomingConfirmations = 3
MinContractPayment = '0.1 link'
Expand Down Expand Up @@ -339,8 +339,8 @@ Mode = 'BlockHistory'
PriceDefault = '20 gwei'
PriceMax = '115792089237316195423570985008687907853269984665.640564039457584007913129639935 tether'
PriceMin = '1 gwei'
LimitDefault = 8000000
LimitMax = 8000000
LimitDefault = 500000
LimitMax = 500000
LimitMultiplier = '1'
LimitTransfer = 21000
EstimateLimit = false
Expand Down Expand Up @@ -417,7 +417,7 @@ LinkContractAddress = '0xa36085F69e2889c224210F603D836748e7dC0088'
LogBackfillBatchSize = 1000
LogPollInterval = '15s'
LogKeepBlocksDepth = 100000
LogPrunePageSize = 10000
LogPrunePageSize = 0
BackupLogPollerBlockDelay = 100
MinIncomingConfirmations = 3
MinContractPayment = '0.1 link'
Expand Down Expand Up @@ -450,8 +450,8 @@ Mode = 'BlockHistory'
PriceDefault = '9.223372036854775807 ether'
PriceMax = '115792089237316195423570985008687907853269984665.640564039457584007913129639935 tether'
PriceMin = '1 gwei'
LimitDefault = 8000000
LimitMax = 8000000
LimitDefault = 500000
LimitMax = 500000
LimitMultiplier = '1'
LimitTransfer = 21000
EstimateLimit = false
Expand Down Expand Up @@ -523,7 +523,7 @@ LinkContractAddress = '0xb0897686c545045aFc77CF20eC7A532E3120E0F1'
LogBackfillBatchSize = 1000
LogPollInterval = '1s'
LogKeepBlocksDepth = 100000
LogPrunePageSize = 10000
LogPrunePageSize = 0
BackupLogPollerBlockDelay = 100
MinIncomingConfirmations = 5
MinContractPayment = '0.00001 link'
Expand Down Expand Up @@ -555,8 +555,8 @@ Mode = 'FixedPrice'
PriceDefault = '30 gwei'
PriceMax = '115792089237316195423570985008687907853269984665.640564039457584007913129639935 tether'
PriceMin = '30 gwei'
LimitDefault = 8000000
LimitMax = 8000000
LimitDefault = 500000
LimitMax = 500000
LimitMultiplier = '1'
LimitTransfer = 21000
EstimateLimit = false
Expand Down
Loading

0 comments on commit f04214d

Please sign in to comment.