diff --git a/.gitignore b/.gitignore index 863f937c..f1c45125 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ .env /dist/ cmd/__debug_bin -**__debug** \ No newline at end of file +**__debug** +tmp \ No newline at end of file diff --git a/bridgesync/bridgesync.go b/bridgesync/bridgesync.go index 31d82511..b51b2387 100644 --- a/bridgesync/bridgesync.go +++ b/bridgesync/bridgesync.go @@ -22,7 +22,7 @@ type Config struct { // BlockFinality indicates the status of the blocks that will be queried in order to sync BlockFinality string `jsonschema:"enum=LatestBlock, enum=SafeBlock, enum=PendingBlock, enum=FinalizedBlock, enum=EarliestBlock" mapstructure:"BlockFinality"` // InitialBlockNum is the first block that will be queried when starting the synchronization from scratch. - // It should be a number equal oir bellow the creation of the bridge contract + // It should be a number equal or bellow the creation of the bridge contract InitialBlockNum uint64 `mapstructure:"InitialBlockNum"` // BridgeAddr is the address of the bridge smart contract BridgeAddr common.Address `mapstructure:"BridgeAddr"` diff --git a/bridgesync/e2e_test.go b/bridgesync/e2e_test.go index f55d8c7e..1f5a080c 100644 --- a/bridgesync/e2e_test.go +++ b/bridgesync/e2e_test.go @@ -86,11 +86,11 @@ func TestBridgeEventE2E(t *testing.T) { // Wait for syncer to catch up syncerUpToDate := false var errMsg string + lb, err := client.Client().BlockNumber(ctx) + require.NoError(t, err) for i := 0; i < 10; i++ { lpb, err := syncer.GetLastProcessedBlock(ctx) require.NoError(t, err) - lb, err := client.Client().BlockNumber(ctx) - require.NoError(t, err) if lpb == lb { syncerUpToDate = true break @@ -101,9 +101,9 @@ func TestBridgeEventE2E(t *testing.T) { require.True(t, syncerUpToDate, errMsg) // Get bridges - lastBlcok, err := client.Client().BlockNumber(ctx) + lastBlock, err := client.Client().BlockNumber(ctx) require.NoError(t, err) - events, err := syncer.GetClaimsAndBridges(ctx, 0, lastBlcok) + events, err := syncer.GetClaimsAndBridges(ctx, 0, lastBlock) require.NoError(t, err) actualBridges := []bridgesync.Bridge{} for _, event := range events { diff --git a/bridgesync/processor_test.go b/bridgesync/processor_test.go index 7d337d08..90fe74be 100644 --- a/bridgesync/processor_test.go +++ b/bridgesync/processor_test.go @@ -440,7 +440,7 @@ func TestHashBridge(t *testing.T) { require.True(t, err) bridge := Bridge{ - OriginNetwork: testVector.OriginalNetwork, + OriginNetwork: testVector.OriginNetwork, OriginAddress: common.HexToAddress(testVector.TokenAddress), Amount: amount, DestinationNetwork: testVector.DestinationNetwork, diff --git a/l1bridge2infoindexsync/downloader.go b/l1bridge2infoindexsync/downloader.go index 6fe80059..f14fcf8e 100644 --- a/l1bridge2infoindexsync/downloader.go +++ b/l1bridge2infoindexsync/downloader.go @@ -29,7 +29,7 @@ func newDownloader( } } -func (d *downloader) getLastFinalisedL1Block(ctx context.Context) (uint64, error) { +func (d *downloader) getLastFinalizedL1Block(ctx context.Context) (uint64, error) { b, err := d.l1Client.BlockByNumber(ctx, big.NewInt(int64(rpc.FinalizedBlockNumber))) if err != nil { return 0, err diff --git a/l1bridge2infoindexsync/driver.go b/l1bridge2infoindexsync/driver.go index a900b5f8..e0e9b5cc 100644 --- a/l1bridge2infoindexsync/driver.go +++ b/l1bridge2infoindexsync/driver.go @@ -136,7 +136,7 @@ func (d *driver) sync(ctx context.Context) { } func (d *driver) getTargetSynchronizationBlock(ctx context.Context, lpbProcessor uint64) (syncUntilBlock uint64, shouldWait bool, err error) { - lastFinalised, err := d.downloader.getLastFinalisedL1Block(ctx) // TODO: configure finality, but then we need to deal with reorgs? + lastFinalised, err := d.downloader.getLastFinalizedL1Block(ctx) // TODO: configure finality, but then we need to deal with reorgs? if err != nil { return } diff --git a/l1bridge2infoindexsync/l1bridge2infoindexsync.go b/l1bridge2infoindexsync/l1bridge2infoindexsync.go index fd2312cd..8510d44a 100644 --- a/l1bridge2infoindexsync/l1bridge2infoindexsync.go +++ b/l1bridge2infoindexsync/l1bridge2infoindexsync.go @@ -66,5 +66,5 @@ func (s *L1Bridge2InfoIndexSync) GetLastProcessedBlock(ctx context.Context) (uin } func (s *L1Bridge2InfoIndexSync) GetL1InfoTreeIndexByDepositCount(ctx context.Context, depositCount uint32) (uint32, error) { - return s.processor.getL1InfoTreeIndexByBrdigeIndex(ctx, depositCount) + return s.processor.getL1InfoTreeIndexByBridgeIndex(ctx, depositCount) } diff --git a/l1bridge2infoindexsync/processor.go b/l1bridge2infoindexsync/processor.go index 91861da3..0d3ba897 100644 --- a/l1bridge2infoindexsync/processor.go +++ b/l1bridge2infoindexsync/processor.go @@ -123,7 +123,7 @@ func (p *processor) processUntilBlock(ctx context.Context, lastProcessedBlock ui } for _, relation := range relations { - if _, err := p.getL1InfoTreeIndexByBrdigeIndexWithTx(tx, relation.bridgeIndex); err != ErrNotFound { + if _, err := p.getL1InfoTreeIndexByBridgeIndexWithTx(tx, relation.bridgeIndex); err != ErrNotFound { // Note that indexes could be repeated as the L1 Info tree update can be produced by a rollup and not mainnet. // Hence if the index already exist, do not update as it's better to have the lowest index possible for the relation continue @@ -166,17 +166,17 @@ func (p *processor) processUntilBlock(ctx context.Context, lastProcessedBlock ui return tx.Commit() } -func (p *processor) getL1InfoTreeIndexByBrdigeIndex(ctx context.Context, depositCount uint32) (uint32, error) { +func (p *processor) getL1InfoTreeIndexByBridgeIndex(ctx context.Context, depositCount uint32) (uint32, error) { tx, err := p.db.BeginRo(ctx) if err != nil { return 0, err } defer tx.Rollback() - return p.getL1InfoTreeIndexByBrdigeIndexWithTx(tx, depositCount) + return p.getL1InfoTreeIndexByBridgeIndexWithTx(tx, depositCount) } -func (p *processor) getL1InfoTreeIndexByBrdigeIndexWithTx(tx kv.Tx, depositCount uint32) (uint32, error) { +func (p *processor) getL1InfoTreeIndexByBridgeIndexWithTx(tx kv.Tx, depositCount uint32) (uint32, error) { indexBytes, err := tx.GetOne(relationTable, common.Uint32ToBytes(depositCount)) if err != nil { return 0, err diff --git a/l1bridge2infoindexsync/processor_test.go b/l1bridge2infoindexsync/processor_test.go index 2389e9c6..9305dd9b 100644 --- a/l1bridge2infoindexsync/processor_test.go +++ b/l1bridge2infoindexsync/processor_test.go @@ -16,7 +16,7 @@ func TestDuplicatedKey(t *testing.T) { require.NoError(t, err) err = p.processUntilBlock(ctx, 7, []bridge2L1InfoRelation{{bridgeIndex: 2, l1InfoTreeIndex: 3}}) require.NoError(t, err) - l1InfoTreeIndex, err := p.getL1InfoTreeIndexByBrdigeIndex(ctx, 2) + l1InfoTreeIndex, err := p.getL1InfoTreeIndexByBridgeIndex(ctx, 2) require.NoError(t, err) require.Equal(t, uint32(2), l1InfoTreeIndex) } diff --git a/l1infotreesync/processor.go b/l1infotreesync/processor.go index a7b8c6f1..d0e2dacd 100644 --- a/l1infotreesync/processor.go +++ b/l1infotreesync/processor.go @@ -156,18 +156,18 @@ func newProcessor(ctx context.Context, dbPath string) (*processor, error) { func (p *processor) GetL1InfoTreeMerkleProof(ctx context.Context, index uint32) ([32]ethCommon.Hash, ethCommon.Hash, error) { tx, err := p.db.BeginRo(ctx) if err != nil { - return [32]ethCommon.Hash{}, ethCommon.Hash{}, err + return tree.EmptyProof, ethCommon.Hash{}, err } defer tx.Rollback() root, err := p.l1InfoTree.GetRootByIndex(tx, index) if err != nil { - return [32]ethCommon.Hash{}, ethCommon.Hash{}, err + return tree.EmptyProof, ethCommon.Hash{}, err } proof, err := p.l1InfoTree.GetProof(ctx, index, root) if err != nil { - return [32]ethCommon.Hash{}, ethCommon.Hash{}, err + return tree.EmptyProof, ethCommon.Hash{}, err } // TODO: check if we need to return root or wat diff --git a/lastgersync/lastgersync.go b/lastgersync/lastgersync.go index aab54ff1..038c94f8 100644 --- a/lastgersync/lastgersync.go +++ b/lastgersync/lastgersync.go @@ -23,7 +23,7 @@ type Config struct { // BlockFinality indicates the status of the blocks that will be queried in order to sync BlockFinality string `jsonschema:"enum=LatestBlock, enum=SafeBlock, enum=PendingBlock, enum=FinalizedBlock, enum=EarliestBlock" mapstructure:"BlockFinality"` // InitialBlockNum is the first block that will be queried when starting the synchronization from scratch. - // It should be a number equal oir bellow the creation of the bridge contract + // It should be a number equal or bellow the creation of the bridge contract InitialBlockNum uint64 `mapstructure:"InitialBlockNum"` // GlobalExitRootL2Addr is the address of the GER smart contract on L2 GlobalExitRootL2Addr common.Address `mapstructure:"GlobalExitRootL2Addr"` diff --git a/tree/testvectors/types.go b/tree/testvectors/types.go index 2d37804d..905718d8 100644 --- a/tree/testvectors/types.go +++ b/tree/testvectors/types.go @@ -10,7 +10,7 @@ import ( // DepositVectorRaw represents the deposit vector type DepositVectorRaw struct { - OriginalNetwork uint32 `json:"originNetwork"` + OriginNetwork uint32 `json:"originNetwork"` TokenAddress string `json:"tokenAddress"` Amount string `json:"amount"` DestinationNetwork uint32 `json:"destinationNetwork"` @@ -22,7 +22,7 @@ type DepositVectorRaw struct { func (d *DepositVectorRaw) Hash() common.Hash { origNet := make([]byte, 4) //nolint:gomnd - binary.BigEndian.PutUint32(origNet, d.OriginalNetwork) + binary.BigEndian.PutUint32(origNet, d.OriginNetwork) destNet := make([]byte, 4) //nolint:gomnd binary.BigEndian.PutUint32(destNet, d.DestinationNetwork)