Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 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: 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
3 changes: 3 additions & 0 deletions src/rpc/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ impl Client {
pub fn base_url(&self) -> &Url {
&self.base_url
}
pub fn token(&self) -> Option<&String> {
self.token.as_ref()
}
pub async fn call<T: crate::lotus_json::HasLotusJson + std::fmt::Debug>(
&self,
req: Request<T>,
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 @@ -211,6 +211,10 @@ impl EthUint64 {
.try_into()?,
)))
}

pub fn to_hex_string(&self) -> String {
format!("0x{:x}", self.0)
}
Comment on lines +215 to +219

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.

nit: as far as I recall, the format! performance is not great, especially compared to dedicated crates like hex. I'd rather we use the latter.

It might make sense to consider https://lib.rs/crates/faster-hex in the future to replace the hex as well.

}

#[derive(
Expand Down Expand Up @@ -2977,14 +2981,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 @@ -500,17 +500,15 @@ lotus_json_with_self!(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 @@ -519,8 +517,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
23 changes: 23 additions & 0 deletions src/tool/subcommands/api_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0, MIT

mod api_compare_tests;
mod api_run_tests;
mod generate_test_snapshot;
mod report;
mod test_snapshot;
Expand Down Expand Up @@ -177,6 +178,17 @@ pub enum ApiCommands {
#[arg(num_args = 1.., required = true)]
files: Vec<PathBuf>,
},
Run {

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.

It'd be great to have comment and help text for this command

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.

I don't think the name and invocation of the command is very expressive. As I understand when looking into it in the description, it should serve some API, similar to forest-tool api serve.

I recommend to changing it to something obvious to what it actually does. For example, forest-tool api test-eth-stateful (there might be a better name...)

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.

Maybe just test-stateful?

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.

Yeah, sounds good. But let's put it under the api subcommand.

/// Forest address
#[clap(long, default_value = "/ip4/127.0.0.1/tcp/2345/http")]
forest: UrlFromMultiAddr,
/// Lotus address
#[clap(long, default_value = "/ip4/127.0.0.1/tcp/1234/http")]
lotus: UrlFromMultiAddr,
/// Filter which tests to run according to method name. Case sensitive.
#[arg(long, default_value = "")]
filter: String,
},
}

impl ApiCommands {
Expand Down Expand Up @@ -323,6 +335,17 @@ impl ApiCommands {
};
}
}
Self::Run {
forest: UrlFromMultiAddr(forest),
lotus: UrlFromMultiAddr(lotus),
filter,
} => {
let forest = Arc::new(rpc::Client::from_url(forest));
let lotus = Arc::new(rpc::Client::from_url(lotus));

let tests = api_run_tests::create_tests().await;
api_run_tests::run_tests(tests, forest.clone(), lotus.clone(), filter).await?;
}
Comment thread
elmattic marked this conversation as resolved.
Self::DumpTests {
create_tests_args,
path,
Expand Down
Loading
Loading