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

Alias fee schedule support #2774

Merged
merged 13 commits into from
Jan 19, 2022

Conversation

anighanta
Copy link
Contributor

@anighanta anighanta commented Jan 19, 2022

Description:

Related issue(s):

addresses #2691

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@@ -120,8 +127,15 @@
return MISSING_FEE_COLLECTOR_RESULT;
}

@Override
public SigningOrderResult<ResponseCodeEnum> forMissingTokenTreasury() {
return MISSING_TOKEN_TRASURY;
Copy link
Member

Choose a reason for hiding this comment

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

typo TREASURY

@@ -584,14 +585,26 @@ public ResponseCodeEnum update(final TokenUpdateTransactionBody changes, final l

private AliasLookup checkNewAutoRenewAccount(final TokenUpdateTransactionBody changes) {
if (changes.hasAutoRenewAccount()) {
return lookUpAccountId(changes.getAutoRenewAccount(), INVALID_AUTORENEW_ACCOUNT);
final var autoRenewLookUp = lookUpAccountId(changes.getAutoRenewAccount(), INVALID_ALIAS_KEY);
Copy link
Member

Choose a reason for hiding this comment

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

should return INVALID_AUTORENEW_ACCOUNT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made it into 2 parts. first we look up the alias key. If found and its not a usable accountId we return INVALID_AUTORENEW_ACCOUNT but if that alias is not found we return INVALID_ALIAS_KEY. I open to change it though.

if (treasuryLookUp.response() != OK) {
return treasuryLookUp;
} else {
final var validity = usableOrElse(treasuryLookUp.resolvedId(), INVALID_TREASURY_ACCOUNT_FOR_TOKEN);
Copy link
Member

Choose a reason for hiding this comment

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

can we do usableOrElse inside lookUpAccountId?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is what we did previously.

Comment on lines 112 to 118
/* I dont think we need these checks as it is handled just aftet these checks */
// if (chunkAccountIDLookup.response() != OK) {
// transactionContext.setStatus(chunkAccountIDLookup.response());
// }
// if (transactionIDLookup.response() != OK) {
// transactionContext.setStatus(transactionIDLookup.response());
// }
Copy link
Member

Choose a reason for hiding this comment

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

why are we removing these ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was actually not sure why we didn't return after the err response for each.

@@ -204,7 +204,7 @@ private boolean canApplyNewAutoRenewAccount(ConsensusUpdateTopicTransactionBody
return true;
}

final var result = ledger.lookUpAccountId(op.getAutoRenewAccount(), INVALID_AUTORENEW_ACCOUNT);
final var result = ledger.lookUpAccountId(op.getAutoRenewAccount());
Copy link
Member

Choose a reason for hiding this comment

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

Need to give INVALID_AUTORENEW_ACCOUNT as response

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Again, that will be handled just below this on line 222

@@ -87,6 +86,12 @@ public void doStateTransition() {
txnCtx.setStatus(result.response());
return;
}
var validity = ledger.usableOrElse(result.resolvedId(), INVALID_ACCOUNT_ID);
Copy link
Member

Choose a reason for hiding this comment

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

may be we should give result.response() instead of INVALID_ACCOUNT_ID . Same in all places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here result.response() will be OK right ?


if (ledger.isDetached(id) || ledger.isDetached(beneficiary)) {
txnCtx.setStatus(ACCOUNT_EXPIRED_AND_PENDING_REMOVAL);
validity = ledger.usableOrElse(result.resolvedId(), INVALID_ACCOUNT_ID);
Copy link
Member

Choose a reason for hiding this comment

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

same here

@@ -171,6 +171,7 @@ private ResponseCodeEnum sanityCheck(AccountID target, HederaAccountCustomizer c
if (result.response() != OK) {
return result.response();
}
return ledger.usableOrElse(result.resolvedId(), INVALID_ACCOUNT_ID);
Copy link
Member

Choose a reason for hiding this comment

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

here as well

Comment on lines 117 to 125
// final var customFeeList = op.getCustomFeesList();
// for (var fee : customFeeList) {
// if (fee.hasFeeCollectorAccountId()) {
// final var feeCollector = fee.getFeeCollectorAccountId();
// final var feeCollectorNum = accountStore.getAccountNumFromAlias(feeCollector.getAlias(), feeCollector.getAccountNum());
// final var feeCollectorId = new Id(feeCollector.getShardNum(), feeCollector.getRealmNum(), feeCollectorNum);
// accountStore.loadAccountOrFailWith(feeCollectorId, INVALID_ACCOUNT_ID);
// }
// }
Copy link
Member

Choose a reason for hiding this comment

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

can these be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup, can be removed. The feeCollector validation is actually already done in sigRequirements.

Comment on lines 99 to 106
// given(validator.isAfterConsensusSecond(expiry)).willReturn(false);
// given(accountsLedger.exists(testId)).willReturn(true);
// given(accountsLedger.get(testId, IS_DELETED)).willReturn(false);
// given(accountsLedger.get(testId, IS_SMART_CONTRACT)).willReturn(false);
// given(accountsLedger.get(testId, BALANCE)).willReturn(balance);
// given(accountsLedger.get(testId, EXPIRY)).willReturn(expiry);
//
// assertEquals(ACCOUNT_EXPIRED_AND_PENDING_REMOVAL, subject.usableOrElse(testId, ACCOUNT_DELETED));
Copy link
Member

Choose a reason for hiding this comment

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

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This needs fixing. Will uncomment and fix

Signed-off-by: anighanta <[email protected]>
@codecov
Copy link

codecov bot commented Jan 19, 2022

Codecov Report

Merging #2774 (8bbf474) into 02691-M-ExtendAliasSupport (4bd9c10) will increase coverage by 0.02%.
The diff coverage is 98.86%.

❗ Current head 8bbf474 differs from pull request most recent head 08aa26b. Consider uploading reports for the commit 08aa26b to get more accurate results
Impacted file tree graph

@@                       Coverage Diff                        @@
##             02691-M-ExtendAliasSupport    #2774      +/-   ##
================================================================
+ Coverage                         95.67%   95.70%   +0.02%     
- Complexity                         9676     9679       +3     
================================================================
  Files                               700      700              
  Lines                             26570    26569       -1     
  Branches                           2738     2733       -5     
================================================================
+ Hits                              25422    25428       +6     
+ Misses                              601      598       -3     
+ Partials                            547      543       -4     
Impacted Files Coverage Δ
.../hedera/services/store/schedule/ScheduleStore.java 100.00% <ø> (ø)
...a/com/hedera/services/store/tokens/TokenStore.java 80.76% <ø> (ø)
...ces/txns/token/TokenDissociateTransitionLogic.java 100.00% <ø> (ø)
...s/txns/consensus/SubmitMessageTransitionLogic.java 90.19% <90.90%> (+6.58%) ⬆️
.../java/com/hedera/services/ledger/HederaLedger.java 94.84% <100.00%> (+0.51%) ⬆️
...dera/services/queries/meta/GetTxnRecordAnswer.java 100.00% <100.00%> (ø)
...era/services/queries/validation/QueryFeeCheck.java 98.80% <100.00%> (ø)
...ra/services/sigs/order/CodeOrderResultFactory.java 100.00% <100.00%> (ø)
...om/hedera/services/sigs/order/SigRequirements.java 93.64% <100.00%> (-0.38%) ⬇️
...services/state/logic/AwareNodeDiligenceScreen.java 100.00% <100.00%> (+3.44%) ⬆️
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4bd9c10...08aa26b. Read the comment docs.

Signed-off-by: anighanta <[email protected]>
Signed-off-by: anighanta <[email protected]>
Signed-off-by: anighanta <[email protected]>
Signed-off-by: anighanta <[email protected]>
Signed-off-by: anighanta <[email protected]>
@@ -120,7 +120,7 @@ private ResponseCodeEnum validityOf(
} else if (op.hasAccountID()) {
final var result = aliasManager.lookUpAccountID(op.getAccountID());
if (result.response() != OK) {
return result.response();
return INVALID_ACCOUNT_ID;
Copy link
Member

Choose a reason for hiding this comment

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

should this be result.response()

@anighanta anighanta merged commit 25e4d6b into 02691-M-ExtendAliasSupport Jan 19, 2022
@anighanta anighanta deleted the alias-FeeScheduleSupport branch January 19, 2022 20:07
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