-
Notifications
You must be signed in to change notification settings - Fork 479
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
Add extrinsic weight and lenght check #637
Add extrinsic weight and lenght check #637
Conversation
73b4a49
to
025655f
Compare
@sorpaas Please take a reivew? |
0448c0a
to
d747b62
Compare
Thank you for taking a look at this. I've been thinking about this change and here is why I don't think is necessary - at least not like this.
Now, for the extrinsic length check. As far as I understand your proposal, However, we want to reject extrinsics which's lenght is greater than the block length upper bound. @sorpaas in our |
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.
Substrate's extensions do not have support for extending custom validations, so I think the approach in this PR is the simplest way to fix the problem.
We should probably add a note in the docs that while self-contained does not behave exactly like unsigned, it does call unsigned validation functions.
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 read the rest of the self-contained logic and I think this will add too much confusion. I'd prefer if we just duplicate some code, which in this case will actually be cleaner.
Please instead add the weight checking directly to validate_self_contained
. All code needed can be copied from the CheckWeight struct's do_validate
function.
Make sense. It seems a bit weird to add unsigned transaction logic under
Do you mean something like this? We might add another runtime parameter to the CheckedSignature::SelfContained(signed_info) => {
// let unsigned_validation = Extra::validate_unsigned(&self.function, info, len)?;
let weight_validation = CheckWeight::<Runtime>::do_validate(info, len)?;
let self_contained_validation =
self.function.validate_self_contained(&signed_info).ok_or(
TransactionValidityError::Invalid(InvalidTransaction::BadProof),
)??;
Ok(weight_validation.combine_with(self_contained_validation))
} |
I was thinking about putting it here: https://github.com/paritytech/frontier/blob/master/frame/ethereum/src/lib.rs#L151 You may want to add it to |
@sorpaas Please take a review again. |
* Try fix * Format code * Add tests * Update evm BlockGasLimit * Format * Fix ts tests * Add weight check to ethereum * Format * Handle review issue and fix unit tests * Fix clippy * Make CI Happy
(1) Add extrinsic weight and lenght check (polkadot-evm#637) (2) fix(frame): CheckWeight controls should be applied on pre_dispatch (polkadot-evm#749)
As
call.validate_self_contained(info)
does not contain any extrinsic length and weight checks, the transaction's max_gas_limit is not restricted and can be higher than the block gas limit. Add this check to thefp-self-contained
scope together withSigned
andUnsigned
.