Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions common/logpoller/mocks/log_poller.go

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

66 changes: 66 additions & 0 deletions core/cmd/blocks_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import (
"bytes"
"encoding/json"
stderrors "errors"
"fmt"
"net/url"
Expand All @@ -21,7 +22,7 @@
Action: s.ReplayFromBlock,
Flags: []cli.Flag{
cli.IntFlag{
Name: "block-number",

Check warning on line 25 in core/cmd/blocks_commands.go

View check run for this annotation

CL-sonarqube-production / SonarQube Code Analysis

Define a constant instead of duplicating this literal "block-number" 4 times.

[S1192] String literals should not be duplicated See more on https://sonarqube.main.prod.cldev.sh/project/issues?id=smartcontractkit_chainlink&pullRequest=23099&issues=256c5324-6f96-4dae-a5be-470c09842eec&open=256c5324-6f96-4dae-a5be-470c09842eec
Usage: "Block number to replay from",
Required: true,
},
Expand All @@ -31,7 +32,7 @@
Required: true,
},
cli.StringFlag{
Name: "chain-id",

Check warning on line 35 in core/cmd/blocks_commands.go

View check run for this annotation

CL-sonarqube-production / SonarQube Code Analysis

Define a constant instead of duplicating this literal "chain-id" 6 times.

[S1192] String literals should not be duplicated See more on https://sonarqube.main.prod.cldev.sh/project/issues?id=smartcontractkit_chainlink&pullRequest=23099&issues=6510c80f-8099-422c-af5a-b4e5065d7335&open=6510c80f-8099-422c-af5a-b4e5065d7335
Usage: "Chain ID of the blockchain",
Required: true,
},
Expand All @@ -53,6 +54,28 @@
},
},
},
{
Name: "lp-skip-to-block",
Usage: `Reposition LogPoller to start processing from the given finalized block number. Note: LogPoller does not guarantee that finalized blocks in the DB and specified block belong to the same chain. LogPoller will remove all unfinalized logs before saving new checkpoint.`,
Action: s.LPSkipToBlock,
Flags: []cli.Flag{
cli.Int64Flag{
Name: "block-number",
Usage: "Block number to skip to",
Required: true,
},
cli.StringFlag{
Name: "family",
Usage: "Chain family for specified chain-id (currently only evm is supported)",
Required: true,
},
cli.StringFlag{
Name: "chain-id",
Usage: "Chain ID of the blockchain",
Required: true,
},
},
},
}
}

Expand Down Expand Up @@ -140,3 +163,46 @@

return s.renderAPIResponse(resp, &LCAPresenter{}, "Last Common Ancestor")
}

