Skip to content

Commit 89b0941

Browse files
authored
fix: support Forrest parity testing for F3 participation APIs (#12615)
* 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.
1 parent 7c0c493 commit 89b0941

10 files changed

+224
-253
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
- 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))
1818
- 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))
1919

20+
- 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))
21+
2022
## Deps
2123

2224
# UNRELEASED Node v1.30.0

api/api_full.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
blocks "github.com/ipfs/go-block-format"
1010
"github.com/ipfs/go-cid"
11-
"github.com/libp2p/go-libp2p/core/peer"
1211

1312
"github.com/filecoin-project/go-address"
1413
"github.com/filecoin-project/go-bitfield"
@@ -923,9 +922,9 @@ type FullNode interface {
923922
//
924923
// If there is an issuer mismatch (ErrF3ParticipationIssuerMismatch), the miner
925924
// must retry obtaining a new ticket to ensure it is only participating in one F3
926-
// instance at any time. If the number of instances is beyond the maximum leasable
927-
// participation instances accepted by the node ErrF3ParticipationTooManyInstances
928-
// is returned.
925+
// instance at any time. The number of instances must be at least 1. If the
926+
// number of instances is beyond the maximum leasable participation instances
927+
// accepted by the node ErrF3ParticipationTooManyInstances is returned.
929928
//
930929
// Note: Successfully acquiring a ticket alone does not constitute participation.
931930
// The retrieved ticket must be used to invoke F3Participate to actively engage
@@ -980,8 +979,8 @@ type F3ParticipationTicket []byte
980979
type F3ParticipationLease struct {
981980
// Network is the name of the network this lease belongs to.
982981
Network gpbft.NetworkName
983-
// Issuer is the identity of the node that issued the lease.
984-
Issuer peer.ID
982+
// Issuer is the identity of the node that issued the lease, encoded as base58.
983+
Issuer string
985984
// MinerID is the actor ID of the miner that holds the lease.
986985
MinerID uint64
987986
// FromInstance specifies the instance ID from which this lease is valid.

api/cbor_gen.go

-225
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)