Skip to content

Commit

Permalink
Add kitchensink config
Browse files Browse the repository at this point in the history
  • Loading branch information
pgherveou committed Oct 4, 2024
1 parent 8c35821 commit 57432d9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
39 changes: 38 additions & 1 deletion substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ use pallet_identity::legacy::IdentityInfo;
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_nfts::PalletFeatures;
use pallet_nis::WithMaximumOf;
use pallet_revive::evm::runtime::EthExtra;
use pallet_session::historical as pallet_session_historical;
// Can't use `FungibleAdapter` here until Treasury pallet migrates to fungibles
// <https://github.com/paritytech/polkadot-sdk/issues/226>
Expand Down Expand Up @@ -1471,6 +1472,7 @@ where
),
),
frame_metadata_hash_extension::CheckMetadataHash::new(false),
pallet_revive::evm::runtime::CheckEthTransact::<Runtime>::default(),
);
let raw_payload = SignedPayload::new(call, extra)
.map_err(|e| {
Expand Down Expand Up @@ -2531,6 +2533,16 @@ mod runtime {
pub type Revive = pallet_revive::Pallet<Runtime>;
}

impl TryInto<pallet_revive::Call<Runtime>> for RuntimeCall {
type Error = ();
fn try_into(self) -> Result<pallet_revive::Call<Runtime>, Self::Error> {
match self {
RuntimeCall::Revive(call) => Ok(call),
_ => Err(()),
}
}
}

/// The address format for describing accounts.
pub type Address = sp_runtime::MultiAddress<AccountId, AccountIndex>;
/// Block header type as expected by this runtime.
Expand Down Expand Up @@ -2559,11 +2571,36 @@ pub type SignedExtra = (
pallet_asset_conversion_tx_payment::ChargeAssetTxPayment<Runtime>,
>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
pallet_revive::evm::runtime::CheckEthTransact<Runtime>,
);

#[derive(Clone, PartialEq, Eq, Debug)]
pub struct EthSignedExtra;

impl EthExtra for EthSignedExtra {
type Config = Runtime;
type Extra = SignedExtra;

fn get_eth_transact_extra(nonce: u32, eth_fee: u128) -> Self::Extra {
(
frame_system::CheckNonZeroSender::<Runtime>::new(),
frame_system::CheckSpecVersion::<Runtime>::new(),
frame_system::CheckTxVersion::<Runtime>::new(),
frame_system::CheckGenesis::<Runtime>::new(),
frame_system::CheckEra::from(crate::generic::Era::Immortal),
frame_system::CheckNonce::<Runtime>::from(nonce),
frame_system::CheckWeight::<Runtime>::new(),
pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::<Runtime>::from(0, None)
.into(),
frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(false),
pallet_revive::evm::runtime::CheckEthTransact::<Runtime>::from(eth_fee),
)
}
}

/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
pallet_revive::evm::runtime::UncheckedExtrinsic<RuntimeCall, EthSignedExtra>;

/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<RuntimeCall, SignedExtra>;
Expand Down
13 changes: 12 additions & 1 deletion substrate/frame/revive/src/evm/api/byte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,21 @@ impl_hex!(Bytes, Vec<u8>, vec![]);
impl_hex!(Bytes256, [u8; 256], [0u8; 256]);

#[test]
fn serialize_byte() {
fn serialize_works() {
let a = Byte(42);
let s = serde_json::to_string(&a).unwrap();
assert_eq!(s, "\"0x2a\"");
let b = serde_json::from_str::<Byte>(&s).unwrap();
assert_eq!(a, b);

let a = Bytes(b"bello world".to_vec());
let s = serde_json::to_string(&a).unwrap();
assert_eq!(s, "\"0x62656c6c6f20776f726c64\"");
let b = serde_json::from_str::<Bytes>(&s).unwrap();
assert_eq!(a, b);

let a = Bytes256([42u8; 256]);
let s = serde_json::to_string(&a).unwrap();
let b = serde_json::from_str::<Bytes256>(&s).unwrap();
assert_eq!(a, b);
}

0 comments on commit 57432d9

Please sign in to comment.