-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: Add Runtime MintGas syscall #4396
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
base: master-n3
Are you sure you want to change the base?
Conversation
|
Transferring 0 NEO to self can achieve the same effect. |
roman-khimov
left a comment
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 don't understand why this complexity for a very simple thing. We have a (pretty much useless) System.Runtime.BurnGas() syscall, what we need is System.Runtime.MintGas() that would add it to the system fee and mint to caller (contract) address, that's about it. Then this fee is a part of the system fee, the user knows how much he spends for the overall transaction and contract gets the amount it needs.
| /// <summary> | ||
| /// The contract owner (deployer) script hash. | ||
| /// </summary> | ||
| public UInt160? Owner { get; set; } |
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.
Why?
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 might misunderstand what we have discussed in the meeting, the first version i did is like what you mentioned, then i checked the NEP from chris again, and updated this pr accordingly. Will refactor this pr again based on your comments.
| if (amount.Sign < 0) | ||
| throw new InvalidOperationException("Fee amount cannot be negative."); | ||
|
|
||
| UInt160 beneficiary = fee.Beneficiary ?? contract.Manifest.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.
Contract requires some fee, contract should be the receiver of it.
|
@roman-khimov i think this one now addressed all your comments, may you please check again? now it only adds MintGas |
|
|
||
| var state = CurrentContext!.GetState<ExecutionContextState>(); | ||
| var wasWhitelisted = state.WhiteListed; | ||
| state.WhiteListed = false; |
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.
Why change WhiteList here?
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.
Ping @Jim8y
| /// Minting GAS to benefit the current contract. | ||
| /// </summary> | ||
| /// <param name="amount">The amount of GAS to mint, in the unit of datoshi, 1 datoshi = 1e-8 GAS</param> | ||
| protected internal void MintGas(BigInteger amount) |
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.
Technically, it's not a minted, as it will only be used in this script. It can be considered minted, but it will be claimed and burned
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 think the syscall should be renamed to "ChargeGas"
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.
Minting gas would also be used in here neo-project/proposals#208
| { | ||
| state.WhiteListed = wasWhitelisted; | ||
| } | ||
| NativeContract.GAS.Mint(this, contract.Hash, amount, false).GetAwaiter().GetResult(); |
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 acceptable for N3, but not for N4 in my opnion
|
Seems related to neo-project/proposals#208 |
Summary
Testing