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

(BIDS-2634) reordered transactions, fix almost-empty table #2663

Merged
merged 9 commits into from
Feb 6, 2024

Conversation

remoterami
Copy link
Collaborator

@remoterami remoterami commented Nov 3, 2023

🤖 Generated by Copilot at a7a7b97

This pull request fixes some issues with the eth1 transactions API and the Bigtable database query. It improves the pagination and order of the eth1Transactions.go endpoint and prevents an error in the GetBlocksDescending function of bigtable_eth1.go.

Copy link
Contributor

@D13ce D13ce left a comment

Choose a reason for hiding this comment

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

The transaction table on the address page does not seem to be affected by your changes.

Here is a random example I have found:
https://holesky.beaconcha.in/address/0x6cc9397c3b38739dacbfaa68ead5f5d77ba5f455
image
=>
https://holesky.beaconcha.in/block/273427#transactions
image

So right now, the txs shown in the tx table on the address page are sorted by block in descending order (i.e. txs in younger blocks are listed ABOVE txs in older blocks) and when there are more txs in one block, lower index tx come first. Your PR should change the latter so that higher indexes are listed below, right? I am asking because of your change here: https://github.com/gobitfly/eth2-beaconchain-explorer/pull/2663/files#diff-143a07e5aa31442d87e5dd9584d1525fc98e8b2fef161a08af276d65f60184acR2137-R2138

If I run your branch and navigate to http://localhost:8081/address/0x6cc9397c3b38739dacbfaa68ead5f5d77ba5f455, it looks the same though:
image

Please share your thoughts.

FYI, I have not tested the other tx tables on the address page as it is possible that I am misunderstanding your intentions.

@remoterami
Copy link
Collaborator Author

remoterami commented Nov 9, 2023

Oh I missed that, great catch. Iterating in reverse order doesn't change anything if we update by index, my bad 😅 Just swapping the insert order won't be enough anyways though if there are more than 25 transactions by one address per block. Because of the way the data is retrieved from bigtable, it wouldn't be sorted anymore at all - indices would be sorted in the interval, but there'd be jumps between intervals. This does also occur in pratice, e.g. with every big NFT mint there'll be >25 transactions per block. I'll try to come up with something, hopefully it's not too inefficient..

EDIT: Disregard this, I wasn't able to recall/reproduce what this was actually about after coming back to this. The new implementation regarding the paragraph below should address and hopefully fix your concern.

And this also made me aware of another issue with reversePaddedIndex - it doesn't do padding correctly, resulting in index 0 being larger than index 1. This currently results in index 0 always being at the top of the list, immediately followed by the max index.

@remoterami remoterami force-pushed the BIDS-2634/reverse_iterate_transactions branch from 552fabe to 80c668e Compare December 19, 2023 12:16
Copy link
Collaborator

@Eisei24 Eisei24 left a comment

Choose a reason for hiding this comment

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

Everything looks correct now according to my testing but please confirm that I understood the issues we have on master correctly:

  1. For the /transactions page the blocks were correctly descending but all the tx were ascending so the tx order needed to be reverted
  2. For the /address page both blocks and tx were already correctly descending, however there was a bug that the first tx (idx 0) was always incorrectly at the top.

}

// first find out if we've a (sub)transaction with index 0 whose block/transaction has maybe not been completed by the request
// if we find one, make sure we do. So we won't miss that (i)tx next time (=> ignoring the query limit)
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor: The comment seems incomplete.

}
// tx idx
if i_splits[6] != j_splits[6] {
if i_splits[6] == "10000" || j_splits[6] == "10000" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

note: Keep in mind that with BIDS-2550 we added TX_PER_BLOCK_LIMIT and ITX_PER_TX_LIMIT.
When some kind of merging happens these should be used throughout the new methods instead of the hardcoded "10000"/"100000".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes I'm aware and intended to take care of this when necessary, just not possible yet when we don't know which PR will be merged first

@remoterami
Copy link
Collaborator Author

Yes, your understanding is correct 👍

Eisei24
Eisei24 previously approved these changes Jan 31, 2024
Copy link
Collaborator

@Eisei24 Eisei24 left a comment

Choose a reason for hiding this comment

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

lgtm

D13ce
D13ce previously approved these changes Jan 31, 2024
Copy link
Contributor

@D13ce D13ce left a comment

Choose a reason for hiding this comment

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

As discussed with @Eisei24 , my initial concerns have been properly tackled.

@remoterami remoterami dismissed stale reviews from D13ce and Eisei24 via 8b8e6e6 February 6, 2024 12:13
@remoterami remoterami force-pushed the BIDS-2634/reverse_iterate_transactions branch from 3b9e3a7 to 8b8e6e6 Compare February 6, 2024 12:13
Eisei24
Eisei24 previously approved these changes Feb 6, 2024
Copy link
Collaborator

@Eisei24 Eisei24 left a comment

Choose a reason for hiding this comment

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

lgtm, error message could still be updated.

@@ -2073,7 +2073,7 @@ func skipBlockIfLastTxIndex(key string) string {
return key
}

func (bigtable *Bigtable) GetEth1TxForAddress(prefix string, limit int64) ([]*types.Eth1TransactionIndexed, string, error) {
func (bigtable *Bigtable) GetEth1TxsForAddress(prefix string, limit int64) ([]*types.Eth1TransactionIndexed, []string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor: This is just a change from a merge but the method name changed here but not in the error message here

logger.WithError(err).WithField("prefix", prefix).WithField("limit", limit).Errorf("error reading rows in bigtable_eth1 / GetEth1TxForAddress")

Copy link
Collaborator

@Eisei24 Eisei24 left a comment

Choose a reason for hiding this comment

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

And again, lgtm.

@remoterami remoterami merged commit 9d21f02 into master Feb 6, 2024
3 checks passed
@remoterami remoterami deleted the BIDS-2634/reverse_iterate_transactions branch February 6, 2024 13:26
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.

3 participants