-
Notifications
You must be signed in to change notification settings - Fork 5
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
Ler2block #61
Ler2block #61
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just review /tree, but I think that the comments can be extended to rest
require.Equal(t, a.expectedErr, actualErr) | ||
} | ||
|
||
// GetBridges |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the comment.
@@ -0,0 +1,35 @@ | |||
package migrations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file and ./l1infotreesync/migrations/migrations.go
looks pretty much the same.. is not possible to move this to db package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's syncer has it's own migrations, it would be odd IMO to have a "centralized" package that imports the migrations files of each syncer, and has functions to run those specific for each syncer
tree/appendonlytree.go
Outdated
@@ -26,7 +27,7 @@ func NewAppendOnlyTree(db *sql.DB, dbPrefix string) *AppendOnlyTree { | |||
} | |||
} | |||
|
|||
func (t *AppendOnlyTree) AddLeaf(tx *sql.Tx, blockNum, blockPosition uint64, leaf types.Leaf) error { | |||
func (t *AppendOnlyTree) AddLeaf(tx *db.Tx, blockNum, blockPosition uint64, leaf types.Leaf) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to use a interface instead real object, It allows to unittest more easy and have multiples implementation (as the case of zkevm-sync-l1 that have one implementation of posgtres and another for sqlite)
@@ -72,10 +73,11 @@ func (t *AppendOnlyTree) AddLeaf(tx *sql.Tx, blockNum, blockPosition uint64, lea | |||
return err | |||
} | |||
t.lastIndex++ | |||
tx.AddRollbackCallback(func() { t.lastIndex-- }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you can't execute in parallel this code, isn't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, there is a single writer, and it's sequential (it flows form ProcessBlock
of each syncer)
@@ -184,7 +184,7 @@ func (p *processor) getLastProcessedBlockWithTx(tx db.DBer) (uint64, error) { | |||
// Reorg triggers a purge and reset process on the processor to leaf it on a state | |||
// as if the last block processed was firstReorgedBlock-1 | |||
func (p *processor) Reorg(ctx context.Context, firstReorgedBlock uint64) error { | |||
tx, err := p.db.BeginTx(ctx, nil) | |||
tx, err := db.NewTx(ctx, p.db) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sugest that newTx belong to DB object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but db
is *sql.DB
, I can't add this method there 😅
Quality Gate failedFailed conditions |
* wip * wip * WIP * decoding direct and indeirecr assets and messages works * connect everything * fix building contract scripts * fix building contract scripts * wip * WIP * tree migrated to SQLite * wip * wip * bridgesync working with sqlite * pass tests * minor cleaning * add GetBlockByLER func * handle err not found * merge develop * use memory for sqlite on the tests * increase timestamp to pass UT * review * add callbacks on db tx * lint * fix compilation * fix linter II * fix linter III * fix linter * increase linter TO * fix UTs and lint * increase linter TO * add PR requests
Description
tree
totree/types
to avoid cycles + created type proof (cleaner + easier for SQL)NOTE: change base branch to
develop
oncefeature/sync-imported-bridges
is merged