Browse Source

consensus: ignore proposals with transactions exceeding cap

aggstam 3 năm trước cách đây
mục cha
commit
1bfef5dce3
2 tập tin đã thay đổi với 14 bổ sung1 xóa
  1. 10 0
      src/consensus/validator.rs
  2. 4 1
      src/error.rs

+ 10 - 0
src/consensus/validator.rs

@@ -375,6 +375,16 @@ impl ValidatorState {
             return Err(Error::ExtendedChainIndexNotFound)
         }
 
+        // Check that proposal transactions don't exceed limit
+        if proposal.block.txs.len() > constants::TXS_CAP {
+            warn!(
+                "receive_proposal(): Received proposal transactions exceed configured cap: {} - {}",
+                proposal.block.txs.len(),
+                constants::TXS_CAP
+            );
+            return Err(Error::ProposalTxsExceedCapError)
+        }
+
         // Verify proposal signature is valid based on producer public key
         // TODO: derive public key from proof
         if !lf.public_key.verify(proposal.header.as_bytes(), &lf.signature) {

+ 4 - 1
src/error.rs

@@ -256,9 +256,12 @@ pub enum Error {
     #[error("Proposal contains different coin creation eta")]
     ProposalDifferentCoinEtaError,
 
-    #[error("proposed coin is spent")]
+    #[error("Proposal contains spent coin")]
     ProposalIsSpent,
 
+    #[error("Proposal contains more transactions than configured cap")]
+    ProposalTxsExceedCapError,
+
     #[error("unable to verify transfer transaction")]
     TransferTxVerification,