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: local wallets #3976

Merged
merged 32 commits into from
Apr 8, 2024
Merged

feat: local wallets #3976

merged 32 commits into from
Apr 8, 2024

Conversation

lemmih
Copy link
Contributor

@lemmih lemmih commented Feb 20, 2024

Summary of changes

Changes introduced in this pull request:

  • Add --remote-wallet flag to forest-wallet. Without it, the tool will use a locally stored wallet.
  • The Forest node still has a separate wallet for compliance with Lotus.

Reference issue to close (if applicable)

Closes #3957

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation,
  • 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.

@lemmih lemmih changed the title [WIP] feat: local wallets feat: local wallets Mar 6, 2024
@lemmih lemmih marked this pull request as ready for review March 6, 2024 12:04
@lemmih lemmih requested a review from a team as a code owner March 6, 2024 12:04
@lemmih lemmih requested review from ruseinov and LesnyRumcajs and removed request for a team March 6, 2024 12:04
@lemmih lemmih marked this pull request as draft March 6, 2024 12:05
@lemmih lemmih marked this pull request as ready for review March 6, 2024 12:29
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.

  1. It'd be great to have the recommended usage (and alternative one) documented somewhere. Wallet handling is something that should be straightforward and as simple as possible for the end user.
  2. Is the --remote-wallet path covered by tests?

@@ -58,7 +58,7 @@ pub static ACCESS_MAP: Lazy<HashMap<&str, Access>> = Lazy::new(|| {
// Message Pool API
access.insert(mpool_api::MPOOL_GET_NONCE, Access::Read);
access.insert(mpool_api::MPOOL_PENDING, Access::Read);
access.insert(mpool_api::MPOOL_PUSH, Access::Write);
access.insert(mpool_api::MPOOL_PUSH, Access::Read);
Copy link
Member

Choose a reason for hiding this comment

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

Anyone can push to mpool? Is it safe?

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'm somewhat convinced that it is safe. Lotus has three ways of receiving signed messages: MPoolPush, MPoolPushUntrusted, and p2p pubsub. MPoolPushUntrusted has a few more sanity checks and a lower cap on outstanding messages. But any peer can send messages through p2p pubsub which does not have a limit and acts just like MPoolPush. Any security we add to MPoolPush is merely security through obscurity since we (and Lotus) blindly accept messages through pubsub.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, thanks for clarification.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, and glif.io doesn't even expose MPoolPushUntrusted. But they do let everyone use MPoolPush. It's kinda strange. All in all, I think we're best off making MPoolPush public and then making it as difficult to spam as possible.

Copy link
Member

Choose a reason for hiding this comment

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

Once we have rate-limiting implemented, we could by default limit it to zero.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a note in the code for why we differ from Lotus.

let Some(dir) = ProjectDirs::from("com", "ChainSafe", "Forest-Wallet") else {
bail!("Failed to find wallet directory");
};
// FIXME: Support encrypted wallets
Copy link
Member

Choose a reason for hiding this comment

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

Do we have a tracking issue for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, no, I wanted to implement it in this PR, but I forgot. I'll make sure to add it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

let StrictAddress(address) = StrictAddress::from_str(&address)
.with_context(|| format!("Invalid address: {address}"))?;

if let Some(mut keystore) = local_keystore {
Copy link
Member

Choose a reason for hiding this comment

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

This if-else proliferation makes it difficult to reason about the code. Can we have it abstracted away?

Copy link
Contributor

Choose a reason for hiding this comment

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

could probably be converted into map_or for all the occurrences or any other more eloquent solution.

Another option is to get rid of else and use return in the if block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cleaned it up a bit but it's still kinda ugly. Suggestions welcome.

@lemmih lemmih marked this pull request as draft March 8, 2024 10:54
@lemmih lemmih changed the title feat: local wallets [WIP] feat: local wallets Mar 18, 2024
@lemmih lemmih marked this pull request as ready for review April 4, 2024 14:03
@LesnyRumcajs
Copy link
Member

@lemmih is it still WIP (see title)?

@lemmih lemmih changed the title [WIP] feat: local wallets feat: local wallets Apr 6, 2024
@lemmih
Copy link
Contributor Author

lemmih commented Apr 8, 2024

@lemmih is it still WIP (see title)?

Fixed.

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.

Should forest-cli send be deprecated / removed?

documentation/src/wallet.md Outdated Show resolved Hide resolved
documentation/src/wallet.md Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

It might make sense to paste this to Grammarly to fix potential typos

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I was too fast and too furious.

Copy link
Contributor

Choose a reason for hiding this comment

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

A side note, don't we have spell checks in CI for md files?

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 could have sworn we had it at one point.

gas_limit: gas_limit as u64,
gas_fee_cap: gas_feecap,
gas_premium,
// JANK(aatifsyed): Why are we using a testing build of fvm_shared?
Copy link
Member

Choose a reason for hiding this comment

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

What do we do with this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a wrinkle in fvm_shared. I guess we could send a patch upstream.

lemmih and others added 4 commits April 8, 2024 11:07
Co-authored-by: Hubert <hubert@chainsafe.io>
Co-authored-by: Hubert <hubert@chainsafe.io>
@lemmih
Copy link
Contributor Author

lemmih commented Apr 8, 2024

Should forest-cli send be deprecated / removed?

Yeah, it should be deprecated. Done.

@@ -113,6 +113,12 @@ Mandatory release that includes:
- [#3955](https://github.com/ChainSafe/forest/pull/3955) Added support for the
NV22 _Dragon_ network upgrade, together with the required state migration.

### Changed

- [#3976](https://github.com/ChainSafe/forest/pull/3976) `forest-wallet`
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is merged after #4152 I believe the position of this log entry needs to be manually adjusted

@lemmih
Copy link
Contributor Author

lemmih commented Apr 8, 2024

@LesnyRumcajs @hanabi1224 Need re-review due to merge mishaps.

@lemmih lemmih enabled auto-merge April 8, 2024 13:26
@lemmih lemmih added this pull request to the merge queue Apr 8, 2024
Merged via the queue into main with commit 070202b Apr 8, 2024
27 checks passed
@lemmih lemmih deleted the lemmih/local-wallet branch April 8, 2024 14:11
@lemmih lemmih mentioned this pull request Apr 11, 2024
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.

Let forest-wallet manage its own wallet
4 participants