-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Limit SYSCALLs in Verification #856
Conversation
Codecov Report
@@ Coverage Diff @@
## master #856 +/- ##
==========================================
+ Coverage 44.93% 45.06% +0.12%
==========================================
Files 177 178 +1
Lines 12577 12605 +28
==========================================
+ Hits 5652 5680 +28
Misses 6925 6925
Continue to review full report at Codecov.
|
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.
Beautiful job, @erikzhang, Yoda Master.
You also improved code readability with this new template for InteropDescriptor.
I like this design, let's discuss the needs, possibilities and visions, then, extend it now.
-
Maybe we need to allow part of the header for time-lock accounts as well.
-
Contract is payable
Neo_Contract_IsPayable
might be included in the transaction as well:transaction_IsPayable
, it would be nice to have a pre-limit of the amount of GAS (even other tokens) that will spend during Application. This would assist a faster re-verification.
@erikzhang congratulations for this amazing step!
I thought a lot about it in the past month, and I think that this is not state-related. We can define two things: ledger structure (blockchain itself, including height); and blockchain state itself (result of operations over this chain).
This is fine, because of item 1. Tx will have limited life.
In fact, this would be the most problematic case, because like you said before, a NEP-5 balance is a state operation. So, this can be "easily" solved, as long as only balances for GAS and NEO are controlled. If we wanted to control every type of asset, on verification, we would need crazy ideas like the Example:
probably it should allow sending back automatically to user B the 40 GAS difference, which was "unused" (this depends on logic). This type of thing guarantees that we only re-manage funds available over verification, so tx will never fail when out of GAS funds inside blocks. |
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.
Very clean implementation, I just think we need to decide upon having or not a deployed contract as witness.
A solution would be creating a new trigger type, only for Contract operations, and attaching this on Transaction Script. I think it's important to have Contract State
as final Erik, even if storage is not final.
The only problem to be solved now is the change in policy. My solution is to clear mempool when policy changed. |
Why policy change is so problematic.. pricing changes? |
Nice commits, Erik, how about the GAS spent during Application on in payable contracts? We need to sum them as well during reverify. |
Yes. |
Don't understand. |
Let's use the following scenario, an account with
Notes:
|
I guess Vitor is worried about the payable operations which we will be able to do during invoke now... I think they shouldn't be purely based on Application, otherwise their effects may become unpredictable in the future, so as user balances. I asset transfer is done purely on application, and storage is delayed, it will be hard to verify future tx, to be sure the funds will actually exist at that time (even to pay network fees, system fees, etc). So I think that payable stuff inside contracts should be pre-paid during verification, with the possibility of "cashing back" the difference or unused gas/neo. |
It is correctly handled currently. neo/neo/Network/P2P/Payloads/Transaction.cs Lines 131 to 135 in 94c4579
|
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.
Good job
Erik,looks like it works, logic is fine. Native nep5 is supposed to be sent on application trigger or only system trigger? Just to clarify how transfers would work, and make sure we are on the same page (nep5 mint operation): Sender = myhash Then, IcoContract would get notifications, including from NativeNeo, and know how much tokens to send, right? My only concern is when contracts start transfering native tokens internally, we need to make sure this wont break balances. But we can discuss this later, we have options. |
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.
Still missing the policy change part I guess.
Yes. I will mark it as |
Erik, do you think we can pass two Script on a tx, first limited to a "system trigger", and second an application trigger? |
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.
Suggestion to put _policyChanged in local scope (while keep _feePerByte in global one)
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 a nice PR, @erikzhang, as I already said. It provides a good refactor.
There are just some minor details I asked above, but maybe we can handle them in another PR if you want to proceed.
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.
A big evolution already, lets keep moving.
This optimization of clean or reverify the txs can be done later.
d829748
_unsortedTransactions.Clear(); | ||
_sortedTransactions.Clear(); | ||
foreach (PoolItem item in _unverifiedSortedTransactions.Reverse()) | ||
_system.Blockchain.Tell(item.Tx, ActorRefs.NoSender); |
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.
Any chance that, in the time you retell, and then you clear already retelled tx? 🤔
@erikzhang, it has been a great PR and discussions. Let's move to the next steps and later we double check everything. |
* Limit SYSCALLs in Verification * Allow deployed contract as verification script * Simplify re-verification * Clear mempool when policy is changed * put _policyChanged in local scope * Reverify transactions when policy changes
I disabled the state-related SYSCALLs from being called in Verification. Now it is possible to avoid the re-verifications of transactions. But we still need to solve a few problems:
Transaction.ValidUntilBlock
is state dependent.