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

Feature/exittree #27

Merged
merged 45 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
30880cd
implementation completed, missing tests
arnaubennassar Jul 23, 2024
73128ae
WIP
arnaubennassar Jul 24, 2024
c7d159a
WIP
arnaubennassar Jul 24, 2024
5cc0c6f
WIP
arnaubennassar Jul 25, 2024
fd0eb73
sync refactor
arnaubennassar Jul 25, 2024
4bd7ef1
decouple sync processors from EVM
arnaubennassar Jul 25, 2024
80157a4
Add CLI for aggOracle
arnaubennassar Jul 26, 2024
08bb5f2
WIP
arnaubennassar Jul 26, 2024
11ec3af
wip
arnaubennassar Jul 26, 2024
f6bf0ad
WIP
arnaubennassar Jul 26, 2024
26ce165
start reorg detector
arnaubennassar Jul 26, 2024
4354830
fix docker
arnaubennassar Jul 26, 2024
f66c337
pass test with docker
arnaubennassar Jul 26, 2024
698f2bd
add TODO
arnaubennassar Jul 26, 2024
d88238b
go mod tidy
Stefan-Ethernal Jul 29, 2024
fc3df5e
Implement base addLeaf
arnaubennassar Jul 29, 2024
abf8be8
pass test vectors
arnaubennassar Jul 30, 2024
bfdc806
fix UT
arnaubennassar Jul 30, 2024
69d9139
Add PR review suggestions from Stefan-Ethernal
arnaubennassar Jul 30, 2024
b90342f
Fix conflicts
arnaubennassar Jul 30, 2024
b1a399b
fix UTs
arnaubennassar Jul 30, 2024
78a5cc8
Add PR review suggestions from Stefan-Ethernal
arnaubennassar Jul 30, 2024
024a57f
fix datacommittee_test deploying proxy contract
joanestebanr Jul 29, 2024
9ffbd57
fix UTs
arnaubennassar Jul 30, 2024
d5f517f
WIP
arnaubennassar Jul 31, 2024
c90f2d0
WIP
arnaubennassar Jul 31, 2024
4869094
abstract tree
arnaubennassar Jul 31, 2024
e971132
Merge pull request #29 from 0xPolygon/feature/rollupExitTree
arnaubennassar Jul 31, 2024
cc03adc
FIx conflict
arnaubennassar Jul 31, 2024
99180de
Fix UTs
arnaubennassar Jul 31, 2024
5f2c29f
Add PR review suggestions from joanestebanr
arnaubennassar Aug 1, 2024
db681b2
bring changes
arnaubennassar Aug 1, 2024
5d0c94f
Fix evmdownloader problems
arnaubennassar Aug 1, 2024
7665527
refactor tree add and rollback to be atomic
arnaubennassar Aug 1, 2024
1453bce
simplify l1infotree
arnaubennassar Aug 1, 2024
5f0d15a
implementation done, test WIP
arnaubennassar Aug 1, 2024
acd372e
pass E2E test
arnaubennassar Aug 2, 2024
ed3f001
Merge develop
arnaubennassar Aug 2, 2024
64cd1d4
remove outdated coment
arnaubennassar Aug 2, 2024
f2f2fda
make test shorter
arnaubennassar Aug 2, 2024
da78344
Add coments
arnaubennassar Aug 2, 2024
c9c63b7
Apply requests from Stefan-Ethernal and goran-ethernal
arnaubennassar Aug 8, 2024
cc7e5b9
Merge branch 'develop' into feature/exittree
arnaubennassar Aug 8, 2024
0270454
increase sleep to pass UT
arnaubennassar Aug 9, 2024
5929562
reduce test iterations
arnaubennassar Aug 13, 2024
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
2 changes: 1 addition & 1 deletion aggoracle/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func commonSetup(t *testing.T) (
require.NoError(t, err)
// Syncer
dbPathSyncer := t.TempDir()
syncer, err := l1infotreesync.New(ctx, dbPathSyncer, gerL1Addr, 10, etherman.LatestBlock, reorg, l1Client.Client(), time.Millisecond, 0, 100*time.Millisecond, 3)
syncer, err := l1infotreesync.New(ctx, dbPathSyncer, gerL1Addr, common.Address{}, 10, etherman.LatestBlock, reorg, l1Client.Client(), time.Millisecond, 0, 100*time.Millisecond, 3)
require.NoError(t, err)
go syncer.Start(ctx)

Expand Down
27 changes: 6 additions & 21 deletions aggoracle/mock_ethtxmanager_test.go

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

69 changes: 60 additions & 9 deletions localbridgesync/localbridgesync.go → bridgesync/bridgesync.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package localbridgesync
package bridgesync

import (
"context"
Expand All @@ -10,7 +10,8 @@ import (
)

const (
reorgDetectorID = "localbridgesync"
bridgeSyncL1 = "bridgesyncl1"
bridgeSyncL2 = "bridgesyncl2"
downloadBufferSize = 1000
)

Expand All @@ -24,17 +25,66 @@ type LocalBridgeSync struct {
driver *sync.EVMDriver
}

func New(
// NewL1 creates a bridge syncer that synchronizes the mainnet exit tree
func NewL1(
ctx context.Context,
dbPath string,
bridge common.Address,
syncBlockChunkSize uint64,
blockFinalityType etherman.BlockNumberFinality,
rd sync.ReorgDetector,
l2Client EthClienter,
ethClient EthClienter,
initialBlock uint64,
) (*LocalBridgeSync, error) {
processor, err := newProcessor(dbPath)
return new(
ctx,
dbPath,
bridge,
syncBlockChunkSize,
blockFinalityType,
rd,
ethClient,
initialBlock,
bridgeSyncL1,
)
}

// NewL2 creates a bridge syncer that synchronizes the local exit tree
func NewL2(
ctx context.Context,
dbPath string,
bridge common.Address,
syncBlockChunkSize uint64,
blockFinalityType etherman.BlockNumberFinality,
rd sync.ReorgDetector,
ethClient EthClienter,
initialBlock uint64,
) (*LocalBridgeSync, error) {
return new(
ctx,
dbPath,
bridge,
syncBlockChunkSize,
blockFinalityType,
rd,
ethClient,
initialBlock,
bridgeSyncL2,
)
}

func new(
ctx context.Context,
dbPath string,
bridge common.Address,
syncBlockChunkSize uint64,
blockFinalityType etherman.BlockNumberFinality,
rd sync.ReorgDetector,
ethClient EthClienter,
initialBlock uint64,
l1OrL2ID string,
) (*LocalBridgeSync, error) {
processor, err := newProcessor(ctx, dbPath, l1OrL2ID)
if err != nil {
return nil, err
}
Expand All @@ -43,7 +93,7 @@ func New(
return nil, err
}
if lastProcessedBlock < initialBlock {
err = processor.ProcessBlock(sync.Block{
err = processor.ProcessBlock(ctx, sync.Block{
Num: initialBlock,
})
if err != nil {
Expand All @@ -55,12 +105,12 @@ func New(
RetryAfterErrorPeriod: retryAfterErrorPeriod,
}

appender, err := buildAppender(l2Client, bridge)
appender, err := buildAppender(ethClient, bridge)
if err != nil {
return nil, err
}
downloader, err := sync.NewEVMDownloader(
l2Client,
ethClient,
syncBlockChunkSize,
blockFinalityType,
waitForNewBlocksPeriod,
Expand All @@ -72,7 +122,7 @@ func New(
return nil, err
}

driver, err := sync.NewEVMDriver(rd, processor, downloader, reorgDetectorID, downloadBufferSize, rh)
driver, err := sync.NewEVMDriver(rd, processor, downloader, l1OrL2ID, downloadBufferSize, rh)
if err != nil {
return nil, err
}
Expand All @@ -82,6 +132,7 @@ func New(
}, nil
}

// Start starts the synchronization process
func (s *LocalBridgeSync) Start(ctx context.Context) {
s.driver.Sync(ctx)
}
2 changes: 1 addition & 1 deletion localbridgesync/downloader.go → bridgesync/downloader.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package localbridgesync
package bridgesync

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion localbridgesync/e2e_test.go → bridgesync/e2e_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package localbridgesync
package bridgesync

// TODO: add E2E test, prolly need a mock contract
Loading
Loading