diff --git a/Makefile b/Makefile
index 55e035f8362..c78ffa8530d 100644
--- a/Makefile
+++ b/Makefile
@@ -230,6 +230,7 @@ devtools:
## mocks: generate test mocks
mocks:
+ @cd erigon-lib && $(MAKE) mocks
rm -f $(GOBIN)/mockgen
$(GOBUILD) -o "$(GOBIN)/mockgen" go.uber.org/mock/mockgen
grep -r -l --exclude-dir="erigon-lib" --exclude-dir="tests" --exclude-dir="*$(GOBINREL)*" "^// Code generated by MockGen. DO NOT EDIT.$$" . | xargs rm -r
diff --git a/cl/beacon/synced_data/mock_services/synced_data_mock.go b/cl/beacon/synced_data/mock_services/synced_data_mock.go
index c89b8a7826e..5a37152a15b 100644
--- a/cl/beacon/synced_data/mock_services/synced_data_mock.go
+++ b/cl/beacon/synced_data/mock_services/synced_data_mock.go
@@ -22,6 +22,7 @@ import (
type MockSyncedData struct {
ctrl *gomock.Controller
recorder *MockSyncedDataMockRecorder
+ isgomock struct{}
}
// MockSyncedDataMockRecorder is the mock recorder for MockSyncedData.
@@ -42,17 +43,17 @@ func (m *MockSyncedData) EXPECT() *MockSyncedDataMockRecorder {
}
// CommitteeCount mocks base method.
-func (m *MockSyncedData) CommitteeCount(arg0 uint64) uint64 {
+func (m *MockSyncedData) CommitteeCount(epoch uint64) uint64 {
m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "CommitteeCount", arg0)
+ ret := m.ctrl.Call(m, "CommitteeCount", epoch)
ret0, _ := ret[0].(uint64)
return ret0
}
// CommitteeCount indicates an expected call of CommitteeCount.
-func (mr *MockSyncedDataMockRecorder) CommitteeCount(arg0 any) *MockSyncedDataCommitteeCountCall {
+func (mr *MockSyncedDataMockRecorder) CommitteeCount(epoch any) *MockSyncedDataCommitteeCountCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitteeCount", reflect.TypeOf((*MockSyncedData)(nil).CommitteeCount), arg0)
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitteeCount", reflect.TypeOf((*MockSyncedData)(nil).CommitteeCount), epoch)
return &MockSyncedDataCommitteeCountCall{Call: call}
}
@@ -156,17 +157,17 @@ func (c *MockSyncedDataHeadSlotCall) DoAndReturn(f func() uint64) *MockSyncedDat
}
// OnHeadState mocks base method.
-func (m *MockSyncedData) OnHeadState(arg0 *state.CachingBeaconState) error {
+func (m *MockSyncedData) OnHeadState(newState *state.CachingBeaconState) error {
m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "OnHeadState", arg0)
+ ret := m.ctrl.Call(m, "OnHeadState", newState)
ret0, _ := ret[0].(error)
return ret0
}
// OnHeadState indicates an expected call of OnHeadState.
-func (mr *MockSyncedDataMockRecorder) OnHeadState(arg0 any) *MockSyncedDataOnHeadStateCall {
+func (mr *MockSyncedDataMockRecorder) OnHeadState(newState any) *MockSyncedDataOnHeadStateCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnHeadState", reflect.TypeOf((*MockSyncedData)(nil).OnHeadState), arg0)
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnHeadState", reflect.TypeOf((*MockSyncedData)(nil).OnHeadState), newState)
return &MockSyncedDataOnHeadStateCall{Call: call}
}
@@ -268,17 +269,17 @@ func (c *MockSyncedDataUnsetHeadStateCall) DoAndReturn(f func()) *MockSyncedData
}
// ViewHeadState mocks base method.
-func (m *MockSyncedData) ViewHeadState(arg0 synced_data.ViewHeadStateFn) error {
+func (m *MockSyncedData) ViewHeadState(fn synced_data.ViewHeadStateFn) error {
m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "ViewHeadState", arg0)
+ ret := m.ctrl.Call(m, "ViewHeadState", fn)
ret0, _ := ret[0].(error)
return ret0
}
// ViewHeadState indicates an expected call of ViewHeadState.
-func (mr *MockSyncedDataMockRecorder) ViewHeadState(arg0 any) *MockSyncedDataViewHeadStateCall {
+func (mr *MockSyncedDataMockRecorder) ViewHeadState(fn any) *MockSyncedDataViewHeadStateCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ViewHeadState", reflect.TypeOf((*MockSyncedData)(nil).ViewHeadState), arg0)
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ViewHeadState", reflect.TypeOf((*MockSyncedData)(nil).ViewHeadState), fn)
return &MockSyncedDataViewHeadStateCall{Call: call}
}
diff --git a/cmd/devnet/services/polygon/heimdall.go b/cmd/devnet/services/polygon/heimdall.go
index bf84b399d3e..077db74c2c5 100644
--- a/cmd/devnet/services/polygon/heimdall.go
+++ b/cmd/devnet/services/polygon/heimdall.go
@@ -424,7 +424,7 @@ func (h *Heimdall) Start(ctx context.Context) error {
return startHTTPServer(ctx, server, "devnet Heimdall service", h.logger)
}
-func makeHeimdallRouter(ctx context.Context, client heimdall.HeimdallClient) *chi.Mux {
+func makeHeimdallRouter(ctx context.Context, client heimdall.Client) *chi.Mux {
router := chi.NewRouter()
writeResponse := func(w http.ResponseWriter, result any, err error) {
diff --git a/cmd/devnet/services/polygon/heimdall_test.go b/cmd/devnet/services/polygon/heimdall_test.go
index 26c9d350da2..305e0511af6 100644
--- a/cmd/devnet/services/polygon/heimdall_test.go
+++ b/cmd/devnet/services/polygon/heimdall_test.go
@@ -34,7 +34,7 @@ func TestHeimdallServer(t *testing.T) {
ctx := context.Background()
ctrl := gomock.NewController(t)
- client := heimdall.NewMockHeimdallClient(ctrl)
+ client := heimdall.NewMockClient(ctrl)
events := []*heimdall.EventRecordWithTime{
{
diff --git a/cmd/devnet/services/polygon/heimdallsim/heimdall_simulator.go b/cmd/devnet/services/polygon/heimdallsim/heimdall_simulator.go
index 2c967f30b85..1904340e036 100644
--- a/cmd/devnet/services/polygon/heimdallsim/heimdall_simulator.go
+++ b/cmd/devnet/services/polygon/heimdallsim/heimdall_simulator.go
@@ -43,7 +43,7 @@ type HeimdallSimulator struct {
logger log.Logger
}
-var _ heimdall.HeimdallClient = (*HeimdallSimulator)(nil)
+var _ heimdall.Client = (*HeimdallSimulator)(nil)
type sprintLengthCalculator struct{}
diff --git a/cmd/integration/commands/stages.go b/cmd/integration/commands/stages.go
index a701f6908ac..6ca998d55e0 100644
--- a/cmd/integration/commands/stages.go
+++ b/cmd/integration/commands/stages.go
@@ -1539,7 +1539,7 @@ func overrideStorageMode(db kv.RwDB, logger log.Logger) error {
})
}
-func initConsensusEngine(ctx context.Context, cc *chain2.Config, dir string, db kv.RwDB, blockReader services.FullBlockReader, logger log.Logger) (engine consensus.Engine, heimdallClient heimdall.HeimdallClient) {
+func initConsensusEngine(ctx context.Context, cc *chain2.Config, dir string, db kv.RwDB, blockReader services.FullBlockReader, logger log.Logger) (engine consensus.Engine, heimdallClient heimdall.Client) {
config := ethconfig.Defaults
var consensusConfig interface{}
@@ -1551,7 +1551,7 @@ func initConsensusEngine(ctx context.Context, cc *chain2.Config, dir string, db
consensusConfig = cc.Bor
config.HeimdallURL = HeimdallURL
if !config.WithoutHeimdall {
- heimdallClient = heimdall.NewHeimdallClient(config.HeimdallURL, logger)
+ heimdallClient = heimdall.NewHttpClient(config.HeimdallURL, logger)
}
} else {
consensusConfig = &config.Ethash
diff --git a/erigon-lib/Makefile b/erigon-lib/Makefile
index 7c1460e3849..1b8e304b0e2 100644
--- a/erigon-lib/Makefile
+++ b/erigon-lib/Makefile
@@ -95,7 +95,7 @@ grpc: protoc-all
mocks:
rm -f $(GOBIN)/mockgen
$(GOBUILD) -o "$(GOBIN)/mockgen" go.uber.org/mock/mockgen
-# grep -r -l --exclude-dir="*$(GOBINREL)*" "^// Code generated by MockGen. DO NOT EDIT.$$" . | xargs rm -r
+ grep -r -l --exclude-dir="*$(GOBINREL)*" "^// Code generated by MockGen. DO NOT EDIT.$$" . | xargs rm -r
PATH="$(GOBIN):$(PATH)" go generate -run "mockgen" ./...
lintci-deps:
diff --git a/eth/backend.go b/eth/backend.go
index c8d40146d70..f527dcb6406 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -530,7 +530,7 @@ func New(ctx context.Context, stack *node.Node, config *ethconfig.Config, logger
consensusConfig = &config.Ethash
}
- var heimdallClient heimdall.HeimdallClient
+ var heimdallClient heimdall.Client
var polygonBridge *bridge.Service
var heimdallService *heimdall.Service
var bridgeRPC *bridge.BackendServer
@@ -538,7 +538,7 @@ func New(ctx context.Context, stack *node.Node, config *ethconfig.Config, logger
if chainConfig.Bor != nil {
if !config.WithoutHeimdall {
- heimdallClient = heimdall.NewHeimdallClient(config.HeimdallURL, logger)
+ heimdallClient = heimdall.NewHttpClient(config.HeimdallURL, logger)
}
if config.PolygonSync {
diff --git a/eth/ethconsensusconfig/config.go b/eth/ethconsensusconfig/config.go
index 8e8afa161ae..f999e1e0ce4 100644
--- a/eth/ethconsensusconfig/config.go
+++ b/eth/ethconsensusconfig/config.go
@@ -45,7 +45,7 @@ import (
)
func CreateConsensusEngine(ctx context.Context, nodeConfig *nodecfg.Config, chainConfig *chain.Config, config interface{}, notify []string, noVerify bool,
- heimdallClient heimdall.HeimdallClient, withoutHeimdall bool, blockReader services.FullBlockReader, readonly bool,
+ heimdallClient heimdall.Client, withoutHeimdall bool, blockReader services.FullBlockReader, readonly bool,
logger log.Logger, polygonBridge *bridge.Service, heimdallService *heimdall.Service,
) consensus.Engine {
var eng consensus.Engine
diff --git a/eth/stagedsync/bor_heimdall_shared.go b/eth/stagedsync/bor_heimdall_shared.go
index fbfaab34a1f..860e8674bd4 100644
--- a/eth/stagedsync/bor_heimdall_shared.go
+++ b/eth/stagedsync/bor_heimdall_shared.go
@@ -42,7 +42,7 @@ func FetchSpanZeroForMiningIfNeeded(
ctx context.Context,
db kv.RwDB,
blockReader services.FullBlockReader,
- heimdallClient heimdall.HeimdallClient,
+ heimdallClient heimdall.Client,
heimdallStore heimdall.Store,
logger log.Logger,
) error {
@@ -106,7 +106,7 @@ func fetchAndWriteHeimdallSpan(
ctx context.Context,
spanID uint64,
tx kv.RwTx,
- heimdallClient heimdall.HeimdallClient,
+ heimdallClient heimdall.Client,
heimdallStore heimdall.Store,
logPrefix string,
logger log.Logger,
@@ -201,7 +201,7 @@ func fetchAndWriteHeimdallCheckpoint(
ctx context.Context,
checkpointId uint64,
tx kv.RwTx,
- heimdallClient heimdall.HeimdallClient,
+ heimdallClient heimdall.Client,
heimdallStore heimdall.Store,
logPrefix string,
logger log.Logger,
@@ -305,7 +305,7 @@ func fetchAndWriteHeimdallMilestone(
ctx context.Context,
milestoneId uint64,
tx kv.RwTx,
- heimdallClient heimdall.HeimdallClient,
+ heimdallClient heimdall.Client,
heimdallStore heimdall.Store,
logPrefix string,
logger log.Logger,
@@ -332,7 +332,7 @@ func fetchRequiredHeimdallStateSyncEventsIfNeeded(
tx kv.RwTx,
borConfig *borcfg.BorConfig,
blockReader services.FullBlockReader,
- heimdallClient heimdall.HeimdallClient,
+ heimdallClient heimdall.Client,
bridgeStore bridge.Store,
chainID string,
logPrefix string,
@@ -371,7 +371,7 @@ func fetchAndWriteHeimdallStateSyncEvents(
tx kv.RwTx,
config *borcfg.BorConfig,
blockReader services.FullBlockReader,
- heimdallClient heimdall.HeimdallClient,
+ heimdallClient heimdall.Client,
bridgeStore bridge.Store,
chainID string,
logPrefix string,
diff --git a/eth/stagedsync/stage_bor_heimdall.go b/eth/stagedsync/stage_bor_heimdall.go
index f47f18eb91a..21df718ba9e 100644
--- a/eth/stagedsync/stage_bor_heimdall.go
+++ b/eth/stagedsync/stage_bor_heimdall.go
@@ -62,7 +62,7 @@ type BorHeimdallCfg struct {
miningState *MiningState
chainConfig *chain.Config
borConfig *borcfg.BorConfig
- heimdallClient heimdall.HeimdallClient
+ heimdallClient heimdall.Client
heimdallStore heimdall.Store
bridgeStore bridge.Store
blockReader services.FullBlockReader
@@ -79,7 +79,7 @@ func StageBorHeimdallCfg(
snapDb kv.RwDB,
miningState MiningState,
chainConfig chain.Config,
- heimdallClient heimdall.HeimdallClient,
+ heimdallClient heimdall.Client,
heimdallStore heimdall.Store,
bridgeStore bridge.Store,
blockReader services.FullBlockReader,
@@ -651,7 +651,7 @@ func initValidatorSets(
tx kv.RwTx,
blockReader services.FullBlockReader,
config *borcfg.BorConfig,
- heimdallClient heimdall.HeimdallClient,
+ heimdallClient heimdall.Client,
heimdallStore heimdall.Store,
chain consensus.ChainHeaderReader,
blockNum uint64,
diff --git a/eth/stagedsync/stage_polygon_sync.go b/eth/stagedsync/stage_polygon_sync.go
index db3c00bc36c..3d8f6553e93 100644
--- a/eth/stagedsync/stage_polygon_sync.go
+++ b/eth/stagedsync/stage_polygon_sync.go
@@ -54,7 +54,7 @@ func NewPolygonSyncStageCfg(
logger log.Logger,
chainConfig *chain.Config,
db kv.RwDB,
- heimdallClient heimdall.HeimdallClient,
+ heimdallClient heimdall.Client,
heimdallStore heimdall.Store,
bridgeStore bridge.Store,
sentry sentryproto.SentryClient,
diff --git a/eth/stagedsync/stagedsynctest/harness.go b/eth/stagedsync/stagedsynctest/harness.go
index facbd0f4d70..d0e362b3bf1 100644
--- a/eth/stagedsync/stagedsynctest/harness.go
+++ b/eth/stagedsync/stagedsynctest/harness.go
@@ -27,11 +27,12 @@ import (
"testing"
"time"
- "github.com/erigontech/erigon-lib/kv/order"
"github.com/holiman/uint256"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
+ "github.com/erigontech/erigon-lib/kv/order"
+
"github.com/erigontech/erigon-lib/chain"
libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/crypto"
@@ -64,7 +65,7 @@ func InitHarness(ctx context.Context, t *testing.T, cfg HarnessCfg) Harness {
blockReader := m.BlockReader
borConsensusDB := memdb.NewTestDB(t)
ctrl := gomock.NewController(t)
- heimdallClient := heimdall.NewMockHeimdallClient(ctrl)
+ heimdallClient := heimdall.NewMockClient(ctrl)
miningState := stagedsync.NewMiningState(ðconfig.Defaults.Miner)
bridgeStore := bridge.NewDbStore(m.DB)
heimdallStore := heimdall.NewDbStore(m.DB)
@@ -180,7 +181,7 @@ type Harness struct {
miningSync *stagedsync.Sync
miningState stagedsync.MiningState
bhCfg stagedsync.BorHeimdallCfg
- heimdallClient *heimdall.MockHeimdallClient
+ heimdallClient *heimdall.MockClient
heimdallNextMockSpan *heimdall.Span
heimdallLastEventID uint64
heimdallLastEventHeaderNum uint64
diff --git a/polygon/bor/bor.go b/polygon/bor/bor.go
index 80e4779c754..e514be0c342 100644
--- a/polygon/bor/bor.go
+++ b/polygon/bor/bor.go
@@ -325,7 +325,7 @@ type Bor struct {
spanner Spanner
stateReceiver StateReceiver
- HeimdallClient heimdall.HeimdallClient
+ HeimdallClient heimdall.Client
useSpanReader bool
spanReader spanReader
useBridgeReader bool
@@ -354,7 +354,7 @@ func New(
db kv.RwDB,
blockReader services.FullBlockReader,
spanner Spanner,
- heimdallClient heimdall.HeimdallClient,
+ heimdallClient heimdall.Client,
genesisContracts StateReceiver,
logger log.Logger,
bridgeReader bridgeReader,
@@ -1608,7 +1608,7 @@ func (c *Bor) CommitStates(
return nil
}
-func (c *Bor) SetHeimdallClient(h heimdall.HeimdallClient) {
+func (c *Bor) SetHeimdallClient(h heimdall.Client) {
c.HeimdallClient = h
}
diff --git a/polygon/bor/bor_internal_test.go b/polygon/bor/bor_internal_test.go
index 486e77c2319..ec507445ae3 100644
--- a/polygon/bor/bor_internal_test.go
+++ b/polygon/bor/bor_internal_test.go
@@ -1,3 +1,19 @@
+// Copyright 2024 The Erigon Authors
+// This file is part of Erigon.
+//
+// Erigon is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Erigon is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with Erigon. If not, see .
+
package bor
import (
diff --git a/polygon/bor/finality/whitelist.go b/polygon/bor/finality/whitelist.go
index cbe72189524..259e1125147 100644
--- a/polygon/bor/finality/whitelist.go
+++ b/polygon/bor/finality/whitelist.go
@@ -32,7 +32,7 @@ import (
)
type config struct {
- heimdall heimdall.HeimdallClient
+ heimdall heimdall.Client
borDB kv.RwDB
chainDB kv.RwDB
blockReader services.BlockReader
@@ -45,7 +45,7 @@ type BorAPI interface {
GetRootHash(start uint64, end uint64) (string, error)
}
-func Whitelist(heimdall heimdall.HeimdallClient, borDB kv.RwDB, chainDB kv.RwDB, blockReader services.BlockReader, logger log.Logger, borAPI BorAPI, closeCh chan struct{}) {
+func Whitelist(heimdall heimdall.Client, borDB kv.RwDB, chainDB kv.RwDB, blockReader services.BlockReader, logger log.Logger, borAPI BorAPI, closeCh chan struct{}) {
if !flags.Milestone {
return
}
@@ -111,7 +111,7 @@ func startNoAckMilestoneByIDService(config *config) {
RetryHeimdallHandler(handleNoAckMilestoneByID, config, tickerDuration, noAckMilestoneTimeout, fnName)
}
-type heimdallHandler func(ctx context.Context, heimdallClient heimdall.HeimdallClient, config *config) error
+type heimdallHandler func(ctx context.Context, heimdallClient heimdall.Client, config *config) error
func RetryHeimdallHandler(fn heimdallHandler, config *config, tickerDuration time.Duration, timeout time.Duration, fnName string) {
retryHeimdallHandler(fn, config, tickerDuration, timeout, fnName)
@@ -174,7 +174,7 @@ func retryHeimdallHandler(fn heimdallHandler, config *config, tickerDuration tim
}
// handleWhitelistCheckpoint handles the checkpoint whitelist mechanism.
-func handleWhitelistCheckpoint(ctx context.Context, heimdallClient heimdall.HeimdallClient, config *config) error {
+func handleWhitelistCheckpoint(ctx context.Context, heimdallClient heimdall.Client, config *config) error {
service := whitelist.GetWhitelistingService()
// Create a new bor verifier, which will be used to verify checkpoints and milestones
@@ -194,7 +194,7 @@ func handleWhitelistCheckpoint(ctx context.Context, heimdallClient heimdall.Heim
}
// handleMilestone handles the milestone mechanism.
-func handleMilestone(ctx context.Context, heimdallClient heimdall.HeimdallClient, config *config) error {
+func handleMilestone(ctx context.Context, heimdallClient heimdall.Client, config *config) error {
service := whitelist.GetWhitelistingService()
// Create a new bor verifier, which will be used to verify checkpoints and milestones
@@ -222,7 +222,7 @@ func handleMilestone(ctx context.Context, heimdallClient heimdall.HeimdallClient
return nil
}
-func handleNoAckMilestone(ctx context.Context, heimdallClient heimdall.HeimdallClient, config *config) error {
+func handleNoAckMilestone(ctx context.Context, heimdallClient heimdall.Client, config *config) error {
service := whitelist.GetWhitelistingService()
milestoneID, err := fetchNoAckMilestone(ctx, heimdallClient, config.logger)
@@ -239,7 +239,7 @@ func handleNoAckMilestone(ctx context.Context, heimdallClient heimdall.HeimdallC
return nil
}
-func handleNoAckMilestoneByID(ctx context.Context, heimdallClient heimdall.HeimdallClient, config *config) error {
+func handleNoAckMilestoneByID(ctx context.Context, heimdallClient heimdall.Client, config *config) error {
service := whitelist.GetWhitelistingService()
milestoneIDs := service.GetMilestoneIDsList()
diff --git a/polygon/bor/finality/whitelist_helpers.go b/polygon/bor/finality/whitelist_helpers.go
index 5e3edb6c5ea..65a01cba3b8 100644
--- a/polygon/bor/finality/whitelist_helpers.go
+++ b/polygon/bor/finality/whitelist_helpers.go
@@ -42,7 +42,7 @@ var (
// fetchWhitelistCheckpoint fetches the latest checkpoint from it's local heimdall
// and verifies the data against bor data.
-func fetchWhitelistCheckpoint(ctx context.Context, heimdallClient heimdall.HeimdallClient, verifier *borVerifier, config *config) (uint64, common.Hash, error) {
+func fetchWhitelistCheckpoint(ctx context.Context, heimdallClient heimdall.Client, verifier *borVerifier, config *config) (uint64, common.Hash, error) {
var (
blockNum uint64
blockHash common.Hash
@@ -82,7 +82,7 @@ func fetchWhitelistCheckpoint(ctx context.Context, heimdallClient heimdall.Heimd
// fetchWhitelistMilestone fetches the latest milestone from it's local heimdall
// and verifies the data against bor data.
-func fetchWhitelistMilestone(ctx context.Context, heimdallClient heimdall.HeimdallClient, verifier *borVerifier, config *config) (uint64, common.Hash, error) {
+func fetchWhitelistMilestone(ctx context.Context, heimdallClient heimdall.Client, verifier *borVerifier, config *config) (uint64, common.Hash, error) {
var (
num uint64
hash common.Hash
@@ -117,7 +117,7 @@ func fetchWhitelistMilestone(ctx context.Context, heimdallClient heimdall.Heimda
return num, hash, nil
}
-func fetchNoAckMilestone(ctx context.Context, heimdallClient heimdall.HeimdallClient, logger log.Logger) (string, error) {
+func fetchNoAckMilestone(ctx context.Context, heimdallClient heimdall.Client, logger log.Logger) (string, error) {
var (
milestoneID string
)
@@ -136,7 +136,7 @@ func fetchNoAckMilestone(ctx context.Context, heimdallClient heimdall.HeimdallCl
return milestoneID, nil
}
-func fetchNoAckMilestoneByID(ctx context.Context, heimdallClient heimdall.HeimdallClient, milestoneID string, logger log.Logger) error {
+func fetchNoAckMilestoneByID(ctx context.Context, heimdallClient heimdall.Client, milestoneID string, logger log.Logger) error {
err := heimdallClient.FetchNoAckMilestone(ctx, milestoneID)
if errors.Is(err, heimdall.ErrServiceUnavailable) {
logger.Debug("[bor.heimdall] Failed to fetch no-ack milestone by ID", "milestoneID", milestoneID, "err", err)
diff --git a/polygon/bor/spanner_mock.go b/polygon/bor/spanner_mock.go
index 0bb851f1619..000df402ea0 100644
--- a/polygon/bor/spanner_mock.go
+++ b/polygon/bor/spanner_mock.go
@@ -81,9 +81,9 @@ func (c *MockSpannerCommitSpanCall) DoAndReturn(f func(heimdall.Span, consensus.
}
// GetCurrentProducers mocks base method.
-func (m *MockSpanner) GetCurrentProducers(arg0 uint64, arg1 ChainHeaderReader) ([]*valset.Validator, error) {
+func (m *MockSpanner) GetCurrentProducers(spanId uint64, chain ChainHeaderReader) ([]*valset.Validator, error) {
m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "GetCurrentProducers", arg0, arg1)
+ ret := m.ctrl.Call(m, "GetCurrentProducers", spanId, chain)
ret0, _ := ret[0].([]*valset.Validator)
ret1, _ := ret[1].(error)
return ret0, ret1
@@ -159,9 +159,9 @@ func (c *MockSpannerGetCurrentSpanCall) DoAndReturn(f func(consensus.SystemCall)
}
// GetCurrentValidators mocks base method.
-func (m *MockSpanner) GetCurrentValidators(arg0 uint64, arg1 ChainHeaderReader) ([]*valset.Validator, error) {
+func (m *MockSpanner) GetCurrentValidators(spanId uint64, chain ChainHeaderReader) ([]*valset.Validator, error) {
m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "GetCurrentValidators", arg0, arg1)
+ ret := m.ctrl.Call(m, "GetCurrentValidators", spanId, chain)
ret0, _ := ret[0].([]*valset.Validator)
ret1, _ := ret[1].(error)
return ret0, ret1
diff --git a/polygon/bridge/service_test.go b/polygon/bridge/service_test.go
index 37ba724e631..5cee92a9884 100644
--- a/polygon/bridge/service_test.go
+++ b/polygon/bridge/service_test.go
@@ -42,10 +42,10 @@ var defaultBorConfig = borcfg.BorConfig{
StateSyncConfirmationDelay: map[string]uint64{"0": 1},
}
-func setup(t *testing.T, borConfig borcfg.BorConfig) (*heimdall.MockHeimdallClient, *Service) {
+func setup(t *testing.T, borConfig borcfg.BorConfig) (*heimdall.MockClient, *Service) {
ctrl := gomock.NewController(t)
logger := testlog.Logger(t, log.LvlDebug)
- heimdallClient := heimdall.NewMockHeimdallClient(ctrl)
+ heimdallClient := heimdall.NewMockClient(ctrl)
b := NewService(ServiceConfig{
Store: NewMdbxStore(t.TempDir(), logger, false, 1),
Logger: logger,
diff --git a/polygon/heimdall/client.go b/polygon/heimdall/client.go
index 477705ed1fb..1c68e412e7d 100644
--- a/polygon/heimdall/client.go
+++ b/polygon/heimdall/client.go
@@ -18,53 +18,11 @@ package heimdall
import (
"context"
- "encoding/json"
- "errors"
- "fmt"
- "io"
- "net/http"
- "net/url"
- "path"
- "sort"
- "strconv"
- "strings"
"time"
-
- "github.com/erigontech/erigon-lib/log/v3"
-
- "github.com/erigontech/erigon-lib/metrics"
-)
-
-var (
- // ErrShutdownDetected is returned if a shutdown was detected
- ErrShutdownDetected = errors.New("shutdown detected")
- ErrNoResponse = errors.New("got a nil response")
- ErrNotSuccessfulResponse = errors.New("error while fetching data from Heimdall")
- ErrNotInRejectedList = errors.New("milestoneId doesn't exist in rejected list")
- ErrNotInMilestoneList = errors.New("milestoneId doesn't exist in Heimdall")
- ErrNotInCheckpointList = errors.New("checkpontId doesn't exist in Heimdall")
- ErrBadGateway = errors.New("bad gateway")
- ErrServiceUnavailable = errors.New("service unavailable")
-
- TransientErrors = []error{
- ErrBadGateway,
- ErrServiceUnavailable,
- context.DeadlineExceeded,
- }
-)
-
-const (
- StateEventsFetchLimit = 50
- SpansFetchLimit = 150
- CheckpointsFetchLimit = 10_000
-
- apiHeimdallTimeout = 10 * time.Second
- retryBackOff = time.Second
- maxRetries = 5
)
-//go:generate mockgen -typed=true -destination=./client_mock.go -package=heimdall . HeimdallClient
-type HeimdallClient interface {
+//go:generate mockgen -typed=true -destination=./client_mock.go -package=heimdall . Client
+type Client interface {
FetchStateSyncEvents(ctx context.Context, fromId uint64, to time.Time, limit int) ([]*EventRecordWithTime, error)
FetchStateSyncEvent(ctx context.Context, id uint64) (*EventRecordWithTime, error)
@@ -91,608 +49,3 @@ type HeimdallClient interface {
Close()
}
-
-var _ HeimdallClient = &Client{}
-
-type Client struct {
- urlString string
- client HttpClient
- retryBackOff time.Duration
- maxRetries int
- closeCh chan struct{}
- logger log.Logger
-}
-
-type Request struct {
- client HttpClient
- url *url.URL
- start time.Time
-}
-
-//go:generate mockgen -typed=true -destination=./http_client_mock.go -package=heimdall . HttpClient
-type HttpClient interface {
- Do(req *http.Request) (*http.Response, error)
- CloseIdleConnections()
-}
-
-func NewHeimdallClient(urlString string, logger log.Logger) *Client {
- httpClient := &http.Client{
- Timeout: apiHeimdallTimeout,
- }
- return newHeimdallClient(urlString, httpClient, retryBackOff, maxRetries, logger)
-}
-
-func newHeimdallClient(urlString string, httpClient HttpClient, retryBackOff time.Duration, maxRetries int, logger log.Logger) *Client {
- return &Client{
- urlString: urlString,
- logger: logger,
- client: httpClient,
- retryBackOff: retryBackOff,
- maxRetries: maxRetries,
- closeCh: make(chan struct{}),
- }
-}
-
-const (
- fetchStateSyncEventsFormat = "from-id=%d&to-time=%d&limit=%d"
- fetchStateSyncEventsPath = "clerk/event-record/list"
- fetchStateSyncEvent = "clerk/event-record/%s"
-
- fetchCheckpoint = "/checkpoints/%s"
- fetchCheckpointCount = "/checkpoints/count"
- fetchCheckpointList = "/checkpoints/list"
- fetchCheckpointListQueryFormat = "page=%d&limit=%d"
-
- fetchMilestoneAt = "/milestone/%d"
- fetchMilestoneLatest = "/milestone/latest"
- fetchMilestoneCount = "/milestone/count"
-
- fetchLastNoAckMilestone = "/milestone/lastNoAck"
- fetchNoAckMilestone = "/milestone/noAck/%s"
- fetchMilestoneID = "/milestone/ID/%s"
-
- fetchSpanFormat = "bor/span/%d"
- fetchSpanLatest = "bor/latest-span"
- fetchSpanListFormat = "page=%d&limit=%d" // max limit = 150
- fetchSpanListPath = "bor/span/list"
-)
-
-func (c *Client) FetchStateSyncEvents(ctx context.Context, fromID uint64, to time.Time, limit int) ([]*EventRecordWithTime, error) {
- eventRecords := make([]*EventRecordWithTime, 0)
-
- for {
- url, err := stateSyncListURL(c.urlString, fromID, to.Unix())
- if err != nil {
- return nil, err
- }
-
- c.logger.Trace(heimdallLogPrefix("Fetching state sync events"), "queryParams", url.RawQuery)
-
- reqCtx := withRequestType(ctx, stateSyncRequest)
-
- response, err := FetchWithRetry[StateSyncEventsResponse](reqCtx, c, url, c.logger)
- if err != nil {
- if errors.Is(err, ErrNoResponse) {
- // for more info check https://github.com/maticnetwork/heimdall/pull/993
- c.logger.Warn(
- heimdallLogPrefix("check heimdall logs to see if it is in sync - no response when querying state sync events"),
- "path", url.Path,
- "queryParams", url.RawQuery,
- )
- }
- return nil, err
- }
-
- if response == nil || response.Result == nil {
- // status 204
- break
- }
-
- eventRecords = append(eventRecords, response.Result...)
-
- if len(response.Result) < StateEventsFetchLimit || (limit > 0 && len(eventRecords) >= limit) {
- break
- }
-
- fromID += uint64(StateEventsFetchLimit)
- }
-
- sort.SliceStable(eventRecords, func(i, j int) bool {
- return eventRecords[i].ID < eventRecords[j].ID
- })
-
- return eventRecords, nil
-}
-
-func (c *Client) FetchStateSyncEvent(ctx context.Context, id uint64) (*EventRecordWithTime, error) {
- url, err := stateSyncURL(c.urlString, id)
-
- if err != nil {
- return nil, err
- }
-
- ctx = withRequestType(ctx, stateSyncRequest)
-
- isRecoverableError := func(err error) bool {
- return !strings.Contains(err.Error(), "could not get state record; No record found")
- }
-
- response, err := FetchWithRetryEx[StateSyncEventResponse](ctx, c, url, isRecoverableError, c.logger)
-
- if err != nil {
- if strings.Contains(err.Error(), "could not get state record; No record found") {
- return nil, ErrEventRecordNotFound
- }
-
- return nil, err
- }
-
- return &response.Result, nil
-}
-
-func (c *Client) FetchLatestSpan(ctx context.Context) (*Span, error) {
- url, err := latestSpanURL(c.urlString)
- if err != nil {
- return nil, err
- }
-
- ctx = withRequestType(ctx, spanRequest)
-
- response, err := FetchWithRetry[SpanResponse](ctx, c, url, c.logger)
- if err != nil {
- return nil, err
- }
-
- return &response.Result, nil
-}
-
-func (c *Client) FetchSpan(ctx context.Context, spanID uint64) (*Span, error) {
- url, err := spanURL(c.urlString, spanID)
- if err != nil {
- return nil, fmt.Errorf("%w, spanID=%d", err, spanID)
- }
-
- ctx = withRequestType(ctx, spanRequest)
-
- response, err := FetchWithRetry[SpanResponse](ctx, c, url, c.logger)
- if err != nil {
- return nil, fmt.Errorf("%w, spanID=%d", err, spanID)
- }
-
- return &response.Result, nil
-}
-
-func (c *Client) FetchSpans(ctx context.Context, page uint64, limit uint64) ([]*Span, error) {
- url, err := spanListURL(c.urlString, page, limit)
- if err != nil {
- return nil, err
- }
-
- ctx = withRequestType(ctx, checkpointListRequest)
-
- response, err := FetchWithRetry[SpanListResponse](ctx, c, url, c.logger)
- if err != nil {
- return nil, err
- }
-
- return response.Result, nil
-}
-
-// FetchCheckpoint fetches the checkpoint from heimdall
-func (c *Client) FetchCheckpoint(ctx context.Context, number int64) (*Checkpoint, error) {
- url, err := checkpointURL(c.urlString, number)
- if err != nil {
- return nil, err
- }
-
- ctx = withRequestType(ctx, checkpointRequest)
-
- response, err := FetchWithRetry[CheckpointResponse](ctx, c, url, c.logger)
- if err != nil {
- return nil, err
- }
-
- return &response.Result, nil
-}
-
-func (c *Client) FetchCheckpoints(ctx context.Context, page uint64, limit uint64) ([]*Checkpoint, error) {
- url, err := checkpointListURL(c.urlString, page, limit)
- if err != nil {
- return nil, err
- }
-
- ctx = withRequestType(ctx, checkpointListRequest)
-
- response, err := FetchWithRetry[CheckpointListResponse](ctx, c, url, c.logger)
- if err != nil {
- return nil, err
- }
-
- return response.Result, nil
-}
-
-func isInvalidMilestoneIndexError(err error) bool {
- return errors.Is(err, ErrNotSuccessfulResponse) &&
- strings.Contains(err.Error(), "Invalid milestone index")
-}
-
-// FetchMilestone fetches a milestone from heimdall
-func (c *Client) FetchMilestone(ctx context.Context, number int64) (*Milestone, error) {
- url, err := milestoneURL(c.urlString, number)
- if err != nil {
- return nil, err
- }
-
- ctx = withRequestType(ctx, milestoneRequest)
-
- isRecoverableError := func(err error) bool {
- if !isInvalidMilestoneIndexError(err) {
- return true
- }
-
- if number == -1 {
- // -1 means fetch latest, which should be retried
- return true
- }
-
- firstNum, err := c.FetchFirstMilestoneNum(ctx)
- if err != nil {
- c.logger.Warn(
- heimdallLogPrefix("issue fetching milestone count when deciding if invalid index err is recoverable"),
- "err", err,
- )
-
- return false
- }
-
- // if number is within expected non pruned range then it should be retried
- return firstNum <= number && number <= firstNum+milestonePruneNumber-1
- }
-
- response, err := FetchWithRetryEx[MilestoneResponse](ctx, c, url, isRecoverableError, c.logger)
- if err != nil {
- if isInvalidMilestoneIndexError(err) {
- return nil, fmt.Errorf("%w: number %d", ErrNotInMilestoneList, number)
- }
- return nil, err
- }
-
- response.Result.Id = MilestoneId(number)
-
- return &response.Result, nil
-}
-
-// FetchCheckpointCount fetches the checkpoint count from heimdall
-func (c *Client) FetchCheckpointCount(ctx context.Context) (int64, error) {
- url, err := checkpointCountURL(c.urlString)
- if err != nil {
- return 0, err
- }
-
- ctx = withRequestType(ctx, checkpointCountRequest)
-
- response, err := FetchWithRetry[CheckpointCountResponse](ctx, c, url, c.logger)
- if err != nil {
- return 0, err
- }
-
- return response.Result.Result, nil
-}
-
-// FetchMilestoneCount fetches the milestone count from heimdall
-func (c *Client) FetchMilestoneCount(ctx context.Context) (int64, error) {
- url, err := milestoneCountURL(c.urlString)
- if err != nil {
- return 0, err
- }
-
- ctx = withRequestType(ctx, milestoneCountRequest)
-
- response, err := FetchWithRetry[MilestoneCountResponse](ctx, c, url, c.logger)
- if err != nil {
- return 0, err
- }
-
- return response.Result.Count, nil
-}
-
-// Heimdall keeps only this amount of latest milestones
-// https://github.com/maticnetwork/heimdall/blob/master/helper/config.go#L141
-const milestonePruneNumber = int64(100)
-
-func (c *Client) FetchFirstMilestoneNum(ctx context.Context) (int64, error) {
- count, err := c.FetchMilestoneCount(ctx)
- if err != nil {
- return 0, err
- }
-
- var first int64
- if count < milestonePruneNumber {
- first = 1
- } else {
- first = count - milestonePruneNumber + 1
- }
-
- return first, nil
-}
-
-// FetchLastNoAckMilestone fetches the last no-ack-milestone from heimdall
-func (c *Client) FetchLastNoAckMilestone(ctx context.Context) (string, error) {
- url, err := lastNoAckMilestoneURL(c.urlString)
- if err != nil {
- return "", err
- }
-
- ctx = withRequestType(ctx, milestoneLastNoAckRequest)
-
- response, err := FetchWithRetry[MilestoneLastNoAckResponse](ctx, c, url, c.logger)
- if err != nil {
- return "", err
- }
-
- return response.Result.Result, nil
-}
-
-// FetchNoAckMilestone fetches the last no-ack-milestone from heimdall
-func (c *Client) FetchNoAckMilestone(ctx context.Context, milestoneID string) error {
- url, err := noAckMilestoneURL(c.urlString, milestoneID)
- if err != nil {
- return err
- }
-
- ctx = withRequestType(ctx, milestoneNoAckRequest)
-
- response, err := FetchWithRetry[MilestoneNoAckResponse](ctx, c, url, c.logger)
- if err != nil {
- return err
- }
-
- if !response.Result.Result {
- return fmt.Errorf("%w: milestoneID %q", ErrNotInRejectedList, milestoneID)
- }
-
- return nil
-}
-
-// FetchMilestoneID fetches the bool result from Heimdall whether the ID corresponding
-// to the given milestone is in process in Heimdall
-func (c *Client) FetchMilestoneID(ctx context.Context, milestoneID string) error {
- url, err := milestoneIDURL(c.urlString, milestoneID)
- if err != nil {
- return err
- }
-
- ctx = withRequestType(ctx, milestoneIDRequest)
-
- response, err := FetchWithRetry[MilestoneIDResponse](ctx, c, url, c.logger)
-
- if err != nil {
- return err
- }
-
- if !response.Result.Result {
- return fmt.Errorf("%w: milestoneID %q", ErrNotInMilestoneList, milestoneID)
- }
-
- return nil
-}
-
-// FetchWithRetry returns data from heimdall with retry
-func FetchWithRetry[T any](ctx context.Context, client *Client, url *url.URL, logger log.Logger) (*T, error) {
- return FetchWithRetryEx[T](ctx, client, url, nil, logger)
-}
-
-// FetchWithRetryEx returns data from heimdall with retry
-func FetchWithRetryEx[T any](
- ctx context.Context,
- client *Client,
- url *url.URL,
- isRecoverableError func(error) bool,
- logger log.Logger,
-) (result *T, err error) {
- attempt := 0
- // create a new ticker for retrying the request
- ticker := time.NewTicker(client.retryBackOff)
- defer ticker.Stop()
-
- for attempt < client.maxRetries {
- attempt++
-
- request := &Request{client: client.client, url: url, start: time.Now()}
- result, err = Fetch[T](ctx, request, logger)
- if err == nil {
- return result, nil
- }
-
- // 503 (Service Unavailable) is thrown when an endpoint isn't activated
- // yet in heimdall. E.g. when the hard fork hasn't hit yet but heimdall
- // is upgraded.
- if errors.Is(err, ErrServiceUnavailable) {
- client.logger.Debug(heimdallLogPrefix("service unavailable at the moment"), "path", url.Path, "queryParams", url.RawQuery, "attempt", attempt, "err", err)
- return nil, err
- }
-
- if (isRecoverableError != nil) && !isRecoverableError(err) {
- return nil, err
- }
-
- client.logger.Warn(heimdallLogPrefix("an error while fetching"), "path", url.Path, "queryParams", url.RawQuery, "attempt", attempt, "err", err)
-
- select {
- case <-ctx.Done():
- client.logger.Debug(heimdallLogPrefix("request canceled"), "reason", ctx.Err(), "path", url.Path, "queryParams", url.RawQuery, "attempt", attempt)
- return nil, ctx.Err()
- case <-client.closeCh:
- client.logger.Debug(heimdallLogPrefix("shutdown detected, terminating request"), "path", url.Path, "queryParams", url.RawQuery)
- return nil, ErrShutdownDetected
- case <-ticker.C:
- // retry
- }
- }
-
- return nil, err
-}
-
-// Fetch fetches response from heimdall
-func Fetch[T any](ctx context.Context, request *Request, logger log.Logger) (*T, error) {
- isSuccessful := false
-
- defer func() {
- if metrics.EnabledExpensive {
- sendMetrics(ctx, request.start, isSuccessful)
- }
- }()
-
- result := new(T)
-
- body, err := internalFetchWithTimeout(ctx, request.client, request.url, logger)
- if err != nil {
- return nil, err
- }
-
- if len(body) == 0 {
- return nil, ErrNoResponse
- }
-
- err = json.Unmarshal(body, result)
- if err != nil {
- return nil, err
- }
-
- isSuccessful = true
-
- return result, nil
-}
-
-func spanURL(urlString string, spanID uint64) (*url.URL, error) {
- return makeURL(urlString, fmt.Sprintf(fetchSpanFormat, spanID), "")
-}
-
-func spanListURL(urlString string, page, limit uint64) (*url.URL, error) {
- return makeURL(urlString, fetchSpanListPath, fmt.Sprintf(fetchSpanListFormat, page, limit))
-}
-
-func latestSpanURL(urlString string) (*url.URL, error) {
- return makeURL(urlString, fetchSpanLatest, "")
-}
-
-func stateSyncListURL(urlString string, fromID uint64, to int64) (*url.URL, error) {
- queryParams := fmt.Sprintf(fetchStateSyncEventsFormat, fromID, to, StateEventsFetchLimit)
- return makeURL(urlString, fetchStateSyncEventsPath, queryParams)
-}
-
-func stateSyncURL(urlString string, id uint64) (*url.URL, error) {
- return makeURL(urlString, fmt.Sprintf(fetchStateSyncEvent, strconv.FormatUint(id, 10)), "")
-}
-
-func checkpointURL(urlString string, number int64) (*url.URL, error) {
- var url string
- if number == -1 {
- url = fmt.Sprintf(fetchCheckpoint, "latest")
- } else {
- url = fmt.Sprintf(fetchCheckpoint, strconv.FormatInt(number, 10))
- }
-
- return makeURL(urlString, url, "")
-}
-
-func checkpointCountURL(urlString string) (*url.URL, error) {
- return makeURL(urlString, fetchCheckpointCount, "")
-}
-
-func checkpointListURL(urlString string, page uint64, limit uint64) (*url.URL, error) {
- return makeURL(urlString, fetchCheckpointList, fmt.Sprintf(fetchCheckpointListQueryFormat, page, limit))
-}
-
-func milestoneURL(urlString string, number int64) (*url.URL, error) {
- if number == -1 {
- return makeURL(urlString, fetchMilestoneLatest, "")
- }
- return makeURL(urlString, fmt.Sprintf(fetchMilestoneAt, number), "")
-}
-
-func milestoneCountURL(urlString string) (*url.URL, error) {
- return makeURL(urlString, fetchMilestoneCount, "")
-}
-
-func lastNoAckMilestoneURL(urlString string) (*url.URL, error) {
- return makeURL(urlString, fetchLastNoAckMilestone, "")
-}
-
-func noAckMilestoneURL(urlString string, id string) (*url.URL, error) {
- return makeURL(urlString, fmt.Sprintf(fetchNoAckMilestone, id), "")
-}
-
-func milestoneIDURL(urlString string, id string) (*url.URL, error) {
- return makeURL(urlString, fmt.Sprintf(fetchMilestoneID, id), "")
-}
-
-func makeURL(urlString, rawPath, rawQuery string) (*url.URL, error) {
- u, err := url.Parse(urlString)
- if err != nil {
- return nil, err
- }
-
- u.Path = path.Join(u.Path, rawPath)
- u.RawQuery = rawQuery
-
- return u, err
-}
-
-// internal fetch method
-func internalFetch(ctx context.Context, client HttpClient, u *url.URL, logger log.Logger) ([]byte, error) {
- req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
- if err != nil {
- return nil, err
- }
-
- logger.Trace(heimdallLogPrefix("http client get request"), "uri", u.RequestURI())
-
- res, err := client.Do(req)
- if err != nil {
- return nil, err
- }
-
- defer func() {
- _ = res.Body.Close()
- }()
-
- if res.StatusCode == http.StatusServiceUnavailable {
- return nil, fmt.Errorf("%w: url='%s', status=%d", ErrServiceUnavailable, u.String(), res.StatusCode)
- }
- if res.StatusCode == http.StatusBadGateway {
- return nil, fmt.Errorf("%w: url='%s', status=%d", ErrBadGateway, u.String(), res.StatusCode)
- }
-
- // unmarshall data from buffer
- if res.StatusCode == 204 {
- return nil, nil
- }
-
- // get response
- body, err := io.ReadAll(res.Body)
- if err != nil {
- return nil, err
- }
-
- // check status code
- if res.StatusCode != 200 {
- return nil, fmt.Errorf("%w: url='%s', status=%d, body='%s'", ErrNotSuccessfulResponse, u.String(), res.StatusCode, string(body))
- }
-
- return body, nil
-}
-
-func internalFetchWithTimeout(ctx context.Context, client HttpClient, url *url.URL, logger log.Logger) ([]byte, error) {
- ctx, cancel := context.WithTimeout(ctx, apiHeimdallTimeout)
- defer cancel()
-
- // request data once
- return internalFetch(ctx, client, url, logger)
-}
-
-// Close sends a signal to stop the running process
-func (c *Client) Close() {
- close(c.closeCh)
- c.client.CloseIdleConnections()
-}
diff --git a/polygon/heimdall/client_http.go b/polygon/heimdall/client_http.go
new file mode 100644
index 00000000000..5e8e3dc74ed
--- /dev/null
+++ b/polygon/heimdall/client_http.go
@@ -0,0 +1,682 @@
+// Copyright 2024 The Erigon Authors
+// This file is part of Erigon.
+//
+// Erigon is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Erigon is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with Erigon. If not, see .
+
+package heimdall
+
+import (
+ "context"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io"
+ "net/http"
+ "net/url"
+ "path"
+ "sort"
+ "strconv"
+ "strings"
+ "time"
+
+ "github.com/erigontech/erigon-lib/log/v3"
+
+ "github.com/erigontech/erigon-lib/metrics"
+)
+
+var (
+ // ErrShutdownDetected is returned if a shutdown was detected
+ ErrShutdownDetected = errors.New("shutdown detected")
+ ErrNoResponse = errors.New("got a nil response")
+ ErrNotSuccessfulResponse = errors.New("error while fetching data from Heimdall")
+ ErrNotInRejectedList = errors.New("milestoneId doesn't exist in rejected list")
+ ErrNotInMilestoneList = errors.New("milestoneId doesn't exist in Heimdall")
+ ErrNotInCheckpointList = errors.New("checkpontId doesn't exist in Heimdall")
+ ErrBadGateway = errors.New("bad gateway")
+ ErrServiceUnavailable = errors.New("service unavailable")
+
+ TransientErrors = []error{
+ ErrBadGateway,
+ ErrServiceUnavailable,
+ context.DeadlineExceeded,
+ }
+)
+
+const (
+ StateEventsFetchLimit = 50
+ SpansFetchLimit = 150
+ CheckpointsFetchLimit = 10_000
+
+ apiHeimdallTimeout = 10 * time.Second
+ retryBackOff = time.Second
+ maxRetries = 5
+)
+
+var _ Client = &HttpClient{}
+
+type HttpClient struct {
+ urlString string
+ handler httpRequestHandler
+ retryBackOff time.Duration
+ maxRetries int
+ closeCh chan struct{}
+ logger log.Logger
+}
+
+type HttpRequest struct {
+ handler httpRequestHandler
+ url *url.URL
+ start time.Time
+}
+
+type HttpClientOption func(*HttpClient)
+
+func WithHttpRequestHandler(handler httpRequestHandler) HttpClientOption {
+ return func(client *HttpClient) {
+ client.handler = handler
+ }
+}
+
+func WithHttpRetryBackOff(retryBackOff time.Duration) HttpClientOption {
+ return func(client *HttpClient) {
+ client.retryBackOff = retryBackOff
+ }
+}
+
+func WithHttpMaxRetries(maxRetries int) HttpClientOption {
+ return func(client *HttpClient) {
+ client.maxRetries = maxRetries
+ }
+}
+
+func NewHttpClient(urlString string, logger log.Logger, opts ...HttpClientOption) *HttpClient {
+ c := &HttpClient{
+ urlString: urlString,
+ logger: logger,
+ handler: &http.Client{Timeout: apiHeimdallTimeout},
+ retryBackOff: retryBackOff,
+ maxRetries: maxRetries,
+ closeCh: make(chan struct{}),
+ }
+
+ for _, opt := range opts {
+ opt(c)
+ }
+
+ return c
+}
+
+const (
+ fetchStateSyncEventsFormat = "from-id=%d&to-time=%d&limit=%d"
+ fetchStateSyncEventsPath = "clerk/event-record/list"
+ fetchStateSyncEvent = "clerk/event-record/%s"
+
+ fetchCheckpoint = "/checkpoints/%s"
+ fetchCheckpointCount = "/checkpoints/count"
+ fetchCheckpointList = "/checkpoints/list"
+ fetchCheckpointListQueryFormat = "page=%d&limit=%d"
+
+ fetchMilestoneAt = "/milestone/%d"
+ fetchMilestoneLatest = "/milestone/latest"
+ fetchMilestoneCount = "/milestone/count"
+
+ fetchLastNoAckMilestone = "/milestone/lastNoAck"
+ fetchNoAckMilestone = "/milestone/noAck/%s"
+ fetchMilestoneID = "/milestone/ID/%s"
+
+ fetchSpanFormat = "bor/span/%d"
+ fetchSpanLatest = "bor/latest-span"
+ fetchSpanListFormat = "page=%d&limit=%d" // max limit = 150
+ fetchSpanListPath = "bor/span/list"
+)
+
+func (c *HttpClient) FetchStateSyncEvents(ctx context.Context, fromID uint64, to time.Time, limit int) ([]*EventRecordWithTime, error) {
+ eventRecords := make([]*EventRecordWithTime, 0)
+
+ for {
+ url, err := stateSyncListURL(c.urlString, fromID, to.Unix())
+ if err != nil {
+ return nil, err
+ }
+
+ c.logger.Trace(heimdallLogPrefix("Fetching state sync events"), "queryParams", url.RawQuery)
+
+ reqCtx := withRequestType(ctx, stateSyncRequest)
+
+ response, err := FetchWithRetry[StateSyncEventsResponse](reqCtx, c, url, c.logger)
+ if err != nil {
+ if errors.Is(err, ErrNoResponse) {
+ // for more info check https://github.com/maticnetwork/heimdall/pull/993
+ c.logger.Warn(
+ heimdallLogPrefix("check heimdall logs to see if it is in sync - no response when querying state sync events"),
+ "path", url.Path,
+ "queryParams", url.RawQuery,
+ )
+ }
+ return nil, err
+ }
+
+ if response == nil || response.Result == nil {
+ // status 204
+ break
+ }
+
+ eventRecords = append(eventRecords, response.Result...)
+
+ if len(response.Result) < StateEventsFetchLimit || (limit > 0 && len(eventRecords) >= limit) {
+ break
+ }
+
+ fromID += uint64(StateEventsFetchLimit)
+ }
+
+ sort.SliceStable(eventRecords, func(i, j int) bool {
+ return eventRecords[i].ID < eventRecords[j].ID
+ })
+
+ return eventRecords, nil
+}
+
+func (c *HttpClient) FetchStateSyncEvent(ctx context.Context, id uint64) (*EventRecordWithTime, error) {
+ url, err := stateSyncURL(c.urlString, id)
+
+ if err != nil {
+ return nil, err
+ }
+
+ ctx = withRequestType(ctx, stateSyncRequest)
+
+ isRecoverableError := func(err error) bool {
+ return !strings.Contains(err.Error(), "could not get state record; No record found")
+ }
+
+ response, err := FetchWithRetryEx[StateSyncEventResponse](ctx, c, url, isRecoverableError, c.logger)
+
+ if err != nil {
+ if strings.Contains(err.Error(), "could not get state record; No record found") {
+ return nil, ErrEventRecordNotFound
+ }
+
+ return nil, err
+ }
+
+ return &response.Result, nil
+}
+
+func (c *HttpClient) FetchLatestSpan(ctx context.Context) (*Span, error) {
+ url, err := latestSpanURL(c.urlString)
+ if err != nil {
+ return nil, err
+ }
+
+ ctx = withRequestType(ctx, spanRequest)
+
+ response, err := FetchWithRetry[SpanResponse](ctx, c, url, c.logger)
+ if err != nil {
+ return nil, err
+ }
+
+ return &response.Result, nil
+}
+
+func (c *HttpClient) FetchSpan(ctx context.Context, spanID uint64) (*Span, error) {
+ url, err := spanURL(c.urlString, spanID)
+ if err != nil {
+ return nil, fmt.Errorf("%w, spanID=%d", err, spanID)
+ }
+
+ ctx = withRequestType(ctx, spanRequest)
+
+ response, err := FetchWithRetry[SpanResponse](ctx, c, url, c.logger)
+ if err != nil {
+ return nil, fmt.Errorf("%w, spanID=%d", err, spanID)
+ }
+
+ return &response.Result, nil
+}
+
+func (c *HttpClient) FetchSpans(ctx context.Context, page uint64, limit uint64) ([]*Span, error) {
+ url, err := spanListURL(c.urlString, page, limit)
+ if err != nil {
+ return nil, err
+ }
+
+ ctx = withRequestType(ctx, checkpointListRequest)
+
+ response, err := FetchWithRetry[SpanListResponse](ctx, c, url, c.logger)
+ if err != nil {
+ return nil, err
+ }
+
+ return response.Result, nil
+}
+
+// FetchCheckpoint fetches the checkpoint from heimdall
+func (c *HttpClient) FetchCheckpoint(ctx context.Context, number int64) (*Checkpoint, error) {
+ url, err := checkpointURL(c.urlString, number)
+ if err != nil {
+ return nil, err
+ }
+
+ ctx = withRequestType(ctx, checkpointRequest)
+
+ response, err := FetchWithRetry[CheckpointResponse](ctx, c, url, c.logger)
+ if err != nil {
+ return nil, err
+ }
+
+ return &response.Result, nil
+}
+
+func (c *HttpClient) FetchCheckpoints(ctx context.Context, page uint64, limit uint64) ([]*Checkpoint, error) {
+ url, err := checkpointListURL(c.urlString, page, limit)
+ if err != nil {
+ return nil, err
+ }
+
+ ctx = withRequestType(ctx, checkpointListRequest)
+
+ response, err := FetchWithRetry[CheckpointListResponse](ctx, c, url, c.logger)
+ if err != nil {
+ return nil, err
+ }
+
+ return response.Result, nil
+}
+
+func isInvalidMilestoneIndexError(err error) bool {
+ return errors.Is(err, ErrNotSuccessfulResponse) &&
+ strings.Contains(err.Error(), "Invalid milestone index")
+}
+
+// FetchMilestone fetches a milestone from heimdall
+func (c *HttpClient) FetchMilestone(ctx context.Context, number int64) (*Milestone, error) {
+ url, err := milestoneURL(c.urlString, number)
+ if err != nil {
+ return nil, err
+ }
+
+ ctx = withRequestType(ctx, milestoneRequest)
+
+ isRecoverableError := func(err error) bool {
+ if !isInvalidMilestoneIndexError(err) {
+ return true
+ }
+
+ if number == -1 {
+ // -1 means fetch latest, which should be retried
+ return true
+ }
+
+ firstNum, err := c.FetchFirstMilestoneNum(ctx)
+ if err != nil {
+ c.logger.Warn(
+ heimdallLogPrefix("issue fetching milestone count when deciding if invalid index err is recoverable"),
+ "err", err,
+ )
+
+ return false
+ }
+
+ // if number is within expected non pruned range then it should be retried
+ return firstNum <= number && number <= firstNum+milestonePruneNumber-1
+ }
+
+ response, err := FetchWithRetryEx[MilestoneResponse](ctx, c, url, isRecoverableError, c.logger)
+ if err != nil {
+ if isInvalidMilestoneIndexError(err) {
+ return nil, fmt.Errorf("%w: number %d", ErrNotInMilestoneList, number)
+ }
+ return nil, err
+ }
+
+ response.Result.Id = MilestoneId(number)
+
+ return &response.Result, nil
+}
+
+// FetchCheckpointCount fetches the checkpoint count from heimdall
+func (c *HttpClient) FetchCheckpointCount(ctx context.Context) (int64, error) {
+ url, err := checkpointCountURL(c.urlString)
+ if err != nil {
+ return 0, err
+ }
+
+ ctx = withRequestType(ctx, checkpointCountRequest)
+
+ response, err := FetchWithRetry[CheckpointCountResponse](ctx, c, url, c.logger)
+ if err != nil {
+ return 0, err
+ }
+
+ return response.Result.Result, nil
+}
+
+// FetchMilestoneCount fetches the milestone count from heimdall
+func (c *HttpClient) FetchMilestoneCount(ctx context.Context) (int64, error) {
+ url, err := milestoneCountURL(c.urlString)
+ if err != nil {
+ return 0, err
+ }
+
+ ctx = withRequestType(ctx, milestoneCountRequest)
+
+ response, err := FetchWithRetry[MilestoneCountResponse](ctx, c, url, c.logger)
+ if err != nil {
+ return 0, err
+ }
+
+ return response.Result.Count, nil
+}
+
+// Heimdall keeps only this amount of latest milestones
+// https://github.com/maticnetwork/heimdall/blob/master/helper/config.go#L141
+const milestonePruneNumber = int64(100)
+
+func (c *HttpClient) FetchFirstMilestoneNum(ctx context.Context) (int64, error) {
+ count, err := c.FetchMilestoneCount(ctx)
+ if err != nil {
+ return 0, err
+ }
+
+ var first int64
+ if count < milestonePruneNumber {
+ first = 1
+ } else {
+ first = count - milestonePruneNumber + 1
+ }
+
+ return first, nil
+}
+
+// FetchLastNoAckMilestone fetches the last no-ack-milestone from heimdall
+func (c *HttpClient) FetchLastNoAckMilestone(ctx context.Context) (string, error) {
+ url, err := lastNoAckMilestoneURL(c.urlString)
+ if err != nil {
+ return "", err
+ }
+
+ ctx = withRequestType(ctx, milestoneLastNoAckRequest)
+
+ response, err := FetchWithRetry[MilestoneLastNoAckResponse](ctx, c, url, c.logger)
+ if err != nil {
+ return "", err
+ }
+
+ return response.Result.Result, nil
+}
+
+// FetchNoAckMilestone fetches the last no-ack-milestone from heimdall
+func (c *HttpClient) FetchNoAckMilestone(ctx context.Context, milestoneID string) error {
+ url, err := noAckMilestoneURL(c.urlString, milestoneID)
+ if err != nil {
+ return err
+ }
+
+ ctx = withRequestType(ctx, milestoneNoAckRequest)
+
+ response, err := FetchWithRetry[MilestoneNoAckResponse](ctx, c, url, c.logger)
+ if err != nil {
+ return err
+ }
+
+ if !response.Result.Result {
+ return fmt.Errorf("%w: milestoneID %q", ErrNotInRejectedList, milestoneID)
+ }
+
+ return nil
+}
+
+// FetchMilestoneID fetches the bool result from Heimdall whether the ID corresponding
+// to the given milestone is in process in Heimdall
+func (c *HttpClient) FetchMilestoneID(ctx context.Context, milestoneID string) error {
+ url, err := milestoneIDURL(c.urlString, milestoneID)
+ if err != nil {
+ return err
+ }
+
+ ctx = withRequestType(ctx, milestoneIDRequest)
+
+ response, err := FetchWithRetry[MilestoneIDResponse](ctx, c, url, c.logger)
+
+ if err != nil {
+ return err
+ }
+
+ if !response.Result.Result {
+ return fmt.Errorf("%w: milestoneID %q", ErrNotInMilestoneList, milestoneID)
+ }
+
+ return nil
+}
+
+// FetchWithRetry returns data from heimdall with retry
+func FetchWithRetry[T any](ctx context.Context, client *HttpClient, url *url.URL, logger log.Logger) (*T, error) {
+ return FetchWithRetryEx[T](ctx, client, url, nil, logger)
+}
+
+// FetchWithRetryEx returns data from heimdall with retry
+func FetchWithRetryEx[T any](
+ ctx context.Context,
+ client *HttpClient,
+ url *url.URL,
+ isRecoverableError func(error) bool,
+ logger log.Logger,
+) (result *T, err error) {
+ attempt := 0
+ // create a new ticker for retrying the request
+ ticker := time.NewTicker(client.retryBackOff)
+ defer ticker.Stop()
+
+ for attempt < client.maxRetries {
+ attempt++
+
+ request := &HttpRequest{handler: client.handler, url: url, start: time.Now()}
+ result, err = Fetch[T](ctx, request, logger)
+ if err == nil {
+ return result, nil
+ }
+
+ // 503 (Service Unavailable) is thrown when an endpoint isn't activated
+ // yet in heimdall. E.g. when the hard fork hasn't hit yet but heimdall
+ // is upgraded.
+ if errors.Is(err, ErrServiceUnavailable) {
+ client.logger.Debug(heimdallLogPrefix("service unavailable at the moment"), "path", url.Path, "queryParams", url.RawQuery, "attempt", attempt, "err", err)
+ return nil, err
+ }
+
+ if (isRecoverableError != nil) && !isRecoverableError(err) {
+ return nil, err
+ }
+
+ client.logger.Warn(heimdallLogPrefix("an error while fetching"), "path", url.Path, "queryParams", url.RawQuery, "attempt", attempt, "err", err)
+
+ select {
+ case <-ctx.Done():
+ client.logger.Debug(heimdallLogPrefix("request canceled"), "reason", ctx.Err(), "path", url.Path, "queryParams", url.RawQuery, "attempt", attempt)
+ return nil, ctx.Err()
+ case <-client.closeCh:
+ client.logger.Debug(heimdallLogPrefix("shutdown detected, terminating request"), "path", url.Path, "queryParams", url.RawQuery)
+ return nil, ErrShutdownDetected
+ case <-ticker.C:
+ // retry
+ }
+ }
+
+ return nil, err
+}
+
+// Fetch fetches response from heimdall
+func Fetch[T any](ctx context.Context, request *HttpRequest, logger log.Logger) (*T, error) {
+ isSuccessful := false
+
+ defer func() {
+ if metrics.EnabledExpensive {
+ sendMetrics(ctx, request.start, isSuccessful)
+ }
+ }()
+
+ result := new(T)
+
+ body, err := internalFetchWithTimeout(ctx, request.handler, request.url, logger)
+ if err != nil {
+ return nil, err
+ }
+
+ if len(body) == 0 {
+ return nil, ErrNoResponse
+ }
+
+ err = json.Unmarshal(body, result)
+ if err != nil {
+ return nil, err
+ }
+
+ isSuccessful = true
+
+ return result, nil
+}
+
+func spanURL(urlString string, spanID uint64) (*url.URL, error) {
+ return makeURL(urlString, fmt.Sprintf(fetchSpanFormat, spanID), "")
+}
+
+func spanListURL(urlString string, page, limit uint64) (*url.URL, error) {
+ return makeURL(urlString, fetchSpanListPath, fmt.Sprintf(fetchSpanListFormat, page, limit))
+}
+
+func latestSpanURL(urlString string) (*url.URL, error) {
+ return makeURL(urlString, fetchSpanLatest, "")
+}
+
+func stateSyncListURL(urlString string, fromID uint64, to int64) (*url.URL, error) {
+ queryParams := fmt.Sprintf(fetchStateSyncEventsFormat, fromID, to, StateEventsFetchLimit)
+ return makeURL(urlString, fetchStateSyncEventsPath, queryParams)
+}
+
+func stateSyncURL(urlString string, id uint64) (*url.URL, error) {
+ return makeURL(urlString, fmt.Sprintf(fetchStateSyncEvent, strconv.FormatUint(id, 10)), "")
+}
+
+func checkpointURL(urlString string, number int64) (*url.URL, error) {
+ var url string
+ if number == -1 {
+ url = fmt.Sprintf(fetchCheckpoint, "latest")
+ } else {
+ url = fmt.Sprintf(fetchCheckpoint, strconv.FormatInt(number, 10))
+ }
+
+ return makeURL(urlString, url, "")
+}
+
+func checkpointCountURL(urlString string) (*url.URL, error) {
+ return makeURL(urlString, fetchCheckpointCount, "")
+}
+
+func checkpointListURL(urlString string, page uint64, limit uint64) (*url.URL, error) {
+ return makeURL(urlString, fetchCheckpointList, fmt.Sprintf(fetchCheckpointListQueryFormat, page, limit))
+}
+
+func milestoneURL(urlString string, number int64) (*url.URL, error) {
+ if number == -1 {
+ return makeURL(urlString, fetchMilestoneLatest, "")
+ }
+ return makeURL(urlString, fmt.Sprintf(fetchMilestoneAt, number), "")
+}
+
+func milestoneCountURL(urlString string) (*url.URL, error) {
+ return makeURL(urlString, fetchMilestoneCount, "")
+}
+
+func lastNoAckMilestoneURL(urlString string) (*url.URL, error) {
+ return makeURL(urlString, fetchLastNoAckMilestone, "")
+}
+
+func noAckMilestoneURL(urlString string, id string) (*url.URL, error) {
+ return makeURL(urlString, fmt.Sprintf(fetchNoAckMilestone, id), "")
+}
+
+func milestoneIDURL(urlString string, id string) (*url.URL, error) {
+ return makeURL(urlString, fmt.Sprintf(fetchMilestoneID, id), "")
+}
+
+func makeURL(urlString, rawPath, rawQuery string) (*url.URL, error) {
+ u, err := url.Parse(urlString)
+ if err != nil {
+ return nil, err
+ }
+
+ u.Path = path.Join(u.Path, rawPath)
+ u.RawQuery = rawQuery
+
+ return u, err
+}
+
+// internal fetch method
+func internalFetch(ctx context.Context, handler httpRequestHandler, u *url.URL, logger log.Logger) ([]byte, error) {
+ req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
+ if err != nil {
+ return nil, err
+ }
+
+ logger.Trace(heimdallLogPrefix("http client get request"), "uri", u.RequestURI())
+
+ res, err := handler.Do(req)
+ if err != nil {
+ return nil, err
+ }
+
+ defer func() {
+ _ = res.Body.Close()
+ }()
+
+ if res.StatusCode == http.StatusServiceUnavailable {
+ return nil, fmt.Errorf("%w: url='%s', status=%d", ErrServiceUnavailable, u.String(), res.StatusCode)
+ }
+ if res.StatusCode == http.StatusBadGateway {
+ return nil, fmt.Errorf("%w: url='%s', status=%d", ErrBadGateway, u.String(), res.StatusCode)
+ }
+
+ // unmarshall data from buffer
+ if res.StatusCode == 204 {
+ return nil, nil
+ }
+
+ // get response
+ body, err := io.ReadAll(res.Body)
+ if err != nil {
+ return nil, err
+ }
+
+ // check status code
+ if res.StatusCode != 200 {
+ return nil, fmt.Errorf("%w: url='%s', status=%d, body='%s'", ErrNotSuccessfulResponse, u.String(), res.StatusCode, string(body))
+ }
+
+ return body, nil
+}
+
+func internalFetchWithTimeout(ctx context.Context, handler httpRequestHandler, url *url.URL, logger log.Logger) ([]byte, error) {
+ ctx, cancel := context.WithTimeout(ctx, apiHeimdallTimeout)
+ defer cancel()
+
+ // request data once
+ return internalFetch(ctx, handler, url, logger)
+}
+
+// Close sends a signal to stop the running process
+func (c *HttpClient) Close() {
+ close(c.closeCh)
+ c.handler.CloseIdleConnections()
+}
diff --git a/polygon/heimdall/client_test.go b/polygon/heimdall/client_http_test.go
similarity index 79%
rename from polygon/heimdall/client_test.go
rename to polygon/heimdall/client_http_test.go
index c7f7121b455..2a007fecf3e 100644
--- a/polygon/heimdall/client_test.go
+++ b/polygon/heimdall/client_http_test.go
@@ -44,8 +44,8 @@ func (ebrc emptyBodyReadCloser) Close() error {
func TestHeimdallClientFetchesTerminateUponTooManyErrors(t *testing.T) {
ctx := context.Background()
ctrl := gomock.NewController(t)
- httpClient := NewMockHttpClient(ctrl)
- httpClient.EXPECT().
+ requestHandler := NewMockhttpRequestHandler(ctrl)
+ requestHandler.EXPECT().
Do(gomock.Any()).
Return(&http.Response{
StatusCode: 404,
@@ -53,7 +53,13 @@ func TestHeimdallClientFetchesTerminateUponTooManyErrors(t *testing.T) {
}, nil).
Times(5)
logger := testlog.Logger(t, log.LvlDebug)
- heimdallClient := newHeimdallClient("https://dummyheimdal.com", httpClient, 100*time.Millisecond, 5, logger)
+ heimdallClient := NewHttpClient(
+ "https://dummyheimdal.com",
+ logger,
+ WithHttpRequestHandler(requestHandler),
+ WithHttpRetryBackOff(100*time.Millisecond),
+ WithHttpMaxRetries(5),
+ )
spanRes, err := heimdallClient.FetchSpan(ctx, 1534)
require.Nil(t, spanRes)
@@ -63,8 +69,8 @@ func TestHeimdallClientFetchesTerminateUponTooManyErrors(t *testing.T) {
func TestHeimdallClientStateSyncEventsReturnsErrNoResponseWhenHttp200WithEmptyBody(t *testing.T) {
ctx := context.Background()
ctrl := gomock.NewController(t)
- httpClient := NewMockHttpClient(ctrl)
- httpClient.EXPECT().
+ requestHandler := NewMockhttpRequestHandler(ctrl)
+ requestHandler.EXPECT().
Do(gomock.Any()).
Return(&http.Response{
StatusCode: 200,
@@ -72,7 +78,13 @@ func TestHeimdallClientStateSyncEventsReturnsErrNoResponseWhenHttp200WithEmptyBo
}, nil).
Times(2)
logger := testlog.Logger(t, log.LvlDebug)
- heimdallClient := newHeimdallClient("https://dummyheimdal.com", httpClient, time.Millisecond, 2, logger)
+ heimdallClient := NewHttpClient(
+ "https://dummyheimdal.com",
+ logger,
+ WithHttpRequestHandler(requestHandler),
+ WithHttpRetryBackOff(time.Millisecond),
+ WithHttpMaxRetries(2),
+ )
spanRes, err := heimdallClient.FetchStateSyncEvents(ctx, 100, time.Now(), 0)
require.Nil(t, spanRes)
diff --git a/polygon/heimdall/client_mock.go b/polygon/heimdall/client_mock.go
index d36d245a787..7710eff7509 100644
--- a/polygon/heimdall/client_mock.go
+++ b/polygon/heimdall/client_mock.go
@@ -1,9 +1,9 @@
// Code generated by MockGen. DO NOT EDIT.
-// Source: github.com/erigontech/erigon/polygon/heimdall (interfaces: HeimdallClient)
+// Source: github.com/erigontech/erigon/polygon/heimdall (interfaces: Client)
//
// Generated by this command:
//
-// mockgen -typed=true -destination=./client_mock.go -package=heimdall . HeimdallClient
+// mockgen -typed=true -destination=./client_mock.go -package=heimdall . Client
//
// Package heimdall is a generated GoMock package.
@@ -17,68 +17,68 @@ import (
gomock "go.uber.org/mock/gomock"
)
-// MockHeimdallClient is a mock of HeimdallClient interface.
-type MockHeimdallClient struct {
+// MockClient is a mock of Client interface.
+type MockClient struct {
ctrl *gomock.Controller
- recorder *MockHeimdallClientMockRecorder
+ recorder *MockClientMockRecorder
isgomock struct{}
}
-// MockHeimdallClientMockRecorder is the mock recorder for MockHeimdallClient.
-type MockHeimdallClientMockRecorder struct {
- mock *MockHeimdallClient
+// MockClientMockRecorder is the mock recorder for MockClient.
+type MockClientMockRecorder struct {
+ mock *MockClient
}
-// NewMockHeimdallClient creates a new mock instance.
-func NewMockHeimdallClient(ctrl *gomock.Controller) *MockHeimdallClient {
- mock := &MockHeimdallClient{ctrl: ctrl}
- mock.recorder = &MockHeimdallClientMockRecorder{mock}
+// NewMockClient creates a new mock instance.
+func NewMockClient(ctrl *gomock.Controller) *MockClient {
+ mock := &MockClient{ctrl: ctrl}
+ mock.recorder = &MockClientMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
-func (m *MockHeimdallClient) EXPECT() *MockHeimdallClientMockRecorder {
+func (m *MockClient) EXPECT() *MockClientMockRecorder {
return m.recorder
}
// Close mocks base method.
-func (m *MockHeimdallClient) Close() {
+func (m *MockClient) Close() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "Close")
}
// Close indicates an expected call of Close.
-func (mr *MockHeimdallClientMockRecorder) Close() *MockHeimdallClientCloseCall {
+func (mr *MockClientMockRecorder) Close() *MockClientCloseCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockHeimdallClient)(nil).Close))
- return &MockHeimdallClientCloseCall{Call: call}
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockClient)(nil).Close))
+ return &MockClientCloseCall{Call: call}
}
-// MockHeimdallClientCloseCall wrap *gomock.Call
-type MockHeimdallClientCloseCall struct {
+// MockClientCloseCall wrap *gomock.Call
+type MockClientCloseCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
-func (c *MockHeimdallClientCloseCall) Return() *MockHeimdallClientCloseCall {
+func (c *MockClientCloseCall) Return() *MockClientCloseCall {
c.Call = c.Call.Return()
return c
}
// Do rewrite *gomock.Call.Do
-func (c *MockHeimdallClientCloseCall) Do(f func()) *MockHeimdallClientCloseCall {
+func (c *MockClientCloseCall) Do(f func()) *MockClientCloseCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHeimdallClientCloseCall) DoAndReturn(f func()) *MockHeimdallClientCloseCall {
+func (c *MockClientCloseCall) DoAndReturn(f func()) *MockClientCloseCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// FetchCheckpoint mocks base method.
-func (m *MockHeimdallClient) FetchCheckpoint(ctx context.Context, number int64) (*Checkpoint, error) {
+func (m *MockClient) FetchCheckpoint(ctx context.Context, number int64) (*Checkpoint, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchCheckpoint", ctx, number)
ret0, _ := ret[0].(*Checkpoint)
@@ -87,37 +87,37 @@ func (m *MockHeimdallClient) FetchCheckpoint(ctx context.Context, number int64)
}
// FetchCheckpoint indicates an expected call of FetchCheckpoint.
-func (mr *MockHeimdallClientMockRecorder) FetchCheckpoint(ctx, number any) *MockHeimdallClientFetchCheckpointCall {
+func (mr *MockClientMockRecorder) FetchCheckpoint(ctx, number any) *MockClientFetchCheckpointCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchCheckpoint", reflect.TypeOf((*MockHeimdallClient)(nil).FetchCheckpoint), ctx, number)
- return &MockHeimdallClientFetchCheckpointCall{Call: call}
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchCheckpoint", reflect.TypeOf((*MockClient)(nil).FetchCheckpoint), ctx, number)
+ return &MockClientFetchCheckpointCall{Call: call}
}
-// MockHeimdallClientFetchCheckpointCall wrap *gomock.Call
-type MockHeimdallClientFetchCheckpointCall struct {
+// MockClientFetchCheckpointCall wrap *gomock.Call
+type MockClientFetchCheckpointCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
-func (c *MockHeimdallClientFetchCheckpointCall) Return(arg0 *Checkpoint, arg1 error) *MockHeimdallClientFetchCheckpointCall {
+func (c *MockClientFetchCheckpointCall) Return(arg0 *Checkpoint, arg1 error) *MockClientFetchCheckpointCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
-func (c *MockHeimdallClientFetchCheckpointCall) Do(f func(context.Context, int64) (*Checkpoint, error)) *MockHeimdallClientFetchCheckpointCall {
+func (c *MockClientFetchCheckpointCall) Do(f func(context.Context, int64) (*Checkpoint, error)) *MockClientFetchCheckpointCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHeimdallClientFetchCheckpointCall) DoAndReturn(f func(context.Context, int64) (*Checkpoint, error)) *MockHeimdallClientFetchCheckpointCall {
+func (c *MockClientFetchCheckpointCall) DoAndReturn(f func(context.Context, int64) (*Checkpoint, error)) *MockClientFetchCheckpointCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// FetchCheckpointCount mocks base method.
-func (m *MockHeimdallClient) FetchCheckpointCount(ctx context.Context) (int64, error) {
+func (m *MockClient) FetchCheckpointCount(ctx context.Context) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchCheckpointCount", ctx)
ret0, _ := ret[0].(int64)
@@ -126,37 +126,37 @@ func (m *MockHeimdallClient) FetchCheckpointCount(ctx context.Context) (int64, e
}
// FetchCheckpointCount indicates an expected call of FetchCheckpointCount.
-func (mr *MockHeimdallClientMockRecorder) FetchCheckpointCount(ctx any) *MockHeimdallClientFetchCheckpointCountCall {
+func (mr *MockClientMockRecorder) FetchCheckpointCount(ctx any) *MockClientFetchCheckpointCountCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchCheckpointCount", reflect.TypeOf((*MockHeimdallClient)(nil).FetchCheckpointCount), ctx)
- return &MockHeimdallClientFetchCheckpointCountCall{Call: call}
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchCheckpointCount", reflect.TypeOf((*MockClient)(nil).FetchCheckpointCount), ctx)
+ return &MockClientFetchCheckpointCountCall{Call: call}
}
-// MockHeimdallClientFetchCheckpointCountCall wrap *gomock.Call
-type MockHeimdallClientFetchCheckpointCountCall struct {
+// MockClientFetchCheckpointCountCall wrap *gomock.Call
+type MockClientFetchCheckpointCountCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
-func (c *MockHeimdallClientFetchCheckpointCountCall) Return(arg0 int64, arg1 error) *MockHeimdallClientFetchCheckpointCountCall {
+func (c *MockClientFetchCheckpointCountCall) Return(arg0 int64, arg1 error) *MockClientFetchCheckpointCountCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
-func (c *MockHeimdallClientFetchCheckpointCountCall) Do(f func(context.Context) (int64, error)) *MockHeimdallClientFetchCheckpointCountCall {
+func (c *MockClientFetchCheckpointCountCall) Do(f func(context.Context) (int64, error)) *MockClientFetchCheckpointCountCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHeimdallClientFetchCheckpointCountCall) DoAndReturn(f func(context.Context) (int64, error)) *MockHeimdallClientFetchCheckpointCountCall {
+func (c *MockClientFetchCheckpointCountCall) DoAndReturn(f func(context.Context) (int64, error)) *MockClientFetchCheckpointCountCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// FetchCheckpoints mocks base method.
-func (m *MockHeimdallClient) FetchCheckpoints(ctx context.Context, page, limit uint64) ([]*Checkpoint, error) {
+func (m *MockClient) FetchCheckpoints(ctx context.Context, page, limit uint64) ([]*Checkpoint, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchCheckpoints", ctx, page, limit)
ret0, _ := ret[0].([]*Checkpoint)
@@ -165,37 +165,37 @@ func (m *MockHeimdallClient) FetchCheckpoints(ctx context.Context, page, limit u
}
// FetchCheckpoints indicates an expected call of FetchCheckpoints.
-func (mr *MockHeimdallClientMockRecorder) FetchCheckpoints(ctx, page, limit any) *MockHeimdallClientFetchCheckpointsCall {
+func (mr *MockClientMockRecorder) FetchCheckpoints(ctx, page, limit any) *MockClientFetchCheckpointsCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchCheckpoints", reflect.TypeOf((*MockHeimdallClient)(nil).FetchCheckpoints), ctx, page, limit)
- return &MockHeimdallClientFetchCheckpointsCall{Call: call}
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchCheckpoints", reflect.TypeOf((*MockClient)(nil).FetchCheckpoints), ctx, page, limit)
+ return &MockClientFetchCheckpointsCall{Call: call}
}
-// MockHeimdallClientFetchCheckpointsCall wrap *gomock.Call
-type MockHeimdallClientFetchCheckpointsCall struct {
+// MockClientFetchCheckpointsCall wrap *gomock.Call
+type MockClientFetchCheckpointsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
-func (c *MockHeimdallClientFetchCheckpointsCall) Return(arg0 []*Checkpoint, arg1 error) *MockHeimdallClientFetchCheckpointsCall {
+func (c *MockClientFetchCheckpointsCall) Return(arg0 []*Checkpoint, arg1 error) *MockClientFetchCheckpointsCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
-func (c *MockHeimdallClientFetchCheckpointsCall) Do(f func(context.Context, uint64, uint64) ([]*Checkpoint, error)) *MockHeimdallClientFetchCheckpointsCall {
+func (c *MockClientFetchCheckpointsCall) Do(f func(context.Context, uint64, uint64) ([]*Checkpoint, error)) *MockClientFetchCheckpointsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHeimdallClientFetchCheckpointsCall) DoAndReturn(f func(context.Context, uint64, uint64) ([]*Checkpoint, error)) *MockHeimdallClientFetchCheckpointsCall {
+func (c *MockClientFetchCheckpointsCall) DoAndReturn(f func(context.Context, uint64, uint64) ([]*Checkpoint, error)) *MockClientFetchCheckpointsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// FetchFirstMilestoneNum mocks base method.
-func (m *MockHeimdallClient) FetchFirstMilestoneNum(ctx context.Context) (int64, error) {
+func (m *MockClient) FetchFirstMilestoneNum(ctx context.Context) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchFirstMilestoneNum", ctx)
ret0, _ := ret[0].(int64)
@@ -204,37 +204,37 @@ func (m *MockHeimdallClient) FetchFirstMilestoneNum(ctx context.Context) (int64,
}
// FetchFirstMilestoneNum indicates an expected call of FetchFirstMilestoneNum.
-func (mr *MockHeimdallClientMockRecorder) FetchFirstMilestoneNum(ctx any) *MockHeimdallClientFetchFirstMilestoneNumCall {
+func (mr *MockClientMockRecorder) FetchFirstMilestoneNum(ctx any) *MockClientFetchFirstMilestoneNumCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchFirstMilestoneNum", reflect.TypeOf((*MockHeimdallClient)(nil).FetchFirstMilestoneNum), ctx)
- return &MockHeimdallClientFetchFirstMilestoneNumCall{Call: call}
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchFirstMilestoneNum", reflect.TypeOf((*MockClient)(nil).FetchFirstMilestoneNum), ctx)
+ return &MockClientFetchFirstMilestoneNumCall{Call: call}
}
-// MockHeimdallClientFetchFirstMilestoneNumCall wrap *gomock.Call
-type MockHeimdallClientFetchFirstMilestoneNumCall struct {
+// MockClientFetchFirstMilestoneNumCall wrap *gomock.Call
+type MockClientFetchFirstMilestoneNumCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
-func (c *MockHeimdallClientFetchFirstMilestoneNumCall) Return(arg0 int64, arg1 error) *MockHeimdallClientFetchFirstMilestoneNumCall {
+func (c *MockClientFetchFirstMilestoneNumCall) Return(arg0 int64, arg1 error) *MockClientFetchFirstMilestoneNumCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
-func (c *MockHeimdallClientFetchFirstMilestoneNumCall) Do(f func(context.Context) (int64, error)) *MockHeimdallClientFetchFirstMilestoneNumCall {
+func (c *MockClientFetchFirstMilestoneNumCall) Do(f func(context.Context) (int64, error)) *MockClientFetchFirstMilestoneNumCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHeimdallClientFetchFirstMilestoneNumCall) DoAndReturn(f func(context.Context) (int64, error)) *MockHeimdallClientFetchFirstMilestoneNumCall {
+func (c *MockClientFetchFirstMilestoneNumCall) DoAndReturn(f func(context.Context) (int64, error)) *MockClientFetchFirstMilestoneNumCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// FetchLastNoAckMilestone mocks base method.
-func (m *MockHeimdallClient) FetchLastNoAckMilestone(ctx context.Context) (string, error) {
+func (m *MockClient) FetchLastNoAckMilestone(ctx context.Context) (string, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchLastNoAckMilestone", ctx)
ret0, _ := ret[0].(string)
@@ -243,37 +243,37 @@ func (m *MockHeimdallClient) FetchLastNoAckMilestone(ctx context.Context) (strin
}
// FetchLastNoAckMilestone indicates an expected call of FetchLastNoAckMilestone.
-func (mr *MockHeimdallClientMockRecorder) FetchLastNoAckMilestone(ctx any) *MockHeimdallClientFetchLastNoAckMilestoneCall {
+func (mr *MockClientMockRecorder) FetchLastNoAckMilestone(ctx any) *MockClientFetchLastNoAckMilestoneCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchLastNoAckMilestone", reflect.TypeOf((*MockHeimdallClient)(nil).FetchLastNoAckMilestone), ctx)
- return &MockHeimdallClientFetchLastNoAckMilestoneCall{Call: call}
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchLastNoAckMilestone", reflect.TypeOf((*MockClient)(nil).FetchLastNoAckMilestone), ctx)
+ return &MockClientFetchLastNoAckMilestoneCall{Call: call}
}
-// MockHeimdallClientFetchLastNoAckMilestoneCall wrap *gomock.Call
-type MockHeimdallClientFetchLastNoAckMilestoneCall struct {
+// MockClientFetchLastNoAckMilestoneCall wrap *gomock.Call
+type MockClientFetchLastNoAckMilestoneCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
-func (c *MockHeimdallClientFetchLastNoAckMilestoneCall) Return(arg0 string, arg1 error) *MockHeimdallClientFetchLastNoAckMilestoneCall {
+func (c *MockClientFetchLastNoAckMilestoneCall) Return(arg0 string, arg1 error) *MockClientFetchLastNoAckMilestoneCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
-func (c *MockHeimdallClientFetchLastNoAckMilestoneCall) Do(f func(context.Context) (string, error)) *MockHeimdallClientFetchLastNoAckMilestoneCall {
+func (c *MockClientFetchLastNoAckMilestoneCall) Do(f func(context.Context) (string, error)) *MockClientFetchLastNoAckMilestoneCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHeimdallClientFetchLastNoAckMilestoneCall) DoAndReturn(f func(context.Context) (string, error)) *MockHeimdallClientFetchLastNoAckMilestoneCall {
+func (c *MockClientFetchLastNoAckMilestoneCall) DoAndReturn(f func(context.Context) (string, error)) *MockClientFetchLastNoAckMilestoneCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// FetchLatestSpan mocks base method.
-func (m *MockHeimdallClient) FetchLatestSpan(ctx context.Context) (*Span, error) {
+func (m *MockClient) FetchLatestSpan(ctx context.Context) (*Span, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchLatestSpan", ctx)
ret0, _ := ret[0].(*Span)
@@ -282,37 +282,37 @@ func (m *MockHeimdallClient) FetchLatestSpan(ctx context.Context) (*Span, error)
}
// FetchLatestSpan indicates an expected call of FetchLatestSpan.
-func (mr *MockHeimdallClientMockRecorder) FetchLatestSpan(ctx any) *MockHeimdallClientFetchLatestSpanCall {
+func (mr *MockClientMockRecorder) FetchLatestSpan(ctx any) *MockClientFetchLatestSpanCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchLatestSpan", reflect.TypeOf((*MockHeimdallClient)(nil).FetchLatestSpan), ctx)
- return &MockHeimdallClientFetchLatestSpanCall{Call: call}
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchLatestSpan", reflect.TypeOf((*MockClient)(nil).FetchLatestSpan), ctx)
+ return &MockClientFetchLatestSpanCall{Call: call}
}
-// MockHeimdallClientFetchLatestSpanCall wrap *gomock.Call
-type MockHeimdallClientFetchLatestSpanCall struct {
+// MockClientFetchLatestSpanCall wrap *gomock.Call
+type MockClientFetchLatestSpanCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
-func (c *MockHeimdallClientFetchLatestSpanCall) Return(arg0 *Span, arg1 error) *MockHeimdallClientFetchLatestSpanCall {
+func (c *MockClientFetchLatestSpanCall) Return(arg0 *Span, arg1 error) *MockClientFetchLatestSpanCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
-func (c *MockHeimdallClientFetchLatestSpanCall) Do(f func(context.Context) (*Span, error)) *MockHeimdallClientFetchLatestSpanCall {
+func (c *MockClientFetchLatestSpanCall) Do(f func(context.Context) (*Span, error)) *MockClientFetchLatestSpanCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHeimdallClientFetchLatestSpanCall) DoAndReturn(f func(context.Context) (*Span, error)) *MockHeimdallClientFetchLatestSpanCall {
+func (c *MockClientFetchLatestSpanCall) DoAndReturn(f func(context.Context) (*Span, error)) *MockClientFetchLatestSpanCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// FetchMilestone mocks base method.
-func (m *MockHeimdallClient) FetchMilestone(ctx context.Context, number int64) (*Milestone, error) {
+func (m *MockClient) FetchMilestone(ctx context.Context, number int64) (*Milestone, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchMilestone", ctx, number)
ret0, _ := ret[0].(*Milestone)
@@ -321,37 +321,37 @@ func (m *MockHeimdallClient) FetchMilestone(ctx context.Context, number int64) (
}
// FetchMilestone indicates an expected call of FetchMilestone.
-func (mr *MockHeimdallClientMockRecorder) FetchMilestone(ctx, number any) *MockHeimdallClientFetchMilestoneCall {
+func (mr *MockClientMockRecorder) FetchMilestone(ctx, number any) *MockClientFetchMilestoneCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchMilestone", reflect.TypeOf((*MockHeimdallClient)(nil).FetchMilestone), ctx, number)
- return &MockHeimdallClientFetchMilestoneCall{Call: call}
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchMilestone", reflect.TypeOf((*MockClient)(nil).FetchMilestone), ctx, number)
+ return &MockClientFetchMilestoneCall{Call: call}
}
-// MockHeimdallClientFetchMilestoneCall wrap *gomock.Call
-type MockHeimdallClientFetchMilestoneCall struct {
+// MockClientFetchMilestoneCall wrap *gomock.Call
+type MockClientFetchMilestoneCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
-func (c *MockHeimdallClientFetchMilestoneCall) Return(arg0 *Milestone, arg1 error) *MockHeimdallClientFetchMilestoneCall {
+func (c *MockClientFetchMilestoneCall) Return(arg0 *Milestone, arg1 error) *MockClientFetchMilestoneCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
-func (c *MockHeimdallClientFetchMilestoneCall) Do(f func(context.Context, int64) (*Milestone, error)) *MockHeimdallClientFetchMilestoneCall {
+func (c *MockClientFetchMilestoneCall) Do(f func(context.Context, int64) (*Milestone, error)) *MockClientFetchMilestoneCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHeimdallClientFetchMilestoneCall) DoAndReturn(f func(context.Context, int64) (*Milestone, error)) *MockHeimdallClientFetchMilestoneCall {
+func (c *MockClientFetchMilestoneCall) DoAndReturn(f func(context.Context, int64) (*Milestone, error)) *MockClientFetchMilestoneCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// FetchMilestoneCount mocks base method.
-func (m *MockHeimdallClient) FetchMilestoneCount(ctx context.Context) (int64, error) {
+func (m *MockClient) FetchMilestoneCount(ctx context.Context) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchMilestoneCount", ctx)
ret0, _ := ret[0].(int64)
@@ -360,37 +360,37 @@ func (m *MockHeimdallClient) FetchMilestoneCount(ctx context.Context) (int64, er
}
// FetchMilestoneCount indicates an expected call of FetchMilestoneCount.
-func (mr *MockHeimdallClientMockRecorder) FetchMilestoneCount(ctx any) *MockHeimdallClientFetchMilestoneCountCall {
+func (mr *MockClientMockRecorder) FetchMilestoneCount(ctx any) *MockClientFetchMilestoneCountCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchMilestoneCount", reflect.TypeOf((*MockHeimdallClient)(nil).FetchMilestoneCount), ctx)
- return &MockHeimdallClientFetchMilestoneCountCall{Call: call}
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchMilestoneCount", reflect.TypeOf((*MockClient)(nil).FetchMilestoneCount), ctx)
+ return &MockClientFetchMilestoneCountCall{Call: call}
}
-// MockHeimdallClientFetchMilestoneCountCall wrap *gomock.Call
-type MockHeimdallClientFetchMilestoneCountCall struct {
+// MockClientFetchMilestoneCountCall wrap *gomock.Call
+type MockClientFetchMilestoneCountCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
-func (c *MockHeimdallClientFetchMilestoneCountCall) Return(arg0 int64, arg1 error) *MockHeimdallClientFetchMilestoneCountCall {
+func (c *MockClientFetchMilestoneCountCall) Return(arg0 int64, arg1 error) *MockClientFetchMilestoneCountCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
-func (c *MockHeimdallClientFetchMilestoneCountCall) Do(f func(context.Context) (int64, error)) *MockHeimdallClientFetchMilestoneCountCall {
+func (c *MockClientFetchMilestoneCountCall) Do(f func(context.Context) (int64, error)) *MockClientFetchMilestoneCountCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHeimdallClientFetchMilestoneCountCall) DoAndReturn(f func(context.Context) (int64, error)) *MockHeimdallClientFetchMilestoneCountCall {
+func (c *MockClientFetchMilestoneCountCall) DoAndReturn(f func(context.Context) (int64, error)) *MockClientFetchMilestoneCountCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// FetchMilestoneID mocks base method.
-func (m *MockHeimdallClient) FetchMilestoneID(ctx context.Context, milestoneID string) error {
+func (m *MockClient) FetchMilestoneID(ctx context.Context, milestoneID string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchMilestoneID", ctx, milestoneID)
ret0, _ := ret[0].(error)
@@ -398,37 +398,37 @@ func (m *MockHeimdallClient) FetchMilestoneID(ctx context.Context, milestoneID s
}
// FetchMilestoneID indicates an expected call of FetchMilestoneID.
-func (mr *MockHeimdallClientMockRecorder) FetchMilestoneID(ctx, milestoneID any) *MockHeimdallClientFetchMilestoneIDCall {
+func (mr *MockClientMockRecorder) FetchMilestoneID(ctx, milestoneID any) *MockClientFetchMilestoneIDCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchMilestoneID", reflect.TypeOf((*MockHeimdallClient)(nil).FetchMilestoneID), ctx, milestoneID)
- return &MockHeimdallClientFetchMilestoneIDCall{Call: call}
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchMilestoneID", reflect.TypeOf((*MockClient)(nil).FetchMilestoneID), ctx, milestoneID)
+ return &MockClientFetchMilestoneIDCall{Call: call}
}
-// MockHeimdallClientFetchMilestoneIDCall wrap *gomock.Call
-type MockHeimdallClientFetchMilestoneIDCall struct {
+// MockClientFetchMilestoneIDCall wrap *gomock.Call
+type MockClientFetchMilestoneIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
-func (c *MockHeimdallClientFetchMilestoneIDCall) Return(arg0 error) *MockHeimdallClientFetchMilestoneIDCall {
+func (c *MockClientFetchMilestoneIDCall) Return(arg0 error) *MockClientFetchMilestoneIDCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
-func (c *MockHeimdallClientFetchMilestoneIDCall) Do(f func(context.Context, string) error) *MockHeimdallClientFetchMilestoneIDCall {
+func (c *MockClientFetchMilestoneIDCall) Do(f func(context.Context, string) error) *MockClientFetchMilestoneIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHeimdallClientFetchMilestoneIDCall) DoAndReturn(f func(context.Context, string) error) *MockHeimdallClientFetchMilestoneIDCall {
+func (c *MockClientFetchMilestoneIDCall) DoAndReturn(f func(context.Context, string) error) *MockClientFetchMilestoneIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// FetchNoAckMilestone mocks base method.
-func (m *MockHeimdallClient) FetchNoAckMilestone(ctx context.Context, milestoneID string) error {
+func (m *MockClient) FetchNoAckMilestone(ctx context.Context, milestoneID string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchNoAckMilestone", ctx, milestoneID)
ret0, _ := ret[0].(error)
@@ -436,37 +436,37 @@ func (m *MockHeimdallClient) FetchNoAckMilestone(ctx context.Context, milestoneI
}
// FetchNoAckMilestone indicates an expected call of FetchNoAckMilestone.
-func (mr *MockHeimdallClientMockRecorder) FetchNoAckMilestone(ctx, milestoneID any) *MockHeimdallClientFetchNoAckMilestoneCall {
+func (mr *MockClientMockRecorder) FetchNoAckMilestone(ctx, milestoneID any) *MockClientFetchNoAckMilestoneCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchNoAckMilestone", reflect.TypeOf((*MockHeimdallClient)(nil).FetchNoAckMilestone), ctx, milestoneID)
- return &MockHeimdallClientFetchNoAckMilestoneCall{Call: call}
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchNoAckMilestone", reflect.TypeOf((*MockClient)(nil).FetchNoAckMilestone), ctx, milestoneID)
+ return &MockClientFetchNoAckMilestoneCall{Call: call}
}
-// MockHeimdallClientFetchNoAckMilestoneCall wrap *gomock.Call
-type MockHeimdallClientFetchNoAckMilestoneCall struct {
+// MockClientFetchNoAckMilestoneCall wrap *gomock.Call
+type MockClientFetchNoAckMilestoneCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
-func (c *MockHeimdallClientFetchNoAckMilestoneCall) Return(arg0 error) *MockHeimdallClientFetchNoAckMilestoneCall {
+func (c *MockClientFetchNoAckMilestoneCall) Return(arg0 error) *MockClientFetchNoAckMilestoneCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
-func (c *MockHeimdallClientFetchNoAckMilestoneCall) Do(f func(context.Context, string) error) *MockHeimdallClientFetchNoAckMilestoneCall {
+func (c *MockClientFetchNoAckMilestoneCall) Do(f func(context.Context, string) error) *MockClientFetchNoAckMilestoneCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHeimdallClientFetchNoAckMilestoneCall) DoAndReturn(f func(context.Context, string) error) *MockHeimdallClientFetchNoAckMilestoneCall {
+func (c *MockClientFetchNoAckMilestoneCall) DoAndReturn(f func(context.Context, string) error) *MockClientFetchNoAckMilestoneCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// FetchSpan mocks base method.
-func (m *MockHeimdallClient) FetchSpan(ctx context.Context, spanID uint64) (*Span, error) {
+func (m *MockClient) FetchSpan(ctx context.Context, spanID uint64) (*Span, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchSpan", ctx, spanID)
ret0, _ := ret[0].(*Span)
@@ -475,37 +475,37 @@ func (m *MockHeimdallClient) FetchSpan(ctx context.Context, spanID uint64) (*Spa
}
// FetchSpan indicates an expected call of FetchSpan.
-func (mr *MockHeimdallClientMockRecorder) FetchSpan(ctx, spanID any) *MockHeimdallClientFetchSpanCall {
+func (mr *MockClientMockRecorder) FetchSpan(ctx, spanID any) *MockClientFetchSpanCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchSpan", reflect.TypeOf((*MockHeimdallClient)(nil).FetchSpan), ctx, spanID)
- return &MockHeimdallClientFetchSpanCall{Call: call}
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchSpan", reflect.TypeOf((*MockClient)(nil).FetchSpan), ctx, spanID)
+ return &MockClientFetchSpanCall{Call: call}
}
-// MockHeimdallClientFetchSpanCall wrap *gomock.Call
-type MockHeimdallClientFetchSpanCall struct {
+// MockClientFetchSpanCall wrap *gomock.Call
+type MockClientFetchSpanCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
-func (c *MockHeimdallClientFetchSpanCall) Return(arg0 *Span, arg1 error) *MockHeimdallClientFetchSpanCall {
+func (c *MockClientFetchSpanCall) Return(arg0 *Span, arg1 error) *MockClientFetchSpanCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
-func (c *MockHeimdallClientFetchSpanCall) Do(f func(context.Context, uint64) (*Span, error)) *MockHeimdallClientFetchSpanCall {
+func (c *MockClientFetchSpanCall) Do(f func(context.Context, uint64) (*Span, error)) *MockClientFetchSpanCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHeimdallClientFetchSpanCall) DoAndReturn(f func(context.Context, uint64) (*Span, error)) *MockHeimdallClientFetchSpanCall {
+func (c *MockClientFetchSpanCall) DoAndReturn(f func(context.Context, uint64) (*Span, error)) *MockClientFetchSpanCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// FetchSpans mocks base method.
-func (m *MockHeimdallClient) FetchSpans(ctx context.Context, page, limit uint64) ([]*Span, error) {
+func (m *MockClient) FetchSpans(ctx context.Context, page, limit uint64) ([]*Span, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchSpans", ctx, page, limit)
ret0, _ := ret[0].([]*Span)
@@ -514,37 +514,37 @@ func (m *MockHeimdallClient) FetchSpans(ctx context.Context, page, limit uint64)
}
// FetchSpans indicates an expected call of FetchSpans.
-func (mr *MockHeimdallClientMockRecorder) FetchSpans(ctx, page, limit any) *MockHeimdallClientFetchSpansCall {
+func (mr *MockClientMockRecorder) FetchSpans(ctx, page, limit any) *MockClientFetchSpansCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchSpans", reflect.TypeOf((*MockHeimdallClient)(nil).FetchSpans), ctx, page, limit)
- return &MockHeimdallClientFetchSpansCall{Call: call}
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchSpans", reflect.TypeOf((*MockClient)(nil).FetchSpans), ctx, page, limit)
+ return &MockClientFetchSpansCall{Call: call}
}
-// MockHeimdallClientFetchSpansCall wrap *gomock.Call
-type MockHeimdallClientFetchSpansCall struct {
+// MockClientFetchSpansCall wrap *gomock.Call
+type MockClientFetchSpansCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
-func (c *MockHeimdallClientFetchSpansCall) Return(arg0 []*Span, arg1 error) *MockHeimdallClientFetchSpansCall {
+func (c *MockClientFetchSpansCall) Return(arg0 []*Span, arg1 error) *MockClientFetchSpansCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
-func (c *MockHeimdallClientFetchSpansCall) Do(f func(context.Context, uint64, uint64) ([]*Span, error)) *MockHeimdallClientFetchSpansCall {
+func (c *MockClientFetchSpansCall) Do(f func(context.Context, uint64, uint64) ([]*Span, error)) *MockClientFetchSpansCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHeimdallClientFetchSpansCall) DoAndReturn(f func(context.Context, uint64, uint64) ([]*Span, error)) *MockHeimdallClientFetchSpansCall {
+func (c *MockClientFetchSpansCall) DoAndReturn(f func(context.Context, uint64, uint64) ([]*Span, error)) *MockClientFetchSpansCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// FetchStateSyncEvent mocks base method.
-func (m *MockHeimdallClient) FetchStateSyncEvent(ctx context.Context, id uint64) (*EventRecordWithTime, error) {
+func (m *MockClient) FetchStateSyncEvent(ctx context.Context, id uint64) (*EventRecordWithTime, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchStateSyncEvent", ctx, id)
ret0, _ := ret[0].(*EventRecordWithTime)
@@ -553,37 +553,37 @@ func (m *MockHeimdallClient) FetchStateSyncEvent(ctx context.Context, id uint64)
}
// FetchStateSyncEvent indicates an expected call of FetchStateSyncEvent.
-func (mr *MockHeimdallClientMockRecorder) FetchStateSyncEvent(ctx, id any) *MockHeimdallClientFetchStateSyncEventCall {
+func (mr *MockClientMockRecorder) FetchStateSyncEvent(ctx, id any) *MockClientFetchStateSyncEventCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchStateSyncEvent", reflect.TypeOf((*MockHeimdallClient)(nil).FetchStateSyncEvent), ctx, id)
- return &MockHeimdallClientFetchStateSyncEventCall{Call: call}
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchStateSyncEvent", reflect.TypeOf((*MockClient)(nil).FetchStateSyncEvent), ctx, id)
+ return &MockClientFetchStateSyncEventCall{Call: call}
}
-// MockHeimdallClientFetchStateSyncEventCall wrap *gomock.Call
-type MockHeimdallClientFetchStateSyncEventCall struct {
+// MockClientFetchStateSyncEventCall wrap *gomock.Call
+type MockClientFetchStateSyncEventCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
-func (c *MockHeimdallClientFetchStateSyncEventCall) Return(arg0 *EventRecordWithTime, arg1 error) *MockHeimdallClientFetchStateSyncEventCall {
+func (c *MockClientFetchStateSyncEventCall) Return(arg0 *EventRecordWithTime, arg1 error) *MockClientFetchStateSyncEventCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
-func (c *MockHeimdallClientFetchStateSyncEventCall) Do(f func(context.Context, uint64) (*EventRecordWithTime, error)) *MockHeimdallClientFetchStateSyncEventCall {
+func (c *MockClientFetchStateSyncEventCall) Do(f func(context.Context, uint64) (*EventRecordWithTime, error)) *MockClientFetchStateSyncEventCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHeimdallClientFetchStateSyncEventCall) DoAndReturn(f func(context.Context, uint64) (*EventRecordWithTime, error)) *MockHeimdallClientFetchStateSyncEventCall {
+func (c *MockClientFetchStateSyncEventCall) DoAndReturn(f func(context.Context, uint64) (*EventRecordWithTime, error)) *MockClientFetchStateSyncEventCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// FetchStateSyncEvents mocks base method.
-func (m *MockHeimdallClient) FetchStateSyncEvents(ctx context.Context, fromId uint64, to time.Time, limit int) ([]*EventRecordWithTime, error) {
+func (m *MockClient) FetchStateSyncEvents(ctx context.Context, fromId uint64, to time.Time, limit int) ([]*EventRecordWithTime, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchStateSyncEvents", ctx, fromId, to, limit)
ret0, _ := ret[0].([]*EventRecordWithTime)
@@ -592,31 +592,31 @@ func (m *MockHeimdallClient) FetchStateSyncEvents(ctx context.Context, fromId ui
}
// FetchStateSyncEvents indicates an expected call of FetchStateSyncEvents.
-func (mr *MockHeimdallClientMockRecorder) FetchStateSyncEvents(ctx, fromId, to, limit any) *MockHeimdallClientFetchStateSyncEventsCall {
+func (mr *MockClientMockRecorder) FetchStateSyncEvents(ctx, fromId, to, limit any) *MockClientFetchStateSyncEventsCall {
mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchStateSyncEvents", reflect.TypeOf((*MockHeimdallClient)(nil).FetchStateSyncEvents), ctx, fromId, to, limit)
- return &MockHeimdallClientFetchStateSyncEventsCall{Call: call}
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchStateSyncEvents", reflect.TypeOf((*MockClient)(nil).FetchStateSyncEvents), ctx, fromId, to, limit)
+ return &MockClientFetchStateSyncEventsCall{Call: call}
}
-// MockHeimdallClientFetchStateSyncEventsCall wrap *gomock.Call
-type MockHeimdallClientFetchStateSyncEventsCall struct {
+// MockClientFetchStateSyncEventsCall wrap *gomock.Call
+type MockClientFetchStateSyncEventsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
-func (c *MockHeimdallClientFetchStateSyncEventsCall) Return(arg0 []*EventRecordWithTime, arg1 error) *MockHeimdallClientFetchStateSyncEventsCall {
+func (c *MockClientFetchStateSyncEventsCall) Return(arg0 []*EventRecordWithTime, arg1 error) *MockClientFetchStateSyncEventsCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
-func (c *MockHeimdallClientFetchStateSyncEventsCall) Do(f func(context.Context, uint64, time.Time, int) ([]*EventRecordWithTime, error)) *MockHeimdallClientFetchStateSyncEventsCall {
+func (c *MockClientFetchStateSyncEventsCall) Do(f func(context.Context, uint64, time.Time, int) ([]*EventRecordWithTime, error)) *MockClientFetchStateSyncEventsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHeimdallClientFetchStateSyncEventsCall) DoAndReturn(f func(context.Context, uint64, time.Time, int) ([]*EventRecordWithTime, error)) *MockHeimdallClientFetchStateSyncEventsCall {
+func (c *MockClientFetchStateSyncEventsCall) DoAndReturn(f func(context.Context, uint64, time.Time, int) ([]*EventRecordWithTime, error)) *MockClientFetchStateSyncEventsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
diff --git a/polygon/heimdall/entity_store_mock.go b/polygon/heimdall/entity_store_mock.go
index 4ef01910dbd..4c42dd1d181 100644
--- a/polygon/heimdall/entity_store_mock.go
+++ b/polygon/heimdall/entity_store_mock.go
@@ -77,6 +77,84 @@ func (c *MockEntityStoreCloseCall[TEntity]) DoAndReturn(f func()) *MockEntitySto
return c
}
+// DeleteFromBlockNum mocks base method.
+func (m *MockEntityStore[TEntity]) DeleteFromBlockNum(ctx context.Context, unwindPoint uint64) (int, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteFromBlockNum", ctx, unwindPoint)
+ ret0, _ := ret[0].(int)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// DeleteFromBlockNum indicates an expected call of DeleteFromBlockNum.
+func (mr *MockEntityStoreMockRecorder[TEntity]) DeleteFromBlockNum(ctx, unwindPoint any) *MockEntityStoreDeleteFromBlockNumCall[TEntity] {
+ mr.mock.ctrl.T.Helper()
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteFromBlockNum", reflect.TypeOf((*MockEntityStore[TEntity])(nil).DeleteFromBlockNum), ctx, unwindPoint)
+ return &MockEntityStoreDeleteFromBlockNumCall[TEntity]{Call: call}
+}
+
+// MockEntityStoreDeleteFromBlockNumCall wrap *gomock.Call
+type MockEntityStoreDeleteFromBlockNumCall[TEntity Entity] struct {
+ *gomock.Call
+}
+
+// Return rewrite *gomock.Call.Return
+func (c *MockEntityStoreDeleteFromBlockNumCall[TEntity]) Return(arg0 int, arg1 error) *MockEntityStoreDeleteFromBlockNumCall[TEntity] {
+ c.Call = c.Call.Return(arg0, arg1)
+ return c
+}
+
+// Do rewrite *gomock.Call.Do
+func (c *MockEntityStoreDeleteFromBlockNumCall[TEntity]) Do(f func(context.Context, uint64) (int, error)) *MockEntityStoreDeleteFromBlockNumCall[TEntity] {
+ c.Call = c.Call.Do(f)
+ return c
+}
+
+// DoAndReturn rewrite *gomock.Call.DoAndReturn
+func (c *MockEntityStoreDeleteFromBlockNumCall[TEntity]) DoAndReturn(f func(context.Context, uint64) (int, error)) *MockEntityStoreDeleteFromBlockNumCall[TEntity] {
+ c.Call = c.Call.DoAndReturn(f)
+ return c
+}
+
+// DeleteToBlockNum mocks base method.
+func (m *MockEntityStore[TEntity]) DeleteToBlockNum(ctx context.Context, unwindPoint uint64, limit int) (int, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteToBlockNum", ctx, unwindPoint, limit)
+ ret0, _ := ret[0].(int)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// DeleteToBlockNum indicates an expected call of DeleteToBlockNum.
+func (mr *MockEntityStoreMockRecorder[TEntity]) DeleteToBlockNum(ctx, unwindPoint, limit any) *MockEntityStoreDeleteToBlockNumCall[TEntity] {
+ mr.mock.ctrl.T.Helper()
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteToBlockNum", reflect.TypeOf((*MockEntityStore[TEntity])(nil).DeleteToBlockNum), ctx, unwindPoint, limit)
+ return &MockEntityStoreDeleteToBlockNumCall[TEntity]{Call: call}
+}
+
+// MockEntityStoreDeleteToBlockNumCall wrap *gomock.Call
+type MockEntityStoreDeleteToBlockNumCall[TEntity Entity] struct {
+ *gomock.Call
+}
+
+// Return rewrite *gomock.Call.Return
+func (c *MockEntityStoreDeleteToBlockNumCall[TEntity]) Return(arg0 int, arg1 error) *MockEntityStoreDeleteToBlockNumCall[TEntity] {
+ c.Call = c.Call.Return(arg0, arg1)
+ return c
+}
+
+// Do rewrite *gomock.Call.Do
+func (c *MockEntityStoreDeleteToBlockNumCall[TEntity]) Do(f func(context.Context, uint64, int) (int, error)) *MockEntityStoreDeleteToBlockNumCall[TEntity] {
+ c.Call = c.Call.Do(f)
+ return c
+}
+
+// DoAndReturn rewrite *gomock.Call.DoAndReturn
+func (c *MockEntityStoreDeleteToBlockNumCall[TEntity]) DoAndReturn(f func(context.Context, uint64, int) (int, error)) *MockEntityStoreDeleteToBlockNumCall[TEntity] {
+ c.Call = c.Call.DoAndReturn(f)
+ return c
+}
+
// Entity mocks base method.
func (m *MockEntityStore[TEntity]) Entity(ctx context.Context, id uint64) (TEntity, bool, error) {
m.ctrl.T.Helper()
@@ -117,6 +195,46 @@ func (c *MockEntityStoreEntityCall[TEntity]) DoAndReturn(f func(context.Context,
return c
}
+// EntityIdFromBlockNum mocks base method.
+func (m *MockEntityStore[TEntity]) EntityIdFromBlockNum(ctx context.Context, blockNum uint64) (uint64, bool, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "EntityIdFromBlockNum", ctx, blockNum)
+ ret0, _ := ret[0].(uint64)
+ ret1, _ := ret[1].(bool)
+ ret2, _ := ret[2].(error)
+ return ret0, ret1, ret2
+}
+
+// EntityIdFromBlockNum indicates an expected call of EntityIdFromBlockNum.
+func (mr *MockEntityStoreMockRecorder[TEntity]) EntityIdFromBlockNum(ctx, blockNum any) *MockEntityStoreEntityIdFromBlockNumCall[TEntity] {
+ mr.mock.ctrl.T.Helper()
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EntityIdFromBlockNum", reflect.TypeOf((*MockEntityStore[TEntity])(nil).EntityIdFromBlockNum), ctx, blockNum)
+ return &MockEntityStoreEntityIdFromBlockNumCall[TEntity]{Call: call}
+}
+
+// MockEntityStoreEntityIdFromBlockNumCall wrap *gomock.Call
+type MockEntityStoreEntityIdFromBlockNumCall[TEntity Entity] struct {
+ *gomock.Call
+}
+
+// Return rewrite *gomock.Call.Return
+func (c *MockEntityStoreEntityIdFromBlockNumCall[TEntity]) Return(arg0 uint64, arg1 bool, arg2 error) *MockEntityStoreEntityIdFromBlockNumCall[TEntity] {
+ c.Call = c.Call.Return(arg0, arg1, arg2)
+ return c
+}
+
+// Do rewrite *gomock.Call.Do
+func (c *MockEntityStoreEntityIdFromBlockNumCall[TEntity]) Do(f func(context.Context, uint64) (uint64, bool, error)) *MockEntityStoreEntityIdFromBlockNumCall[TEntity] {
+ c.Call = c.Call.Do(f)
+ return c
+}
+
+// DoAndReturn rewrite *gomock.Call.DoAndReturn
+func (c *MockEntityStoreEntityIdFromBlockNumCall[TEntity]) DoAndReturn(f func(context.Context, uint64) (uint64, bool, error)) *MockEntityStoreEntityIdFromBlockNumCall[TEntity] {
+ c.Call = c.Call.DoAndReturn(f)
+ return c
+}
+
// LastEntity mocks base method.
func (m *MockEntityStore[TEntity]) LastEntity(ctx context.Context) (TEntity, bool, error) {
m.ctrl.T.Helper()
@@ -387,121 +505,3 @@ func (c *MockEntityStoreSnapTypeCall[TEntity]) DoAndReturn(f func() snaptype.Typ
c.Call = c.Call.DoAndReturn(f)
return c
}
-
-// EntityIdFromBlockNum mocks base method.
-func (m *MockEntityStore[TEntity]) EntityIdFromBlockNum(ctx context.Context, blockNum uint64) (uint64, bool, error) {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "EntityIdFromBlockNum", ctx, blockNum)
- ret0, _ := ret[0].(uint64)
- ret1, _ := ret[1].(bool)
- ret2, _ := ret[2].(error)
- return ret0, ret1, ret2
-}
-
-// EntityIdFromBlockNum indicates an expected call of EntityIdFromBlockNum.
-func (mr *MockEntityStoreMockRecorder[TEntity]) EntityIdFromBlockNum(ctx any, blockNum any) *MockEntityStoreEntityIdFromBlockNumCall[TEntity] {
- mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EntityIdFromBlockNum", reflect.TypeOf((*MockEntityStore[TEntity])(nil).EntityIdFromBlockNum), ctx, blockNum)
- return &MockEntityStoreEntityIdFromBlockNumCall[TEntity]{Call: call}
-}
-
-// MockEntityStoreEntityIdFromBlockNumCall wrap *gomock.Call
-type MockEntityStoreEntityIdFromBlockNumCall[TEntity Entity] struct {
- *gomock.Call
-}
-
-// Return rewrite *gomock.Call.Return
-func (c *MockEntityStoreEntityIdFromBlockNumCall[TEntity]) Return(arg0 uint64, arg1 bool, arg2 error) *MockEntityStoreEntityIdFromBlockNumCall[TEntity] {
- c.Call = c.Call.Return(arg0, arg1, arg2)
- return c
-}
-
-// Do rewrite *gomock.Call.Do
-func (c *MockEntityStoreEntityIdFromBlockNumCall[TEntity]) Do(f func(context.Context, uint64) (uint64, bool, error)) *MockEntityStoreEntityIdFromBlockNumCall[TEntity] {
- c.Call = c.Call.Do(f)
- return c
-}
-
-// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockEntityStoreEntityIdFromBlockNumCall[TEntity]) DoAndReturn(f func(context.Context, uint64) (uint64, bool, error)) *MockEntityStoreEntityIdFromBlockNumCall[TEntity] {
- c.Call = c.Call.DoAndReturn(f)
- return c
-}
-
-// EntityIdFromBlockNum mocks base method.
-func (m *MockEntityStore[TEntity]) DeleteToBlockNum(ctx context.Context, blockNum uint64, limit int) (int, error) {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "DeleteToBlockNum", ctx, blockNum, limit)
- ret0, _ := ret[0].(int)
- ret1, _ := ret[1].(error)
- return ret0, ret1
-}
-
-// DeleteToBlockNum indicates an expected call of DeleteToBlockNum.
-func (mr *MockEntityStoreMockRecorder[TEntity]) DeleteToBlockNum(ctx any, blockNum any, limit any) *MockEntityStoreDeleteToBlockNumCall[TEntity] {
- mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteToBlockNum", reflect.TypeOf((*MockEntityStore[TEntity])(nil).DeleteToBlockNum), ctx, blockNum, limit)
- return &MockEntityStoreDeleteToBlockNumCall[TEntity]{Call: call}
-}
-
-// MockEntityStoreDeleteToBlockNumCall wrap *gomock.Call
-type MockEntityStoreDeleteToBlockNumCall[TEntity Entity] struct {
- *gomock.Call
-}
-
-// Return rewrite *gomock.Call.Return
-func (c *MockEntityStoreDeleteToBlockNumCall[TEntity]) Return(arg0 int, arg1 error) *MockEntityStoreDeleteToBlockNumCall[TEntity] {
- c.Call = c.Call.Return(arg0, arg1)
- return c
-}
-
-// Do rewrite *gomock.Call.Do
-func (c *MockEntityStoreDeleteToBlockNumCall[TEntity]) Do(f func(context.Context, uint64, int) (int, error)) *MockEntityStoreDeleteToBlockNumCall[TEntity] {
- c.Call = c.Call.Do(f)
- return c
-}
-
-// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockEntityStoreDeleteToBlockNumCall[TEntity]) DoAndReturn(f func(context.Context, uint64, int) (int, error)) *MockEntityStoreDeleteToBlockNumCall[TEntity] {
- c.Call = c.Call.DoAndReturn(f)
- return c
-}
-
-// EntityIdFromBlockNum mocks base method.
-func (m *MockEntityStore[TEntity]) DeleteFromBlockNum(ctx context.Context, blockNum uint64) (int, error) {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "DeleteFromBlockNum", ctx, blockNum)
- ret0, _ := ret[0].(int)
- ret1, _ := ret[1].(error)
- return ret0, ret1
-}
-
-// DeleteFromBlockNum indicates an expected call of DeleteFromBlockNum.
-func (mr *MockEntityStoreMockRecorder[TEntity]) DeleteFromBlockNum(ctx any, blockNum any) *MockEntityStoreDeleteFromBlockNumCall[TEntity] {
- mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteFromBlockNum", reflect.TypeOf((*MockEntityStore[TEntity])(nil).DeleteFromBlockNum), ctx, blockNum)
- return &MockEntityStoreDeleteFromBlockNumCall[TEntity]{Call: call}
-}
-
-// MockEntityStoreDeleteToBlockNumCall wrap *gomock.Call
-type MockEntityStoreDeleteFromBlockNumCall[TEntity Entity] struct {
- *gomock.Call
-}
-
-// Return rewrite *gomock.Call.Return
-func (c *MockEntityStoreDeleteFromBlockNumCall[TEntity]) Return(arg0 int, arg1 error) *MockEntityStoreDeleteFromBlockNumCall[TEntity] {
- c.Call = c.Call.Return(arg0, arg1)
- return c
-}
-
-// Do rewrite *gomock.Call.Do
-func (c *MockEntityStoreDeleteFromBlockNumCall[TEntity]) Do(f func(context.Context, uint64) (int, error)) *MockEntityStoreDeleteFromBlockNumCall[TEntity] {
- c.Call = c.Call.Do(f)
- return c
-}
-
-// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockEntityStoreDeleteFromBlockNumCall[TEntity]) DoAndReturn(f func(context.Context, uint64) (int, error)) *MockEntityStoreDeleteFromBlockNumCall[TEntity] {
- c.Call = c.Call.DoAndReturn(f)
- return c
-}
diff --git a/polygon/heimdall/event_fetch_test.go b/polygon/heimdall/event_fetch_test.go
index 47ea8882f6c..5673c778fd4 100644
--- a/polygon/heimdall/event_fetch_test.go
+++ b/polygon/heimdall/event_fetch_test.go
@@ -16,7 +16,7 @@ func TestOver50EventBlockFetch(t *testing.T) {
return
}
- heimdallClient := NewHeimdallClient("https://heimdall-api.polygon.technology/", log.New())
+ heimdallClient := NewHttpClient("https://heimdall-api.polygon.technology/", log.New())
// block := 48077376
// block time := Sep-28-2023 08:13:58 AM
diff --git a/polygon/heimdall/http_client_mock.go b/polygon/heimdall/http_client_mock.go
deleted file mode 100644
index 3bbdbb314c8..00000000000
--- a/polygon/heimdall/http_client_mock.go
+++ /dev/null
@@ -1,116 +0,0 @@
-// Code generated by MockGen. DO NOT EDIT.
-// Source: github.com/erigontech/erigon/polygon/heimdall (interfaces: HttpClient)
-//
-// Generated by this command:
-//
-// mockgen -typed=true -destination=./http_client_mock.go -package=heimdall . HttpClient
-//
-
-// Package heimdall is a generated GoMock package.
-package heimdall
-
-import (
- http "net/http"
- reflect "reflect"
-
- gomock "go.uber.org/mock/gomock"
-)
-
-// MockHttpClient is a mock of HttpClient interface.
-type MockHttpClient struct {
- ctrl *gomock.Controller
- recorder *MockHttpClientMockRecorder
- isgomock struct{}
-}
-
-// MockHttpClientMockRecorder is the mock recorder for MockHttpClient.
-type MockHttpClientMockRecorder struct {
- mock *MockHttpClient
-}
-
-// NewMockHttpClient creates a new mock instance.
-func NewMockHttpClient(ctrl *gomock.Controller) *MockHttpClient {
- mock := &MockHttpClient{ctrl: ctrl}
- mock.recorder = &MockHttpClientMockRecorder{mock}
- return mock
-}
-
-// EXPECT returns an object that allows the caller to indicate expected use.
-func (m *MockHttpClient) EXPECT() *MockHttpClientMockRecorder {
- return m.recorder
-}
-
-// CloseIdleConnections mocks base method.
-func (m *MockHttpClient) CloseIdleConnections() {
- m.ctrl.T.Helper()
- m.ctrl.Call(m, "CloseIdleConnections")
-}
-
-// CloseIdleConnections indicates an expected call of CloseIdleConnections.
-func (mr *MockHttpClientMockRecorder) CloseIdleConnections() *MockHttpClientCloseIdleConnectionsCall {
- mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseIdleConnections", reflect.TypeOf((*MockHttpClient)(nil).CloseIdleConnections))
- return &MockHttpClientCloseIdleConnectionsCall{Call: call}
-}
-
-// MockHttpClientCloseIdleConnectionsCall wrap *gomock.Call
-type MockHttpClientCloseIdleConnectionsCall struct {
- *gomock.Call
-}
-
-// Return rewrite *gomock.Call.Return
-func (c *MockHttpClientCloseIdleConnectionsCall) Return() *MockHttpClientCloseIdleConnectionsCall {
- c.Call = c.Call.Return()
- return c
-}
-
-// Do rewrite *gomock.Call.Do
-func (c *MockHttpClientCloseIdleConnectionsCall) Do(f func()) *MockHttpClientCloseIdleConnectionsCall {
- c.Call = c.Call.Do(f)
- return c
-}
-
-// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHttpClientCloseIdleConnectionsCall) DoAndReturn(f func()) *MockHttpClientCloseIdleConnectionsCall {
- c.Call = c.Call.DoAndReturn(f)
- return c
-}
-
-// Do mocks base method.
-func (m *MockHttpClient) Do(req *http.Request) (*http.Response, error) {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "Do", req)
- ret0, _ := ret[0].(*http.Response)
- ret1, _ := ret[1].(error)
- return ret0, ret1
-}
-
-// Do indicates an expected call of Do.
-func (mr *MockHttpClientMockRecorder) Do(req any) *MockHttpClientDoCall {
- mr.mock.ctrl.T.Helper()
- call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Do", reflect.TypeOf((*MockHttpClient)(nil).Do), req)
- return &MockHttpClientDoCall{Call: call}
-}
-
-// MockHttpClientDoCall wrap *gomock.Call
-type MockHttpClientDoCall struct {
- *gomock.Call
-}
-
-// Return rewrite *gomock.Call.Return
-func (c *MockHttpClientDoCall) Return(arg0 *http.Response, arg1 error) *MockHttpClientDoCall {
- c.Call = c.Call.Return(arg0, arg1)
- return c
-}
-
-// Do rewrite *gomock.Call.Do
-func (c *MockHttpClientDoCall) Do(f func(*http.Request) (*http.Response, error)) *MockHttpClientDoCall {
- c.Call = c.Call.Do(f)
- return c
-}
-
-// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockHttpClientDoCall) DoAndReturn(f func(*http.Request) (*http.Response, error)) *MockHttpClientDoCall {
- c.Call = c.Call.DoAndReturn(f)
- return c
-}
diff --git a/polygon/heimdall/http_request_handler.go b/polygon/heimdall/http_request_handler.go
new file mode 100644
index 00000000000..b1991f64288
--- /dev/null
+++ b/polygon/heimdall/http_request_handler.go
@@ -0,0 +1,25 @@
+// Copyright 2024 The Erigon Authors
+// This file is part of Erigon.
+//
+// Erigon is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Erigon is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with Erigon. If not, see .
+
+package heimdall
+
+import "net/http"
+
+//go:generate mockgen -typed=true -source=./http_request_handler.go -destination=./http_request_handler_mock.go -package=heimdall httpRequestHandler
+type httpRequestHandler interface {
+ Do(req *http.Request) (*http.Response, error)
+ CloseIdleConnections()
+}
diff --git a/polygon/heimdall/http_request_handler_mock.go b/polygon/heimdall/http_request_handler_mock.go
new file mode 100644
index 00000000000..b3e4e9f5dd9
--- /dev/null
+++ b/polygon/heimdall/http_request_handler_mock.go
@@ -0,0 +1,116 @@
+// Code generated by MockGen. DO NOT EDIT.
+// Source: ./http_request_handler.go
+//
+// Generated by this command:
+//
+// mockgen -typed=true -source=./http_request_handler.go -destination=./http_request_handler_mock.go -package=heimdall httpRequestHandler
+//
+
+// Package heimdall is a generated GoMock package.
+package heimdall
+
+import (
+ http "net/http"
+ reflect "reflect"
+
+ gomock "go.uber.org/mock/gomock"
+)
+
+// MockhttpRequestHandler is a mock of httpRequestHandler interface.
+type MockhttpRequestHandler struct {
+ ctrl *gomock.Controller
+ recorder *MockhttpRequestHandlerMockRecorder
+ isgomock struct{}
+}
+
+// MockhttpRequestHandlerMockRecorder is the mock recorder for MockhttpRequestHandler.
+type MockhttpRequestHandlerMockRecorder struct {
+ mock *MockhttpRequestHandler
+}
+
+// NewMockhttpRequestHandler creates a new mock instance.
+func NewMockhttpRequestHandler(ctrl *gomock.Controller) *MockhttpRequestHandler {
+ mock := &MockhttpRequestHandler{ctrl: ctrl}
+ mock.recorder = &MockhttpRequestHandlerMockRecorder{mock}
+ return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *MockhttpRequestHandler) EXPECT() *MockhttpRequestHandlerMockRecorder {
+ return m.recorder
+}
+
+// CloseIdleConnections mocks base method.
+func (m *MockhttpRequestHandler) CloseIdleConnections() {
+ m.ctrl.T.Helper()
+ m.ctrl.Call(m, "CloseIdleConnections")
+}
+
+// CloseIdleConnections indicates an expected call of CloseIdleConnections.
+func (mr *MockhttpRequestHandlerMockRecorder) CloseIdleConnections() *MockhttpRequestHandlerCloseIdleConnectionsCall {
+ mr.mock.ctrl.T.Helper()
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseIdleConnections", reflect.TypeOf((*MockhttpRequestHandler)(nil).CloseIdleConnections))
+ return &MockhttpRequestHandlerCloseIdleConnectionsCall{Call: call}
+}
+
+// MockhttpRequestHandlerCloseIdleConnectionsCall wrap *gomock.Call
+type MockhttpRequestHandlerCloseIdleConnectionsCall struct {
+ *gomock.Call
+}
+
+// Return rewrite *gomock.Call.Return
+func (c *MockhttpRequestHandlerCloseIdleConnectionsCall) Return() *MockhttpRequestHandlerCloseIdleConnectionsCall {
+ c.Call = c.Call.Return()
+ return c
+}
+
+// Do rewrite *gomock.Call.Do
+func (c *MockhttpRequestHandlerCloseIdleConnectionsCall) Do(f func()) *MockhttpRequestHandlerCloseIdleConnectionsCall {
+ c.Call = c.Call.Do(f)
+ return c
+}
+
+// DoAndReturn rewrite *gomock.Call.DoAndReturn
+func (c *MockhttpRequestHandlerCloseIdleConnectionsCall) DoAndReturn(f func()) *MockhttpRequestHandlerCloseIdleConnectionsCall {
+ c.Call = c.Call.DoAndReturn(f)
+ return c
+}
+
+// Do mocks base method.
+func (m *MockhttpRequestHandler) Do(req *http.Request) (*http.Response, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Do", req)
+ ret0, _ := ret[0].(*http.Response)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// Do indicates an expected call of Do.
+func (mr *MockhttpRequestHandlerMockRecorder) Do(req any) *MockhttpRequestHandlerDoCall {
+ mr.mock.ctrl.T.Helper()
+ call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Do", reflect.TypeOf((*MockhttpRequestHandler)(nil).Do), req)
+ return &MockhttpRequestHandlerDoCall{Call: call}
+}
+
+// MockhttpRequestHandlerDoCall wrap *gomock.Call
+type MockhttpRequestHandlerDoCall struct {
+ *gomock.Call
+}
+
+// Return rewrite *gomock.Call.Return
+func (c *MockhttpRequestHandlerDoCall) Return(arg0 *http.Response, arg1 error) *MockhttpRequestHandlerDoCall {
+ c.Call = c.Call.Return(arg0, arg1)
+ return c
+}
+
+// Do rewrite *gomock.Call.Do
+func (c *MockhttpRequestHandlerDoCall) Do(f func(*http.Request) (*http.Response, error)) *MockhttpRequestHandlerDoCall {
+ c.Call = c.Call.Do(f)
+ return c
+}
+
+// DoAndReturn rewrite *gomock.Call.DoAndReturn
+func (c *MockhttpRequestHandlerDoCall) DoAndReturn(f func(*http.Request) (*http.Response, error)) *MockhttpRequestHandlerDoCall {
+ c.Call = c.Call.DoAndReturn(f)
+ return c
+}
diff --git a/polygon/heimdall/service.go b/polygon/heimdall/service.go
index 2bab50fc8dc..9a0ba47bba6 100644
--- a/polygon/heimdall/service.go
+++ b/polygon/heimdall/service.go
@@ -35,7 +35,7 @@ import (
type ServiceConfig struct {
Store Store
BorConfig *borcfg.BorConfig
- Client HeimdallClient
+ Client Client
Logger log.Logger
}
@@ -100,7 +100,7 @@ func NewService(config ServiceConfig) *Service {
}
}
-func NewCheckpointFetcher(client HeimdallClient, logger log.Logger) *EntityFetcher[*Checkpoint] {
+func NewCheckpointFetcher(client Client, logger log.Logger) *EntityFetcher[*Checkpoint] {
return NewEntityFetcher(
"CheckpointFetcher",
func(ctx context.Context) (int64, error) {
@@ -115,7 +115,7 @@ func NewCheckpointFetcher(client HeimdallClient, logger log.Logger) *EntityFetch
)
}
-func NewMilestoneFetcher(client HeimdallClient, logger log.Logger) *EntityFetcher[*Milestone] {
+func NewMilestoneFetcher(client Client, logger log.Logger) *EntityFetcher[*Milestone] {
return NewEntityFetcher(
"MilestoneFetcher",
client.FetchFirstMilestoneNum,
@@ -128,7 +128,7 @@ func NewMilestoneFetcher(client HeimdallClient, logger log.Logger) *EntityFetche
)
}
-func NewSpanFetcher(client HeimdallClient, logger log.Logger) *EntityFetcher[*Span] {
+func NewSpanFetcher(client Client, logger log.Logger) *EntityFetcher[*Span] {
fetchLastEntityId := func(ctx context.Context) (int64, error) {
span, err := client.FetchLatestSpan(ctx)
if err != nil {
diff --git a/polygon/heimdall/service_test.go b/polygon/heimdall/service_test.go
index 4a51a73cad3..dce598fd10f 100644
--- a/polygon/heimdall/service_test.go
+++ b/polygon/heimdall/service_test.go
@@ -136,7 +136,7 @@ type ServiceTestSuite struct {
ctx context.Context
cancel context.CancelFunc
eg errgroup.Group
- client *MockHeimdallClient
+ client *MockClient
service *Service
observedMilestones []*Milestone
observedSpans []*Span
@@ -159,7 +159,7 @@ func (suite *ServiceTestSuite) SetupSuite() {
suite.checkpointsTestDataDir = filepath.Join(suite.testDataDir, "checkpoints")
suite.milestonesTestDataDir = filepath.Join(suite.testDataDir, "milestones")
suite.proposerSequencesTestDataDir = filepath.Join(suite.testDataDir, "getSnapshotProposerSequence")
- suite.client = NewMockHeimdallClient(ctrl)
+ suite.client = NewMockClient(ctrl)
suite.setupSpans()
suite.setupCheckpoints()
suite.setupMilestones()
diff --git a/polygon/heimdall/snapshots.go b/polygon/heimdall/snapshots.go
index 27970144bac..01e3e86d9cb 100644
--- a/polygon/heimdall/snapshots.go
+++ b/polygon/heimdall/snapshots.go
@@ -257,7 +257,7 @@ func ValidateBorEvents(ctx context.Context, config *borcfg.BorConfig, db kv.RoDB
}
func RemoteEventCheckForBlock(header *types.Header, previousHeader *types.Header, chainId string, startEventId uint64, events []rlp.RawValue,
- heimdallClient HeimdallClient, config *borcfg.BorConfig, logger log.Logger) error {
+ heimdallClient Client, config *borcfg.BorConfig, logger log.Logger) error {
blockNum := header.Number.Uint64()
diff --git a/polygon/sync/p2p_service_mock.go b/polygon/sync/p2p_service_mock.go
index c146a16ed24..b9560633e8c 100644
--- a/polygon/sync/p2p_service_mock.go
+++ b/polygon/sync/p2p_service_mock.go
@@ -24,6 +24,7 @@ import (
type Mockp2pService struct {
ctrl *gomock.Controller
recorder *Mockp2pServiceMockRecorder
+ isgomock struct{}
}
// Mockp2pServiceMockRecorder is the mock recorder for Mockp2pService.
diff --git a/turbo/jsonrpc/bor_api_test.go b/turbo/jsonrpc/bor_api_test.go
index 6cf6ae38275..6e6ae2d49bd 100644
--- a/turbo/jsonrpc/bor_api_test.go
+++ b/turbo/jsonrpc/bor_api_test.go
@@ -1,3 +1,19 @@
+// Copyright 2024 The Erigon Authors
+// This file is part of Erigon.
+//
+// Erigon is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Erigon is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with Erigon. If not, see .
+
package jsonrpc
import (
diff --git a/turbo/stages/stageloop.go b/turbo/stages/stageloop.go
index fa00de372af..be7df5cd917 100644
--- a/turbo/stages/stageloop.go
+++ b/turbo/stages/stageloop.go
@@ -678,7 +678,7 @@ func NewDefaultStages(ctx context.Context,
agg *state.Aggregator,
silkworm *silkworm.Silkworm,
forkValidator *engine_helpers.ForkValidator,
- heimdallClient heimdall.HeimdallClient,
+ heimdallClient heimdall.Client,
heimdallStore heimdall.Store,
bridgeStore bridge.Store,
recents *lru.ARCCache[libcommon.Hash, *bor.Snapshot],
@@ -780,7 +780,7 @@ func NewPolygonSyncStages(
agg *state.Aggregator,
silkworm *silkworm.Silkworm,
forkValidator *engine_helpers.ForkValidator,
- heimdallClient heimdall.HeimdallClient,
+ heimdallClient heimdall.Client,
heimdallStore heimdall.Store,
bridgeStore bridge.Store,
sentry sentryproto.SentryClient,