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

Allow up-to 6 decimals for transfer values #1211

Merged
merged 7 commits into from
Dec 5, 2023

Conversation

platfowner
Copy link
Member

Change summary:

  • Allow up-to 6 decimals for transfer values
  • Apply gas cost flooring up-to 6 decimals

Related issues:

Copy link
Member

@jiyoung-an jiyoung-an left a comment

Choose a reason for hiding this comment

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

LGTM with some questions! Thanks!

path: ['rules', 'transfer', '$from', '$to', '$key', 'value' ],
value: {
'.rule': {
"write": "(auth.addr === $from || auth.fid === '_stake' || auth.fid === '_unstake' || auth.fid === '_pay' || auth.fid === '_claim' || auth.fid === '_hold' || auth.fid === '_release' || auth.fid === '_collectFee' || auth.fid === '_claimReward' || auth.fid === '_openCheckout' || auth.fid === '_closeCheckout' || auth.fid === '_closeCheckin') && !getValue('transfer/' + $from + '/' + $to + '/' + $key) && (util.isServAcntName($from, blockNumber) || util.isCksumAddr($from)) && (util.isServAcntName($to, blockNumber) || util.isCksumAddr($to)) && $from !== $to && util.isNumber(newData) && newData > 0 && util.countDecimals(newData) <= 6 && util.getBalance($from, getValue) >= newData"
Copy link
Member

Choose a reason for hiding this comment

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

I'm not entirely sure, but shouldn't the write rule be auth.addr === $from && (auth.fid === '_stake' || ... )? I ㅣlook forward to your comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

When a native function is triggered, it runs with only its auth.fid set clearing the original user's auth.addr. This distinguishes state writes by native functions from those by users.

// From allow_non_negative_transfer_value_only.js bandage file.
prevValue: {
".rule": {
"write": "(auth.addr === $from || auth.fid === '_stake' || auth.fid === '_unstake' || auth.fid === '_pay' || auth.fid === '_claim' || auth.fid === '_hold' || auth.fid === '_release' || auth.fid === '_collectFee' || auth.fid === '_claimReward' || auth.fid === '_openCheckout' || auth.fid === '_closeCheckout' || auth.fid === '_closeCheckin') && !getValue('transfer/' + $from + '/' + $to + '/' + $key) && (util.isServAcntName($from, blockNumber) || util.isCksumAddr($from)) && (util.isServAcntName($to, blockNumber) || util.isCksumAddr($to)) && $from !== $to && util.isNumber(newData) && newData > 0 && util.getBalance($from, getValue) >= newData"
Copy link
Member

Choose a reason for hiding this comment

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

What is a service account name, and how does it differ from a checksum address?

Copy link
Member Author

Choose a reason for hiding this comment

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

Service accounts are accounts that can hold tokens for service constructions. For example, the accounts under /service_accounts/staking/consensus are service accounts for staking to participate in the blockchain consensus (block producing).
https://testnet-insight.ainetwork.ai/database/values/service_accounts/staking/consensus

@@ -55,5 +55,9 @@
"tweak_transfer_gc_rule": {
"enabled_block": 2,
"has_bandage": true
},
"allow_up_to_6_decimal_transfer_value_only": {
Copy link
Member

Choose a reason for hiding this comment

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

What is timer_flag?

Copy link
Member Author

Choose a reason for hiding this comment

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

Timer flags are a flag with its enabled and disabled block numbers. For backward compatibility, any new features that affects the consensus (including state root hash) need to be enabled after specific block number.

@platfowner
Copy link
Member Author

Thanks for the review! @jiyoung-an Now merging..

@platfowner platfowner merged commit 3f62167 into develop Dec 5, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants