-
Notifications
You must be signed in to change notification settings - Fork 11
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
Refactor indexing #1302
Refactor indexing #1302
Conversation
31274d8
to
b06f30c
Compare
0e7877e
to
1a39ae4
Compare
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.
Generally looks OK. I would like to note that this CR is enormous, and so couldn't review it for functional changes. Since this review concentrates mostly on testing, I focused my efforts there, specifically on the structure and ensuring we were creating a good model that others could use moving forward.
Your suggestion to use table-based tests is a good one, and raises the quality and our confidence of the code as a whole. I have concerns however about the flexibility of the testing code if we were to for example change the underlying database model, and how much of these tests we would have to re-write. However, as we had 0 tests prior to this CR and because this is clearly already a measurable improvement, I believe that is out of scope and we can tackle that problem later.
Please avoid having "TODOs" in the code, as it is very unlikely we will go back and revisit them. Consider any TODOs as essentially final. Also, next time it would make sense to split such a large CR up in to smaller pieces, so that they are reviewable and can be iterated on more quickly. This saves time for both the author of the changes and the reviewers.
}, | ||
// TODO add transfer bulk when bug fixed | ||
} |
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.
Whats this?
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.
It's related to a bug I found but did not fix.
https://github.com/gobitfly/beaconchain/blob/refactor-indexing/backend/pkg/executionlayer/transformer.go#L398
To sum up, erc1155 can be transferred in batch, in that case we only save the last batched transfer because we overwrite our indexed log for each batch elem.
There is no easy fix to that because we store those indexed log with key <tx_index>:<log_index>
but in this case all the batched transfer have the same log index. So even if we fix our indexing, it will be overwritten in the db.
/* | ||
list of filter | ||
data.ByMethod(method) | ||
data.ByAsset(asset) | ||
data.OnlyReceived() | ||
data.OnlySent() | ||
data.IgnoreTransactions() | ||
data.IgnoreTransfers() | ||
data.WithTimeRange(from, to) | ||
*/ |
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.
Why commented out code?
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.
it was more a test to showcase how to interact with the data.Store
, I can remove it bring confusion.
// BaseFeeChange: new(big.Int).Sub(new(big.Int).SetBytes(block.GetBaseFee()), new(big.Int).SetBytes(previous.GetBaseFee())).Bytes(), | ||
// BlockUtilizationChange: new(big.Int).Sub(new(big.Int).Div(big.NewInt(int64(block.GetGasUsed())), big.NewInt(int64(block.GetGasLimit()))), new(big.Int).Div(big.NewInt(int64(previous.GetGasUsed())), big.NewInt(int64(previous.GetGasLimit())))).Bytes(), |
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.
?
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.
copy pasted previous code
GasUsed: block.GetGasUsed(), | ||
Time: block.GetTime(), | ||
BaseFee: block.GetBaseFee(), | ||
// Duration: uint64(block.GetTime().AsTime().Unix() - previous.GetTime().AsTime().Unix()), |
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.
?
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.
copy pasted previous code
b8ad60b
to
a08b73f
Compare
a08b73f
to
4202159
Compare
The main goal of this PR is to remove functionalities from
⚠️ Please do not focus on the code quality, I tried to change as little as possible to reduce risk of breaking something. The goal here is not to refactor everything but to separate things, remove coupling, introduce dependancies injections and a tests.
db
package and put them into there own object "easily" testable. Those changes aim at removing the basic indexing flow.Overview of the new architecture
Those are the main package to focus your review on.
Lot of the changed lines come from generated code around contract bindings. You can find those in
internal/contracts
, and I would suggest to not spend too much time on those beside maybe having a look at the readme hereinternal/contracts/README.md
.