diff --git a/crates/testing/src/block_builder/simple.rs b/crates/testing/src/block_builder/simple.rs index 10ea1132dd..e1207a4fc2 100644 --- a/crates/testing/src/block_builder/simple.rs +++ b/crates/testing/src/block_builder/simple.rs @@ -141,7 +141,7 @@ where &self, _parent_view: u64, _parent_hash: &VidCommitment, - _view_number: u64, + view_number: u64, ) -> Result, BuildError> { let transactions = self .transactions @@ -170,6 +170,7 @@ where fee_signature: TYPES::BuilderSignatureKey::sign_sequencing_fee_marketplace( &self.priv_key.clone(), fee_amount, + view_number, ) .expect("Failed to sign fee!"), }; diff --git a/crates/types/src/data.rs b/crates/types/src/data.rs index db891c8a0b..71b682aa19 100644 --- a/crates/types/src/data.rs +++ b/crates/types/src/data.rs @@ -801,7 +801,7 @@ pub mod null_block { use crate::{ traits::{ block_contents::BuilderFee, - node_implementation::{NodeType, Versions}, + node_implementation::{ConsensusTime, NodeType, Versions}, signature_key::BuilderSignatureKey, BlockPayload, }, @@ -840,8 +840,11 @@ pub mod null_block { ); if version >= V::Marketplace::VERSION { - match TYPES::BuilderSignatureKey::sign_sequencing_fee_marketplace(&priv_key, FEE_AMOUNT) - { + match TYPES::BuilderSignatureKey::sign_sequencing_fee_marketplace( + &priv_key, + FEE_AMOUNT, + *TYPES::View::genesis(), + ) { Ok(sig) => Some(BuilderFee { fee_amount: FEE_AMOUNT, fee_account: pub_key, diff --git a/crates/types/src/traits/signature_key.rs b/crates/types/src/traits/signature_key.rs index e9133e9286..52503c0cd5 100644 --- a/crates/types/src/traits/signature_key.rs +++ b/crates/types/src/traits/signature_key.rs @@ -227,8 +227,12 @@ pub trait BuilderSignatureKey: &self, signature: &Self::BuilderSignature, fee_amount: u64, + view_number: u64, ) -> bool { - self.validate_builder_signature(signature, &fee_amount.to_be_bytes()) + self.validate_builder_signature( + signature, + &aggregate_fee_data_marketplace(fee_amount, view_number), + ) } /// validate the bundle's signature using the builder's public key @@ -285,12 +289,15 @@ pub trait BuilderSignatureKey: /// sign fee offer for proposed payload (marketplace version) /// # Errors /// If unable to sign the data with the key - // TODO: this should include view number fn sign_sequencing_fee_marketplace( private_key: &Self::BuilderPrivateKey, fee_amount: u64, + view_number: u64, ) -> Result { - Self::sign_builder_message(private_key, &fee_amount.to_be_bytes()) + Self::sign_builder_message( + private_key, + &aggregate_fee_data_marketplace(fee_amount, view_number), + ) } /// sign transactions (marketplace version) @@ -340,6 +347,14 @@ fn aggregate_fee_data( fee_info } +/// Aggregate all inputs used for signature over fee data +fn aggregate_fee_data_marketplace(fee_amount: u64, view_number: u64) -> Vec { + let mut fee_info = Vec::new(); + fee_info.extend_from_slice(fee_amount.to_be_bytes().as_ref()); + fee_info.extend_from_slice(view_number.to_be_bytes().as_ref()); + fee_info +} + /// Aggregate all inputs used for signature over block info fn aggregate_block_info_data( block_size: u64,