-
Notifications
You must be signed in to change notification settings - Fork 2
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
Height-Based Tx Parsing #282
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few comments, but it looks amazing
tools/version_mapping.go
Outdated
) | ||
|
||
func (v version) IsSupported(network string, height int64) bool { | ||
if network == "calibration" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a constant
factory.go
Outdated
parserV1ActorV1: parserV1ActorV1, | ||
parserV1ActorV2: parserV1ActorV2, | ||
|
||
parserV2ActorV1: parserV2ActorV1, | ||
parserV2ActorV2: parserV2ActorV2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a bit confusing actually, parserV1, ActorV1? sounds confusing, again... maybe some comments?
actors/v2/actors.go
Outdated
case manifest.EthAccountKey: | ||
// metadata, err = p.ParseEthAccount(txType, msg, msgRct) | ||
case manifest.PlaceholderKey: | ||
// metadata, err = p.ParsePlaceholder(txType, msg, msgRct) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't remember why this is commented here.
@ziscky we need to fix CI first |
Height Based Parsing 3
Height Based Parsing 2
Actors V2
Overview
ActorsV2 is a new implementation of the actor parsing logic that is more flexible and easier to maintain while properly handling all legacy spec-actors and new builtin-actors structs. This ensures that the parser can properly parse all actor messages for any network version.
Design
The
ActorParser
struct is tasked with parsing actor messages and is composed of ahelper.Helper
and azap.Logger
.Each actor implements the
Actor
interface, which includes the following methods:Name() string
: Returns the actor's name.Parse(network string, height int64, txType string, msg *parser.LotusMessage, msgRct *parser.LotusMessageReceipt, mainMsgCid cid.Cid, key filTypes.TipSetKey) (map[string]interface{}, *types.AddressInfo, error)
: Parses the actor message.TransactionTypes() map[string]any
: Provides a map of all transaction types supported by the actor.Actor Folder Structure
Each actor is organized within its own directory under
actors/v2
. The directory contains the following files:generic.go
: Defines generic functions, typed with specific builtin-actors/spec-actors version structs, for parsing actor messages.parse.go
: Contains the switch case logic for parsing specific transaction types for the actor.Testing
There are different types of tests to ensure comprehensive coverage:
Actor Support Verification
Test Function:
TestAllActorsSupported
This test verifies that all actors in the latest builtin-actor release and all legacy spec-actors are supported by the parser.
It will fail if any actor is not supported.
To add a new actor:
actors/v2
.Actor
interface.ActorParser.GetActor
function.Method Coverage Verification
Test Function:
TestMethodCoverage
This test verifies that all methods exposed by the actor in all builtin-actor and spec-actor releases are supported by the actors.
It will fail if any method is not covered.
To add support for a new method:
TransactionTypes
map.Parse
function.Network Version Coverage Verification
Test Function:
TestVersionCoverage
This test verifies that all the actor methods can correctly handle all network versions ( decided by the height of the block ).
It will fail if any network version is not supported.
To add support for a new network version:
tools/version_mapping.go
.Actor Functionality Tests
Test Location:
actors/tests/{actor_name}_test.go
These tests, originally developed for actors version 1 (v1), are designed to validate the functionality of actors by comparing their function outputs against a set of pre-calculated expected values. These expected values are stored in the data/actors/{actor_name} directory.
Each actor undergoes both v1 and v2 tests, and passing both test suites is a mandatory requirement. This dual testing approach ensures backward compatibility and adherence to established specifications.
Important Note: The pre-computed data currently stored within data/actors corresponds to network version V20. If testing against a different network version is required, the
cmd/tracedl
tool provides a mechanism for automatically updating the stored data to the desired network version. This ensures that tests are always executed against the correct expected values for the target network version.These tests are designed to ensure that the actor parser accurately handles all releases of both builtin-actors and spec-actors. They are configured to automatically fail upon the release of any new builtin-actor version. This failure mechanism guides developers to the necessary modifications, thereby eliminating the need for manual verification of the parser with each new Filecoin upgrade.
Compatibility
The
ActorParser
is designed to be backwards compatible and a drop in replacement for ActorsV1.Misc
Filecoin Network Version - Actor Version Mapping
The following table shows the mapping of Filecoin network versions to actor versions:
🔗 zboto Link