Repository: gakonst/ethers-rs
Pull request #1805 (2022-10-24 03:11:44)

chore(deps): bump rlp from 0.5.1 to 0.5.2
Bumps [rlp](https://github.com/paritytech/parity-common) from 0.5.1 to 0.5.2.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/paritytech/parity-common/commit/86676b08e89cb99fdff0c882453ad0746dd070cf"><code>86676b0</code></a> rlp: release 0.5.2</li>
<li><a href="https://github.com/paritytech/parity-common/commit/7b10e2b1eefac7db9715b9edcaa39ed8bf966dbf"><code>7b10e2b</code></a> build(deps): bump Swatinem/rust-cache from 2.0.0 to 2.0.1 (<a href="https://github-redirect.dependabot.com/paritytech/parity-common/issues/683">#683</a>)</li>
<li><a href="https://github.com/paritytech/parity-common/commit/baebea7c3c0f90d825b7024a5ffe97870f819317"><code>baebea7</code></a> Add if_ethbloom conditional macro (<a href="https://github-redirect.dependabot.com/paritytech/parity-common/issues/682">#682</a>)</li>
<li><a href="https://github.com/paritytech/parity-common/commit/6aa58bfeaa870b4f7387e50319004151443f7297"><code>6aa58bf</code></a> release is coming (<a href="https://github-redirect.dependabot.com/paritytech/parity-common/issues/680">#680</a>)</li>
<li><a href="https://github.com/paritytech/parity-common/commit/738e7a3fc6e732d1637bced06e5ed4f6196eddcf"><code>738e7a3</code></a> build(deps): update lru requirement from 0.7 to 0.8 (<a href="https://github-redirect.dependabot.com/paritytech/parity-common/issues/675">#675</a>)</li>
<li><a href="https://github.com/paritytech/parity-common/commit/4d799dc082ba0a54bb305dc218947e5828ec3143"><code>4d799dc</code></a> parity-util-mem: remove wee_alloc (<a href="https://github-redirect.dependabot.com/paritytech/parity-common/issues/678">#678</a>)</li>
<li><a href="https://github.com/paritytech/parity-common/commit/6e5fe5013530f81c929ec8255aa80b7afc5153d8"><code>6e5fe50</code></a> build(deps): update criterion requirement from 0.3.0 to 0.4.0 (<a href="https://github-redirect.dependabot.com/paritytech/parity-common/issues/676">#676</a>)</li>
<li><a href="https://github.com/paritytech/parity-common/commit/62aa409ac8ee3b9e5227ba81a6c9512ec0828c2e"><code>62aa409</code></a> kvdb-rocksdb: do not attepmt to repair (<a href="https://github-redirect.dependabot.com/paritytech/parity-common/issues/667">#667</a>)</li>
<li><a href="https://github.com/paritytech/parity-common/commit/7a9cc3b03c5311c24623c66fe8a750903cf34484"><code>7a9cc3b</code></a> ethereum-types: make ethbloom optional (<a href="https://github-redirect.dependabot.com/paritytech/parity-common/issues/625">#625</a>)</li>
<li><a href="https://github.com/paritytech/parity-common/commit/9642a0e53e33c9663307e7036d01475a2326dad8"><code>9642a0e</code></a> Upgrade quickcheck in uint, fixed-hash (<a href="https://github-redirect.dependabot.com/paritytech/parity-common/issues/674">#674</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/paritytech/parity-common/compare/rlp-v0.5.1...rlp-v0.5.2">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=rlp&package-manager=cargo&previous-version=0.5.1&new-version=0.5.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 46ff1884..06169b9e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -93,6 +93,7 @@
 -   [#1632](https://github.com/gakonst/ethers-rs/pull/1632) Re-export `H32` from `ethabi`.
 -   [#1634](https://github.com/gakonst/ethers-rs/pull/1634) Derive missing `Clone`, `Copy` and `Debug` impls in ethers-etherscan.
 -   Bytes debug format now displays hex literals [#1658](https://github.com/gakonst/ethers-rs/pull/1658)
+-   Fix `get_logs_paginated` trying to fetch beyond the latest block
 
 ## ethers-contract-abigen
 
diff --git a/Cargo.lock b/Cargo.lock
index 3db56c4d..6d26c424 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -186,9 +186,9 @@ checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
 
 [[package]]
 name = "base64"
-version = "0.13.0"
+version = "0.13.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
+checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
 
 [[package]]
 name = "base64ct"
@@ -1392,7 +1392,7 @@ version = "1.0.0"
 dependencies = [
  "async-trait",
  "auto_impl 1.0.1",
- "base64 0.13.0",
+ "base64 0.13.1",
  "bytes",
  "ethers-core",
  "futures-channel",
@@ -3094,7 +3094,7 @@ version = "0.11.12"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc"
 dependencies = [
- "base64 0.13.0",
+ "base64 0.13.1",
  "bytes",
  "encoding_rs",
  "futures-core",
@@ -3167,9 +3167,9 @@ dependencies = [
 
 [[package]]
 name = "rlp"
-version = "0.5.1"
+version = "0.5.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "999508abb0ae792aabed2460c45b89106d97fe4adac593bdaef433c2605847b5"
+checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec"
 dependencies = [
  "bytes",
  "rustc-hex",
@@ -3203,7 +3203,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "1db30db44ea73551326269adcf7a2169428a054f14faf9e1768f2163494f2fa2"
 dependencies = [
  "async-trait",
- "base64 0.13.0",
+ "base64 0.13.1",
  "bytes",
  "crc32fast",
  "futures",
@@ -3259,7 +3259,7 @@ version = "0.48.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a5ae95491c8b4847931e291b151127eccd6ff8ca13f33603eb3d0035ecb05272"
 dependencies = [
- "base64 0.13.0",
+ "base64 0.13.1",
  "bytes",
  "chrono",
  "digest 0.9.0",
@@ -3312,7 +3312,7 @@ version = "1.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "e7522c9de787ff061458fe9a829dc790a3f5b22dc571694fc5883f448b94d9a9"
 dependencies = [
- "base64 0.13.0",
+ "base64 0.13.1",
 ]
 
 [[package]]
@@ -4212,7 +4212,7 @@ version = "0.17.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0"
 dependencies = [
- "base64 0.13.0",
+ "base64 0.13.1",
  "byteorder",
  "bytes",
  "http",
diff --git a/README.md b/README.md
index 7171cf9c..a13e15e0 100644
--- a/README.md
+++ b/README.md
@@ -175,7 +175,7 @@ issues itself: `cargo +nightly clippy --fix -Z unstable-options`
 
 ## Related Projects
 
-This library would not have been possibly without the great work done in:
+This library would not have been possible without the great work done in:
 
 -   [`ethers.js`](https://github.com/ethers-io/ethers.js/)
 -   [`rust-web3`](https://github.com/tomusdrw/rust-web3/)
diff --git a/ethers-core/Cargo.toml b/ethers-core/Cargo.toml
index da1eda32..1b94812c 100644
--- a/ethers-core/Cargo.toml
+++ b/ethers-core/Cargo.toml
@@ -13,7 +13,7 @@ keywords = ["ethereum", "web3", "celo", "ethers"]
 [dependencies]
 # Pin FastRLP to 0.1.2 when it was still Apache.
 open-fastrlp = { version = "=0.1.2", features = ["std", "derive", "ethereum-types"] }
-rlp = { version = "0.5.0", default-features = false, features = ["std"] }
+rlp = { version = "0.5.2", default-features = false, features = ["std"] }
 ethabi = { version = "17.2.0", default-features = false, features = ["full-serde", "rlp"] }
 arrayvec = { version = "0.7.2", default-features = false }
 rlp-derive = { version = "0.1.0", default-features = false }
diff --git a/ethers-providers/src/log_query.rs b/ethers-providers/src/log_query.rs
index 43cf7086..ea8c145a 100644
--- a/ethers-providers/src/log_query.rs
+++ b/ethers-providers/src/log_query.rs
@@ -93,7 +93,7 @@ where
                         // this is okay because we will only enter this state when the filter is
                         // paginatable i.e. from block is set
                         let from_block = self.filter.get_from_block().unwrap();
-                        let to_block = from_block + self.page_size;
+                        let to_block = std::cmp::min(from_block + self.page_size, last_block);
                         self.from_block = Some(to_block + 1);
 
                         let filter = self.filter.clone().from_block(from_block).to_block(to_block);
@@ -122,7 +122,7 @@ where
                         // load new logs if there are still more pages to go through
                         // can safely assume this will always be set in this state
                         let from_block = self.from_block.unwrap();
-                        let to_block = from_block + self.page_size;
+                        let to_block = std::cmp::min(from_block + self.page_size, self.last_block.unwrap());
 
                         // no more pages to load, and everything is consumed
                         // can safely assume this will always be set in this state


Test patch:
diff --git a/ethers-providers/tests/log_query.rs b/ethers-providers/tests/log_query.rs
new file mode 100644
index 00000000..641272c6
--- /dev/null
+++ b/ethers-providers/tests/log_query.rs
@@ -0,0 +1,21 @@
+#![cfg(not(target_arch = "wasm32"))]
+use ethers_core::{
+    types::{Filter, BlockNumber},
+    utils::Anvil,
+};
+use ethers_providers::{Http, Middleware, Provider, StreamExt};
+use std::convert::TryFrom;
+
+#[tokio::test]
+async fn get_logs_paginated() {
+    let geth = Anvil::new().block_time(20u64).spawn();
+    let provider = Provider::<Http>::try_from(geth.endpoint()).unwrap();
+
+    let filter = Filter::new().from_block(BlockNumber::Latest);
+    // try to get beyond the number of blocks available
+    let mut stream = provider.get_logs_paginated(&filter, 10);
+    let res = stream.next().await;
+    assert!(res.is_some());
+    let log = res.unwrap();
+    assert!(log.is_ok());
+}