-
Notifications
You must be signed in to change notification settings - Fork 116
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
HIP-1056 Account BlockItem to RecordItem transformers #10249
base: main
Are you sure you want to change the base?
HIP-1056 Account BlockItem to RecordItem transformers #10249
Conversation
…oDeleteLiveHash Signed-off-by: Harsh Sawarkar <[email protected]>
...va/com/hedera/mirror/importer/downloader/block/transformer/CryptoAddLiveHashTransformer.java
Outdated
Show resolved
Hide resolved
...va/com/hedera/mirror/importer/downloader/block/transformer/CryptoAddLiveHashTransformer.java
Outdated
Show resolved
Hide resolved
...om/hedera/mirror/importer/downloader/block/transformer/CryptoDeleteAllowanceTransformer.java
Outdated
Show resolved
Hide resolved
...com/hedera/mirror/importer/downloader/block/transformer/CryptoDeleteLiveHashTransformer.java
Outdated
Show resolved
Hide resolved
Thanks for contributing. There are tests that need to be added, you can find example test cases in |
Signed-off-by: Harsh Sawarkar <[email protected]>
Signed-off-by: Harsh Sawarkar <[email protected]>
@edwin-greene Sure! I will update the tests for all the account transformers. In the meantime, could you please review the transformer classes and suggest any necessary changes? |
…into chore-HIP-1056-Account-BlockItem-to-RecordItem-transformers
…into chore-HIP-1056-Account-BlockItem-to-RecordItem-transformers
Signed-off-by: Harsh Sawarkar <[email protected]>
for (var stateChange : stateChanges.getStateChangesList()) { | ||
if (stateChange.getStateId() == STATE_ID_ACCOUNTS.getNumber() && stateChange.hasMapUpdate()) { | ||
var value = stateChange.getMapUpdate().getValue(); | ||
if (value.hasAccountIdValue()) { |
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 key issue here is any account with state changes will be here, with exact same state id, change case, key case, and value case.
It's very common for any transaction having at least the following account map update in state changes
- node account id
- fee collector account id, 0.0.98
- staking reward account 0.0.800
- node reward account 0.0.801
There isn't a way for us to confidently identify the new account. Using the key in the transaction body can work in most cases however the network allows many accounts to use the same key so it's not a 100% reliable method.
We may have to ask for a change to add the new account id to CreateAccountOutput
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.
@edwin-greene Please chase this down with the relevant teams
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 agree that this is a miss in the protobuf definitions.
Suggested resolution:
- CreateAccountOutput should be added to TransactionOutput
- The created AccountID should be added to CreateAccountOutput
- The Account ID newly assigned for any account that is created (via CryptoCreate, EVM CREATE2, or similar) should be recorded in the CreateAccountOutput.
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.
To be complete.
This is, I believe, specific to account. In most cases the state changes (which immediately follow the triggering transaction) are more than sufficient to identify the created entity.
Unfortunately, as noted above, Account state changes follow every transaction, and it is unusually difficult to separate the create from other account updates; particularly if an account is created as a result of an EVM transaction.
@Override | ||
protected void updateTransactionRecord(BlockItem blockItem, TransactionRecord.Builder transactionRecordBuilder) { | ||
if (blockItem.transactionResult().getStatus() != SUCCESS) { | ||
return; | ||
} | ||
|
||
for (var stateChanges : blockItem.stateChanges()) { | ||
for (var stateChange : stateChanges.getStateChangesList()) { | ||
if (stateChange.getStateId() == STATE_ID_ACCOUNTS.getNumber() && stateChange.hasMapUpdate()) { | ||
var value = stateChange.getMapUpdate().getValue(); | ||
if (value.hasAccountValue()) { | ||
var accountDelete = value.getAccountValue(); | ||
if (accountDelete.getDeleted()) { | ||
transactionRecordBuilder.getReceiptBuilder().setAccountID(accountDelete.getAccountId()); | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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.
receipt.account_id
shouldn't be set for crypto delete transaction
@Override | |
protected void updateTransactionRecord(BlockItem blockItem, TransactionRecord.Builder transactionRecordBuilder) { | |
if (blockItem.transactionResult().getStatus() != SUCCESS) { | |
return; | |
} | |
for (var stateChanges : blockItem.stateChanges()) { | |
for (var stateChange : stateChanges.getStateChangesList()) { | |
if (stateChange.getStateId() == STATE_ID_ACCOUNTS.getNumber() && stateChange.hasMapUpdate()) { | |
var value = stateChange.getMapUpdate().getValue(); | |
if (value.hasAccountValue()) { | |
var accountDelete = value.getAccountValue(); | |
if (accountDelete.getDeleted()) { | |
transactionRecordBuilder.getReceiptBuilder().setAccountID(accountDelete.getAccountId()); | |
return; | |
} | |
} | |
} | |
} | |
} | |
} |
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.
Updated
if (stateChange.getStateId() == STATE_ID_ACCOUNTS.getNumber() && stateChange.hasMapUpdate()) { | ||
var value = stateChange.getMapUpdate().getValue(); | ||
if (value.hasAccountIdValue()) { | ||
transactionRecordBuilder.getReceiptBuilder().setAccountID(value.getAccountIdValue()); | ||
} | ||
} |
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.
weird enough, receipt.account_id
for crypto update transaction is set in record stream files.
again, the logic shares the same problem in the comment for crypto create transaction.
Think we can choose not to set it at all, or set it to the value from crypto update transaction body
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.
Temporarily removing the updateTransactionRecord method until we identify a better solution.
Signed-off-by: Harsh Sawarkar <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10249 +/- ##
============================================
- Coverage 92.33% 92.28% -0.06%
- Complexity 7841 7855 +14
============================================
Files 954 961 +7
Lines 32952 32984 +32
Branches 4158 4163 +5
============================================
+ Hits 30425 30438 +13
- Misses 1548 1565 +17
- Partials 979 981 +2 ☔ View full report in Codecov by Sentry. |
…into chore-HIP-1056-Account-BlockItem-to-RecordItem-transformers
Signed-off-by: Harsh Sawarkar <[email protected]>
...va/com/hedera/mirror/importer/downloader/block/transformer/CryptoAddLiveHashTransformer.java
Outdated
Show resolved
Hide resolved
...m/hedera/mirror/importer/downloader/block/transformer/CryptoApproveAllowanceTransformer.java
Outdated
Show resolved
Hide resolved
|
||
@Override | ||
protected void updateTransactionRecord(BlockItem blockItem, TransactionRecord.Builder transactionRecordBuilder) { | ||
if (blockItem.transactionResult().getStatus() != SUCCESS) { |
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'll want to update this with the new blockItem.successful()
method from #10248 once it's merged.
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 will update it once the PR is merged.
for (var stateChange : stateChanges.getStateChangesList()) { | ||
if (stateChange.getStateId() == STATE_ID_ACCOUNTS.getNumber() && stateChange.hasMapUpdate()) { | ||
var value = stateChange.getMapUpdate().getValue(); | ||
if (value.hasAccountIdValue()) { |
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.
@edwin-greene Please chase this down with the relevant teams
…into chore-HIP-1056-Account-BlockItem-to-RecordItem-transformers
Signed-off-by: Harsh Sawarkar <[email protected]>
Description:
Added tranformers for CryptoAddLiveHash, CryptoDeleteAllowance, CryptoDeleteLiveHash
Related issue(s):
Fixes #10164
Notes for reviewer:
Checklist