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

fix: support Forrest parity testing for F3 participation APIs #12615

Merged
merged 4 commits into from
Oct 18, 2024

Conversation

masih
Copy link
Member

@masih masih commented Oct 18, 2024

Related Issues

Proposed Changes

For parity testing, Forest nodes need to decode an F3 participation ticket that is issued by Lotus. Lotus so happens to use CBOR to encode tickets, which it then decodes to issue a lease.

The lease issuer is of type peer.ID which is an alias of type string that may contain non UTF-8 characters. If this type is used directly in CBOR encoding then it gets encoded as string, which works fine in Golang but not Rust, which in turn results in decoding issues in Forest.

To avoid this use []byte as the type to encode the issuer public key. In Lotus, the value will be the binary marshalling of peer.ID that issued the ticket.

While at it, also fix two issues that were brought up during discussion:

  • A miner must not be able to ask for a ticket to participate in zero instances. Validate and return error if instances is set to zero.

  • Use CBOR tuple encoding for a slightly better efficient wire encoding of ticket. cborgen.Write* APIs explicitly create a given file; hence the need to separate the file to which tuple kinds are generated since the existing encoding for types in api/cbor_gen.go use maps.

Additional Info

Checklist

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

For parity testing, Forest nodes need to decode an F3 participation
ticket that is issued by Lotus. Lotus so happens to use CBOR to encode
tickets, which it then decodes to issue a lease.

The lease issuer is of type `peer.ID` which is an alias of type `string`
that may contain non UTF-8 characters. If this type is used directly in
CBOR encoding then it gets encoded as string, which works fine in Golang
but not Rust, which in turn results in decoding issues in Forest.

To avoid this use `[]byte` as the type to encode the issuer public key.
In Lotus, the value will be the binary marshalling of `peer.ID` that
issued the ticket.

While at it, also fix two issues that were brought up during discussion:

* A miner must not be able to ask for a ticket to participate in zero
  instances. Validate and return error if instances is set to zero.

* Use CBOR tuple encoding for a slightly better efficient wire encoding
  of ticket. `cborgen.Write*` APIs explicitly create a given file; hence
  the need to separate the file to which tuple kinds are generated since
  the existing encoding for types in `api/cbor_gen.go` use maps.
@masih masih changed the title Support Forrest parity testing for F3 participation APIs fix: support Forrest parity testing for F3 participation APIs Oct 18, 2024
@masih masih marked this pull request as ready for review October 18, 2024 11:19
api/api_full.go Outdated Show resolved Hide resolved
@masih masih force-pushed the masih/f3-participate-forest-parity-test branch 2 times, most recently from e208e68 to 3939292 Compare October 18, 2024 13:40
@masih masih force-pushed the masih/f3-participate-forest-parity-test branch from 3939292 to b7bd37e Compare October 18, 2024 13:56
@masih masih merged commit 89b0941 into master Oct 18, 2024
83 checks passed
@masih masih deleted the masih/f3-participate-forest-parity-test branch October 18, 2024 15:11
@masih masih self-assigned this Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🎉 Done
Development

Successfully merging this pull request may close these issues.

3 participants