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

Refactor indexing #1302

Open
wants to merge 5 commits into
base: staging
Choose a base branch
from
Open

Refactor indexing #1302

wants to merge 5 commits into from

Conversation

Tangui-Bitfly
Copy link
Contributor

@Tangui-Bitfly Tangui-Bitfly commented Jan 29, 2025

The main goal of this PR is to remove functionalities from db package and put them into there own object "easily" testable. Those changes aim at removing the basic indexing flow.
⚠️ 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.

Overview of the new architecture

pkg
    commons
        db2
            database            // wrappers around database interractions
                databasetest    // test utility that provide an in mem database that database wrappers can use
            data                // handles all the interactions with the store `data` (indexing resulted objects)
            metadaupdates       // handles all the interactions with the store `metadaupdates` (balances, contracts, ...)
    executionlayer              // contains the indexer and the transformers      

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 here internal/contracts/README.md.

@Tangui-Bitfly Tangui-Bitfly force-pushed the refactor-indexing branch 2 times, most recently from 06801e4 to 31274d8 Compare January 30, 2025 09:04
@Tangui-Bitfly Tangui-Bitfly marked this pull request as ready for review January 30, 2025 14:51
}
remote := database.NewRemote(database.Wrap(bt, table))
go func() {
log.Info("starting remote raw store on port 8087")
Copy link

@Monika-Bitfly Monika-Bitfly Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid confusion we should read the port number from the args here

for _, blob := range blobs {
if blob.TxIndex > txPerBlockLimit {
return nil, fmt.Errorf("unexpected number of transactions in block expected at most %d but got: %v, tx: %x", txPerBlockLimit, blob.TxIndex, blob.Indexed.GetHash())
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably good to add validation for the transaction hash length


func (t *Transformer) Withdrawal(chainID string, block *types.Eth1Block) (map[string][]database.Item, map[string][]database.Item, error) {
updateMetadata := make(map[string][]database.Item)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add back the validation to throw an error if the number of block withdrawals exceeds MaxWithdrawalsPerPayload


func parseTx(tx *types.Eth1TransactionIndexed) *Interaction {
return &Interaction{
ChainID: "",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ChainID: "",
ChainID: "", // TODO parse chain ID

Time: tx.Time.AsTime(),
Type: "Transaction",
Value: tx.Value,
Asset: "ETH",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Asset: "ETH",
Asset: "ETH", // TODO parse asset from tx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants