Skip to content

Commit

Permalink
Post cherry-pick fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-sekara committed Nov 15, 2023
1 parent 0f9bf06 commit a4b98b9
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 19 deletions.
4 changes: 2 additions & 2 deletions core/chains/evm/logpoller/orm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ func TestInsertLogsWithBlock(t *testing.T) {
// We need full db here, because we want to test transaction rollbacks.
// Using pgtest.NewSqlxDB(t) will run all tests in TXs which is not desired for this type of test
// (inner tx rollback will rollback outer tx, blocking rest of execution)
_, db := heavyweight.FullTestDBV2(t, nil)
_, db := heavyweight.FullTestDBV2(t, "insert_test", nil)
o := logpoller.NewORM(chainID, db, logger.TestLogger(t), pgtest.NewQConfig(true))

correctLog := GenLog(chainID, 1, 1, utils.RandomAddress().String(), event[:], address)
Expand Down Expand Up @@ -1389,7 +1389,7 @@ func TestInsertLogsInTx(t *testing.T) {
maxLogsSize := 9000

// We need full db here, because we want to test transaction rollbacks.
_, db := heavyweight.FullTestDBV2(t, nil)
_, db := heavyweight.FullTestDBV2(t, "insert_logs_tx", nil)
o := logpoller.NewORM(chainID, db, logger.TestLogger(t), pgtest.NewQConfig(true))

logs := make([]logpoller.Log, maxLogsSize, maxLogsSize+1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ func (r *ExecutionReportingPlugin) getReportsWithSendRequests(
}

// get executable sequence numbers
executedMp, err := r.getExecutedSeqNrsInRange(ctx, intervalMin, intervalMax, latestBlock)
executedMp, err := r.getExecutedSeqNrsInRange(ctx, intervalMin, intervalMax, latestBlock.BlockNumber)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller"
lpMocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal"
Expand Down Expand Up @@ -108,7 +109,7 @@ func TestExecutionReportingPlugin_Observation(t *testing.T) {
p.config.commitStoreReader = commitStoreReader

destReader := ccipdatamocks.NewReader(t)
destReader.On("LatestBlock", ctx).Return(int64(1234), nil).Maybe()
destReader.On("LatestBlock", ctx).Return(logpoller.LogPollerBlock{BlockNumber: 1234}, nil).Maybe()
p.config.destReader = destReader

var executionEvents []ccipdata.Event[ccipdata.ExecutionStateChanged]
Expand Down Expand Up @@ -1014,7 +1015,7 @@ func TestExecutionReportingPlugin_getReportsWithSendRequests(t *testing.T) {
p.config.onRampReader = sourceReader

destReader := ccipdatamocks.NewReader(t)
destReader.On("LatestBlock", ctx).Return(tc.destLatestBlock, nil).Maybe()
destReader.On("LatestBlock", ctx).Return(logpoller.LogPollerBlock{BlockNumber: tc.destLatestBlock}, nil).Maybe()
var executedEvents []ccipdata.Event[ccipdata.ExecutionStateChanged]
for _, executedSeqNum := range tc.destExecutedSeqNums {
executedEvents = append(executedEvents, ccipdata.Event[ccipdata.ExecutionStateChanged]{
Expand Down
2 changes: 1 addition & 1 deletion core/services/ocr2/plugins/ccip/internal/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (c *CachedChain[T]) initializeCache(ctx context.Context) (T, error) {
return empty, err
}

c.updateCache(value, latestBlock-c.optimisticConfirmations)
c.updateCache(value, latestBlock.BlockNumber-c.optimisticConfirmations)
return c.copyCachedValue(), nil

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (

func TestGet_InitDataForTheFirstTime(t *testing.T) {
lp := lpMocks.NewLogPoller(t)
lp.On("LatestBlock", mock.Anything).Maybe().Return(int64(100), nil)
lp.On("LatestBlock", mock.Anything).Maybe().Return(logpoller.LogPollerBlock{BlockNumber: 100}, nil)

contract := newCachedContract(lp, "", []string{"value1"}, 0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/smartcontractkit/chainlink/v2/core/logger"
Expand Down Expand Up @@ -74,7 +75,7 @@ func TestNewTokenPools(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
mockLp := mocks.NewLogPoller(t)
mockLp.On("LatestBlock", mock.Anything).Return(int64(100), nil)
mockLp.On("LatestBlock", mock.Anything).Return(logpoller.LogPollerBlock{BlockNumber: 100}, nil)

offRamp := ccipdatamocks.NewOffRampReader(t)
offRamp.On("TokenEvents").Return([]common.Hash{})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewLogPollerReader(lp logpoller.LogPoller, lggr logger.Logger, client evmcl
}
}

func (c *LogPollerReader) LatestBlock(ctx context.Context) (int64, error) {
func (c *LogPollerReader) LatestBlock(ctx context.Context) (logpoller.LogPollerBlock, error) {
return c.lp.LatestBlock(pg.WithParentCtx(ctx))
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/rpclib"
Expand Down Expand Up @@ -79,7 +80,7 @@ func TestOffRampGetDestinationTokensFromSourceTokens(t *testing.T) {
}

lp := mocks.NewLogPoller(t)
lp.On("LatestBlock", mock.Anything).Return(int64(rand.Uint64()), nil)
lp.On("LatestBlock", mock.Anything).Return(logpoller.LogPollerBlock{BlockNumber: rand.Int63()}, nil)

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (o *OffRampV1_0_0) GetDestinationTokensFromSourceTokens(ctx context.Context
return nil, fmt.Errorf("get latest block: %w", err)
}

results, err := o.evmBatchCaller.BatchCall(ctx, uint64(latestBlock), evmCalls)
results, err := o.evmBatchCaller.BatchCall(ctx, uint64(latestBlock.BlockNumber), evmCalls)
if err != nil {
return nil, fmt.Errorf("batch call limit: %w", err)
}
Expand Down Expand Up @@ -207,7 +207,7 @@ func (o *OffRampV1_0_0) GetTokenPoolsRateLimits(ctx context.Context, poolAddress
return nil, fmt.Errorf("get latest block: %w", err)
}

results, err := o.evmBatchCaller.BatchCall(ctx, uint64(latestBlock), evmCalls)
results, err := o.evmBatchCaller.BatchCall(ctx, uint64(latestBlock.BlockNumber), evmCalls)
if err != nil {
return nil, fmt.Errorf("batch call limit: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (p *PriceRegistryV1_0_0) GetTokensDecimals(ctx context.Context, tokenAddres
return nil, fmt.Errorf("get latest block: %w", err)
}

results, err := p.evmBatchCaller.BatchCall(ctx, uint64(latestBlock), evmCalls)
results, err := p.evmBatchCaller.BatchCall(ctx, uint64(latestBlock.BlockNumber), evmCalls)
if err != nil {
return nil, fmt.Errorf("batch call limit: %w", err)
}
Expand Down
3 changes: 2 additions & 1 deletion core/services/ocr2/plugins/ccip/internal/ccipdata/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/ethereum/go-ethereum/common"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller"
"github.com/smartcontractkit/chainlink/v2/core/services/pg"
)

Expand Down Expand Up @@ -36,5 +37,5 @@ type Closer interface {
//go:generate mockery --quiet --name Reader --filename reader_mock.go --case=underscore
type Reader interface {
// LatestBlock returns the latest known/parsed block of the underlying implementation.
LatestBlock(ctx context.Context) (int64, error)
LatestBlock(ctx context.Context) (logpoller.LogPollerBlock, error)
}

0 comments on commit a4b98b9

Please sign in to comment.