diff --git a/node/src/components/block_validator/state.rs b/node/src/components/block_validator/state.rs index 489d51a006..6b01b88736 100644 --- a/node/src/components/block_validator/state.rs +++ b/node/src/components/block_validator/state.rs @@ -197,7 +197,10 @@ impl BlockValidationState { .transaction_v1_config .get_max_transaction_count(supported_lane); if lane_count_limit < transactions as u64 { - warn!("too many transactions in lane: {lane_count_limit}"); + warn!( + supported_lane, + lane_count_limit, transactions, "too many transactions in lane" + ); return Err(()); } } @@ -674,11 +677,12 @@ mod tests { } // Please note: values in the following test cases must match the production chainspec. - const MAX_LARGE_COUNT: u64 = 3; + const MAX_LARGE_COUNT: u64 = 1; const MAX_AUCTION_COUNT: u64 = 145; const MAX_INSTALL_UPGRADE_COUNT: u64 = 1; const MAX_MINT_COUNT: u64 = 650; + #[derive(Debug)] struct TestCase { mint_count: u64, auction_count: u64, @@ -760,13 +764,13 @@ mod tests { }, }; - const LESS_THAN_MAX_STANDARD: TestCase = TestCase { - standard_count: FULL_STANDARD.standard_count - 1, - state_validator: |(state, responder)| { - responder.is_none() && matches!(state, BlockValidationState::InProgress { .. }) - }, - ..FULL_STANDARD - }; + // const LESS_THAN_MAX_STANDARD: TestCase = TestCase { + // standard_count: FULL_STANDARD.standard_count - 1, + // state_validator: |(state, responder)| { + // responder.is_none() && matches!(state, BlockValidationState::InProgress { .. }) + // }, + // ..FULL_STANDARD + // }; const TOO_MANY_STANDARD: TestCase = TestCase { standard_count: FULL_STANDARD.standard_count + 1, @@ -850,7 +854,8 @@ mod tests { let mut rng = TestRng::new(); run_test_case(TOO_MANY_STANDARD, &mut rng); run_test_case(FULL_STANDARD, &mut rng); - run_test_case(LESS_THAN_MAX_STANDARD, &mut rng); + // NOTE: current prod chainspec has a limit of 1 large transaction, so one less is 0 which + // makes the test invalid run_test_case(LESS_THAN_MAX_STANDARD, &mut rng); } #[test] @@ -943,7 +948,7 @@ mod tests { fn should_add_responder_if_in_progress() { let mut rng = TestRng::new(); let mut fixture = Fixture::new(&mut rng); - let (mut state, _maybe_responder) = fixture.new_state(2, 2, 1, 2); + let (mut state, _maybe_responder) = fixture.new_state(2, 2, 1, 1); assert!(matches!(state, BlockValidationState::InProgress { .. })); assert_eq!(state.responder_count(), 1); @@ -984,7 +989,7 @@ mod tests { fn should_add_new_holder_if_in_progress() { let mut rng = TestRng::new(); let mut fixture = Fixture::new(&mut rng); - let (mut state, _maybe_responder) = fixture.new_state(2, 2, 1, 2); + let (mut state, _maybe_responder) = fixture.new_state(2, 2, 1, 1); assert!(matches!(state, BlockValidationState::InProgress { .. })); assert_eq!(state.holders_mut().unwrap().len(), 1); @@ -1001,7 +1006,7 @@ mod tests { fn should_not_change_holder_state() { let mut rng = TestRng::new(); let mut fixture = Fixture::new(&mut rng); - let (mut state, _maybe_responder) = fixture.new_state(2, 2, 1, 2); + let (mut state, _maybe_responder) = fixture.new_state(2, 2, 1, 1); assert!(matches!(state, BlockValidationState::InProgress { .. })); let (holder, holder_state) = state .holders_mut() @@ -1024,7 +1029,7 @@ mod tests { fn should_start_fetching() { let mut rng = TestRng::new(); let mut fixture = Fixture::new(&mut rng); - let (mut state, _maybe_responder) = fixture.new_state(2, 2, 1, 2); + let (mut state, _maybe_responder) = fixture.new_state(2, 2, 1, 1); assert!(matches!(state, BlockValidationState::InProgress { .. })); let (holder, holder_state) = state .holders_mut() @@ -1052,7 +1057,7 @@ mod tests { .. } => { assert_eq!(holder, original_holder); - assert_eq!(missing_transactions.len(), 7); + assert_eq!(missing_transactions.len(), 6); } _ => panic!("unexpected return value"), } @@ -1066,7 +1071,7 @@ mod tests { fn start_fetching_should_return_ongoing_if_any_holder_in_asked_state() { let mut rng = TestRng::new(); let mut fixture = Fixture::new(&mut rng); - let (mut state, _maybe_responder) = fixture.new_state(2, 2, 1, 2); + let (mut state, _maybe_responder) = fixture.new_state(2, 2, 1, 1); assert!(matches!(state, BlockValidationState::InProgress { .. })); // Change the current (only) holder's state to `Asked`. @@ -1111,7 +1116,7 @@ mod tests { fn start_fetching_should_return_unable_if_all_holders_in_failed_state() { let mut rng = TestRng::new(); let mut fixture = Fixture::new(&mut rng); - let (mut state, _maybe_responder) = fixture.new_state(2, 2, 1, 2); + let (mut state, _maybe_responder) = fixture.new_state(2, 2, 1, 1); assert!(matches!(state, BlockValidationState::InProgress { .. })); // Set the original holder's state to `Failed` and add some more failed. @@ -1192,7 +1197,7 @@ mod tests { fn unrelated_transaction_added_should_not_change_state() { let mut rng = TestRng::new(); let mut fixture = Fixture::new(&mut rng); - let (mut state, _maybe_responder) = fixture.new_state(2, 2, 1, 2); + let (mut state, _maybe_responder) = fixture.new_state(2, 2, 1, 1); let (appendable_block_before, missing_transactions_before, holders_before) = match &state { BlockValidationState::InProgress { appendable_block, diff --git a/node/src/components/block_validator/tests.rs b/node/src/components/block_validator/tests.rs index b73c36f136..07116d0655 100644 --- a/node/src/components/block_validator/tests.rs +++ b/node/src/components/block_validator/tests.rs @@ -858,7 +858,7 @@ async fn transfer_transaction_mixup_and_replay() { let transfer_v1 = new_v1_transfer(&mut rng, timestamp, ttl); // First we make sure that our transfers and transactions would normally be valid. - let transactions = vec![deploy.clone(), transaction_v1.clone()]; + let transactions = vec![transaction_v1.clone()]; let transfers = vec![transfer_orig.clone(), transfer_v1.clone()]; let mut context = ValidationContext::new() .with_num_validators(&mut rng, 1) @@ -1146,7 +1146,6 @@ async fn should_validate_block_with_signatures() { let mut rng = TestRng::new(); let ttl = TimeDiff::from_millis(200); let timestamp = Timestamp::from(1000); - let deploy = new_deploy(&mut rng, timestamp, ttl); let transaction_v1 = new_v1_standard(&mut rng, timestamp, ttl); let transfer = new_transfer(&mut rng, timestamp, ttl); let transfer_v1 = new_v1_transfer(&mut rng, timestamp, ttl); @@ -1154,7 +1153,7 @@ async fn should_validate_block_with_signatures() { let context = ValidationContext::new() .with_num_validators(&mut rng, 3) .with_past_blocks(&mut rng, 0, 5, 0.into()) - .with_transactions(vec![deploy, transaction_v1]) + .with_transactions(vec![transaction_v1]) .with_transfers(vec![transfer, transfer_v1]) .include_all_transactions() .include_all_transfers(); @@ -1173,7 +1172,6 @@ async fn should_fetch_missing_signature() { let mut rng = TestRng::new(); let ttl = TimeDiff::from_millis(200); let timestamp = Timestamp::from(1000); - let deploy = new_deploy(&mut rng, timestamp, ttl); let transaction_v1 = new_v1_standard(&mut rng, timestamp, ttl); let transfer = new_transfer(&mut rng, timestamp, ttl); let transfer_v1 = new_v1_transfer(&mut rng, timestamp, ttl); @@ -1181,7 +1179,7 @@ async fn should_fetch_missing_signature() { let context = ValidationContext::new() .with_num_validators(&mut rng, 3) .with_past_blocks(&mut rng, 0, 5, 0.into()) - .with_transactions(vec![deploy, transaction_v1]) + .with_transactions(vec![transaction_v1]) .with_transfers(vec![transfer, transfer_v1]) .include_all_transactions() .include_all_transfers(); @@ -1253,7 +1251,6 @@ async fn should_validate_with_delayed_block() { let mut rng = TestRng::new(); let ttl = TimeDiff::from_millis(200); let timestamp = Timestamp::from(1000); - let deploy = new_deploy(&mut rng, timestamp, ttl); let transaction_v1 = new_v1_standard(&mut rng, timestamp, ttl); let transfer = new_transfer(&mut rng, timestamp, ttl); let transfer_v1 = new_v1_transfer(&mut rng, timestamp, ttl); @@ -1262,7 +1259,7 @@ async fn should_validate_with_delayed_block() { .with_num_validators(&mut rng, 3) .with_past_blocks(&mut rng, 0, 4, 0.into()) .with_delayed_blocks(&mut rng, 5, 5, 0.into()) - .with_transactions(vec![deploy, transaction_v1]) + .with_transactions(vec![transaction_v1]) .with_transfers(vec![transfer, transfer_v1]) .include_all_transactions() .include_all_transfers();