Skip to content

Commit

Permalink
disable with_fee_paid_by (#2187)
Browse files Browse the repository at this point in the history
* disable with_fee_paid_by

* fix clippy

* fix clippy

Co-authored-by: zqh <[email protected]>
  • Loading branch information
xlc and zqhxuyuan authored Jun 8, 2022
1 parent 92daa48 commit 7727abe
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 30 deletions.
32 changes: 17 additions & 15 deletions runtime/acala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{
AccountIdConversion, AccountIdLookup, BadOrigin, BlakeTwo256, Block as BlockT, Convert, SaturatedConversion,
StaticLookup, Verify,
StaticLookup,
},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, DispatchResult, FixedPointNumber, Perbill, Percent, Permill, Perquintill,
Expand Down Expand Up @@ -2179,23 +2179,25 @@ impl Convert<(Call, SignedExtra), Result<(EthereumTransactionMessage, SignedExtr
pub struct PayerSignatureVerification;

impl Convert<(Call, SignedExtra), Result<(), InvalidTransaction>> for PayerSignatureVerification {
fn convert((call, extra): (Call, SignedExtra)) -> Result<(), InvalidTransaction> {
fn convert((call, _extra): (Call, SignedExtra)) -> Result<(), InvalidTransaction> {
if let Call::TransactionPayment(module_transaction_payment::Call::with_fee_paid_by {
call,
payer_addr,
payer_sig,
call: _,
payer_addr: _,
payer_sig: _,
}) = call
{
let payer_account: [u8; 32] = payer_addr
.encode()
.as_slice()
.try_into()
.map_err(|_| InvalidTransaction::BadSigner)?;
// payer signature is aim at inner call of `with_fee_paid_by` call.
let raw_payload = SignedPayload::new(*call, extra).map_err(|_| InvalidTransaction::BadSigner)?;
if !raw_payload.using_encoded(|payload| payer_sig.verify(payload, &payer_account.into())) {
return Err(InvalidTransaction::BadProof);
}
// Disabled for now
return Err(InvalidTransaction::BadProof);
// let payer_account: [u8; 32] = payer_addr
// .encode()
// .as_slice()
// .try_into()
// .map_err(|_| InvalidTransaction::BadSigner)?;
// // payer signature is aim at inner call of `with_fee_paid_by` call.
// let raw_payload = SignedPayload::new(*call, extra).map_err(|_|
// InvalidTransaction::BadSigner)?; if !raw_payload.using_encoded(|payload|
// payer_sig.verify(payload, &payer_account.into())) { return Err(InvalidTransaction::
// BadProof); }
}
Ok(())
}
Expand Down
32 changes: 17 additions & 15 deletions runtime/karura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{
AccountIdConversion, AccountIdLookup, BadOrigin, BlakeTwo256, Block as BlockT, Convert, SaturatedConversion,
StaticLookup, Verify,
StaticLookup,
},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, DispatchResult, FixedPointNumber, Perbill, Percent, Permill, Perquintill,
Expand Down Expand Up @@ -2221,23 +2221,25 @@ impl Convert<(Call, SignedExtra), Result<(EthereumTransactionMessage, SignedExtr
pub struct PayerSignatureVerification;

impl Convert<(Call, SignedExtra), Result<(), InvalidTransaction>> for PayerSignatureVerification {
fn convert((call, extra): (Call, SignedExtra)) -> Result<(), InvalidTransaction> {
fn convert((call, _extra): (Call, SignedExtra)) -> Result<(), InvalidTransaction> {
if let Call::TransactionPayment(module_transaction_payment::Call::with_fee_paid_by {
call,
payer_addr,
payer_sig,
call: _,
payer_addr: _,
payer_sig: _,
}) = call
{
let payer_account: [u8; 32] = payer_addr
.encode()
.as_slice()
.try_into()
.map_err(|_| InvalidTransaction::BadSigner)?;
// payer signature is aim at inner call of `with_fee_paid_by` call.
let raw_payload = SignedPayload::new(*call, extra).map_err(|_| InvalidTransaction::BadSigner)?;
if !raw_payload.using_encoded(|payload| payer_sig.verify(payload, &payer_account.into())) {
return Err(InvalidTransaction::BadProof);
}
// Disabled for now
return Err(InvalidTransaction::BadProof);
// let payer_account: [u8; 32] = payer_addr
// .encode()
// .as_slice()
// .try_into()
// .map_err(|_| InvalidTransaction::BadSigner)?;
// // payer signature is aim at inner call of `with_fee_paid_by` call.
// let raw_payload = SignedPayload::new(*call, extra).map_err(|_|
// InvalidTransaction::BadSigner)?; if !raw_payload.using_encoded(|payload|
// payer_sig.verify(payload, &payer_account.into())) { return Err(InvalidTransaction::
// BadProof); }
}
Ok(())
}
Expand Down

0 comments on commit 7727abe

Please sign in to comment.