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

build: backport changes to release/v1.30.0 branch #12663

Merged
merged 10 commits into from
Nov 6, 2024
Merged
Binary file modified build/actors/v15.tar.zst
Binary file not shown.
4 changes: 2 additions & 2 deletions build/buildconstants/params_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ const UpgradePhoenixHeight abi.ChainEpoch = UpgradeDragonHeight + 120
// 2024-08-06T12:00:00Z
const UpgradeWaffleHeight abi.ChainEpoch = 4154640

// ??????
var UpgradeTuktukHeight = abi.ChainEpoch(9999999999)
// 2024-11-20T23:00:00Z
var UpgradeTuktukHeight = abi.ChainEpoch(4461240)

// FIP-0081: for the power actor state for pledge calculations.
// UpgradeTuktukPowerRampDurationEpochs ends up in the power actor state after
Expand Down
14 changes: 7 additions & 7 deletions build/builtin_actors_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ var EmbeddedBuiltinActorsMetadata = []*BuiltinActorsMetadata{{
}, {
Network: "butterflynet",
Version: 15,
BundleGitTag: "v15.0.0-rc1",
BundleGitTag: "v15.0.0",
ManifestCid: cid.MustParse("bafy2bzacearjal5rsmzloz3ny7aoju2rgw66wgxdrydgg27thcsazbmf5qihq"),
Actors: map[string]cid.Cid{
"account": cid.MustParse("bafk2bzaceapjxl4kobnxn267u42nh2feouubkxcm62vzrk2nrfkqmtz6rgfw4"),
Expand Down Expand Up @@ -341,7 +341,7 @@ var EmbeddedBuiltinActorsMetadata = []*BuiltinActorsMetadata{{
}, {
Network: "calibrationnet",
Version: 15,
BundleGitTag: "v15.0.0-rc1",
BundleGitTag: "v15.0.0",
ManifestCid: cid.MustParse("bafy2bzaceax5zkysst7vtyup4whdxwzlpnaya3qp34rnoi6gyt4pongps7obw"),
Actors: map[string]cid.Cid{
"account": cid.MustParse("bafk2bzacecwdkoknhok52hlddoetdkqfwohhv4bx6csu3x6o7aduryv5ufssu"),
Expand Down Expand Up @@ -525,7 +525,7 @@ var EmbeddedBuiltinActorsMetadata = []*BuiltinActorsMetadata{{
}, {
Network: "caterpillarnet",
Version: 15,
BundleGitTag: "v15.0.0-rc1",
BundleGitTag: "v15.0.0",
ManifestCid: cid.MustParse("bafy2bzaceaw24gctg3dx6pzrymhggsp32c7mofjscwnylk4pzsqmilolygwhi"),
Actors: map[string]cid.Cid{
"account": cid.MustParse("bafk2bzacecmm4ymqjjbonet2yxe7l4jqg3uphcxmiz6vwyza4d4tfiy7hu3j4"),
Expand Down Expand Up @@ -700,7 +700,7 @@ var EmbeddedBuiltinActorsMetadata = []*BuiltinActorsMetadata{{
}, {
Network: "devnet",
Version: 15,
BundleGitTag: "v15.0.0-rc1",
BundleGitTag: "v15.0.0",
ManifestCid: cid.MustParse("bafy2bzacedlusqjwf7chvl2ve2fum5noyqrtjzcrzkhpbzpkg7puiru7dj4ug"),
Actors: map[string]cid.Cid{
"account": cid.MustParse("bafk2bzaceb7f7gjyz2fkzkbf6jlwttjinny4nci4zdoby7r246xuyc4e2n7me"),
Expand Down Expand Up @@ -898,7 +898,7 @@ var EmbeddedBuiltinActorsMetadata = []*BuiltinActorsMetadata{{
}, {
Network: "mainnet",
Version: 15,
BundleGitTag: "v15.0.0-rc1",
BundleGitTag: "v15.0.0",
ManifestCid: cid.MustParse("bafy2bzaceakwje2hyinucrhgtsfo44p54iw4g6otbv5ghov65vajhxgntr53u"),
Actors: map[string]cid.Cid{
"account": cid.MustParse("bafk2bzacecia5zacqt4gvd4z7275lnkhgraq75shy63cphakphhw6crf4joii"),
Expand Down Expand Up @@ -1073,7 +1073,7 @@ var EmbeddedBuiltinActorsMetadata = []*BuiltinActorsMetadata{{
}, {
Network: "testing",
Version: 15,
BundleGitTag: "v15.0.0-rc1",
BundleGitTag: "v15.0.0",
ManifestCid: cid.MustParse("bafy2bzacedio6qbcgxduz3y2zksor5dgyt3ieiugnugvsz6k2jdzwvugwahag"),
Actors: map[string]cid.Cid{
"account": cid.MustParse("bafk2bzaceabav73gljoyhtozycl5dqwomg4vviuy2jimte545yx3vgg3vfnyo"),
Expand Down Expand Up @@ -1248,7 +1248,7 @@ var EmbeddedBuiltinActorsMetadata = []*BuiltinActorsMetadata{{
}, {
Network: "testing-fake-proofs",
Version: 15,
BundleGitTag: "v15.0.0-rc1",
BundleGitTag: "v15.0.0",
ManifestCid: cid.MustParse("bafy2bzacea3jtzs4jz75ht3ncdyvabef4spz7w375ja7spp36yy3zwp5ji2wi"),
Actors: map[string]cid.Cid{
"account": cid.MustParse("bafk2bzaceabav73gljoyhtozycl5dqwomg4vviuy2jimte545yx3vgg3vfnyo"),
Expand Down
21 changes: 21 additions & 0 deletions build/params_shared_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,24 @@ func IsF3Enabled() bool {
return false
}
}

func IsF3PassiveTestingEnabled() bool {
if !IsF3Enabled() {
return false
}
const F3DisablePassiveTesting = "LOTUS_DISABLE_F3_PASSIVE_TESTING"

v, disableEnvVarSet := os.LookupEnv(F3DisablePassiveTesting)
if !disableEnvVarSet {
// Environment variable to disable F3 passive testing is not set.
return true
}
switch strings.TrimSpace(strings.ToLower(v)) {
case "", "0", "false", "no":
// Consider these values as "do not disable".
return true
default:
// Consider any other value as disable.
return false
}
}
3 changes: 2 additions & 1 deletion chain/lf3/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/filecoin-project/go-f3/ec"
"github.com/filecoin-project/go-f3/manifest"

"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/node/modules/helpers"
Expand All @@ -35,7 +36,7 @@ func (hg *headGetter) GetHead(context.Context) (ec.TipSet, error) {
var MaxDynamicManifestChangesAllowed = 1000

func NewManifestProvider(mctx helpers.MetricsCtx, config *Config, cs *store.ChainStore, ps *pubsub.PubSub, mds dtypes.MetadataDS) (prov manifest.ManifestProvider, err error) {
if config.DynamicManifestProvider == "" {
if config.DynamicManifestProvider == "" || !build.IsF3PassiveTestingEnabled() {
if config.StaticManifest == nil {
return manifest.NoopManifestProvider{}, nil
}
Expand Down
6 changes: 6 additions & 0 deletions chain/lf3/participation.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/filecoin-project/go-f3/manifest"

"github.com/filecoin-project/lotus/api"
cliutil "github.com/filecoin-project/lotus/cli/util"
"github.com/filecoin-project/lotus/node/modules/dtypes"
)

Expand Down Expand Up @@ -89,6 +90,11 @@ func (p *Participant) run(ctx context.Context) (_err error) {
}
}()

// Try to make send all requests to the same node. If a request fails, we'll switch nodes.
// This interacts with the FullNodeProxy, which is how we support multi-node setups by
// default.
ctx = cliutil.OnSingleNode(ctx)

var ticket api.F3ParticipationTicket
for ctx.Err() == nil {
var err error
Expand Down
2 changes: 2 additions & 0 deletions chain/lf3/participation_lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ func (l *leaser) participate(ticket api.F3ParticipationTicket) (api.F3Participat
if found {
// short-circuite for reparticipation.
if currentLease == newLease {
newLease.ValidityTerm = newLease.ToInstance() - instant.ID
newLease.FromInstance = instant.ID
return newLease, nil
}
if currentLease.Network == newLease.Network && currentLease.FromInstance > newLease.FromInstance {
Expand Down
9 changes: 9 additions & 0 deletions chain/lf3/participation_lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ func TestLeaser(t *testing.T) {
require.Equal(t, issuer.String(), lease.Issuer)
require.Equal(t, uint64(10), lease.FromInstance) // Current instance (10) + offset (5)
require.Equal(t, uint64(5), lease.ValidityTerm) // Current instance (10) + offset (5)

progress.currentInstance += 2

lease, err = subject.participate(ticket)
require.NoError(t, err)
require.Equal(t, uint64(123), lease.MinerID)
require.Equal(t, issuer.String(), lease.Issuer)
require.Equal(t, uint64(12), lease.FromInstance) // Current instance (10) + offset (5)
require.Equal(t, uint64(3), lease.ValidityTerm) // Current instance (10) + offset (5)
})
t.Run("get participants", func(t *testing.T) {
progress.currentInstance = 11
Expand Down
1 change: 1 addition & 0 deletions cli/clicommands/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var Commands = []*cli.Command{
lcli.WithCategory("developer", lcli.EvmCmd),
lcli.WithCategory("network", lcli.NetCmd),
lcli.WithCategory("network", lcli.SyncCmd),
lcli.WithCategory("network", lcli.F3Cmd),
lcli.WithCategory("status", lcli.StatusCmd),
lcli.PprofCmd,
lcli.VersionCmd,
Expand Down
11 changes: 8 additions & 3 deletions cli/f3.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ An omitted <from> value is always interpreted as 0, and an omitted
<to> value indicates the latest instance. If both are specified, <from>
must never exceed <to>.

If no range is specified all certificates are listed, i.e. the range
of '0..'.
If no range is specified, the latest 10 certificates are listed, i.e.
the range of '0..' with limit of 10. Otherwise, all certificates in
the specified range are listed unless limit is explicitly specified.

Examples:
* All certificates from newest to oldest:
Expand Down Expand Up @@ -181,6 +182,10 @@ Examples:
fromTo := cctx.Args().First()
if fromTo == "" {
fromTo = "0.."
if !cctx.IsSet(f3FlagInstanceLimit.Name) {
// Default to limit of 10 if no explicit range and limit is given.
limit = 10
}
}
r, err := newRanger(fromTo, limit, reverse, func() (uint64, error) {
latest, err := api.F3GetLatestCertificate(cctx.Context)
Expand Down Expand Up @@ -306,7 +311,7 @@ Examples:
f3FlagInstanceLimit = &cli.IntFlag{
Name: "limit",
Usage: "The maximum number of instances. A value less than 0 indicates no limit.",
DefaultText: "No limit",
DefaultText: "10 when no range is specified. Otherwise, unlimited.",
Value: -1,
}
f3FlagReverseOrder = &cli.BoolFlag{
Expand Down
36 changes: 21 additions & 15 deletions cli/util/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os/signal"
"reflect"
"strings"
"sync/atomic"
"syscall"
"time"

Expand Down Expand Up @@ -229,9 +230,12 @@ func GetFullNodeAPI(ctx *cli.Context) (v0api.FullNode, jsonrpc.ClientCloser, err

type contextKey string

// OnSingleNode is not thread safe
// OnSingleNode returns a modified context that, when passed to a method on a FullNodeProxy, will
// cause all calls to be directed at the same node when possible.
//
// Think "sticky sessions".
func OnSingleNode(ctx context.Context) context.Context {
return context.WithValue(ctx, contextKey("retry-node"), new(*int))
return context.WithValue(ctx, contextKey("retry-node"), new(atomic.Int32))
}

func FullNodeProxy[T api.FullNode](ins []T, outstr *api.FullNodeStruct) {
Expand Down Expand Up @@ -262,27 +266,29 @@ func FullNodeProxy[T api.FullNode](ins []T, outstr *api.FullNodeStruct) {

ctx := args[0].Interface().(context.Context)

curr := -1

// for calls that need to be performed on the same node
// primarily for miner when calling create block and submit block subsequently
key := contextKey("retry-node")
if ctx.Value(key) != nil {
if (*ctx.Value(key).(**int)) == nil {
*ctx.Value(key).(**int) = &curr
} else {
curr = **ctx.Value(key).(**int) - 1
}
var curr *atomic.Int32
if v, ok := ctx.Value(contextKey("retry-node")).(*atomic.Int32); ok {
curr = v
} else {
curr = new(atomic.Int32)
}

total := len(rins)
total := int32(len(rins))
result, _ := retry.Retry(ctx, 5, initialBackoff, errorsToRetry, func() ([]reflect.Value, error) {
curr = (curr + 1) % total

result := fns[curr].Call(args)
idx := curr.Load()
result := fns[idx].Call(args)
if result[len(result)-1].IsNil() {
return result, nil
}
// On failure, switch to the next node.
//
// We CAS instead of incrementing because this might have
// already been incremented by a concurrent call if we have
// a shared `curr` (we're sticky to a single node).
curr.CompareAndSwap(idx, (idx+1)%total)

e := result[len(result)-1].Interface().(error)
return result, e
})
Expand Down
Loading
Loading