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

Fix: Ethereum extrinsic size is accounted twice for proof size #1568

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions primitives/self-contained/src/checked_extrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use frame_support::dispatch::{DispatchInfo, GetDispatchInfo};
use frame_support::{
dispatch::{DispatchInfo, GetDispatchInfo, PostDispatchInfo},
pallet_prelude::Weight,
};
use sp_runtime::{
traits::{
self, DispatchInfoOf, Dispatchable, MaybeDisplay, Member, PostDispatchInfoOf,
Expand Down Expand Up @@ -62,7 +65,7 @@ impl<AccountId, Call, Extra, SelfContainedSignedInfo, Origin> traits::Applyable
where
AccountId: Member + MaybeDisplay,
Call: Member
+ Dispatchable<RuntimeOrigin = Origin>
+ Dispatchable<RuntimeOrigin = Origin, PostInfo = PostDispatchInfo>
+ SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,
Extra: SignedExtension<AccountId = AccountId, Call = Call>,
Origin: From<Option<AccountId>>,
Expand Down Expand Up @@ -148,7 +151,26 @@ where
TransactionValidityError::Invalid(InvalidTransaction::BadProof),
)?;
let post_info = match res {
Ok(info) => info,
Ok(PostDispatchInfo {
actual_weight,
pays_fee,
}) => {
if let Some(weight) = &actual_weight {
// Ethereum extrinsic size is accounted twice for proof size,
// so we need to substract it's size here.
PostDispatchInfo {
actual_weight: Some(
weight.saturating_sub(Weight::from_parts(0, len as u64)),
),
pays_fee,
}
} else {
PostDispatchInfo {
actual_weight,
pays_fee,
}
}
}
Err(err) => err.post_info,
};
Extra::post_dispatch(
Expand Down
Loading