Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaubennassar committed Nov 15, 2024
1 parent dac8cfc commit 294dfc1
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 3,822 deletions.
11 changes: 6 additions & 5 deletions bridgesync/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import (

func TestBridgeEventE2E(t *testing.T) {
const (
totalBridges = 1000
totalReorgs = 700
maxReorgDepth = 5
reorgEveryXIterations = 7 // every X blocks go back [1,maxReorgDepth] blocks
blockTime = time.Millisecond * 10
totalBridges = 80
totalReorgs = 40
maxReorgDepth = 2
reorgEveryXIterations = 4 // every X blocks go back [1,maxReorgDepth] blocks
)
env := helpers.NewE2EEnvWithEVML2(t)
ctx := context.Background()
Expand Down Expand Up @@ -48,7 +49,7 @@ func TestBridgeEventE2E(t *testing.T) {
true, nil,
)
require.NoError(t, err)
helpers.CommitBlocks(t, env.L1Client, 1, time.Millisecond)
helpers.CommitBlocks(t, env.L1Client, 1, blockTime)
bn, err := env.L1Client.Client().BlockNumber(ctx)
require.NoError(t, err)
bridge.BlockNum = bn
Expand Down
4 changes: 0 additions & 4 deletions bridgesync/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ func (p *processor) Reorg(ctx context.Context, firstReorgedBlock uint64) error {
if err != nil {
return err
}
log.Debug("<xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx BRIDGE SYNC xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
defer func() {
if err != nil {
if errRllbck := tx.Rollback(); errRllbck != nil {
Expand Down Expand Up @@ -269,7 +268,6 @@ func (p *processor) Reorg(ctx context.Context, firstReorgedBlock uint64) error {
p.haltedReason = ""
}

log.Debug("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx BRIDGE SYNC xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>")
return nil
}

Expand All @@ -284,7 +282,6 @@ func (p *processor) ProcessBlock(ctx context.Context, block sync.Block) error {
if err != nil {
return err
}
p.log.Debug("<======================= BRIDGE SYNC =================================")
shouldRollback := true
defer func() {
if shouldRollback {
Expand Down Expand Up @@ -332,7 +329,6 @@ func (p *processor) ProcessBlock(ctx context.Context, block sync.Block) error {
shouldRollback = false

p.log.Debugf("processed %d events until block %d", len(block.Events), block.Num)
p.log.Debug("======================= BRIDGE SYNC =================================>")
return nil
}

Expand Down
11 changes: 0 additions & 11 deletions db/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ var (
// NewSQLiteDB creates a new SQLite DB
func NewSQLiteDB(dbPath string) (*sql.DB, error) {
return sql.Open("sqlite3", fmt.Sprintf("file:%s?_txlock=exclusive&_foreign_keys=on", dbPath))
// db,err := sql.Open("sqlite3", fmt.Sprintf("file:%s?_foreign_keys=on", dbPath))
// if err != nil {
// return nil, err
// }
// _, err = db.Exec(`
// PRAGMA foreign_keys = ON;
// pragma journal_mode = WAL;
// pragma synchronous = normal;
// pragma journal_size_limit = 6144000;
// `)
// return db, err
}

func ReturnErrNotFound(err error) error {
Expand Down
54 changes: 0 additions & 54 deletions l1infotreesync/cascade_test.go

This file was deleted.

52 changes: 1 addition & 51 deletions l1infotreesync/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ func (p *processor) Reorg(ctx context.Context, firstReorgedBlock uint64) error {
if err != nil {
return err
}
log.Debug("<xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx L1INFO xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
log.Debugf("init reorg, first reorged block: %d", firstReorgedBlock)
shouldRollback := true
defer func() {
if shouldRollback {
Expand All @@ -251,36 +249,10 @@ func (p *processor) Reorg(ctx context.Context, firstReorgedBlock uint64) error {
}
}()

info := &L1InfoTreeLeaf{}
err = meddler.QueryRow(tx, info, `
SELECT * FROM l1info_leaf
ORDER BY block_num DESC, block_pos DESC
LIMIT 1;
`)
log.Debugf("info before delete: %d", info.BlockNumber)
log.Debug("xxxxxxxxxxxx going to delete")
res, err := tx.Exec(`DELETE FROM block WHERE num >= $1;`, firstReorgedBlock)
if err != nil {
return err
}
info = &L1InfoTreeLeaf{}
err = meddler.QueryRow(tx, info, `
SELECT * FROM l1info_leaf
ORDER BY block_num DESC, block_pos DESC
LIMIT 1;
`)
if err != nil {
panic("nope " + err.Error())
}
if info.BlockNumber >= firstReorgedBlock {
log.Fatalf("on the tx: info block num before reorg: %d")
}
log.Debug("done deleting xxxxxxxxxxxx")

// _, err = tx.Exec(`DELETE FROM l1info_leaf WHERE block_num >= $1;`, firstReorgedBlock)
// if err != nil {
// return err
// }

if err = p.l1InfoTree.Reorg(tx, firstReorgedBlock); err != nil {
return err
Expand All @@ -294,19 +266,6 @@ func (p *processor) Reorg(ctx context.Context, firstReorgedBlock uint64) error {
return err
}

info = &L1InfoTreeLeaf{}
err = meddler.QueryRow(tx, info, `
SELECT * FROM l1info_leaf
ORDER BY block_num DESC, block_pos DESC
LIMIT 1;
`)
if err != nil {
panic("nope " + err.Error())
}
log.Debugf("last info: %+v", info)
if info.BlockNumber >= firstReorgedBlock {
log.Fatal("on the tx 2 !!!!! unsuccessful reorg, l1 info table has invalid info")
}
if err := tx.Commit(); err != nil {
return err
}
Expand All @@ -316,14 +275,7 @@ func (p *processor) Reorg(ctx context.Context, firstReorgedBlock uint64) error {
p.halted = false
p.haltedReason = ""
}
shouldRollback = false
log.Debugf("reorged until block %d (included)", firstReorgedBlock)
info, _ = p.GetLastInfo()
log.Debugf("last info: %+v", info)
if info.BlockNumber >= firstReorgedBlock {
log.Fatal("unsuccessful reorg, l1 info table has invalid info")
}
log.Debug("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx L1INFO xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>")

return nil
}

Expand All @@ -338,7 +290,6 @@ func (p *processor) ProcessBlock(ctx context.Context, block sync.Block) error {
if err != nil {
return err
}
log.Debug("<======================= L1 INFO =================================")
log.Debugf("init block processing for block %d", block.Num)
shouldRollback := true
defer func() {
Expand Down Expand Up @@ -450,7 +401,6 @@ func (p *processor) ProcessBlock(ctx context.Context, block sync.Block) error {
}
shouldRollback = false
log.Infof("block %d processed with %d events", block.Num, len(block.Events))
log.Debug("======================= L1 INFO =================================>")
return nil
}

Expand Down
2 changes: 0 additions & 2 deletions lastgersync/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ func (p *processor) ProcessBlock(ctx context.Context, block sync.Block) error {
}

func (p *processor) Reorg(ctx context.Context, firstReorgedBlock uint64) error {
log.Debug("<xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx LASTGER SYNC xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
_, err := p.db.Exec(`DELETE FROM block WHERE num >= $1;`, firstReorgedBlock)
log.Debug("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx LASTGER SYNC xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>")
return err
}

Expand Down
Loading

0 comments on commit 294dfc1

Please sign in to comment.