@@ -30,8 +30,8 @@ use sp_domains::{
3030 ProofOfElection , RuntimeType , SealedBundleHeader , StakingHoldIdentifier ,
3131} ;
3232use sp_domains_fraud_proof:: fraud_proof:: {
33- FraudProof , InvalidBundlesFraudProof , InvalidDomainBlockHashProof , InvalidExtrinsicsRootProof ,
34- InvalidTotalRewardsProof , ValidBundleDigest ,
33+ FraudProof , InvalidBlockFeesProof , InvalidBundlesFraudProof , InvalidDomainBlockHashProof ,
34+ InvalidExtrinsicsRootProof , ValidBundleDigest ,
3535} ;
3636use sp_domains_fraud_proof:: {
3737 FraudProofExtension , FraudProofHostFunctions , FraudProofVerificationInfoRequest ,
@@ -68,6 +68,7 @@ frame_support::construct_runtime!(
6868 Balances : pallet_balances,
6969 Domains : pallet_domains,
7070 DomainExecutive : domain_pallet_executive,
71+ BlockFees : pallet_block_fees,
7172 }
7273) ;
7374
@@ -188,6 +189,7 @@ parameter_types! {
188189 pub const BlockReward : Balance = 10 * SSC ;
189190 pub const MaxPendingStakingOperation : u32 = 100 ;
190191 pub const MaxNominators : u32 = 5 ;
192+ pub const DomainChainByteFee : Balance = 1 ;
191193}
192194
193195pub struct MockRandomness ;
@@ -242,7 +244,7 @@ impl domain_pallet_executive::ExtrinsicStorageFees<Test> for ExtrinsicStorageFee
242244 ( None , DispatchInfo :: default ( ) )
243245 }
244246
245- fn on_storage_fees_charged ( _charged_fees : Balance ) { }
247+ fn on_storage_fees_charged ( _charged_fees : Balance , _tx_size : u32 ) { }
246248}
247249
248250impl domain_pallet_executive:: Config for Test {
@@ -253,6 +255,11 @@ impl domain_pallet_executive::Config for Test {
253255 type ExtrinsicStorageFees = ExtrinsicStorageFees ;
254256}
255257
258+ impl pallet_block_fees:: Config for Test {
259+ type Balance = Balance ;
260+ type DomainChainByteFee = DomainChainByteFee ;
261+ }
262+
256263pub ( crate ) fn new_test_ext ( ) -> sp_io:: TestExternalities {
257264 let t = frame_system:: GenesisConfig :: < Test > :: default ( )
258265 . build_storage ( )
@@ -295,6 +302,17 @@ impl FraudProofHostFunctions for MockDomainFraudProofExtension {
295302 . encode ( ) ,
296303 )
297304 }
305+ FraudProofVerificationInfoRequest :: ConsensusChainByteFeeExtrinsic ( _) => {
306+ FraudProofVerificationInfoResponse :: ConsensusChainByteFeeExtrinsic (
307+ UncheckedExtrinsic :: new_unsigned (
308+ pallet_block_fees:: Call :: < Test > :: set_next_consensus_chain_byte_fee {
309+ transaction_byte_fee : Default :: default ( ) ,
310+ }
311+ . into ( ) ,
312+ )
313+ . encode ( ) ,
314+ )
315+ }
298316 FraudProofVerificationInfoRequest :: DomainBundleBody { .. } => {
299317 FraudProofVerificationInfoResponse :: DomainBundleBody ( Default :: default ( ) )
300318 }
@@ -417,7 +435,7 @@ pub(crate) fn create_dummy_receipt(
417435 final_state_root : Default :: default ( ) ,
418436 execution_trace,
419437 execution_trace_root,
420- total_rewards : 0 ,
438+ block_fees : Default :: default ( ) ,
421439 }
422440}
423441
@@ -908,7 +926,7 @@ fn test_invalid_fraud_proof() {
908926}
909927
910928#[ test]
911- fn test_invalid_total_rewards_fraud_proof ( ) {
929+ fn test_invalid_block_fees_fraud_proof ( ) {
912930 let creator = 0u64 ;
913931 let operator_id = 1u64 ;
914932 let head_domain_number = 10 ;
@@ -927,11 +945,22 @@ fn test_invalid_total_rewards_fraud_proof() {
927945 let bad_receipt_hash = domain_block
928946 . execution_receipt
929947 . hash :: < DomainHashingFor < Test > > ( ) ;
930- let ( fraud_proof, root) = generate_invalid_total_rewards_fraud_proof :: < Test > (
948+ let ( fraud_proof, root) = generate_invalid_block_fees_fraud_proof :: < Test > (
931949 domain_id,
932950 bad_receipt_hash,
933951 // set different reward in the storage and generate proof for that value
934- domain_block. execution_receipt . total_rewards + 1 ,
952+ domain_runtime_primitives:: BlockFees :: new (
953+ domain_block
954+ . execution_receipt
955+ . block_fees
956+ . domain_execution_fee
957+ + 1 ,
958+ domain_block
959+ . execution_receipt
960+ . block_fees
961+ . consensus_storage_fee
962+ + 1 ,
963+ ) ,
935964 ) ;
936965 domain_block. execution_receipt . final_state_root = root;
937966 BlockTreeNodes :: < Test > :: insert ( bad_receipt_hash, domain_block) ;
@@ -942,23 +971,23 @@ fn test_invalid_total_rewards_fraud_proof() {
942971type FraudProofFor < T > =
943972 FraudProof < BlockNumberFor < T > , <T as frame_system:: Config >:: Hash , <T as Config >:: DomainHeader > ;
944973
945- fn generate_invalid_total_rewards_fraud_proof < T : Config > (
974+ fn generate_invalid_block_fees_fraud_proof < T : Config > (
946975 domain_id : DomainId ,
947976 bad_receipt_hash : ReceiptHashFor < T > ,
948- rewards : BalanceOf < T > ,
977+ block_fees : domain_runtime_primitives :: BlockFees < BalanceOf < T > > ,
949978) -> ( FraudProofFor < T > , T :: Hash ) {
950- let storage_key = sp_domains_fraud_proof:: fraud_proof:: operator_block_rewards_final_key ( ) ;
979+ let storage_key = sp_domains_fraud_proof:: fraud_proof:: operator_block_fees_final_key ( ) ;
951980 let mut root = T :: Hash :: default ( ) ;
952981 let mut mdb = PrefixedMemoryDB :: < T :: Hashing > :: default ( ) ;
953982 {
954983 let mut trie = TrieDBMutBuilderV1 :: new ( & mut mdb, & mut root) . build ( ) ;
955- trie. insert ( & storage_key, & rewards . encode ( ) ) . unwrap ( ) ;
984+ trie. insert ( & storage_key, & block_fees . encode ( ) ) . unwrap ( ) ;
956985 } ;
957986
958987 let backend = TrieBackendBuilder :: new ( mdb, root) . build ( ) ;
959988 let ( root, storage_proof) = storage_proof_for_key :: < T , _ > ( backend, StorageKey ( storage_key) ) ;
960989 (
961- FraudProof :: InvalidTotalRewards ( InvalidTotalRewardsProof {
990+ FraudProof :: InvalidBlockFees ( InvalidBlockFeesProof {
962991 domain_id,
963992 bad_receipt_hash,
964993 storage_proof,
0 commit comments