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

NV18: Filecoin EVM runtime + Actor Events + EthAccount + EAM + f4 addressing #9998

Merged
merged 288 commits into from
Jan 13, 2023

Conversation

raulk
Copy link
Member

@raulk raulk commented Jan 13, 2023

Final landable version of #9617 with review comments addressed.


Related Issues

This mega-PR is the result of several months of development on the FVM Milestone 2.1 (Filecoin EVM compatibility). It includes the Lotus-side implementation of the following FIPs:

Proposed Changes

This 14,000 LoC PR has a ton of changes, but they broadly fall into these headlines:

  1. The f4 address class is introduced with support for delegated addresses.
  2. Uses a new bundle that includes the brand new EVM, EAM, and EthAccount actors.
  3. An implementation of the Ethereum JSON-RPC API is included, mapping over to Filecoin specifics.
  4. Added support for Actor Events (although needs an update to align with the final draft of FIP-0049 (tracked in FIP-0049 (actor events): align with implementation. FIPs#581). This includes event processing, indexing, and subscription mechanisms.
  5. Adds support for the Wallaby testnet, although the intention is to move such support to a separate branch.
  6. The migration for nv18 is included.
  7. Genesis changes to instantiate the Eth Null Address at 0x0 and the EAM are also included.
  8. An eth CLI has been implemented for diagnostics and quick experimentation.
  9. TipsetCID generation and persistence is also implemented as per FIP-0054.
  10. FVM v3 is integrated via filecoin-ffi.

Additional Info

  • There are some TODOs left over from the original review, marked with TODO::FVM. Fixing them is tracked in Fix TODO::FVM comments in Lotus ref-fvm#1446.
  • Should probably merge by squashing and making sure that the collective authorship is retained (I can take care of this once approved).

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message.
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
    • In progress
  • CI is green

raulk and others added 30 commits November 9, 2022 19:47
Make it use GasEstimateMessageGas, which applies overestimation
by default. This accounts for inclusion costs.
Also updates the actors to accommodate this change, and fix a bug in
looking up addresses for f4 actors.
We need to add full FEVM state support, but that will require merging
master. This is enough for now.

fixes filecoin-project/ref-fvm#1022
and skip a non-testing test; printing doesn't constitute testing.
Only when actors version is >= 10
it breaks the gen script in proxy_gen
it's in the actor state only if it is a v5 (or later) state tree
it's a dummy, but at least it makes tests pass
@raulk raulk marked this pull request as ready for review January 13, 2023 01:31
@raulk raulk requested a review from a team as a code owner January 13, 2023 01:31
@raulk raulk changed the base branch from master to release/v1.20.0 January 13, 2023 02:10
Copy link
Contributor

@arajasek arajasek left a comment

Choose a reason for hiding this comment

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

Let's do it.

Comment on lines +1617 to +1623
// Use half the CPUs for pre-migration, but leave at least 3.
workerCount := MigrationMaxWorkerCount
if workerCount <= 4 {
workerCount = 1
} else {
workerCount /= 2
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not too sure about the math here, doesn't look like we always have at least 3 workers

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

It's at least 3 workers if possible -- that is, never take more than 1, if that would doing so would leave regular processing with fewer than 3. But do take at least one always.

}

// Assume short lists of addresses
// TODO: binary search for longer lists or restrict list length
Copy link
Contributor

Choose a reason for hiding this comment

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

"PRAGMA read_uncommitted = ON",
}

var ddls = []string{
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we want to add at least some indexes here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, we do. @iand wanted to get a good understanding of performance before indices are added, but I am fully onboard with adding them already since it's a no-brainer.

Comment on lines +864 to +865
// TODO: I'm not thrilled about depending on filcns here, but I prefer this to duplicating logic
if !filcns.IsValidForSending(nv, senderAct) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Pretty sure one of the recently merged IPC PRs has moved this to a better place

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably on master, not on release/v1.20.0; we'll need to reconcile once we merge release/v1.20.0 into master.

@@ -97,7 +97,7 @@ func (sm *selectedMessages) tryToAdd(mc *msgChain) bool {
sm.msgs = append(sm.msgs, mc.msgs...)
sm.blsLimit -= l
sm.gasLimit -= mc.gasLimit
} else if mc.sigType == crypto.SigTypeSecp256k1 {
} else if mc.sigType == crypto.SigTypeSecp256k1 || mc.sigType == crypto.SigTypeDelegated {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not related to this particular line, but I feel like after the upgrade we should rename places which handle both delegated and secp messages to signed or something like that (including the field in blockheader, which we can rename because it's tuple-serialized).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, Signature-bearing or something rather than Signed. (BLS message are also signed, we just aggregate their signatures when we pack them into a block).

@@ -0,0 +1,53 @@
package chain
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a fan of putting things in the chain package, can easily generate dependency loops

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack, if that's the case we can move out. This used to be in a signatures package, but @arajasek asked to move it out. We can move it somewhere else easily.

}
default:
// XXX: Hack to make sending from f099 (and others) "just work".
// REMOVE ME.
Copy link
Contributor

Choose a reason for hiding this comment

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

REMOVE ME

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@@ -42,7 +42,7 @@ type StateManagerAPI interface {
GetPaychState(ctx context.Context, addr address.Address, ts *types.TipSet) (*types.Actor, paych.State, error)
LoadActorTsk(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*types.Actor, error)
LookupID(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error)
ResolveToKeyAddress(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error)
ResolveToDeterministicAddress(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Pretty sure this rename breaks lite mode as StateManagerAPI is also supplied from api.Gateway

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.