Skip to content

Commit dd3bd6b

Browse files
authored
Merge branch 'master' into GH-598
2 parents 858adfa + e82da77 commit dd3bd6b

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

.github/workflows/ci-matrix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
matrix:
1515
target:
1616
- { name: linux, os: ubuntu-22.04 }
17-
- { name: macos, os: macos-13 }
17+
- { name: macos, os: macos-latest }
1818
- { name: windows, os: windows-2022 }
1919

2020
name: Build node on ${{ matrix.target.os }}

node/src/blockchain/blockchain_bridge.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@ impl BlockchainBridge {
513513

514514
pub fn extract_max_block_count(error: BlockchainInterfaceError) -> Option<u64> {
515515
let regex_result =
516-
Regex::new(r".* (max: |allowed for your plan: |is limited to |block range limit \(|exceeds max block range )(?P<max_block_count>\d+).*")
517-
.expect("Invalid regex");
516+
Regex::new(r".* (max: |allowed for your plan: |is limited to |block range limit \(|exceeds max block range |maximum allowed is )(?P<max_block_count>\d+).*")
517+
.expect("Invalid regex");
518518
let max_block_count = match error {
519519
BlockchainInterfaceError::QueryFailed(msg) => match regex_result.captures(msg.as_str())
520520
{
@@ -1539,7 +1539,7 @@ mod tests {
15391539
system.run();
15401540
let after = SystemTime::now();
15411541
let expected_transactions = RetrievedBlockchainTransactions {
1542-
new_start_block: BlockMarker::Value(42 + 9_000_000 + 1),
1542+
new_start_block: BlockMarker::Value(42 + 9_000_000),
15431543
transactions: vec![
15441544
BlockchainTransaction {
15451545
block_number: 6040059,
@@ -1740,7 +1740,7 @@ mod tests {
17401740
let received_payments_message = accountant_recording.get_record::<ReceivedPayments>(0);
17411741
check_timestamp(before, received_payments_message.timestamp, after);
17421742
let expected_transactions = RetrievedBlockchainTransactions {
1743-
new_start_block: BlockMarker::Value(6 + 5000 + 1),
1743+
new_start_block: BlockMarker::Value(6 + 5000),
17441744
transactions: vec![BlockchainTransaction {
17451745
block_number: 2000,
17461746
from: earning_wallet.clone(),
@@ -2203,6 +2203,15 @@ mod tests {
22032203
assert_eq!(Some(100000), max_block_count);
22042204
}
22052205

2206+
#[test]
2207+
fn extract_max_block_range_for_nodies_error_response_v2() {
2208+
let result = BlockchainError::QueryFailed("RPC error: Error { code: ServerError(-32001), message: \"Block range too large: maximum allowed is 20000 blocks\", data: None }".to_string());
2209+
2210+
let max_block_count = BlockchainBridge::extract_max_block_count(result);
2211+
2212+
assert_eq!(Some(20000), max_block_count);
2213+
}
2214+
22062215
#[test]
22072216
fn extract_max_block_range_for_expected_batch_got_single_error_response() {
22082217
let result = BlockchainInterfaceError::QueryFailed(

node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,9 @@ impl BlockchainInterfaceWeb3 {
396396
) -> BlockMarker {
397397
let locally_determined_end_block_marker = match (start_block_marker, scan_range) {
398398
(BlockMarker::Value(start_block), BlockScanRange::Range(scan_range_number)) => {
399-
BlockMarker::Value(start_block + scan_range_number)
399+
// Subtract 1 because the range is inclusive: [start_block, end_block]
400+
// Example: If max range is 20000, we need start_block to start_block+20000-1 (ending up with 20000 blocks total)
401+
BlockMarker::Value(start_block + scan_range_number - 1)
400402
}
401403
(_, _) => BlockMarker::Uninitialized,
402404
};
@@ -562,8 +564,8 @@ mod tests {
562564
let start_block_marker = BlockMarker::Value(42);
563565
let scan_range = BlockScanRange::Range(1000);
564566
let block_response = "0x7d0"; // 2_000
565-
let expected_new_start_block = BlockMarker::Value(42 + 1000 + 1);
566-
let expected_log = "from start block: Number(42) to end block: Number(1042)";
567+
let expected_new_start_block = BlockMarker::Value(42 + 1000);
568+
let expected_log = "from start block: Number(42) to end block: Number(1041)";
567569
assert_on_retrieves_transactions(
568570
start_block_marker,
569571
scan_range,
@@ -1272,7 +1274,7 @@ mod tests {
12721274
Err(BlockchainInterfaceError::InvalidResponse),
12731275
&logger
12741276
),
1275-
BlockMarker::Value(150)
1277+
BlockMarker::Value(149)
12761278
);
12771279
assert_eq!(
12781280
Subject::calculate_end_block_marker(
@@ -1290,7 +1292,7 @@ mod tests {
12901292
Ok(120.into()),
12911293
&logger
12921294
),
1293-
BlockMarker::Value(50 + 10)
1295+
BlockMarker::Value(59)
12941296
);
12951297
}
12961298

0 commit comments

Comments
 (0)