-
Notifications
You must be signed in to change notification settings - Fork 135
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
Do only the necessary validation prior to including transaction into a chunk #84
Comments
I don't understand why this is needed. Which part of the validation is unnecessary today? |
The reason for the validation before including into the chunk is to only include the valid transactions in the chunk. It decreases the size of the chunk by putting extra effort on the chunk producer, but decreases the load from everybody else who's validating this chunk. |
Size of the chunk can be measured by its size in bytes and CPU time to execute on signer. The idea is to split it and make sure that sender paid at least for transmission. During transaction application, we charge account incrementally action-by-action (like we do it when we create Promises). In general idea is to make user input opaque to the chain layer and deserialize actions only on a chunk application. So, in a trust-less setting it makes sense to execute user input in accountable environment. |
It fact, the proposal simply changes the definition of a "valid transaction", making it more general. |
@fckt the transaction itself is usually quite cheap. This will allow people to spam with invalid transactions at a relatively low cost. |
@bowenwang1996 The idea is to allow (potentially invalid from a state transition function stand point) transactions to join chunk, since account is guaranteed to be charged at least by amount of |
But you still need to pull account and access_key, verify signature and make sure there is enough cost. Then you'll need to pre-charge the account/access key for TX costs first before you start validate transactions. |
Rationale
Currently, the network layer is aware of receipt (transaction) actions semantics in a way that node does TX validation outside of a chunk validation:
https://github.com/nearprotocol/nearcore/blob/a3ffe63f03c6d0e5f121aa783ff1091428036802/runtime/runtime/src/verifier.rs#L57-L178
On a chunk validation, runtime does the same TX validation once again. This proposal suggest a change to the protocol to allow to make only the necessary TX checks prior to the inclusion into a chunk.
Solution
We can change SignedTransaction to the following, exposing only the necessary information to check that the signature is authentic, the signer (access_key) is solvent to cover
attached_gas
andattached_gas
>config.receipt_cost_per_byte * receipt.len()
:We can have a
receipt_cost_per_byte
in the chain config and thus (on the chunk generation) we have to check only that account (access_key) has funds to cover gas to parse ActionReceipt. Thus client do not aware of receipt structure at all.This way, the minimum
attached_gas
to be included into a chunk will be equal toconfig.receipt_cost_per_byte * transaction.receipt.len()
. Of course, signer (nearlib) better attach gas to cover total cost of included actions otherwise transaction outcome will beExecutionOutcome(ExecutionStatus::Failure)
on a chunk application (the validator will burn allattached_gas
for the actual CPU work done).Recap
Proposed change allows chunk producer do not parse and validate Tx body (actions) prior including it into a chunk and leave this validation to validator. This gives us the following interdependent advantages:
Issues:
nearlib
changes required: it must calculateattached_gas
, based on the actions, included in transactionComments?
@evgenykuzyakov @nearmax @bowenwang1996 @ilblackdragon @SkidanovAlex
The text was updated successfully, but these errors were encountered: