Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
e383a9e
Add run subcommand
elmattic Jul 4, 2025
6c24d61
Add more tests and framework
elmattic Jul 11, 2025
92e36d9
Add EthNewBlockFilter test
elmattic Jul 11, 2025
1166dbe
Add method filtering
elmattic Jul 15, 2025
8025482
Check for effective filter change
elmattic Jul 15, 2025
a103025
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Jul 15, 2025
d2aa97f
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Jul 16, 2025
7069381
Refactor
elmattic Jul 16, 2025
da92434
Add pending tx filter test (wip)
elmattic Jul 17, 2025
fefbbc2
Fix params
elmattic Jul 17, 2025
155c539
Simplify calls
elmattic Jul 17, 2025
4a316c0
Add filter change check
elmattic Jul 18, 2025
032778d
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Jul 28, 2025
9c0afbf
Complete test
elmattic Jul 28, 2025
e893aeb
Add tests for eth_getFilterLogs
elmattic Jul 28, 2025
722ca1b
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Jul 28, 2025
1c90178
Fix incorrect used method
elmattic Jul 29, 2025
797ee37
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Jul 29, 2025
cc1b2ba
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Jul 29, 2025
4f0c2a4
Remove use imports
elmattic Jul 29, 2025
b65cc97
Refactor subcommand arguments
elmattic Jul 29, 2025
f5d86d9
Refactor to pass the test tx using cli
elmattic Jul 29, 2025
db3655e
Remove comments
elmattic Jul 29, 2025
c3913bb
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Jul 29, 2025
884de14
Remove comments and fix ambiguous empty vec deserial
elmattic Jul 29, 2025
e8b6bb6
Rework test
elmattic Jul 30, 2025
cdea50f
Add a topic flag
elmattic Jul 30, 2025
ab02767
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Jul 31, 2025
4fb1c99
Add developer documentation
elmattic Jul 31, 2025
cc6defe
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Jul 31, 2025
95c36d9
Add subcommand help
elmattic Aug 1, 2025
ee14d70
Fix typos
elmattic Aug 1, 2025
e172cde
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 1, 2025
d8b5576
Fix typo
elmattic Aug 1, 2025
e1c2729
Fix typo
elmattic Aug 1, 2025
8fed6e0
Remove calls to sleep
elmattic Aug 5, 2025
6171f1e
Use an actual link
elmattic Aug 5, 2025
1e93afe
Use hex crate
elmattic Aug 5, 2025
8713195
Add calls to MpoolPending to check message presence
elmattic Aug 6, 2025
20b22a9
Rename subcommand
elmattic Aug 6, 2025
c2fbe02
Proper close channel
elmattic Aug 6, 2025
6c17c65
Make clippy happy
elmattic Aug 6, 2025
4095010
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 6, 2025
54659d7
Properly close stream
elmattic Aug 6, 2025
78dc2c7
Properly handle reorgs
elmattic Aug 7, 2025
70ad519
Fix lint error
elmattic Aug 7, 2025
b610bf3
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 7, 2025
585c279
Use v1 API
elmattic Aug 7, 2025
c6d419e
Add comment
elmattic Aug 7, 2025
e8b936b
Add ignore method
elmattic Aug 7, 2025
41afdca
Fix incorrect schema in ChainNotify message
elmattic Aug 7, 2025
1a40061
Add CI check
elmattic Aug 8, 2025
61c6dc1
Fix yaml
elmattic Aug 8, 2025
d969a28
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 8, 2025
ab46e8e
Fix permissions
elmattic Aug 8, 2025
8907015
Fix yaml
elmattic Aug 8, 2025
34283bc
Fix fullnode api info
elmattic Aug 8, 2025
a65918e
Add gh link
elmattic Aug 8, 2025
06b9c46
Add gh link
elmattic Aug 8, 2025
9842f14
Add gh link
elmattic Aug 8, 2025
a127f9d
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 11, 2025
33f37bd
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 11, 2025
515cf18
Use saturating sub
elmattic Aug 11, 2025
1e819fa
Use less aggressive timeout
elmattic Aug 11, 2025
f64456b
Remove print of token
elmattic Aug 11, 2025
9258ee6
Fix lint error
elmattic Aug 11, 2025
66f6a11
Properly propagate error
elmattic Aug 11, 2025
2a340ef
Use a smaller timeout
elmattic Aug 11, 2025
ca998b1
Propagate token when possible
elmattic Aug 11, 2025
258621e
Remove unwrap usage and use a timeout while waiting next event
elmattic Aug 11, 2025
9ebf228
Fix incorrect logic
elmattic Aug 11, 2025
1407333
Use absolute path
elmattic Aug 11, 2025
c07de53
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 11, 2025
0971f06
Revert changes to fix CI
elmattic Aug 11, 2025
c53a2b5
Fix lint error
elmattic Aug 11, 2025
4517417
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 12, 2025
e840947
Better error handling
elmattic Aug 12, 2025
706ef61
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 12, 2025
20a9c8d
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 12, 2025
e67db40
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 13, 2025
248fa27
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 14, 2025
6e41430
Add lock file
elmattic Aug 14, 2025
cd831aa
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 18, 2025
b89f0e7
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 20, 2025
e8ac160
Use v5
elmattic Aug 20, 2025
4146221
Use ensure
elmattic Aug 20, 2025
7b2cdeb
Use unreachable macro
elmattic Aug 20, 2025
d9b1239
Print ignored tests
elmattic Aug 20, 2025
86f4c3f
Fix ensure macros
elmattic Aug 20, 2025
7492451
Rename module
elmattic Aug 20, 2025
c353ad3
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 20, 2025
07d772f
Add a simple erc20 contract
elmattic Aug 22, 2025
d068413
Add explanations on how we compute all parameters
elmattic Aug 22, 2025
9fd72b4
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 22, 2025
4752dee
Fix broken link
elmattic Aug 22, 2025
907bd29
Use saturating sub
elmattic Aug 22, 2025
589a0b9
Apply coderabbitai suggestion
elmattic Aug 22, 2025
1446872
Apply coderabbitai suggestion
elmattic Aug 22, 2025
5bd721f
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 22, 2025
d1a2afa
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 22, 2025
58e86a6
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 25, 2025
b07fac6
Use text instead of markdown
elmattic Aug 25, 2025
3a8de44
Add top comment that describes contract purpose
elmattic Aug 25, 2025
b7dfcfc
Revert changes
elmattic Aug 25, 2025
8e0702e
Revert changes
elmattic Aug 25, 2025
98b7dde
Remove passing preloaded wallet
elmattic Aug 25, 2025
21aa151
Add -E flag for better Bash compat
elmattic Aug 25, 2025
737edb0
Fix shellcheck issue
elmattic Aug 25, 2025
9614295
Use FULLNODE_API_INFO var for client creation
elmattic Aug 25, 2025
a47c4eb
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 25, 2025
7de68a9
Fix example output
elmattic Aug 25, 2025
cac27de
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 25, 2025
7f164b6
Remove clone
elmattic Aug 25, 2025
11dfa3f
Remove -E flag
elmattic Aug 25, 2025
b63f1bd
Apply some nits
elmattic Aug 25, 2025
87e33de
Fix spellcheck issues
elmattic Aug 26, 2025
5bca9bb
Apply coderabbitai suggestions
elmattic Aug 26, 2025
bad13d6
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 26, 2025
9c72ec8
Export full node api during forest_init
elmattic Aug 26, 2025
5beb9d6
Improve doc comments
elmattic Aug 26, 2025
79667c9
Fix data_dir path
elmattic Aug 26, 2025
70fe4fd
Trim double quotes
elmattic Aug 26, 2025
30433fb
Remove positional param and add 0x prefix to calldata
elmattic Aug 26, 2025
1e3e088
Merge branch 'main' into elmattic/api-run-subcommand
elmattic Aug 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .config/forest.dic
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ blockstore/SM
BLS
butterflynet
calibnet
calldata
callee
canonicalization
CAR/SM
Expand Down Expand Up @@ -51,6 +52,7 @@ Ethereum
eth
exa
EVM
f4
F3
FFI
FIL
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/forest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,39 @@
chmod +x ~/.cargo/bin/forest*
- run: ./scripts/tests/calibnet_eth_mapping_check.sh
timeout-minutes: ${{ fromJSON(env.SCRIPT_TIMEOUT_MINUTES) }}
calibnet-api-test-stateful:
needs:
- build-ubuntu
name: Calibnet api test-stateful check
runs-on: ubuntu-24.04
steps:
- run: lscpu
- uses: actions/cache@v4
with:
path: "${{ env.FIL_PROOFS_PARAMETER_CACHE }}"
key: proof-params-keys
- name: Checkout Sources
uses: actions/checkout@v4
- uses: actions/download-artifact@v5
with:
name: "forest-${{ runner.os }}"
path: ~/.cargo/bin
- uses: actions/download-artifact@v4
with:
name: "forest-${{ runner.os }}"
path: ~/.cargo/bin
- name: Set permissions
run: |
chmod +x ~/.cargo/bin/forest*
- name: Api test stateful check
env:
CALIBNET_WALLET: "${{ secrets.CALIBNET_WALLET }}"
run: |
if [[ "$CALIBNET_WALLET" != "" ]]; then
./scripts/tests/calibnet_api_test_stateful_check.sh "$CALIBNET_WALLET"
fi
timeout-minutes: ${{ fromJSON(env.SCRIPT_TIMEOUT_MINUTES) }}
db-migration-checks:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
needs:
- build-ubuntu
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -603,6 +635,7 @@
- calibnet-no-discovery-checks
- calibnet-kademlia-checks
- calibnet-eth-mapping-check
- calibnet-api-test-stateful
- db-migration-checks
- local-devnet-check
# - local-devnet-curio-check
Expand Down
36 changes: 36 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ tera = { version = "1", default-features = false }
thiserror = "2"
tokio = { version = "1", features = ['full'] }
tokio-stream = { version = "0.1", features = ["fs", "io-util"] }
tokio-tungstenite = "0.27.0"
tokio-util = { version = "0.7", features = ["compat", "io-util"] }
toml = "0.8"
tower = { version = "0.5", features = ["util"] }
Expand Down
76 changes: 76 additions & 0 deletions documentation/src/developer_documentation/rpc_stateful_tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# RPC Stateful Tests

Some methods in the Filecoin Ethereum JSON-RPC API require stateful interactions for meaningful testing. These tests validate both **schema compatibility** and **method semantics**, especially for RPC endpoints that rely on internal node state.

This includes:

- All subscription-based methods
- Filter-related methods (e.g., `eth_newFilter`, `eth_getFilterLogs`)

## Prerequisites

Before running the tests, perform the following setup steps:

1. Run a Lotus or Forest node (calibnet recommended). Make sure `FULLNODE_API_INFO` is defined.
2. Create an f4 address, fund it, and deploy a test smart contract (the deployed contract must emit an event with a known topic when invoked).
3. The f4 address must hold enough FIL to invoke the contract.

Run the test suite with:
`forest-tool api test-stateful --to <CONTRACT_ADDR> --from <FROM_ADDR> --payload <INVOKE_PAYLOAD> --topic <TOPIC>`

where:

- `CONTRACT_ADDR`: f4 address of the deployed smart contract
- `FROM_ADDR`: f4 address invoking the contract
- `INVOKE_PAYLOAD`: Calldata that will trigger the contract's event
- `TOPIC`: The event topic expected to be emitted during invocation

## Example output

```console
export FULLNODE_API_INFO="<TOKEN>:/ip4/127.0.0.1/tcp/1234/http"
forest-tool api test-stateful \
--to t410f2jhqlciub25ad3immo5kug2fluj625xiex6lbyi \
--from t410f5uudc3yoiodsva73rxyx5sxeiaadpaplsu6mofy \
--payload 40c10f19000000000000000000000000ed28316f0e43872a83fb8df17ecae440003781eb00000000000000000000000000000000000000000000000006f05b59d3b20000 \
--topic 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
running 7 tests
test eth_newFilter install/uninstall ... ok
test eth_newFilter under limit ... ok
test eth_newFilter just under limit ... ok
test eth_newFilter over limit ... ok
test eth_newBlockFilter works ... ok
test eth_newPendingTransactionFilter works ... ok
test eth_getFilterLogs works ... ok
test result: ok. 7 passed; 0 failed; 0 ignored; 0 filtered out
```

The goal is to ensure that Forest now passes all the existing scenarios. These scenarios are not exhaustive, and additional ones can be added as needed.

## Adding a new test

To extend test coverage for another RPC method or cover more semantics:

1. Add the RPC method to Forest if not yet implemented, following the guidance in [RPC compatibility guide](./rpc_api_compatibility.md).
2. Create a new test scenario in:
[`stateful_tests.rs`](../../../src/tool/subcommands/api_cmd/stateful_tests.rs)
3. Your internal test function should return `Ok(())` on success. Use `anyhow::Result` for error handling.

Ensure the test behaves consistently on both Lotus and Forest nodes.

## Example test function
```rust
pub async fn test_eth_method(client: Arc<Client>) -> anyhow::Result<()> {
// Setup call to the method
// Assert intermediate states
// State cleanup
// Return Ok when the sequence completes successfully
Ok(())
}
```

## Notes

The current test framework assumes a running node and a valid wallet.

Consider implementing `forest-tool evm deploy` and `forest-tool evm invoke` subcommands to simplify contract deployment and test invocation.
34 changes: 34 additions & 0 deletions scripts/tests/calibnet_api_test_stateful_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# This script tests RPC API stateful tests on a live forest node.
# It requires both `forest`, `forest-wallet` and `forest-tool` to be in the PATH.

set -euxo pipefail

source "$(dirname "$0")/harness.sh"
Comment on lines +5 to +7
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Do not enable xtrace while handling secrets

set -x will print commands and arguments, leaking the wallet secret. Disable xtrace during secret handling and only re-enable afterward.

-set -euxo pipefail
+set -Eeuo pipefail
+
+# Capture xtrace state and turn it off to avoid leaking secrets
+XTRACE_STATE="$(set +o | grep -E '^xtrace' || true)"
+set +x
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
set -euxo pipefail
source "$(dirname "$0")/harness.sh"
set -Eeuo pipefail
# Capture xtrace state and turn it off to avoid leaking secrets
XTRACE_STATE="$(set +o | grep -E '^xtrace' || true)"
set +x
source "$(dirname "$0")/harness.sh"
🤖 Prompt for AI Agents
In scripts/tests/calibnet_api_test_stateful_check.sh around lines 5 to 7, the
script enables xtrace with set -x which can leak sensitive wallet secrets by
printing commands and arguments. Modify the script to disable xtrace before
handling any secrets and re-enable it afterward to prevent secret leakage while
maintaining debugging output elsewhere.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elmattic, is this actionable?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!



forest_init "$@"

# This is the address of a Calibnet pre-deployed simple ERC20 contract.
# You can find the hex and source code in 'src/tool/subcommands/api_cmd/contracts/erc20'.
TO_ADDRESS="t410fp6e7drelxau7nf76tcn6gva22t5jafefhevubwi"

FROM_ADDRESS="t410f2avianksmit2cl2bqk53qant7nm7rdmk63twa5y"

# This payload corresponds to minting new tokens for the 'FROM_ADDRESS' and will trigger a log event upon success.
# To compute the calldata, you can use the 'cast calldata' subcommand with the following arguments:
# cast calldata "mint(address,uint256)" 0x7f89f1c48bb829f697fe989be3541ad4fa901485 1000000000000000000
#
# Note that 0x7f89f1c48bb829f697fe989be3541ad4fa901485 is the Ethereum address corresponding to the contract f4 address.
PAYLOAD="0x40c10f190000000000000000000000007f89f1c48bb829f697fe989be3541ad4fa9014850000000000000000000000000000000000000000000000000de0b6b3a7640000"

# This topic is derived using the keccak256 hash of the event signature 'Mint(address,uint256)'
# To compute the topic, you can use the 'cast keccak256' subcommand with the following argument:
# cast keccak256 "Mint(address,uint256)"
TOPIC="0x0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885"

$FOREST_TOOL_PATH api test-stateful \
--to "$TO_ADDRESS" \
--from "$FROM_ADDRESS" \
--payload "$PAYLOAD" \
--topic "$TOPIC"
6 changes: 6 additions & 0 deletions scripts/tests/harness.sh
Comment thread
elmattic marked this conversation as resolved.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to handle the tokens? It's saved and consumed already from a default location, as introduced in #5629

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed it.

Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ function forest_init {
forest_wait_api
forest_wait_for_sync
forest_check_db_stats

DATA_DIR=$( $FOREST_CLI_PATH config dump | grep "data_dir" | cut -d' ' -f3- | tr -d '"' )
ADMIN_TOKEN=$(cat "${DATA_DIR}/token")
FULLNODE_API_INFO="${ADMIN_TOKEN}:/ip4/127.0.0.1/tcp/2345/http"

export FULLNODE_API_INFO
}

function forest_init_with_f3 {
Expand Down
2 changes: 1 addition & 1 deletion src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
mod eip_1559_transaction;
mod eip_155_transaction;
mod homestead_transaction;
mod transaction;
pub mod transaction;

pub use eip_155_transaction::*;
pub use eip_1559_transaction::*;
Expand Down
3 changes: 2 additions & 1 deletion src/eth/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub enum EVMMethod {

/// Ethereum transaction which can be of different types.
/// The currently supported types are defined in [FIP-0091](https://github.com/filecoin-project/FIPs/blob/020bcb412ee20a2879b4a710337959c51b938d3b/FIPS/fip-0091.md).
#[derive(Debug)]
pub enum EthTx {
Homestead(Box<EthLegacyHomesteadTxArgs>),
Eip1559(Box<EthEip1559TxArgs>),
Expand Down Expand Up @@ -155,7 +156,7 @@ impl EthTx {
}
}

fn rlp_signed_message(&self) -> anyhow::Result<Vec<u8>> {
pub fn rlp_signed_message(&self) -> anyhow::Result<Vec<u8>> {
match self {
Self::Homestead(tx) => (*tx).rlp_signed_message(),
Self::Eip1559(tx) => (*tx).rlp_signed_message(),
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ fn create_notif_message(
) -> anyhow::Result<Box<RawValue>> {
let method = sink.method_name();
let channel_id = sink.channel_id();
let result = serde_json::to_string(result)?;
let result = serde_json::to_value(result)?;
let msg = serde_json::json!({
"jsonrpc": "2.0",
"method": method,
Expand Down
10 changes: 8 additions & 2 deletions src/rpc/methods/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ impl EthUint64 {
.try_into()?,
)))
}

pub fn to_hex_string(&self) -> String {
format!("0x{}", hex::encode(self.0.to_be_bytes()))
}
}

#[derive(
Expand Down Expand Up @@ -3038,14 +3042,16 @@ fn eth_filter_result_from_events<DB: Blockstore>(
}

fn eth_filter_result_from_tipsets(events: &[CollectedEvent]) -> anyhow::Result<EthFilterResult> {
Ok(EthFilterResult::Txs(eth_filter_logs_from_tipsets(events)?))
Ok(EthFilterResult::Hashes(eth_filter_logs_from_tipsets(
events,
)?))
}

fn eth_filter_result_from_messages<DB: Blockstore>(
ctx: &Ctx<DB>,
events: &[CollectedEvent],
) -> anyhow::Result<EthFilterResult> {
Ok(EthFilterResult::Txs(eth_filter_logs_from_messages(
Ok(EthFilterResult::Hashes(eth_filter_logs_from_messages(
ctx, events,
)?))
}
Expand Down
9 changes: 3 additions & 6 deletions src/rpc/methods/eth/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,17 +556,15 @@ impl From<LogFilter> for EthFilterSpec {
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(untagged)]
pub enum EthFilterResult {
Blocks(Vec<EthHash>),
Txs(Vec<EthHash>),
Hashes(Vec<EthHash>),
Logs(Vec<EthLog>),
}
lotus_json_with_self!(EthFilterResult);

impl EthFilterResult {
pub fn is_empty(&self) -> bool {
match self {
Self::Blocks(v) => v.is_empty(),
Self::Txs(v) => v.is_empty(),
Self::Hashes(v) => v.is_empty(),
Self::Logs(v) => v.is_empty(),
}
}
Expand All @@ -575,8 +573,7 @@ impl EthFilterResult {
impl PartialEq for EthFilterResult {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Blocks(a), Self::Blocks(b)) => a == b,
(Self::Txs(a), Self::Txs(b)) => a == b,
(Self::Hashes(a), Self::Hashes(b)) => a == b,
(Self::Logs(a), Self::Logs(b)) => a == b,
_ => self.is_empty() && other.is_empty(),
}
Expand Down
Loading
Loading