Skip to content

Commit

Permalink
Remove WeightToFee (paritytech#1713)
Browse files Browse the repository at this point in the history
* Remove WeightToFee

* Remove leftover
  • Loading branch information
serban300 committed Apr 10, 2024
1 parent b633bc1 commit 5d8fda4
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 33 deletions.
21 changes: 1 addition & 20 deletions bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use frame_support::{
dispatch::DispatchClass,
parameter_types,
sp_runtime::{MultiAddress, MultiSigner},
weights::{constants, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial},
weights::constants,
};
use frame_system::limits;

Expand Down Expand Up @@ -80,25 +80,6 @@ parameter_types! {
.build_or_panic();
}

/// [`WeightToFee`] should reflect cumulus/bridge-hub-* [`WeightToFee`]
pub struct WeightToFee;
impl WeightToFeePolynomial for WeightToFee {
type Balance = Balance;
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
pub const CENTS: Balance = polkadot_runtime_constants::currency::CENTS;

// In BridgeHub, we map the extrinsic base weight to 1/100 CENT.
let p = CENTS;
let q = 100 * Balance::from(constants::ExtrinsicBaseWeight::get().ref_time());
smallvec::smallvec![WeightToFeeCoefficient {
degree: 1,
negative: false,
coeff_frac: Perbill::from_rational(p % q, q),
coeff_integer: p / q,
}]
}
}

/// Public key of the chain account that may be used to verify signatures.
pub type AccountSigner = MultiSigner;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.

#![allow(unused_macros)] // TODO (https://github.com/paritytech/parity-bridges-common/issues/1629): remove me

use async_trait::async_trait;
use std::sync::Arc;

Expand Down
1 change: 0 additions & 1 deletion bridges/relays/client-bridge-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ impl ChainWithMessages for BridgeHubRococo {
const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
bp_bridge_hub_rococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;

type WeightToFee = bp_bridge_hub_rococo::WeightToFee;
// TODO: fix (https://github.com/paritytech/parity-bridges-common/issues/1640)
type WeightInfo = ();
}
Expand Down
1 change: 0 additions & 1 deletion bridges/relays/client-bridge-hub-wococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ impl ChainWithMessages for BridgeHubWococo {
const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
bp_bridge_hub_wococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;

type WeightToFee = bp_bridge_hub_wococo::WeightToFee;
// TODO: fix (https://github.com/paritytech/parity-bridges-common/issues/1640)
type WeightInfo = ();
}
Expand Down
1 change: 0 additions & 1 deletion bridges/relays/client-millau/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ impl ChainWithMessages for Millau {
bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
type WeightToFee = bp_millau::WeightToFee;
type WeightInfo = ();
}

Expand Down
1 change: 0 additions & 1 deletion bridges/relays/client-rialto-parachain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ impl ChainWithMessages for RialtoParachain {
bp_rialto_parachain::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
bp_rialto_parachain::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
type WeightToFee = bp_rialto_parachain::WeightToFee;
type WeightInfo = ();
}

Expand Down
1 change: 0 additions & 1 deletion bridges/relays/client-rialto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ impl ChainWithMessages for Rialto {
bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
type WeightToFee = bp_rialto::WeightToFee;
type WeightInfo = ();
}

Expand Down
5 changes: 0 additions & 5 deletions bridges/relays/client-substrate/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use bp_runtime::{
Chain as ChainBase, EncodedOrDecodedCall, HashOf, TransactionEra, TransactionEraOf,
};
use codec::{Codec, Encode};
use frame_support::weights::WeightToFee;
use jsonrpsee::core::{DeserializeOwned, Serialize};
use num_traits::Zero;
use sc_transaction_pool_api::TransactionStatus;
Expand Down Expand Up @@ -111,16 +110,12 @@ pub trait ChainWithMessages: Chain {
/// `ChainWithMessages`.
const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce;

/// Type that is used by the chain, to convert from weight to fee.
type WeightToFee: WeightToFee<Balance = Self::Balance>;
/// Weights of message pallet calls.
type WeightInfo: pallet_bridge_messages::WeightInfoExt;
}

/// Call type used by the chain.
pub type CallOf<C> = <C as Chain>::Call;
/// Weight-to-Fee type used by the chain.
pub type WeightToFeeOf<C> = <C as ChainWithMessages>::WeightToFee;
/// Transaction status of the chain.
pub type TransactionStatusOf<C> = TransactionStatus<HashOf<C>, HashOf<C>>;

Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/client-substrate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub use crate::{
chain::{
AccountKeyPairOf, BlockWithJustification, CallOf, Chain, ChainWithBalances,
ChainWithGrandpa, ChainWithMessages, ChainWithTransactions, RelayChain, SignParam,
TransactionStatusOf, UnsignedTransaction, WeightToFeeOf,
TransactionStatusOf, UnsignedTransaction,
},
client::{ChainRuntimeVersion, Client, OpaqueGrandpaAuthoritiesSet, Subscription},
error::{Error, Result},
Expand Down

0 comments on commit 5d8fda4

Please sign in to comment.