-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Indexer] Add transactions by address indexing #9076
Conversation
24a39cf
to
9157f6f
Compare
5a0e9c3
to
56eecdf
Compare
8ddaa67
to
204191b
Compare
pub fn from_transaction( | ||
transaction: &Transaction, | ||
) -> anyhow::Result<HashMap<AccountTransactionPK, Self>> { | ||
let (events, wscs, signatures, txn_version) = match transaction { |
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 looks like a fair amount of common code. Is there a common library to call to do 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.
This will need to be cleaned up but for now I don't have time to refactor all that 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.
Gotcha. Just the OCD me saying :P
@@ -120,35 +108,42 @@ impl Object { | |||
/// This should never really happen since it's very difficult to delete the entire resource group |
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 is not true. Unnamed token objects can be burnt and deleted very thoroughly. For most use cases using aptos_token, we'll see clean deletions so let's make sure we handle this case well (can be in a separate PR though).
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.
Yea I've seen this already so I'll change the comments.
@@ -157,4 +152,44 @@ impl Object { | |||
Ok(None) | |||
} | |||
} | |||
|
|||
/// This is actually not great because object owner can change. The best we can do now though | |||
fn get_object_owner( |
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 wonder if this can lead to some performance/failure issue for the processor if the data is stored in remote databases (e.g. in Hive). If a processor has to query the object owner multiple times, this means multiple remote calls
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.
We don't delete that often so it should be fine for now.
retried += 1; | ||
match CurrentObjectQuery::get_by_address(object_address, conn) { | ||
Ok(res) => { | ||
return Ok(CurrentObject { |
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 thought we also planned to do this for table items?
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.
Did you read the summary lol. We can't do this for table items performantly.
fa96bee
to
cfbe271
Compare
Going to merge. ack about another sync based on PR: aptos-labs/aptos-core#9076
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
/// We will consider all transactions that modify a resource or event associated with a particular account. | ||
/// We will do 1 level of redirection for now (e.g. if it's an object, we will record the owner as account address). | ||
/// We will also consider transactions that the account signed or is part of a multi sig / multi agent. | ||
/// TODO: recursively find the parent account of an 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.
Should this be done in post-processing instead of in the processor?
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.
we might not have a choice lol.
) -> anyhow::Result<Option<(Self, CurrentObject)>> { | ||
if delete_resource.resource.to_string() == "0x1::object::ObjectCore" { | ||
if delete_resource.resource.to_string() == "0x1::object::ObjectGroup" { |
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.
What's object group and why do we need to change 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.
the old thing wasn't working hahaha. I assuemd it would be ObjectCore but actually when it's deleted it's ObjectGroup. It was just buggy before.
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.
that's weird that the resource type is different for writes and deletes.
@@ -524,12 +526,54 @@ impl TransactionProcessor for DefaultTransactionProcessor { | |||
} | |||
|
|||
// TODO, merge this loop with above | |||
// Moving object handling here because we need a single 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.
What's the difference between this new way and the old way of getting the objects? They look like they're doing the same thing.
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.
They are. If you notice though that I'm passing all_objects into the from_delete_resource function. That's the main difference. I mean I could've made it work as before as well but the right thing to do is to use a general forloop to avoid the duplicate work so I just refactored this at the same time.
5ed6317
to
a302422
Compare
Pull request was closed
a302422
to
0cdd064
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
✅ Forge suite
|
* make changes to old indexer * apply change to grpc processors * remove unecessary log
* make changes to old indexer * apply change to grpc processors * remove unecessary log
* make changes to old indexer * apply change to grpc processors * remove unecessary log
* make changes to old indexer * apply change to grpc processors * remove unecessary log
Description
It's nice to have a dedicated table to get all transactions that touch an address instead of a view. I'm adding this to the coin_processor because the coin processor already needs to process every transaction. We don't want this to be in default processor currently because we've had instances where default processor takes forever to run migrations and it stalls explorer and wallet.
What qualifies as a transaction associated with an address:
I called out a bunch of TODOs here. Notably what we're currently unable to do:
P.S. This PR also fixes a bug where we're not actually recording object deletes.
Test Plan