Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make the fetching of extra claim data optional for bridge sync #111

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions bridgesync/bridgesync.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func NewL1(
waitForNewBlocksPeriod time.Duration,
retryAfterErrorPeriod time.Duration,
maxRetryAttemptsAfterError int,
syncFullClaims bool,
) (*BridgeSync, error) {
return newBridgeSync(
ctx,
Expand All @@ -49,7 +50,7 @@ func NewL1(
waitForNewBlocksPeriod,
retryAfterErrorPeriod,
maxRetryAttemptsAfterError,
false,
syncFullClaims,
)
}

Expand All @@ -66,6 +67,7 @@ func NewL2(
waitForNewBlocksPeriod time.Duration,
retryAfterErrorPeriod time.Duration,
maxRetryAttemptsAfterError int,
syncFullClaims bool,
) (*BridgeSync, error) {
return newBridgeSync(
ctx,
Expand All @@ -80,7 +82,7 @@ func NewL2(
waitForNewBlocksPeriod,
retryAfterErrorPeriod,
maxRetryAttemptsAfterError,
true,
syncFullClaims,
)
}

Expand Down
2 changes: 2 additions & 0 deletions bridgesync/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ type Config struct {
MaxRetryAttemptsAfterError int `mapstructure:"MaxRetryAttemptsAfterError"`
// WaitForNewBlocksPeriod time that will be waited when the synchronizer has reached the latest block
WaitForNewBlocksPeriod types.Duration `mapstructure:"WaitForNewBlocksPeriod"`
// SyncFullClaims enables the full sync of the claims, needed to generate certificates (aggSender)
SyncFullClaims bool `mapstructure:"SyncFullClaims"`
}
2 changes: 1 addition & 1 deletion bridgesync/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestBridgeEventE2E(t *testing.T) {
go rd.Start(ctx) //nolint:errcheck

testClient := helpers.TestClient{ClientRenamed: client.Client()}
syncer, err := bridgesync.NewL1(ctx, dbPathSyncer, bridgeAddr, 10, etherman.LatestBlock, rd, testClient, 0, time.Millisecond*10, 0, 0)
syncer, err := bridgesync.NewL1(ctx, dbPathSyncer, bridgeAddr, 10, etherman.LatestBlock, rd, testClient, 0, time.Millisecond*10, 0, 0, false)
require.NoError(t, err)

go syncer.Start(ctx)
Expand Down
2 changes: 1 addition & 1 deletion claimsponsor/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestE2EL1toEVML2(t *testing.T) {
env := helpers.SetupAggoracleWithEVMChain(t)
dbPathBridgeSyncL1 := path.Join(t.TempDir(), "file::memory:?cache=shared")
testClient := helpers.TestClient{ClientRenamed: env.L1Client.Client()}
bridgeSyncL1, err := bridgesync.NewL1(ctx, dbPathBridgeSyncL1, env.BridgeL1Addr, 10, etherman.LatestBlock, env.ReorgDetector, testClient, 0, time.Millisecond*10, 0, 0)
bridgeSyncL1, err := bridgesync.NewL1(ctx, dbPathBridgeSyncL1, env.BridgeL1Addr, 10, etherman.LatestBlock, env.ReorgDetector, testClient, 0, time.Millisecond*10, 0, 0, false)
require.NoError(t, err)
go bridgeSyncL1.Start(ctx)

Expand Down
2 changes: 2 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ func runBridgeSyncL1IfNeeded(
cfg.WaitForNewBlocksPeriod.Duration,
cfg.RetryAfterErrorPeriod.Duration,
cfg.MaxRetryAttemptsAfterError,
cfg.SyncFullClaims,
)
if err != nil {
log.Fatalf("error creating bridgeSyncL1: %s", err)
Expand Down Expand Up @@ -710,6 +711,7 @@ func runBridgeSyncL2IfNeeded(
cfg.WaitForNewBlocksPeriod.Duration,
cfg.RetryAfterErrorPeriod.Duration,
cfg.MaxRetryAttemptsAfterError,
cfg.SyncFullClaims,
)
if err != nil {
log.Fatalf("error creating bridgeSyncL2: %s", err)
Expand Down
3 changes: 2 additions & 1 deletion config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ SyncBlockChunkSize = 100
RetryAfterErrorPeriod = "1s"
MaxRetryAttemptsAfterError = -1
WaitForNewBlocksPeriod = "3s"

SyncFullClaims = false
[BridgeL2Sync]
DBPath = "/tmp/bridgel2sync"
BlockFinality = "LatestBlock"
Expand All @@ -252,6 +252,7 @@ SyncBlockChunkSize = 100
RetryAfterErrorPeriod = "1s"
MaxRetryAttemptsAfterError = -1
WaitForNewBlocksPeriod = "3s"
SyncFullClaims = false

[LastGERSync]
DBPath = "/tmp/lastgersync"
Expand Down
Loading