Skip to content

Commit

Permalink
fix: support Forrest parity testing for F3 participation APIs (#12615)
Browse files Browse the repository at this point in the history
* Support Forrest parity testing for F3 participation APIs

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.
  • Loading branch information
masih authored Oct 18, 2024
1 parent 7c0c493 commit 89b0941
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 253 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
- Add logic to check if the miner's owner address is delegated (f4 address). If it is delegated, the `lotus-shed sectors termination-estimate` command now sends the termination state call using the worker ID. This fix resolves the issue where termination-estimate did not function correctly for miners with delegated owner addresses. ([filecoin-project/lotus#12569](https://github.com/filecoin-project/lotus/pull/12569))
- Fix a bug in F3 participation API where valid leases may get removed due to dynamic manifest update. ([filecoin-project/lotus#12597](https://github.com/filecoin-project/lotus/pull/12597))

- Change the F3 participation ticket encoding to allow parity testing across non-go implementations, where a ticket issued by Lotus may need to be decoded by, for example, Forest . The changes also enforce the minimum instance participation of 1 for miners. ([filecoin-project/lotus#12615](https://github.com/filecoin-project/lotus/pull/12615))

## Deps

# UNRELEASED Node v1.30.0
Expand Down
11 changes: 5 additions & 6 deletions api/api_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p/core/peer"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
Expand Down Expand Up @@ -923,9 +922,9 @@ type FullNode interface {
//
// If there is an issuer mismatch (ErrF3ParticipationIssuerMismatch), the miner
// must retry obtaining a new ticket to ensure it is only participating in one F3
// instance at any time. If the number of instances is beyond the maximum leasable
// participation instances accepted by the node ErrF3ParticipationTooManyInstances
// is returned.
// instance at any time. The number of instances must be at least 1. If the
// number of instances is beyond the maximum leasable participation instances
// accepted by the node ErrF3ParticipationTooManyInstances is returned.
//
// Note: Successfully acquiring a ticket alone does not constitute participation.
// The retrieved ticket must be used to invoke F3Participate to actively engage
Expand Down Expand Up @@ -980,8 +979,8 @@ type F3ParticipationTicket []byte
type F3ParticipationLease struct {
// Network is the name of the network this lease belongs to.
Network gpbft.NetworkName
// Issuer is the identity of the node that issued the lease.
Issuer peer.ID
// Issuer is the identity of the node that issued the lease, encoded as base58.
Issuer string
// MinerID is the actor ID of the miner that holds the lease.
MinerID uint64
// FromInstance specifies the instance ID from which this lease is valid.
Expand Down
225 changes: 0 additions & 225 deletions api/cbor_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 89b0941

Please sign in to comment.