Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rpc) Implement Filecoin.EthTraceBlock #4991

Merged
merged 76 commits into from
Jan 9, 2025
Merged

Conversation

elmattic
Copy link
Contributor

@elmattic elmattic commented Nov 21, 2024

Summary of changes

Changes introduced in this pull request:

  • implement RPC method Filecoin.EthTraceBlock
  • API compare tests
  • fix bug in eth::decode_payload and add unit tests
$ forest-tool api compare --lotus /ip4/127.0.0.1/tcp/1234/http --forest /ip4/127.0.0.1/tcp/2345/http forest_snapshot_calibnet_2024-12-16_height_2233655.forest.car.zst --filter EthTraceBlock -n 200
| RPC Method                   | Forest | Lotus |
|------------------------------|--------|-------|
| Filecoin.EthTraceBlock (200) | Valid  | Valid |

Reference issue to close (if applicable)

Closes #4708

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

@elmattic elmattic marked this pull request as ready for review January 7, 2025 17:19
@elmattic elmattic requested a review from a team as a code owner January 7, 2025 17:19
@elmattic elmattic requested review from hanabi1224 and LesnyRumcajs and removed request for a team January 7, 2025 17:19
code if code > ExitCode_latest::SYS_MISSING_RETURN.value()
&& code < ExitCode_latest::FIRST_USER_EXIT_CODE =>
{
write!(f, "SysErrReserved{}({})", code - 10, code)
Copy link
Member

Choose a reason for hiding this comment

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

Why subtract 10?

Copy link
Contributor Author

@elmattic elmattic Jan 8, 2025

Choose a reason for hiding this comment

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

We want to align errors with Lotus display, so code - 10 does that.

Maybe using SYS_ASSERTION_FAILED code instead? (it equals to 10).

Copy link
Member

Choose a reason for hiding this comment

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

Do you know why Lotus subtracts 10? I'm okay with having it as well. Just please comment in the code the reason for this so the magic number is less magical.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will explain in a comment the rational behind this.

Copy link
Contributor Author

@elmattic elmattic Jan 9, 2025

Choose a reason for hiding this comment

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

I think there is a better, cleaner and more correct solution to match Lotus exit codes.

We just need to create a PR in ref-fvm to uncomment those dead lines:
https://github.com/filecoin-project/ref-fvm/blob/master/shared/src/error/mod.rs#L64
https://github.com/filecoin-project/ref-fvm/blob/master/shared/src/error/mod.rs#L74
https://github.com/filecoin-project/ref-fvm/blob/master/shared/src/error/mod.rs#L81-L84

And add those constants to our match expression in forest/src/shim/error.rs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's address that in a subsequent PR.

Comment on lines 17 to 22
use fil_actor_eam_state::v12 as eam12;
use fil_actor_evm_state::v15 as evm12;
use fil_actor_init_state::v12::ExecReturn;
use fil_actor_init_state::v15::Method as InitMethod;
use fvm_ipld_blockstore::Blockstore;
use fvm_shared4::{error::ExitCode as ExitCodeV4, METHOD_CONSTRUCTOR};
Copy link
Member

@LesnyRumcajs LesnyRumcajs Jan 8, 2025

Choose a reason for hiding this comment

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

Do we have to lock the actor version and the FVM version here? It would be great to avoid it and work through actor interface and shims.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can have a look.

Copy link
Member

@LesnyRumcajs LesnyRumcajs left a comment

Choose a reason for hiding this comment

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

In general, does Lotus have a more extensive suite for this tracing? If so, could we migrate some of those tests?

@elmattic
Copy link
Contributor Author

elmattic commented Jan 9, 2025

In general, does Lotus have a more extensive suite for this tracing? If so, could we migrate some of those tests?

Unfortunately, no. They have very few tests. I've already migrated the one that tests decode_payload free function.

@LesnyRumcajs
Copy link
Member

In general, does Lotus have a more extensive suite for this tracing? If so, could we migrate some of those tests?

Unfortunately, no. They have very few tests. I've already migrated the one that tests decode_payload free function.

Well, then, fortunately, I'm a man of great faith. 🙏

@elmattic elmattic enabled auto-merge January 9, 2025 11:59
@elmattic elmattic added this pull request to the merge queue Jan 9, 2025
Merged via the queue into main with commit 1f1c818 Jan 9, 2025
42 checks passed
@elmattic elmattic deleted the elmattic/eth-trace-block branch January 9, 2025 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EthTraceBlock
3 participants