// LPSkipToBlock repositions LogPoller to start processing from the given block number.
func (s *Shell) LPSkipToBlock(c *cli.Context) (err error) {
blockNumber := c.Int64("block-number")
if blockNumber < 2 {
return s.errorOut(errors.New("Must pass a value >= 2 in '--block-number' parameter"))
}

if !c.IsSet("family") {
return s.errorOut(errors.New("Must set '--family' parameter to specify chain family type"))
}

if !c.IsSet("chain-id") {
return s.errorOut(errors.New("Must set '--chain-id' parameter"))
}

request, err := json.Marshal(web.LPSkipToBlockRequest{
BlockNumber: blockNumber,
Family: c.String("family"),
ChainID: c.String("chain-id"),
})
if err != nil {
return s.errorOut(err)
}

resp, err := s.HTTP.Post(s.ctx(), "/v2/lp_skip_to_block", bytes.NewReader(request))
if err != nil {
return s.errorOut(errors.Wrap(err, "failed to send request to reposition LogPoller"))
}

defer func() {
if cerr := resp.Body.Close(); cerr != nil {
err = stderrors.Join(err, cerr)
}
}()

_, err = s.parseResponse(resp)
if err != nil {
return s.errorOut(err)
}
fmt.Println("Log poller will start processing from the new block on next tick")
return nil
}
37 changes: 36 additions & 1 deletion core/cmd/blocks_commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func Test_ReplayFromBlock(t *testing.T) {
flagSetApplyFromAction(client.ReplayFromBlock, set, "")

t.Run("invalid args", func(t *testing.T) {
t.Parallel()
// Incorrect block number
require.NoError(t, set.Set("block-number", "0"))
c := cli.NewContext(nil, set, nil)
Expand All @@ -45,6 +46,7 @@ func Test_ReplayFromBlock(t *testing.T) {
})

t.Run("evm replay", func(t *testing.T) {
t.Parallel()
require.NoError(t, set.Set("block-number", "1"))
require.NoError(t, set.Set("chain-id", "5"))
require.NoError(t, set.Set("family", "evm"))
Expand All @@ -59,7 +61,7 @@ func Test_FindLCA(t *testing.T) {
// ethClient.On("BalanceAt", mock.Anything, mock.Anything, mock.Anything).Return(big.NewInt(42), nil)
app := startNewApplicationV2(t, func(c *chainlink.Config, s *chainlink.Secrets) {
c.EVM[0].ChainID = (*sqlutil.Big)(big.NewInt(5))
c.EVM[0].Enabled = ptr(true)
c.EVM[0].Enabled = new(true)
})

client, _ := app.NewShellAndRenderer()
Expand All @@ -77,3 +79,36 @@ func Test_FindLCA(t *testing.T) {
c = cli.NewContext(nil, set, nil)
require.ErrorContains(t, client.FindLCA(c), "FindLCA is only available if LogPoller is enabled")
}

func Test_LPSkipToBlock(t *testing.T) {
t.Parallel()

app := startNewApplicationV2(t, func(c *chainlink.Config, s *chainlink.Secrets) {
c.Feature.LogPoller = new(true)
c.EVM[0].ChainID = (*sqlutil.Big)(big.NewInt(5))
c.EVM[0].Enabled = new(true)
})

client, _ := app.NewShellAndRenderer()

set := flag.NewFlagSet("test", 0)
flagSetApplyFromAction(client.LPSkipToBlock, set, "")

t.Run("invalid args", func(t *testing.T) {
t.Parallel()
require.NoError(t, set.Set("block-number", "1"))
c := cli.NewContext(nil, set, nil)
require.ErrorContains(t, client.LPSkipToBlock(c), "Must pass a value >= 2")

require.NoError(t, set.Set("block-number", "100"))
require.NoError(t, set.Set("chain-id", "123"))
require.NoError(t, set.Set("family", "evm"))
c = cli.NewContext(nil, set, nil)
require.ErrorContains(t, client.LPSkipToBlock(c), "relayer does not exist")

require.NoError(t, set.Set("chain-id", "5"))
require.NoError(t, set.Set("family", "solana"))
c = cli.NewContext(nil, set, nil)
require.ErrorContains(t, client.LPSkipToBlock(c), "only evm is supported")
})
}
49 changes: 49 additions & 0 deletions core/internal/mocks/application.go

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

36 changes: 19 additions & 17 deletions core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ require (
github.com/moby/moby/api v1.54.2
github.com/moby/moby/client v0.4.1
github.com/montanaflynn/stats v0.7.1
github.com/olekukonko/tablewriter v0.0.5
github.com/olekukonko/tablewriter v1.0.9
github.com/pelletier/go-toml/v2 v2.3.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.23.2
Expand All @@ -47,20 +47,20 @@ require (
github.com/smartcontractkit/chain-selectors v1.0.106
github.com/smartcontractkit/chainlink-automation v0.8.1
github.com/smartcontractkit/chainlink-ccip/chains/evm v0.0.0-20260624154507-ea7ff77a0ddb
github.com/smartcontractkit/chainlink-common v0.11.2-0.20260714160921-4033d0253977
github.com/smartcontractkit/chainlink-common/keystore v1.2.0
github.com/smartcontractkit/chainlink-common v0.11.2-0.20260715145851-8219609496a4
github.com/smartcontractkit/chainlink-common/keystore v1.2.1-0.20260623104656-f39eba3e2bc6
github.com/smartcontractkit/chainlink-data-streams v0.1.15-0.20260707105132-2da5d31f22fc
github.com/smartcontractkit/chainlink-deployments-framework v0.111.1-0.20260612191326-e31c0ae4cd54
github.com/smartcontractkit/chainlink-evm v0.3.4-0.20260623170329-4577ef4ba0ae
github.com/smartcontractkit/chainlink-evm v0.3.4-0.20260715161014-611d8ac32364
github.com/smartcontractkit/chainlink-evm/gethwrappers v0.0.0-20260713161920-de075095648b
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20260623200841-e0322b819f62
github.com/smartcontractkit/chainlink-protos/job-distributor v0.20.1-0.20260701185448-696c075849ea
github.com/smartcontractkit/chainlink-testing-framework/framework v0.16.6-0.20260630120514-36abe27604df
github.com/smartcontractkit/chainlink-testing-framework/framework v0.16.6-0.20260708113039-95f97b2d25e9
github.com/smartcontractkit/chainlink-testing-framework/framework/components/dockercompose v0.1.23
github.com/smartcontractkit/chainlink-testing-framework/seth v1.51.5
github.com/smartcontractkit/chainlink/core/scripts/cre/environment/examples/workflows/proof-of-reserve/cron-based v0.0.0-00010101000000-000000000000
github.com/smartcontractkit/chainlink/system-tests/lib v0.0.0-00010101000000-000000000000
github.com/smartcontractkit/libocr v0.0.0-20260508200755-99940c85383c
github.com/smartcontractkit/libocr v0.0.0-20260529134643-c101335a64cd
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
github.com/spf13/viper v1.21.0
Expand Down Expand Up @@ -109,14 +109,14 @@ require (
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
github.com/Azure/go-ntlmssp v0.1.1 // indirect
github.com/BurntSushi/toml v1.6.0 // indirect
github.com/DataDog/zstd v1.5.6 // indirect
github.com/DataDog/zstd v1.5.7 // indirect
github.com/DefangLabs/secret-detector v0.0.0-20250403165618-22662109213e // indirect
github.com/Depado/ginprom v1.8.0 // indirect
github.com/Khan/genqlient v0.8.1 // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/NethermindEth/juno v0.12.5 // indirect
github.com/NethermindEth/starknet.go v0.8.0 // indirect
github.com/NethermindEth/juno v0.15.11 // indirect
github.com/NethermindEth/starknet.go v0.17.1 // indirect
github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260416073033-7c2071eaa8d4 // indirect
github.com/Unheilbar/anchor-go v1.0.3 // indirect
github.com/VictoriaMetrics/fastcache v1.13.0 // indirect
Expand Down Expand Up @@ -180,12 +180,12 @@ require (
github.com/cloudevents/sdk-go/binding/format/protobuf/v2 v2.16.2 // indirect
github.com/cloudevents/sdk-go/v2 v2.16.2 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
github.com/cockroachdb/errors v1.12.0 // indirect
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 // indirect
github.com/cockroachdb/pebble v1.1.5 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cockroachdb/redact v1.1.6 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb // indirect
github.com/coder/websocket v1.8.14 // indirect
github.com/cometbft/cometbft v0.38.21 // indirect
github.com/cometbft/cometbft-db v1.0.1 // indirect
Expand Down Expand Up @@ -263,7 +263,7 @@ require (
github.com/gagliardetto/solana-go v1.13.0 // indirect
github.com/gagliardetto/treeout v0.1.4 // indirect
github.com/gedex/inflector v0.0.0-20170307190818-16278e9db813 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/getsentry/sentry-go v0.35.1 // indirect
github.com/gin-contrib/cors v1.7.2 // indirect
github.com/gin-contrib/expvar v0.0.1 // indirect
github.com/gin-contrib/sessions v0.0.5 // indirect
Expand Down Expand Up @@ -492,13 +492,13 @@ require (
github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee // indirect
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20260624154507-ea7ff77a0ddb // indirect
github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings v0.0.0-20260624154507-ea7ff77a0ddb // indirect
github.com/smartcontractkit/chainlink-ccv v0.0.2-0.20260706093831-dad26b360094 // indirect
github.com/smartcontractkit/chainlink-ccv v0.1.1-0.20260715132147-59df1b138100 // indirect
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.11-0.20260626151909-052e55e62e62 // indirect
github.com/smartcontractkit/chainlink-evm/contracts/cre/gobindings v0.0.0-20260403151002-2c91155b5501 // indirect
github.com/smartcontractkit/chainlink-feeds v0.1.2-0.20250227211209-7cd000095135 // indirect
github.com/smartcontractkit/chainlink-framework/capabilities v0.0.0-20260423135514-5b1a7565a99c // indirect
github.com/smartcontractkit/chainlink-framework/chains v0.0.0-20260423135514-5b1a7565a99c // indirect
github.com/smartcontractkit/chainlink-framework/metrics v0.0.0-20260521164805-26d78d5e1243 // indirect
github.com/smartcontractkit/chainlink-framework/chains v0.0.0-20260709082627-78ab5315e367 // indirect
github.com/smartcontractkit/chainlink-framework/metrics v0.0.0-20260709082627-78ab5315e367 // indirect
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20260625152110-9afcf56e4053 // indirect
github.com/smartcontractkit/chainlink-protos/billing/go v0.0.0-20251024234028-0988426d98f4 // indirect
github.com/smartcontractkit/chainlink-protos/chainlink-ccv/committee-verifier v0.0.0-20251211142334-5c3421fe2c8d // indirect
Expand Down Expand Up @@ -661,3 +661,5 @@ replace github.com/fbsobreira/gotron-sdk => github.com/smartcontractkit/chainlin
// docker/cli@v28.5.x still uses. docker/compose has not migrated to docker/cli v29
// yet, so we pin to v0.1.0 which has both the old aliases and the new compression API.
replace github.com/moby/go-archive v0.2.0 => github.com/moby/go-archive v0.1.0

replace github.com/olekukonko/tablewriter => github.com/olekukonko/tablewriter v0.0.5
Loading
Loading