diff --git a/app/node/builder.go b/app/node/builder.go index af606fc015..23f7f46ddd 100644 --- a/app/node/builder.go +++ b/app/node/builder.go @@ -15,6 +15,7 @@ import ( "github.com/libp2p/go-libp2p" "github.com/pkg/errors" + "github.com/filecoin-project/venus/app/submodule/actorevent" "github.com/filecoin-project/venus/app/submodule/blockstore" "github.com/filecoin-project/venus/app/submodule/chain" "github.com/filecoin-project/venus/app/submodule/common" @@ -171,6 +172,10 @@ func (b *Builder) build(ctx context.Context) (*Node, error) { return nil, err } + if nd.actorEvent, err = actorevent.NewActorEventSubModule(ctx, b.repo.Config(), nd.chain, nd.eth); err != nil { + return nil, err + } + apiBuilder := NewBuilder() apiBuilder.NameSpace("Filecoin") @@ -188,6 +193,7 @@ func (b *Builder) build(ctx context.Context) (*Node, error) { nd.market, nd.common, nd.eth, + nd.actorEvent, ) if err != nil { diff --git a/app/node/node.go b/app/node/node.go index 6134eef64a..8a55c3baac 100644 --- a/app/node/node.go +++ b/app/node/node.go @@ -11,6 +11,7 @@ import ( "github.com/awnumar/memguard" "github.com/etherlabsio/healthcheck/v2" "github.com/filecoin-project/go-jsonrpc" + "github.com/filecoin-project/venus/app/submodule/actorevent" "github.com/filecoin-project/venus/app/submodule/blockstore" chain2 "github.com/filecoin-project/venus/app/submodule/chain" "github.com/filecoin-project/venus/app/submodule/common" @@ -100,7 +101,8 @@ type Node struct { common *common.CommonModule - eth *eth.EthSubModule + eth *eth.EthSubModule + actorEvent *actorevent.ActorEventSubModule // // Jsonrpc diff --git a/app/node/rpc.go b/app/node/rpc.go index 04a3a55fb2..549e48eecf 100644 --- a/app/node/rpc.go +++ b/app/node/rpc.go @@ -5,6 +5,7 @@ import ( "reflect" "github.com/filecoin-project/go-jsonrpc" + "github.com/filecoin-project/venus/app/submodule/actorevent" "github.com/filecoin-project/venus/app/submodule/eth" v0api "github.com/filecoin-project/venus/venus-shared/api/chain/v0" v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1" @@ -40,6 +41,7 @@ func (builder *RPCBuilder) AddServices(services ...RPCService) error { } var ethSubModuleTyp = reflect.TypeOf(ð.EthSubModule{}).Elem() +var actorEventSubModuleTyp = reflect.TypeOf(&actorevent.ActorEventSubModule{}).Elem() func skipV0API(in interface{}) bool { inT := reflect.TypeOf(in) @@ -47,7 +49,7 @@ func skipV0API(in interface{}) bool { inT = inT.Elem() } - return inT.AssignableTo(ethSubModuleTyp) + return inT.AssignableTo(ethSubModuleTyp) || inT.AssignableTo(actorEventSubModuleTyp) } func (builder *RPCBuilder) AddV0API(service RPCService) error { diff --git a/app/submodule/actorevent/actor_event.go b/app/submodule/actorevent/actor_event.go new file mode 100644 index 0000000000..26d0156b56 --- /dev/null +++ b/app/submodule/actorevent/actor_event.go @@ -0,0 +1,364 @@ +package actorevent + +import ( + "context" + "fmt" + "time" + + "github.com/ipfs/go-cid" + logging "github.com/ipfs/go-log/v2" + "github.com/raulk/clock" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + + "github.com/filecoin-project/venus/pkg/events/filter" + "github.com/filecoin-project/venus/venus-shared/api" + v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1" + "github.com/filecoin-project/venus/venus-shared/types" +) + +var log = logging.Logger("actor_event") + +type ChainAccessor interface { + GetHead() *types.TipSet +} + +type EventFilterManager interface { + Install( + ctx context.Context, + minHeight, maxHeight abi.ChainEpoch, + tipsetCid cid.Cid, + addresses []address.Address, + keysWithCodec map[string][]types.ActorEventBlock, + excludeReverted bool, + ) (filter.EventFilter, error) + Remove(ctx context.Context, id types.FilterID) error +} + +type ActorEventHandler struct { // nolint + chain ChainAccessor + eventFilterManager EventFilterManager + blockDelay time.Duration + maxFilterHeightRange abi.ChainEpoch + clock clock.Clock +} + +var _ v1api.IActorEvent = (*ActorEventHandler)(nil) + +func NewActorEventHandler( + chain ChainAccessor, + eventFilterManager EventFilterManager, + blockDelay time.Duration, + maxFilterHeightRange abi.ChainEpoch, +) *ActorEventHandler { + return &ActorEventHandler{ + chain: chain, + eventFilterManager: eventFilterManager, + blockDelay: blockDelay, + maxFilterHeightRange: maxFilterHeightRange, + clock: clock.New(), + } +} + +func NewActorEventHandlerWithClock( + chain ChainAccessor, + eventFilterManager EventFilterManager, + blockDelay time.Duration, + maxFilterHeightRange abi.ChainEpoch, + clock clock.Clock, +) *ActorEventHandler { + return &ActorEventHandler{ + chain: chain, + eventFilterManager: eventFilterManager, + blockDelay: blockDelay, + maxFilterHeightRange: maxFilterHeightRange, + clock: clock, + } +} + +func (a *ActorEventHandler) GetActorEvents(ctx context.Context, evtFilter *types.ActorEventFilter) ([]*types.ActorEvent, error) { + if a.eventFilterManager == nil { + return nil, api.ErrNotSupported + } + + if evtFilter == nil { + evtFilter = &types.ActorEventFilter{} + } + params, err := a.parseFilter(*evtFilter) + if err != nil { + return nil, err + } + + // Install a filter just for this call, collect events, remove the filter + tipSetCid, err := params.GetTipSetCid() + if err != nil { + return nil, fmt.Errorf("failed to get tipset cid: %w", err) + } + f, err := a.eventFilterManager.Install(ctx, params.MinHeight, params.MaxHeight, tipSetCid, evtFilter.Addresses, evtFilter.Fields, false) + if err != nil { + return nil, err + } + defer func() { + // Remove the temporary filter regardless of the original context. + if err := a.eventFilterManager.Remove(context.Background(), f.ID()); err != nil { + log.Warnf("failed to remove filter: %s", err) + } + }() + return getCollected(ctx, f), nil +} + +type filterParams struct { + MinHeight abi.ChainEpoch + MaxHeight abi.ChainEpoch + TipSetKey types.TipSetKey +} + +func (fp filterParams) GetTipSetCid() (cid.Cid, error) { + if fp.TipSetKey.IsEmpty() { + return cid.Undef, nil + } + return fp.TipSetKey.Cid() +} + +func (a *ActorEventHandler) parseFilter(f types.ActorEventFilter) (*filterParams, error) { + if f.TipSetKey != nil && !f.TipSetKey.IsEmpty() { + if f.FromHeight != nil || f.ToHeight != nil { + return nil, fmt.Errorf("cannot specify both TipSetKey and FromHeight/ToHeight") + } + + return &filterParams{ + MinHeight: 0, + MaxHeight: 0, + TipSetKey: *f.TipSetKey, + }, nil + } + + min, max, err := parseHeightRange(a.chain.GetHead().Height(), f.FromHeight, f.ToHeight, a.maxFilterHeightRange) + if err != nil { + return nil, err + } + + return &filterParams{ + MinHeight: min, + MaxHeight: max, + TipSetKey: types.EmptyTSK, + }, nil +} + +// parseHeightRange is similar to eth's parseBlockRange but with slightly different semantics but +// results in equivalent values that we can plug in to the EventFilterManager. +// +// * Uses "height", allowing for nillable values rather than strings +// * No "latest" and "earliest", those are now represented by nil on the way in and -1 on the way out +// * No option for hex representation +func parseHeightRange(heaviest abi.ChainEpoch, fromHeight, toHeight *abi.ChainEpoch, maxRange abi.ChainEpoch) (minHeight abi.ChainEpoch, maxHeight abi.ChainEpoch, err error) { + if fromHeight != nil && *fromHeight < 0 { + return 0, 0, fmt.Errorf("range 'from' must be greater than or equal to 0") + } + if fromHeight == nil { + minHeight = -1 + } else { + minHeight = *fromHeight + } + if toHeight == nil { + maxHeight = -1 + } else { + maxHeight = *toHeight + } + + // Validate height ranges are within limits set by node operator + if minHeight == -1 && maxHeight > 0 { + // Here the client is looking for events between the head and some future height + if maxHeight-heaviest > maxRange { + return 0, 0, fmt.Errorf("invalid epoch range: 'to' height is too far in the future (maximum: %d)", maxRange) + } + } else if minHeight >= 0 && maxHeight == -1 { + // Here the client is looking for events between some time in the past and the current head + if heaviest-minHeight > maxRange { + return 0, 0, fmt.Errorf("invalid epoch range: 'from' height is too far in the past (maximum: %d)", maxRange) + } + } else if minHeight >= 0 && maxHeight >= 0 { + if minHeight > maxHeight { + return 0, 0, fmt.Errorf("invalid epoch range: 'to' height (%d) must be after 'from' height (%d)", minHeight, maxHeight) + } else if maxHeight-minHeight > maxRange { + return 0, 0, fmt.Errorf("invalid epoch range: range between to and 'from' heights is too large (maximum: %d)", maxRange) + } + } + return minHeight, maxHeight, nil +} + +func (a *ActorEventHandler) SubscribeActorEvents(ctx context.Context, evtFilter *types.ActorEventFilter) (<-chan *types.ActorEvent, error) { + if a.eventFilterManager == nil { + return nil, api.ErrNotSupported + } + + if evtFilter == nil { + evtFilter = &types.ActorEventFilter{} + } + params, err := a.parseFilter(*evtFilter) + if err != nil { + return nil, err + } + + tipSetCid, err := params.GetTipSetCid() + if err != nil { + return nil, fmt.Errorf("failed to get tipset cid: %w", err) + } + fm, err := a.eventFilterManager.Install(ctx, params.MinHeight, params.MaxHeight, tipSetCid, evtFilter.Addresses, evtFilter.Fields, false) + if err != nil { + return nil, err + } + + // The goal for the code below is to send events on the `out` channel as fast as possible and not + // let it get too far behind the rate at which the events are generated. + // For historical events, we aim to send all events within a single block's time (30s on mainnet). + // This ensures that the client can catch up quickly enough to start receiving new events. + // For ongoing events, we also aim to send all events within a single block's time, so we never + // want to be buffering events (approximately) more than one epoch behind the current head. + // It's approximate because we only update our notion of "current epoch" once per ~blocktime. + + out := make(chan *types.ActorEvent) + + // When we start sending real-time events, we want to make sure that we don't fall behind more + // than one epoch's worth of events (approximately). Capture this value now, before we send + // historical events to allow for a little bit of slack in the historical event sending. + minBacklogHeight := a.chain.GetHead().Height() - 1 + + go func() { + defer func() { + // tell the caller we're done + close(out) + fm.ClearSubChannel() + if err := a.eventFilterManager.Remove(ctx, fm.ID()); err != nil { + log.Warnf("failed to remove filter: %s", err) + } + }() + + // Handle any historical events that our filter may have picked up ----------------------------- + + evs := getCollected(ctx, fm) + if len(evs) > 0 { + // ensure we get all events out on the channel within one block's time (30s on mainnet) + timer := a.clock.Timer(a.blockDelay) + for _, ev := range evs { + select { + case out <- ev: + case <-timer.C: + log.Errorf("closing event subscription due to slow event sending rate") + timer.Stop() + return + case <-ctx.Done(): + timer.Stop() + return + } + } + timer.Stop() + } + + // for the case where we have a MaxHeight set, we don't get a signal from the filter when we + // reach that height, so we need to check it ourselves, do it now but also in the loop + if params.MaxHeight > 0 && minBacklogHeight+1 >= params.MaxHeight { + return + } + + // Handle ongoing events from the filter ------------------------------------------------------- + + in := make(chan interface{}, 256) + fm.SetSubChannel(in) + + var buffer []*types.ActorEvent + nextBacklogHeightUpdate := a.clock.Now().Add(a.blockDelay) + + collectEvent := func(ev interface{}) bool { + ce, ok := ev.(*filter.CollectedEvent) + if !ok { + log.Errorf("got unexpected value from event filter: %T", ev) + return false + } + + if ce.Height < minBacklogHeight { + // since we mostly care about buffer size, we only trigger a too-slow close when the buffer + // increases, i.e. we collect a new event + log.Errorf("closing event subscription due to slow event sending rate") + return false + } + + buffer = append(buffer, &types.ActorEvent{ + Entries: ce.Entries, + Emitter: ce.EmitterAddr, + Reverted: ce.Reverted, + Height: ce.Height, + TipSetKey: ce.TipSetKey, + MsgCid: ce.MsgCid, + }) + return true + } + + ticker := a.clock.Ticker(a.blockDelay) + defer ticker.Stop() + + for ctx.Err() == nil { + if len(buffer) > 0 { + select { + case ev, ok := <-in: // incoming event + if !ok || !collectEvent(ev) { + return + } + case out <- buffer[0]: // successful send + buffer[0] = nil + buffer = buffer[1:] + case <-ticker.C: + // check that our backlog isn't too big by looking at the oldest event + if buffer[0].Height < minBacklogHeight { + log.Errorf("closing event subscription due to slow event sending rate") + return + } + case <-ctx.Done(): + return + } + } else { + select { + case ev, ok := <-in: // incoming event + if !ok || !collectEvent(ev) { + return + } + case <-ctx.Done(): + return + case <-ticker.C: + currentHeight := a.chain.GetHead().Height() + if params.MaxHeight > 0 && currentHeight > params.MaxHeight { + // we've reached the filter's MaxHeight, we're done so we can close the channel + return + } + } + } + + if a.clock.Now().After(nextBacklogHeightUpdate) { + minBacklogHeight = a.chain.GetHead().Height() - 1 + nextBacklogHeightUpdate = a.clock.Now().Add(a.blockDelay) + } + } + }() + + return out, nil +} + +func getCollected(ctx context.Context, f filter.EventFilter) []*types.ActorEvent { + ces := f.TakeCollectedEvents(ctx) + + var out []*types.ActorEvent + + for _, e := range ces { + out = append(out, &types.ActorEvent{ + Entries: e.Entries, + Emitter: e.EmitterAddr, + Reverted: e.Reverted, + Height: e.Height, + TipSetKey: e.TipSetKey, + MsgCid: e.MsgCid, + }) + } + + return out +} diff --git a/app/submodule/actorevent/actor_event_module.go b/app/submodule/actorevent/actor_event_module.go new file mode 100644 index 0000000000..a1bfa700d4 --- /dev/null +++ b/app/submodule/actorevent/actor_event_module.go @@ -0,0 +1,59 @@ +package actorevent + +import ( + "context" + "time" + + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/venus/app/submodule/chain" + "github.com/filecoin-project/venus/app/submodule/eth" + "github.com/filecoin-project/venus/pkg/config" + v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1" +) + +type ActorEventSubModule struct { // nolint + chainModule *chain.ChainSubmodule + ethModule *eth.EthSubModule + cfg *config.Config + actorEventHandler v1api.IActorEvent +} + +func NewActorEventSubModule(ctx context.Context, + cfg *config.Config, + chainModule *chain.ChainSubmodule, + ethModule *eth.EthSubModule, +) (*ActorEventSubModule, error) { + aem := &ActorEventSubModule{ + cfg: cfg, + ethModule: ethModule, + chainModule: chainModule, + actorEventHandler: &ActorEventDummy{}, + } + + if !cfg.EventsConfig.EnableActorEventsAPI { + return aem, nil + } + + fm := ethModule.GetEventFilterManager() + if cfg.FevmConfig.Event.DisableRealTimeFilterAPI { + fm = nil + } + + netParams, err := chainModule.API().StateGetNetworkParams(ctx) + if err != nil { + return nil, err + } + + aem.actorEventHandler = NewActorEventHandler( + chainModule.ChainReader, + fm, + time.Duration(netParams.BlockDelaySecs)*time.Second, + abi.ChainEpoch(cfg.FevmConfig.Event.MaxFilterHeightRange), + ) + + return aem, nil +} + +func (aem *ActorEventSubModule) API() v1api.IActorEvent { + return aem.actorEventHandler +} diff --git a/app/submodule/actorevent/actor_event_test.go b/app/submodule/actorevent/actor_event_test.go new file mode 100644 index 0000000000..063b68b76d --- /dev/null +++ b/app/submodule/actorevent/actor_event_test.go @@ -0,0 +1,780 @@ +package actorevent + +import ( + "context" + "fmt" + pseudo "math/rand" + "sync" + "testing" + "time" + + "github.com/ipfs/go-cid" + "github.com/multiformats/go-multihash" + "github.com/raulk/clock" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/crypto" + + "github.com/filecoin-project/venus/pkg/events/filter" + "github.com/filecoin-project/venus/venus-shared/types" +) + +var testCid = cid.MustParse("bafyreicmaj5hhoy5mgqvamfhgexxyergw7hdeshizghodwkjg6qmpoco7i") + +func TestParseHeightRange(t *testing.T) { + testCases := []struct { + name string + heaviest abi.ChainEpoch + from *abi.ChainEpoch + to *abi.ChainEpoch + maxRange abi.ChainEpoch + minOut abi.ChainEpoch + maxOut abi.ChainEpoch + errStr string + }{ + { + name: "fails when both are specified and range is greater than max allowed range", + heaviest: 100, + from: epochPtr(256), + to: epochPtr(512), + maxRange: 10, + minOut: 0, + maxOut: 0, + errStr: "too large", + }, + { + name: "fails when min is specified and range is greater than max allowed range", + heaviest: 500, + from: epochPtr(16), + to: nil, + maxRange: 10, + minOut: 0, + maxOut: 0, + errStr: "'from' height is too far in the past", + }, + { + name: "fails when max is specified and range is greater than max allowed range", + heaviest: 500, + from: nil, + to: epochPtr(65536), + maxRange: 10, + minOut: 0, + maxOut: 0, + errStr: "'to' height is too far in the future", + }, + { + name: "fails when from is greater than to", + heaviest: 100, + from: epochPtr(512), + to: epochPtr(256), + maxRange: 10, + minOut: 0, + maxOut: 0, + errStr: "must be after", + }, + { + name: "works when range is valid (nil from)", + heaviest: 500, + from: nil, + to: epochPtr(48), + maxRange: 1000, + minOut: -1, + maxOut: 48, + }, + { + name: "works when range is valid (nil to)", + heaviest: 500, + from: epochPtr(0), + to: nil, + maxRange: 1000, + minOut: 0, + maxOut: -1, + }, + { + name: "works when range is valid (nil from and to)", + heaviest: 500, + from: nil, + to: nil, + maxRange: 1000, + minOut: -1, + maxOut: -1, + }, + { + name: "works when range is valid and specified", + heaviest: 500, + from: epochPtr(16), + to: epochPtr(48), + maxRange: 1000, + minOut: 16, + maxOut: 48, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + req := require.New(t) + min, max, err := parseHeightRange(tc.heaviest, tc.from, tc.to, tc.maxRange) + req.Equal(tc.minOut, min) + req.Equal(tc.maxOut, max) + if tc.errStr != "" { + t.Log(err) + req.Error(err) + req.Contains(err.Error(), tc.errStr) + } else { + req.NoError(err) + } + }) + } +} + +func TestGetActorEvents(t *testing.T) { + ctx := context.Background() + req := require.New(t) + + const ( + seed = 984651320 + maxFilterHeightRange = 100 + ) + + t.Logf("seed: %d", seed) + rng := pseudo.New(pseudo.NewSource(seed)) + + minerAddr, err := address.NewIDAddress(uint64(rng.Int63())) + req.NoError(err) + + testCases := []struct { + name string + filter *types.ActorEventFilter + currentHeight int64 + installMinHeight int64 + installMaxHeight int64 + installTipSetKey cid.Cid + installAddresses []address.Address + installKeysWithCodec map[string][]types.ActorEventBlock + installExcludeReverted bool + expectErr string + }{ + { + name: "nil filter", + filter: nil, + installMinHeight: -1, + installMaxHeight: -1, + }, + { + name: "empty filter", + filter: &types.ActorEventFilter{}, + installMinHeight: -1, + installMaxHeight: -1, + }, + { + name: "basic height range filter", + filter: &types.ActorEventFilter{ + FromHeight: epochPtr(0), + ToHeight: epochPtr(maxFilterHeightRange), + }, + installMinHeight: 0, + installMaxHeight: maxFilterHeightRange, + }, + { + name: "from, no to height", + filter: &types.ActorEventFilter{ + FromHeight: epochPtr(0), + }, + currentHeight: maxFilterHeightRange - 1, + installMinHeight: 0, + installMaxHeight: -1, + }, + { + name: "to, no from height", + filter: &types.ActorEventFilter{ + ToHeight: epochPtr(maxFilterHeightRange - 1), + }, + installMinHeight: -1, + installMaxHeight: maxFilterHeightRange - 1, + }, + { + name: "from, no to height, too far", + filter: &types.ActorEventFilter{ + FromHeight: epochPtr(0), + }, + currentHeight: maxFilterHeightRange + 1, + expectErr: "invalid epoch range: 'from' height is too far in the past", + }, + { + name: "to, no from height, too far", + filter: &types.ActorEventFilter{ + ToHeight: epochPtr(maxFilterHeightRange + 1), + }, + currentHeight: 0, + expectErr: "invalid epoch range: 'to' height is too far in the future", + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + efm := newMockEventFilterManager(t) + collectedEvents := makeCollectedEvents(t, rng, 0, 1, 10) + filter := newMockFilter(ctx, t, rng, collectedEvents) + + if tc.expectErr == "" { + efm.expectInstall(abi.ChainEpoch(tc.installMinHeight), abi.ChainEpoch(tc.installMaxHeight), tc.installTipSetKey, tc.installAddresses, tc.installKeysWithCodec, tc.installExcludeReverted, filter) + } + + ts, err := types.NewTipSet([]*types.BlockHeader{newBlockHeader(minerAddr, tc.currentHeight)}) + req.NoError(err) + chain := newMockChainAccessor(t, ts) + + handler := NewActorEventHandler(chain, efm, 50*time.Millisecond, maxFilterHeightRange) + + gotEvents, err := handler.GetActorEvents(ctx, tc.filter) + if tc.expectErr != "" { + req.Error(err) + req.Contains(err.Error(), tc.expectErr) + } else { + req.NoError(err) + expectedEvents := collectedToActorEvents(collectedEvents) + req.Equal(expectedEvents, gotEvents) + efm.requireRemoved(filter.ID()) + } + }) + } +} + +func TestSubscribeActorEvents(t *testing.T) { + const ( + seed = 984651320 + maxFilterHeightRange = 100 + blockDelay = 30 * time.Second + filterStartHeight = 0 + currentHeight = 10 + finishHeight = 20 + eventsPerEpoch = 2 + ) + t.Logf("seed: %d", seed) + rng := pseudo.New(pseudo.NewSource(seed)) + mockClock := clock.NewMock() + + minerAddr, err := address.NewIDAddress(uint64(rng.Int63())) + require.NoError(t, err) + + for _, tc := range []struct { + name string + receiveSpeed time.Duration // how fast will we receive all events _per epoch_ + expectComplete bool // do we expect this to succeed? + endEpoch int // -1 for no end + }{ + {"fast", 0, true, -1}, + {"fast with end", 0, true, finishHeight}, + {"half block speed", blockDelay / 2, true, -1}, + {"half block speed with end", blockDelay / 2, true, finishHeight}, + // testing exactly blockDelay is a border case and will be flaky + {"1.5 block speed", blockDelay * 3 / 2, false, -1}, + {"twice block speed", blockDelay * 2, false, -1}, + } { + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) + defer cancel() + + tc := tc + t.Run(tc.name, func(t *testing.T) { + req := require.New(t) + + mockClock.Set(time.Now()) + mockFilterManager := newMockEventFilterManager(t) + allEvents := makeCollectedEvents(t, rng, filterStartHeight, eventsPerEpoch, finishHeight) + historicalEvents := allEvents[0 : (currentHeight-filterStartHeight)*eventsPerEpoch] + mockFilter := newMockFilter(ctx, t, rng, historicalEvents) + mockFilterManager.expectInstall(abi.ChainEpoch(0), abi.ChainEpoch(tc.endEpoch), cid.Undef, nil, nil, false, mockFilter) + + ts, err := types.NewTipSet([]*types.BlockHeader{newBlockHeader(minerAddr, currentHeight)}) + req.NoError(err) + mockChain := newMockChainAccessor(t, ts) + + handler := NewActorEventHandlerWithClock(mockChain, mockFilterManager, blockDelay, maxFilterHeightRange, mockClock) + + aef := &types.ActorEventFilter{FromHeight: epochPtr(0)} + if tc.endEpoch >= 0 { + aef.ToHeight = epochPtr(tc.endEpoch) + } + eventChan, err := handler.SubscribeActorEvents(ctx, aef) + req.NoError(err) + + // assume we can cleanly pick up all historical events in one go + var gotEvents []*types.ActorEvent + for len(gotEvents) < len(historicalEvents) && ctx.Err() == nil { + select { + case e, ok := <-eventChan: + req.True(ok) + gotEvents = append(gotEvents, e) + case <-ctx.Done(): + t.Fatalf("timed out waiting for event") + } + } + req.Equal(collectedToActorEvents(historicalEvents), gotEvents) + + mockClock.Add(blockDelay) + nextReceiveTime := mockClock.Now() + + // Ticker to simulate both time and the chain advancing, including emitting events at + // the right time directly to the filter. + + var wg sync.WaitGroup + wg.Add(1) + go func() { + defer wg.Done() + for thisHeight := int64(currentHeight); ctx.Err() == nil; thisHeight++ { + ts, err := types.NewTipSet([]*types.BlockHeader{newBlockHeader(minerAddr, thisHeight)}) + req.NoError(err) + mockChain.setHeaviestTipSet(ts) + + var eventsThisEpoch []*filter.CollectedEvent + if thisHeight <= finishHeight { + eventsThisEpoch = allEvents[(thisHeight-filterStartHeight)*eventsPerEpoch : (thisHeight-filterStartHeight+2)*eventsPerEpoch] + } + for i := 0; i < eventsPerEpoch && ctx.Err() == nil; i++ { + if len(eventsThisEpoch) > 0 { + mockFilter.sendEventToChannel(eventsThisEpoch[0]) + eventsThisEpoch = eventsThisEpoch[1:] + } + select { + case <-time.After(2 * time.Millisecond): // allow everyone to catch a breath + mockClock.Add(blockDelay / eventsPerEpoch) + case <-ctx.Done(): + return + } + } + + if thisHeight == finishHeight+1 && tc.expectComplete && tc.endEpoch < 0 && ctx.Err() == nil { + // at finish+1, for the case where we expect clean completion and there is no ToEpoch + // set on the filter, if we send one more event at the next height so we end up with + // something uncollected in the buffer, causing a disconnect + evt := makeCollectedEvents(t, rng, finishHeight+1, 1, finishHeight+1)[0] + mockFilter.sendEventToChannel(evt) + } // else if endEpoch is set, we expect the chain advance to force closure + } + }() + + // Client collecting events off the channel + + var prematureEnd bool + for thisHeight := int64(currentHeight); thisHeight <= finishHeight && !prematureEnd && ctx.Err() == nil; thisHeight++ { + // delay to simulate latency + select { + case <-mockClock.After(nextReceiveTime.Sub(mockClock.Now())): + case <-ctx.Done(): + t.Fatalf("timed out simulating receive delay") + } + + // collect eventsPerEpoch more events + var newEvents []*types.ActorEvent + for len(newEvents) < eventsPerEpoch && !prematureEnd && ctx.Err() == nil { + select { + case e, ok := <-eventChan: // receive the events from the subscription + if ok { + newEvents = append(newEvents, e) + } else { + prematureEnd = true + } + case <-ctx.Done(): + t.Fatalf("timed out waiting for event") + } + nextReceiveTime = nextReceiveTime.Add(tc.receiveSpeed) + } + + if tc.expectComplete || !prematureEnd { + // sanity check that we got what we expected this epoch + req.Len(newEvents, eventsPerEpoch) + epochEvents := allEvents[(thisHeight)*eventsPerEpoch : (thisHeight+1)*eventsPerEpoch] + req.Equal(collectedToActorEvents(epochEvents), newEvents) + gotEvents = append(gotEvents, newEvents...) + } + } + + req.Equal(tc.expectComplete, !prematureEnd, "expected to complete") + if tc.expectComplete { + req.Len(gotEvents, len(allEvents)) + req.Equal(collectedToActorEvents(allEvents), gotEvents) + } else { + req.NotEqual(len(gotEvents), len(allEvents)) + } + + // cleanup + mockFilter.requireClearSubChannelCalledEventually(500 * time.Millisecond) + mockFilterManager.requireRemovedEventually(mockFilter.ID(), 500*time.Millisecond) + cancel() + wg.Wait() // wait for the chain to stop advancing + }) + } +} + +func TestSubscribeActorEvents_OnlyHistorical(t *testing.T) { + // Similar to TestSubscribeActorEvents but we set an explicit end that caps out at the current height + const ( + seed = 984651320 + maxFilterHeightRange = 100 + blockDelay = 30 * time.Second + filterStartHeight = 0 + currentHeight = 10 + eventsPerEpoch = 2 + ) + t.Logf("seed: %d", seed) + rng := pseudo.New(pseudo.NewSource(seed)) + mockClock := clock.NewMock() + + minerAddr, err := address.NewIDAddress(uint64(rng.Int63())) + require.NoError(t, err) + + for _, tc := range []struct { + name string + blockTimeToComplete float64 // fraction of a block time that it takes to receive all events + expectComplete bool // do we expect this to succeed? + }{ + {"fast", 0, true}, + {"half block speed", 0.5, true}, + {"1.5 block speed", 1.5, false}, + {"twice block speed", 2, false}, + } { + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) + defer cancel() + + tc := tc + t.Run(tc.name, func(t *testing.T) { + req := require.New(t) + + mockClock.Set(time.Now()) + mockFilterManager := newMockEventFilterManager(t) + allEvents := makeCollectedEvents(t, rng, filterStartHeight, eventsPerEpoch, currentHeight) + mockFilter := newMockFilter(ctx, t, rng, allEvents) + mockFilterManager.expectInstall(abi.ChainEpoch(0), abi.ChainEpoch(currentHeight), cid.Undef, nil, nil, false, mockFilter) + + ts, err := types.NewTipSet([]*types.BlockHeader{newBlockHeader(minerAddr, currentHeight)}) + req.NoError(err) + mockChain := newMockChainAccessor(t, ts) + + handler := NewActorEventHandlerWithClock(mockChain, mockFilterManager, blockDelay, maxFilterHeightRange, mockClock) + + aef := &types.ActorEventFilter{FromHeight: epochPtr(0), ToHeight: epochPtr(currentHeight)} + eventChan, err := handler.SubscribeActorEvents(ctx, aef) + req.NoError(err) + + var gotEvents []*types.ActorEvent + + // assume we can cleanly pick up all historical events in one go + receiveLoop: + for ctx.Err() == nil { + select { + case e, ok := <-eventChan: + if ok { + gotEvents = append(gotEvents, e) + mockClock.Add(time.Duration(float64(blockDelay) * tc.blockTimeToComplete / float64(len(allEvents)))) + // no need to advance the chain, we're also testing that's not necessary + time.Sleep(2 * time.Millisecond) // catch a breath + } else { + break receiveLoop + } + case <-ctx.Done(): + t.Fatalf("timed out waiting for event, got %d/%d events", len(gotEvents), len(allEvents)) + } + } + if tc.expectComplete { + req.Equal(collectedToActorEvents(allEvents), gotEvents) + } else { + req.NotEqual(len(gotEvents), len(allEvents)) + } + // advance the chain and observe cleanup + ts, err = types.NewTipSet([]*types.BlockHeader{newBlockHeader(minerAddr, currentHeight+1)}) + req.NoError(err) + mockChain.setHeaviestTipSet(ts) + mockClock.Add(blockDelay) + mockFilterManager.requireRemovedEventually(mockFilter.ID(), 1*time.Second) + }) + } +} + +var ( + _ ChainAccessor = (*mockChainAccessor)(nil) + _ filter.EventFilter = (*mockFilter)(nil) + _ EventFilterManager = (*mockEventFilterManager)(nil) +) + +type mockChainAccessor struct { + t *testing.T + ts *types.TipSet + lk sync.Mutex +} + +func newMockChainAccessor(t *testing.T, ts *types.TipSet) *mockChainAccessor { + return &mockChainAccessor{t: t, ts: ts} +} + +func (m *mockChainAccessor) setHeaviestTipSet(ts *types.TipSet) { + m.lk.Lock() + defer m.lk.Unlock() + m.ts = ts +} + +func (m *mockChainAccessor) GetHead() *types.TipSet { + m.lk.Lock() + defer m.lk.Unlock() + return m.ts +} + +type mockFilter struct { + t *testing.T + ctx context.Context + id types.FilterID + lastTaken time.Time + ch chan<- interface{} + historicalEvents []*filter.CollectedEvent + subChannelCalls int + clearSubChannelCalls int + lk sync.Mutex +} + +func newMockFilter(ctx context.Context, t *testing.T, rng *pseudo.Rand, historicalEvents []*filter.CollectedEvent) *mockFilter { + t.Helper() + var id [32]byte + _, err := rng.Read(id[:]) + require.NoError(t, err) + return &mockFilter{ + t: t, + ctx: ctx, + id: id, + historicalEvents: historicalEvents, + } +} + +func (m *mockFilter) sendEventToChannel(e *filter.CollectedEvent) { + m.lk.Lock() + defer m.lk.Unlock() + if m.ch != nil { + select { + case m.ch <- e: + case <-m.ctx.Done(): + } + } +} + +func (m *mockFilter) requireClearSubChannelCalledEventually(timeout time.Duration) { + m.t.Helper() + require.Eventually(m.t, + func() bool { + m.lk.Lock() + c := m.clearSubChannelCalls + m.lk.Unlock() + switch c { + case 0: + return false + case 1: + return true + default: + m.t.Fatalf("ClearSubChannel called more than once: %d", c) + return false + } + }, timeout, 10*time.Millisecond, "ClearSubChannel is not called exactly once") +} + +func (m *mockFilter) ID() types.FilterID { + return m.id +} + +func (m *mockFilter) LastTaken() time.Time { + return m.lastTaken +} + +func (m *mockFilter) SetSubChannel(ch chan<- interface{}) { + m.t.Helper() + m.lk.Lock() + defer m.lk.Unlock() + m.subChannelCalls++ + m.ch = ch +} + +func (m *mockFilter) ClearSubChannel() { + m.t.Helper() + m.lk.Lock() + defer m.lk.Unlock() + m.clearSubChannelCalls++ + m.ch = nil +} + +func (m *mockFilter) TakeCollectedEvents(context.Context) []*filter.CollectedEvent { + e := m.historicalEvents + m.historicalEvents = nil + m.lastTaken = time.Now() + return e +} + +func (m *mockFilter) CollectEvents(context.Context, *filter.TipSetEvents, bool, filter.AddressResolver) error { + m.t.Fatalf("unexpected call to CollectEvents") + return nil +} + +type filterManagerExpectation struct { + minHeight, maxHeight abi.ChainEpoch + tipsetCid cid.Cid + addresses []address.Address + keysWithCodec map[string][]types.ActorEventBlock + excludeReverted bool + returnFilter filter.EventFilter +} + +type mockEventFilterManager struct { + t *testing.T + expectations []filterManagerExpectation + removed []types.FilterID + lk sync.Mutex +} + +func newMockEventFilterManager(t *testing.T) *mockEventFilterManager { + return &mockEventFilterManager{t: t} +} + +func (m *mockEventFilterManager) expectInstall( + minHeight, maxHeight abi.ChainEpoch, + tipsetCid cid.Cid, + addresses []address.Address, + keysWithCodec map[string][]types.ActorEventBlock, + excludeReverted bool, + returnFilter filter.EventFilter) { + + m.t.Helper() + m.expectations = append(m.expectations, filterManagerExpectation{ + minHeight: minHeight, + maxHeight: maxHeight, + tipsetCid: tipsetCid, + addresses: addresses, + keysWithCodec: keysWithCodec, + excludeReverted: excludeReverted, + returnFilter: returnFilter, + }) +} + +func (m *mockEventFilterManager) requireRemoved(id types.FilterID) { + m.t.Helper() + m.lk.Lock() + defer m.lk.Unlock() + require.Contains(m.t, m.removed, id) +} + +func (m *mockEventFilterManager) requireRemovedEventually(id types.FilterID, timeout time.Duration) { + m.t.Helper() + require.Eventuallyf(m.t, func() bool { + m.lk.Lock() + defer m.lk.Unlock() + if len(m.removed) == 0 { + return false + } + assert.Contains(m.t, m.removed, id) + return true + }, timeout, 10*time.Millisecond, "filter %x not removed", id) +} + +func (m *mockEventFilterManager) Install( + _ context.Context, + minHeight, maxHeight abi.ChainEpoch, + tipsetCid cid.Cid, + addresses []address.Address, + keysWithCodec map[string][]types.ActorEventBlock, + excludeReverted bool, +) (filter.EventFilter, error) { + + require.True(m.t, len(m.expectations) > 0, "unexpected call to Install") + exp := m.expectations[0] + m.expectations = m.expectations[1:] + // check the expectation matches the call then return the attached filter + require.Equal(m.t, exp.minHeight, minHeight) + require.Equal(m.t, exp.maxHeight, maxHeight) + require.Equal(m.t, exp.tipsetCid, tipsetCid) + require.Equal(m.t, exp.addresses, addresses) + require.Equal(m.t, exp.keysWithCodec, keysWithCodec) + require.Equal(m.t, exp.excludeReverted, excludeReverted) + return exp.returnFilter, nil +} + +func (m *mockEventFilterManager) Remove(_ context.Context, id types.FilterID) error { + m.lk.Lock() + defer m.lk.Unlock() + m.removed = append(m.removed, id) + return nil +} + +func newBlockHeader(minerAddr address.Address, height int64) *types.BlockHeader { + return &types.BlockHeader{ + Miner: minerAddr, + Ticket: &types.Ticket{ + VRFProof: []byte("vrf proof0000000vrf proof0000000"), + }, + ElectionProof: &types.ElectionProof{ + VRFProof: []byte("vrf proof0000000vrf proof0000000"), + }, + Parents: []cid.Cid{testCid, testCid}, + ParentMessageReceipts: testCid, + BLSAggregate: &crypto.Signature{Type: crypto.SigTypeBLS, Data: []byte("sign me up")}, + ParentWeight: types.NewInt(123125126212), + Messages: testCid, + Height: abi.ChainEpoch(height), + ParentStateRoot: testCid, + BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS, Data: []byte("sign me up")}, + ParentBaseFee: types.NewInt(3432432843291), + } +} + +func epochPtr(i int) *abi.ChainEpoch { + e := abi.ChainEpoch(i) + return &e +} + +func collectedToActorEvents(collected []*filter.CollectedEvent) []*types.ActorEvent { + var out []*types.ActorEvent + for _, c := range collected { + out = append(out, &types.ActorEvent{ + Entries: c.Entries, + Emitter: c.EmitterAddr, + Reverted: c.Reverted, + Height: c.Height, + TipSetKey: c.TipSetKey, + MsgCid: c.MsgCid, + }) + } + return out +} + +func makeCollectedEvents(t *testing.T, rng *pseudo.Rand, eventStartHeight, eventsPerHeight, eventEndHeight int64) []*filter.CollectedEvent { + var out []*filter.CollectedEvent + for h := eventStartHeight; h <= eventEndHeight; h++ { + for i := int64(0); i < eventsPerHeight; i++ { + out = append(out, makeCollectedEvent(t, rng, types.NewTipSetKey(mkCid(t, fmt.Sprintf("h=%d", h))), abi.ChainEpoch(h))) + } + } + return out +} + +func makeCollectedEvent(t *testing.T, rng *pseudo.Rand, tsKey types.TipSetKey, height abi.ChainEpoch) *filter.CollectedEvent { + addr, err := address.NewIDAddress(uint64(rng.Int63())) + require.NoError(t, err) + + return &filter.CollectedEvent{ + Entries: []types.EventEntry{ + {Flags: 0x01, Key: "k1", Codec: cid.Raw, Value: []byte("v1")}, + {Flags: 0x01, Key: "k2", Codec: cid.Raw, Value: []byte("v2")}, + }, + EmitterAddr: addr, + EventIdx: 0, + Reverted: false, + Height: height, + TipSetKey: tsKey, + MsgIdx: 0, + MsgCid: testCid, + } +} + +func mkCid(t *testing.T, s string) cid.Cid { + h, err := multihash.Sum([]byte(s), multihash.SHA2_256, -1) + require.NoError(t, err) + return cid.NewCidV1(cid.Raw, h) +} diff --git a/app/submodule/actorevent/dummy.go b/app/submodule/actorevent/dummy.go new file mode 100644 index 0000000000..b0754b2db9 --- /dev/null +++ b/app/submodule/actorevent/dummy.go @@ -0,0 +1,23 @@ +package actorevent + +import ( + "context" + "errors" + + v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1" + "github.com/filecoin-project/venus/venus-shared/types" +) + +var ErrActorEventModuleDisabled = errors.New("module disabled, enable with Fevm.EnableActorEventsAPI") + +type ActorEventDummy struct{} // nolint + +func (a *ActorEventDummy) GetActorEvents(ctx context.Context, filter *types.ActorEventFilter) ([]*types.ActorEvent, error) { + return nil, ErrActorEventModuleDisabled +} + +func (a *ActorEventDummy) SubscribeActorEvents(ctx context.Context, filter *types.ActorEventFilter) (<-chan *types.ActorEvent, error) { + return nil, ErrActorEventModuleDisabled +} + +var _ v1api.IActorEvent = &ActorEventDummy{} diff --git a/app/submodule/chain/chain_submodule.go b/app/submodule/chain/chain_submodule.go index 54c988d909..502e5cb912 100644 --- a/app/submodule/chain/chain_submodule.go +++ b/app/submodule/chain/chain_submodule.go @@ -11,6 +11,7 @@ import ( "github.com/filecoin-project/venus/pkg/beacon" "github.com/filecoin-project/venus/pkg/chain" "github.com/filecoin-project/venus/pkg/consensus" + "github.com/filecoin-project/venus/pkg/consensus/chainselector" "github.com/filecoin-project/venus/pkg/consensusfault" "github.com/filecoin-project/venus/pkg/fork" "github.com/filecoin-project/venus/pkg/repo" @@ -55,7 +56,7 @@ func NewChainSubmodule(ctx context.Context, ) (*ChainSubmodule, error) { repo := config.Repo() // initialize chain store - chainStore := chain.NewStore(repo.ChainDatastore(), repo.Datastore(), config.GenesisCid(), circulatiingSupplyCalculator) + chainStore := chain.NewStore(repo.ChainDatastore(), repo.Datastore(), config.GenesisCid(), circulatiingSupplyCalculator, chainselector.Weight) // drand genBlk, err := chainStore.GetGenesisBlock(context.TODO()) if err != nil { diff --git a/app/submodule/chain/chaininfo_api.go b/app/submodule/chain/chaininfo_api.go index 0a3c5f0483..d8f5e64c28 100644 --- a/app/submodule/chain/chaininfo_api.go +++ b/app/submodule/chain/chaininfo_api.go @@ -343,7 +343,7 @@ func (cia *chainInfoAPI) GetEntry(ctx context.Context, height abi.ChainEpoch, ro // VerifyEntry verifies that child is a valid entry if its parent is. func (cia *chainInfoAPI) VerifyEntry(parent, child *types.BeaconEntry, height abi.ChainEpoch) bool { - return cia.chain.Drand.BeaconForEpoch(height).VerifyEntry(*parent, *child) != nil + return cia.chain.Drand.BeaconForEpoch(height).VerifyEntry(*parent, child.Data) != nil } // StateGetBeaconEntry returns the beacon entry for the given filecoin epoch. If @@ -743,6 +743,8 @@ func (cia *chainInfoAPI) StateGetNetworkParams(ctx context.Context) (*types.Netw UpgradeLightningHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeLightningHeight, UpgradeThunderHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeThunderHeight, UpgradeWatermelonHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeWatermelonHeight, + UpgradeDragonHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeDragonHeight, + UpgradePhoenixHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradePhoenixHeight, }, Eip155ChainID: cfg.NetworkParams.Eip155ChainID, } diff --git a/app/submodule/chain/miner_api.go b/app/submodule/chain/miner_api.go index 954c0178c5..b1ff9192f4 100644 --- a/app/submodule/chain/miner_api.go +++ b/app/submodule/chain/miner_api.go @@ -35,6 +35,7 @@ import ( lminer "github.com/filecoin-project/venus/venus-shared/actors/builtin/miner" "github.com/filecoin-project/venus/venus-shared/actors/builtin/power" "github.com/filecoin-project/venus/venus-shared/actors/builtin/reward" + "github.com/filecoin-project/venus/venus-shared/actors/builtin/verifreg" "github.com/filecoin-project/venus/venus-shared/actors/policy" v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1" "github.com/filecoin-project/venus/venus-shared/types" @@ -374,24 +375,33 @@ func (msa *minerStateAPI) StateMarketStorageDeal(ctx context.Context, dealID abi return &types.MarketDeal{ Proposal: *proposal, - State: *st, + State: types.MakeDealState(st), }, nil } -// StateGetAllocationForPendingDeal returns the allocation for a given deal ID of a pending deal. Returns nil if -// pending allocation is not found. -func (msa *minerStateAPI) StateGetAllocationForPendingDeal(ctx context.Context, dealID abi.DealID, tsk types.TipSetKey) (*types.Allocation, error) { +func (msa *minerStateAPI) StateGetAllocationIdForPendingDeal(ctx context.Context, dealID abi.DealID, tsk types.TipSetKey) (verifreg.AllocationId, error) { _, view, err := msa.Stmgr.ParentStateViewTsk(ctx, tsk) if err != nil { - return nil, fmt.Errorf("Stmgr.ParentStateViewTsk failed:%v", err) + return verifreg.NoAllocationID, fmt.Errorf("Stmgr.ParentStateViewTsk failed:%v", err) } - st, err := view.LoadMarketState(ctx) + mas, err := view.LoadMarketState(ctx) if err != nil { - return nil, fmt.Errorf("failed to load miner actor state: %v", err) + return verifreg.NoAllocationID, fmt.Errorf("failed to load miner actor state: %v", err) } - allocationID, err := st.GetAllocationIdForPendingDeal(dealID) + allocationID, err := mas.GetAllocationIdForPendingDeal(dealID) + if err != nil { + return verifreg.NoAllocationID, err + } + + return allocationID, nil +} + +// StateGetAllocationForPendingDeal returns the allocation for a given deal ID of a pending deal. Returns nil if +// pending allocation is not found. +func (msa *minerStateAPI) StateGetAllocationForPendingDeal(ctx context.Context, dealID abi.DealID, tsk types.TipSetKey) (*types.Allocation, error) { + allocationID, err := msa.StateGetAllocationIdForPendingDeal(ctx, dealID, tsk) if err != nil { return nil, err } @@ -422,7 +432,7 @@ func (msa *minerStateAPI) StateGetAllocation(ctx context.Context, clientAddr add st, err := view.LoadVerifregActor(ctx) if err != nil { - return nil, fmt.Errorf("failed to load miner actor state: %v", err) + return nil, fmt.Errorf("failed to load verifreg actor state: %v", err) } allocation, found, err := st.GetAllocation(idAddr, allocationID) @@ -436,6 +446,25 @@ func (msa *minerStateAPI) StateGetAllocation(ctx context.Context, clientAddr add return allocation, nil } +func (msa *minerStateAPI) StateGetAllAllocations(ctx context.Context, tsk types.TipSetKey) (map[types.AllocationId]types.Allocation, error) { + _, view, err := msa.Stmgr.ParentStateViewTsk(ctx, tsk) + if err != nil { + return nil, fmt.Errorf("Stmgr.ParentStateViewTsk failed:%v", err) + } + + st, err := view.LoadVerifregActor(ctx) + if err != nil { + return nil, fmt.Errorf("failed to load verifreg actor state: %v", err) + } + + allocations, err := st.GetAllAllocations() + if err != nil { + return nil, fmt.Errorf("getting all allocations: %w", err) + } + + return allocations, nil +} + // StateGetAllocations returns the all the allocations for a given client. func (msa *minerStateAPI) StateGetAllocations(ctx context.Context, clientAddr address.Address, tsk types.TipSetKey) (map[types.AllocationId]types.Allocation, error) { idAddr, err := msa.ChainSubmodule.API().StateLookupID(ctx, clientAddr, tsk) @@ -450,7 +479,7 @@ func (msa *minerStateAPI) StateGetAllocations(ctx context.Context, clientAddr ad st, err := view.LoadVerifregActor(ctx) if err != nil { - return nil, fmt.Errorf("failed to load miner actor state: %v", err) + return nil, fmt.Errorf("failed to load verifreg actor state: %v", err) } allocations, err := st.GetAllocations(idAddr) @@ -475,7 +504,7 @@ func (msa *minerStateAPI) StateGetClaim(ctx context.Context, providerAddr addres st, err := view.LoadVerifregActor(ctx) if err != nil { - return nil, fmt.Errorf("failed to load miner actor state: %v", err) + return nil, fmt.Errorf("failed to load verifreg actor state: %v", err) } claim, found, err := st.GetClaim(idAddr, claimID) @@ -503,7 +532,7 @@ func (msa *minerStateAPI) StateGetClaims(ctx context.Context, providerAddr addre st, err := view.LoadVerifregActor(ctx) if err != nil { - return nil, fmt.Errorf("failed to load miner actor state: %v", err) + return nil, fmt.Errorf("failed to load verifreg actor state: %v", err) } claims, err := st.GetClaims(idAddr) @@ -514,6 +543,25 @@ func (msa *minerStateAPI) StateGetClaims(ctx context.Context, providerAddr addre return claims, nil } +func (msa *minerStateAPI) StateGetAllClaims(ctx context.Context, tsk types.TipSetKey) (map[verifreg.ClaimId]verifreg.Claim, error) { + _, view, err := msa.Stmgr.ParentStateViewTsk(ctx, tsk) + if err != nil { + return nil, fmt.Errorf("Stmgr.ParentStateViewTsk failed:%v", err) + } + + st, err := view.LoadVerifregActor(ctx) + if err != nil { + return nil, fmt.Errorf("failed to load verifreg actor state: %v", err) + } + + claims, err := st.GetAllClaims() + if err != nil { + return nil, fmt.Errorf("getting all claims: %w", err) + } + + return claims, nil +} + // StateComputeDataCID computes DataCID from a set of on-chain deals func (msa *minerStateAPI) StateComputeDataCID(ctx context.Context, maddr address.Address, sectorType abi.RegisteredSealProof, deals []abi.DealID, tsk types.TipSetKey) (cid.Cid, error) { nv, err := msa.API().StateNetworkVersion(ctx, tsk) diff --git a/app/submodule/eth/dummy.go b/app/submodule/eth/dummy.go index 72f6070575..09b0b69139 100644 --- a/app/submodule/eth/dummy.go +++ b/app/submodule/eth/dummy.go @@ -125,7 +125,7 @@ func (e *ethAPIDummy) EthGasPrice(ctx context.Context) (types.EthBigInt, error) return types.EthBigIntZero, ErrModuleDisabled } -func (e *ethAPIDummy) EthEstimateGas(ctx context.Context, tx types.EthCall) (types.EthUint64, error) { +func (e *ethAPIDummy) EthEstimateGas(ctx context.Context, p jsonrpc.RawParams) (types.EthUint64, error) { return 0, ErrModuleDisabled } diff --git a/app/submodule/eth/eth_api.go b/app/submodule/eth/eth_api.go index 93345c8cfc..665ca7fd5a 100644 --- a/app/submodule/eth/eth_api.go +++ b/app/submodule/eth/eth_api.go @@ -849,8 +849,13 @@ func (a *ethAPI) applyMessage(ctx context.Context, msg *types.Message, tsk types return res, nil } -func (a *ethAPI) EthEstimateGas(ctx context.Context, tx types.EthCall) (types.EthUint64, error) { - msg, err := ethCallToFilecoinMessage(ctx, tx) +func (a *ethAPI) EthEstimateGas(ctx context.Context, p jsonrpc.RawParams) (types.EthUint64, error) { + params, err := jsonrpc.DecodeParams[types.EthEstimateGasParams](p) + if err != nil { + return types.EthUint64(0), fmt.Errorf("decoding params: %w", err) + } + + msg, err := ethCallToFilecoinMessage(ctx, params.Tx) if err != nil { return types.EthUint64(0), err } @@ -858,9 +863,17 @@ func (a *ethAPI) EthEstimateGas(ctx context.Context, tx types.EthCall) (types.Et // gas estimation actually run. msg.GasLimit = 0 - ts, err := a.chain.ChainHead(ctx) - if err != nil { - return types.EthUint64(0), err + var ts *types.TipSet + if params.BlkParam == nil { + ts, err = a.chain.ChainHead(ctx) + if err != nil { + return types.EthUint64(0), err + } + } else { + ts, err = getTipsetByEthBlockNumberOrHash(ctx, a.em.chainModule.ChainReader, *params.BlkParam) + if err != nil { + return types.EthUint64(0), fmt.Errorf("failed to process block param: %v; %w", params.BlkParam, err) + } } gassedMsg, err := a.mpool.GasEstimateMessageGas(ctx, msg, nil, ts.Key()) if err != nil { @@ -1094,19 +1107,21 @@ func (a *ethAPI) EthTraceBlock(ctx context.Context, blkNum string) ([]*types.Eth return nil, fmt.Errorf("failed to get transaction hash by cid: %w", err) } if txHash == nil { - log.Warnf("cannot find transaction hash for cid %s", ir.MsgCid) - continue + return nil, fmt.Errorf("cannot find transaction hash for cid %s", ir.MsgCid) + } + + env, err := baseEnvironment(ctx, ir.Msg.From, a.chain) + if err != nil { + return nil, fmt.Errorf("when processing message %s: %w", ir.MsgCid, err) } - traces := []*types.EthTrace{} - err = buildTraces(ctx, &traces, nil, []int{}, ir.ExecutionTrace, int64(ts.Height()), a.chain) + err = buildTraces(env, []int{}, &ir.ExecutionTrace) if err != nil { - return nil, fmt.Errorf("failed building traces: %w", err) + return nil, fmt.Errorf("failed building traces for msg %s: %w", ir.MsgCid, err) } - traceBlocks := make([]*types.EthTraceBlock, 0, len(traces)) - for _, trace := range traces { - traceBlocks = append(traceBlocks, &types.EthTraceBlock{ + for _, trace := range env.traces { + allTraces = append(allTraces, &types.EthTraceBlock{ EthTrace: trace, BlockHash: blkHash, BlockNumber: int64(ts.Height()), @@ -1114,8 +1129,6 @@ func (a *ethAPI) EthTraceBlock(ctx context.Context, blkNum string) ([]*types.Eth TransactionPosition: msgIdx, }) } - - allTraces = append(allTraces, traceBlocks...) } return allTraces, nil @@ -1148,34 +1161,36 @@ func (a *ethAPI) EthTraceReplayBlockTransactions(ctx context.Context, blkNum str return nil, fmt.Errorf("failed to get transaction hash by cid: %w", err) } if txHash == nil { - log.Warnf("cannot find transaction hash for cid %s", ir.MsgCid) - continue + return nil, fmt.Errorf("cannot find transaction hash for cid %s", ir.MsgCid) } - var output types.EthBytes - invokeCreateOnEAM := ir.Msg.To == builtin.EthereumAddressManagerActorAddr && (ir.Msg.Method == builtin.MethodsEAM.Create || ir.Msg.Method == builtin.MethodsEAM.Create2) - if ir.Msg.Method == builtin.MethodsEVM.InvokeContract || invokeCreateOnEAM { - output, err = decodePayload(ir.ExecutionTrace.MsgRct.Return, ir.ExecutionTrace.MsgRct.ReturnCodec) - if err != nil { - return nil, fmt.Errorf("failed to decode payload: %w", err) + env, err := baseEnvironment(ctx, ir.Msg.From, a.chain) + if err != nil { + return nil, fmt.Errorf("when processing message %s: %w", ir.MsgCid, err) + } + + err = buildTraces(env, []int{}, &ir.ExecutionTrace) + if err != nil { + return nil, fmt.Errorf("failed building traces for msg %s: %w", ir.MsgCid, err) + } + + var output []byte + if len(env.traces) > 0 { + switch r := env.traces[0].Result.(type) { + case *types.EthCallTraceResult: + output = r.Output + case *types.EthCreateTraceResult: + output = r.Code } - } else { - output = encodeFilecoinReturnAsABI(ir.ExecutionTrace.MsgRct.ExitCode, ir.ExecutionTrace.MsgRct.ReturnCodec, ir.ExecutionTrace.MsgRct.Return) } - t := types.EthTraceReplayBlockTransaction{ + allTraces = append(allTraces, &types.EthTraceReplayBlockTransaction{ Output: output, TransactionHash: *txHash, + Trace: env.traces, StateDiff: nil, VMTrace: nil, - } - - err = buildTraces(ctx, &t.Trace, nil, []int{}, ir.ExecutionTrace, int64(ts.Height()), a.chain) - if err != nil { - return nil, fmt.Errorf("failed building traces: %w", err) - } - - allTraces = append(allTraces, &t) + }) } return allTraces, nil diff --git a/app/submodule/eth/eth_event_api.go b/app/submodule/eth/eth_event_api.go index db87a7dcf0..ee896c2173 100644 --- a/app/submodule/eth/eth_event_api.go +++ b/app/submodule/eth/eth_event_api.go @@ -13,7 +13,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-jsonrpc" "github.com/filecoin-project/go-state-types/abi" - builtintypes "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/venus/pkg/chain" "github.com/filecoin-project/venus/pkg/events" "github.com/filecoin-project/venus/pkg/events/filter" @@ -22,7 +21,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/types" "github.com/google/uuid" "github.com/ipfs/go-cid" - "github.com/multiformats/go-varint" + "github.com/multiformats/go-multicodec" "github.com/zyedidia/generic/queue" ) @@ -82,17 +81,9 @@ func newEthEventAPI(ctx context.Context, em *EthSubModule) (*ethEventAPI, error) actor, err := em.chainModule.Stmgr.GetActorAt(ctx, idAddr, ts) if err != nil || actor.Address == nil { - return address.Undef, false + return idAddr, true } - // if robust address is not f4 then we won't match against it so bail early - if actor.Address.Protocol() != address.Delegated { - return address.Undef, false - } - // we have an f4 address, make sure it's assigned by the EAM - if namespace, _, err := varint.FromUvarint(actor.Address.Payload()); err != nil || namespace != builtintypes.EthereumAddressManagerActorID { - return address.Undef, false - } return *actor.Address, true }, @@ -212,7 +203,65 @@ func (e *ethEventAPI) EthGetFilterLogs(ctx context.Context, id types.EthFilterID return nil, fmt.Errorf("wrong filter type") } -func (e *ethEventAPI) installEthFilterSpec(ctx context.Context, filterSpec *types.EthFilterSpec) (*filter.EventFilter, error) { +// parseBlockRange is similar to actor event's parseHeightRange but with slightly different semantics +// +// * "block" instead of "height" +// * strings that can have "latest" and "earliest" and nil +// * hex strings for actual heights +func parseBlockRange(heaviest abi.ChainEpoch, fromBlock, toBlock *string, maxRange abi.ChainEpoch) (minHeight abi.ChainEpoch, maxHeight abi.ChainEpoch, err error) { + if fromBlock == nil || *fromBlock == "latest" || len(*fromBlock) == 0 { + minHeight = heaviest + } else if *fromBlock == "earliest" { + minHeight = 0 + } else { + if !strings.HasPrefix(*fromBlock, "0x") { + return 0, 0, fmt.Errorf("FromBlock is not a hex") + } + epoch, err := types.EthUint64FromHex(*fromBlock) + if err != nil { + return 0, 0, fmt.Errorf("invalid epoch") + } + minHeight = abi.ChainEpoch(epoch) + } + + if toBlock == nil || *toBlock == "latest" || len(*toBlock) == 0 { + // here latest means the latest at the time + maxHeight = -1 + } else if *toBlock == "earliest" { + maxHeight = 0 + } else { + if !strings.HasPrefix(*toBlock, "0x") { + return 0, 0, fmt.Errorf("ToBlock is not a hex") + } + epoch, err := types.EthUint64FromHex(*toBlock) + if err != nil { + return 0, 0, fmt.Errorf("invalid epoch") + } + maxHeight = abi.ChainEpoch(epoch) + } + + // Validate height ranges are within limits set by node operator + if minHeight == -1 && maxHeight > 0 { + // Here the client is looking for events between the head and some future height + if maxHeight-heaviest > maxRange { + return 0, 0, fmt.Errorf("invalid epoch range: to block is too far in the future (maximum: %d)", maxRange) + } + } else if minHeight >= 0 && maxHeight == -1 { + // Here the client is looking for events between some time in the past and the current head + if heaviest-minHeight > maxRange { + return 0, 0, fmt.Errorf("invalid epoch range: from block is too far in the past (maximum: %d)", maxRange) + } + } else if minHeight >= 0 && maxHeight >= 0 { + if minHeight > maxHeight { + return 0, 0, fmt.Errorf("invalid epoch range: to block (%d) must be after from block (%d)", minHeight, maxHeight) + } else if maxHeight-minHeight > maxRange { + return 0, 0, fmt.Errorf("invalid epoch range: range between to and from blocks is too large (maximum: %d)", maxRange) + } + } + return minHeight, maxHeight, nil +} + +func (e *ethEventAPI) installEthFilterSpec(ctx context.Context, filterSpec *types.EthFilterSpec) (filter.EventFilter, error) { var ( minHeight abi.ChainEpoch maxHeight abi.ChainEpoch @@ -228,70 +277,13 @@ func (e *ethEventAPI) installEthFilterSpec(ctx context.Context, filterSpec *type tipsetCid = filterSpec.BlockHash.ToCid() } else { - if filterSpec.FromBlock == nil || *filterSpec.FromBlock == "latest" { - ts, err := e.ChainAPI.ChainHead(ctx) - if err != nil { - return nil, fmt.Errorf("failed to got head %v", err) - } - minHeight = ts.Height() - } else if *filterSpec.FromBlock == "earliest" { - minHeight = 0 - } else if *filterSpec.FromBlock == "pending" { - return nil, api.ErrNotSupported - } else { - if !strings.HasPrefix(*filterSpec.FromBlock, "0x") { - return nil, fmt.Errorf("FromBlock is not a hex") - } - epoch, err := types.EthUint64FromHex(*filterSpec.FromBlock) - if err != nil { - return nil, fmt.Errorf("invalid epoch") - } - minHeight = abi.ChainEpoch(epoch) - } - - if filterSpec.ToBlock == nil || *filterSpec.ToBlock == "latest" { - // here latest means the latest at the time - maxHeight = -1 - } else if *filterSpec.ToBlock == "earliest" { - maxHeight = 0 - } else if *filterSpec.ToBlock == "pending" { - return nil, api.ErrNotSupported - } else { - if !strings.HasPrefix(*filterSpec.ToBlock, "0x") { - return nil, fmt.Errorf("ToBlock is not a hex") - } - epoch, err := types.EthUint64FromHex(*filterSpec.ToBlock) - if err != nil { - return nil, fmt.Errorf("invalid epoch") - } - maxHeight = abi.ChainEpoch(epoch) + head, err := e.ChainAPI.ChainHead(ctx) + if err != nil { + return nil, err } - - // Validate height ranges are within limits set by node operator - if minHeight == -1 && maxHeight > 0 { - // Here the client is looking for events between the head and some future height - ts, err := e.ChainAPI.ChainHead(ctx) - if err != nil { - return nil, fmt.Errorf("failed to got head %v", err) - } - if maxHeight-ts.Height() > e.MaxFilterHeightRange { - return nil, fmt.Errorf("invalid epoch range: to block is too far in the future (maximum: %d)", e.MaxFilterHeightRange) - } - } else if minHeight >= 0 && maxHeight == -1 { - // Here the client is looking for events between some time in the past and the current head - ts, err := e.ChainAPI.ChainHead(ctx) - if err != nil { - return nil, fmt.Errorf("failed to got head %v", err) - } - if ts.Height()-minHeight > e.MaxFilterHeightRange { - return nil, fmt.Errorf("invalid epoch range: from block is too far in the past (maximum: %d)", e.MaxFilterHeightRange) - } - } else if minHeight >= 0 && maxHeight >= 0 { - if minHeight > maxHeight { - return nil, fmt.Errorf("invalid epoch range: to block (%d) must be after from block (%d)", minHeight, maxHeight) - } else if maxHeight-minHeight > e.MaxFilterHeightRange { - return nil, fmt.Errorf("invalid epoch range: range between to and from blocks is too large (maximum: %d)", e.MaxFilterHeightRange) - } + minHeight, maxHeight, err = parseBlockRange(head.Height(), filterSpec.FromBlock, filterSpec.ToBlock, e.MaxFilterHeightRange) + if err != nil { + return nil, err } } @@ -309,7 +301,20 @@ func (e *ethEventAPI) installEthFilterSpec(ctx context.Context, filterSpec *type return nil, err } - return e.EventFilterManager.Install(ctx, minHeight, maxHeight, tipsetCid, addresses, keys) + return e.EventFilterManager.Install(ctx, minHeight, maxHeight, tipsetCid, addresses, keysToKeysWithCodec(keys), true) +} + +func keysToKeysWithCodec(keys map[string][][]byte) map[string][]types.ActorEventBlock { + keysWithCodec := make(map[string][]types.ActorEventBlock) + for k, v := range keys { + for _, vv := range v { + keysWithCodec[k] = append(keysWithCodec[k], types.ActorEventBlock{ + Codec: uint64(multicodec.Raw), // FEVM smart contract events are always encoded with the `raw` Codec. + Value: vv, + }) + } + } + return keysWithCodec } func (e *ethEventAPI) EthNewFilter(ctx context.Context, filterSpec *types.EthFilterSpec) (types.EthFilterID, error) { @@ -403,7 +408,7 @@ func (e *ethEventAPI) EthUninstallFilter(ctx context.Context, id types.EthFilter func (e *ethEventAPI) uninstallFilter(ctx context.Context, f filter.Filter) error { switch f.(type) { - case *filter.EventFilter: + case filter.EventFilter: err := e.EventFilterManager.Remove(ctx, f.ID()) if err != nil && !errors.Is(err, filter.ErrFilterNotFound) { return err @@ -485,7 +490,7 @@ func (e *ethEventAPI) EthSubscribe(ctx context.Context, p jsonrpc.RawParams) (ty } } - f, err := e.EventFilterManager.Install(ctx, -1, -1, cid.Undef, addresses, keys) + f, err := e.EventFilterManager.Install(ctx, -1, -1, cid.Undef, addresses, keysToKeysWithCodec(keys), true) if err != nil { // clean up any previous filters added and stop the sub _, _ = e.EthUnsubscribe(ctx, sub.id) diff --git a/app/submodule/eth/eth_submodule.go b/app/submodule/eth/eth_submodule.go index 3a8d9cba59..caa4ddab2a 100644 --- a/app/submodule/eth/eth_submodule.go +++ b/app/submodule/eth/eth_submodule.go @@ -10,6 +10,7 @@ import ( "github.com/filecoin-project/venus/app/submodule/mpool" "github.com/filecoin-project/venus/pkg/config" "github.com/filecoin-project/venus/pkg/constants" + "github.com/filecoin-project/venus/pkg/events/filter" v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1" ) @@ -92,6 +93,10 @@ func (em *EthSubModule) Close(ctx context.Context) error { return em.ethAPIAdapter.close() } +func (em *EthSubModule) GetEventFilterManager() *filter.EventFilterManager { + return em.ethEventAPI.EventFilterManager +} + type ethAPIAdapter interface { v1api.IETH start(ctx context.Context) error diff --git a/app/submodule/eth/eth_test.go b/app/submodule/eth/eth_test.go index aa015dcad9..66a32f3ab7 100644 --- a/app/submodule/eth/eth_test.go +++ b/app/submodule/eth/eth_test.go @@ -1,17 +1,96 @@ package eth import ( + "bytes" "encoding/hex" + "fmt" "testing" "github.com/ipfs/go-cid" + "github.com/multiformats/go-multicodec" "github.com/stretchr/testify/require" + cbg "github.com/whyrusleeping/cbor-gen" + "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/venus/pkg/messagepool" "github.com/filecoin-project/venus/venus-shared/types" ) +func TestParseBlockRange(t *testing.T) { + pstring := func(s string) *string { return &s } + + tcs := map[string]struct { + heaviest abi.ChainEpoch + from *string + to *string + maxRange abi.ChainEpoch + minOut abi.ChainEpoch + maxOut abi.ChainEpoch + errStr string + }{ + "fails when both are specified and range is greater than max allowed range": { + heaviest: 100, + from: pstring("0x100"), + to: pstring("0x200"), + maxRange: 10, + minOut: 0, + maxOut: 0, + errStr: "too large", + }, + "fails when min is specified and range is greater than max allowed range": { + heaviest: 500, + from: pstring("0x10"), + to: pstring("latest"), + maxRange: 10, + minOut: 0, + maxOut: 0, + errStr: "too far in the past", + }, + "fails when max is specified and range is greater than max allowed range": { + heaviest: 500, + from: pstring("earliest"), + to: pstring("0x10000"), + maxRange: 10, + minOut: 0, + maxOut: 0, + errStr: "too large", + }, + "works when range is valid": { + heaviest: 500, + from: pstring("earliest"), + to: pstring("latest"), + maxRange: 1000, + minOut: 0, + maxOut: -1, + }, + "works when range is valid and specified": { + heaviest: 500, + from: pstring("0x10"), + to: pstring("0x30"), + maxRange: 1000, + minOut: 16, + maxOut: 48, + }, + } + + for name, tc := range tcs { + tc2 := tc + t.Run(name, func(t *testing.T) { + min, max, err := parseBlockRange(tc2.heaviest, tc2.from, tc2.to, tc2.maxRange) + require.Equal(t, tc2.minOut, min) + require.Equal(t, tc2.maxOut, max) + if tc2.errStr != "" { + fmt.Println(err) + require.Error(t, err) + require.Contains(t, err.Error(), tc2.errStr) + } else { + require.NoError(t, err) + } + }) + } +} + func TestEthLogFromEvent(t *testing.T) { // basic empty data, topics, ok := ethLogFromEvent(nil) @@ -176,3 +255,40 @@ func TestABIEncoding(t *testing.T) { require.Equal(t, expectedBytes, encodeAsABIHelper(22, 81, dataBytes)) } + +func TestDecodePayload(t *testing.T) { + // "empty" + b, err := decodePayload(nil, 0) + require.NoError(t, err) + require.Empty(t, b) + + // raw empty + _, err = decodePayload(nil, uint64(multicodec.Raw)) + require.NoError(t, err) + require.Empty(t, b) + + // raw non-empty + b, err = decodePayload([]byte{1}, uint64(multicodec.Raw)) + require.NoError(t, err) + require.EqualValues(t, b, []byte{1}) + + // Invalid cbor bytes + _, err = decodePayload(nil, uint64(multicodec.DagCbor)) + require.Error(t, err) + + // valid cbor bytes + var w bytes.Buffer + require.NoError(t, cbg.WriteByteArray(&w, []byte{1})) + b, err = decodePayload(w.Bytes(), uint64(multicodec.DagCbor)) + require.NoError(t, err) + require.EqualValues(t, b, []byte{1}) + + // regular cbor also works. + b, err = decodePayload(w.Bytes(), uint64(multicodec.Cbor)) + require.NoError(t, err) + require.EqualValues(t, b, []byte{1}) + + // random codec should fail + _, err = decodePayload(w.Bytes(), 42) + require.Error(t, err) +} diff --git a/app/submodule/eth/eth_trace.go b/app/submodule/eth/eth_trace.go index f15805fb12..d794015ce3 100644 --- a/app/submodule/eth/eth_trace.go +++ b/app/submodule/eth/eth_trace.go @@ -8,20 +8,22 @@ import ( "github.com/multiformats/go-multicodec" cbg "github.com/whyrusleeping/cbor-gen" + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/go-state-types/builtin/v10/evm" + eam12 "github.com/filecoin-project/go-state-types/builtin/v12/eam" + evm12 "github.com/filecoin-project/go-state-types/builtin/v12/evm" + init12 "github.com/filecoin-project/go-state-types/builtin/v12/init" + "github.com/filecoin-project/go-state-types/exitcode" + "github.com/filecoin-project/venus/venus-shared/actors/builtin/evm" + v1 "github.com/filecoin-project/venus/venus-shared/api/chain/v1" builtinactors "github.com/filecoin-project/venus/venus-shared/actors/builtin" - v1 "github.com/filecoin-project/venus/venus-shared/api/chain/v1" "github.com/filecoin-project/venus/venus-shared/types" ) // decodePayload is a utility function which decodes the payload using the given codec func decodePayload(payload []byte, codec uint64) (types.EthBytes, error) { - if len(payload) == 0 { - return nil, nil - } - switch multicodec.Code(codec) { case multicodec.Identity: return nil, nil @@ -38,210 +40,566 @@ func decodePayload(payload []byte, codec uint64) (types.EthBytes, error) { return nil, fmt.Errorf("decodePayload: unsupported codec: %d", codec) } -// buildTraces recursively builds the traces for a given ExecutionTrace by walking the subcalls -func buildTraces(ctx context.Context, traces *[]*types.EthTrace, parent *types.EthTrace, addr []int, et types.ExecutionTrace, height int64, ca v1.IChain) error { - // lookup the eth address from the from/to addresses. Note that this may fail but to support - // this we need to include the ActorID in the trace. For now, just log a warning and skip - // this trace. - // - // TODO: Add ActorID in trace, see https://github.com/filecoin-project/lotus/pull/11100#discussion_r1302442288 - from, err := lookupEthAddress(ctx, et.Msg.From, ca) +func decodeParams[P any, T interface { + *P + cbg.CBORUnmarshaler +}](msg *types.MessageTrace) (T, error) { + var params T = new(P) + switch msg.ParamsCodec { + case uint64(multicodec.DagCbor), uint64(multicodec.Cbor): + default: + return nil, fmt.Errorf("method called with unexpected codec %d", msg.ParamsCodec) + } + + if err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)); err != nil { + return nil, fmt.Errorf("failed to decode params: %w", err) + } + + return params, nil +} + +func decodeReturn[R any, T interface { + *R + cbg.CBORUnmarshaler +}](ret *types.ReturnTrace) (T, error) { + var retval T = new(R) + switch ret.ReturnCodec { + case uint64(multicodec.DagCbor), uint64(multicodec.Cbor): + default: + return nil, fmt.Errorf("method returned an unexpected codec %d", ret.ReturnCodec) + } + + if err := retval.UnmarshalCBOR(bytes.NewReader(ret.Return)); err != nil { + return nil, fmt.Errorf("failed to decode return value: %w", err) + } + + return retval, nil +} + +func find[T any](values []T, cb func(t *T) *T) *T { + for i := range values { + if o := cb(&values[i]); o != nil { + return o + } + } + return nil +} + +type environment struct { + caller types.EthAddress + isEVM bool + subtraceCount int + traces []*types.EthTrace + lastByteCode *types.EthAddress +} + +func baseEnvironment(ctx context.Context, from address.Address, ca v1.IChain) (*environment, error) { + sender, err := lookupEthAddress(ctx, from, ca) if err != nil { - log.Warnf("buildTraces: failed to lookup from address %s: %v", et.Msg.From, err) - return nil + return nil, fmt.Errorf("top-level message sender %s s could not be found: %w", from, err) + } + return &environment{caller: sender}, nil +} + +func traceToAddress(act *types.ActorTrace) types.EthAddress { + if act.State.Address != nil { + if addr, err := types.EthAddressFromFilecoinAddress(*act.State.Address); err == nil { + return addr + } + } + return types.EthAddressFromActorID(act.Id) +} + +// traceIsEVMOrEAM returns true if the trace is a call to an EVM or EAM actor. +func traceIsEVMOrEAM(et *types.ExecutionTrace) bool { + if et.InvokedActor == nil { + return false + } + return builtinactors.IsEvmActor(et.InvokedActor.State.Code) || + et.InvokedActor.Id != abi.ActorID(builtin.EthereumAddressManagerActorID) +} + +func traceErrMsg(et *types.ExecutionTrace) string { + code := et.MsgRct.ExitCode + + if code.IsSuccess() { + return "" + } + + // EVM tools often expect this literal string. + if code == exitcode.SysErrOutOfGas { + return "out of gas" + } + + // indicate when we have a "system" error. + if code < exitcode.FirstActorErrorCode { + return fmt.Sprintf("vm error: %s", code) } - to, err := lookupEthAddress(ctx, et.Msg.To, ca) + + // handle special exit codes from the EVM/EAM. + if traceIsEVMOrEAM(et) { + switch code { + case evm.ErrReverted: + return "Reverted" // capitalized for compatibility + case evm.ErrInvalidInstruction: + return "invalid instruction" + case evm.ErrUndefinedInstruction: + return "undefined instruction" + case evm.ErrStackUnderflow: + return "stack underflow" + case evm.ErrStackOverflow: + return "stack overflow" + case evm.ErrIllegalMemoryAccess: + return "illegal memory access" + case evm.ErrBadJumpdest: + return "invalid jump destination" + case evm.ErrSelfdestructFailed: + return "self destruct failed" + } + } + // everything else... + return fmt.Sprintf("actor error: %s", code.Error()) +} + +// buildTraces recursively builds the traces for a given ExecutionTrace by walking the subcalls +func buildTraces(env *environment, addr []int, et *types.ExecutionTrace) error { + trace, recurseInto, err := buildTrace(env, addr, et) if err != nil { - log.Warnf("buildTraces: failed to lookup to address %s: %w", et.Msg.To, err) + return fmt.Errorf("at trace %v: %w", addr, err) + } + + if trace != nil { + env.traces = append(env.traces, trace) + env.subtraceCount++ + } + + // Skip if there's nothing more to do and/or `buildTrace` told us to skip this one. + if recurseInto == nil || recurseInto.InvokedActor == nil || len(recurseInto.Subcalls) == 0 { return nil } - trace := &types.EthTrace{ - Action: types.EthTraceAction{ - From: from, - To: to, - Gas: types.EthUint64(et.Msg.GasLimit), - Input: nil, - Value: types.EthBigInt(et.Msg.Value), + subEnv := &environment{ + caller: traceToAddress(recurseInto.InvokedActor), + isEVM: builtinactors.IsEvmActor(recurseInto.InvokedActor.State.Code), + traces: env.traces, + } + // Set capacity to the length so each `append` below creates a new slice. Otherwise, we'll + // end up repeatedly mutating previous paths. + addr = addr[:len(addr):len(addr)] + + for i := range recurseInto.Subcalls { + err := buildTraces(subEnv, append(addr, subEnv.subtraceCount), &recurseInto.Subcalls[i]) + if err != nil { + return err + } + } + trace.Subtraces = subEnv.subtraceCount + env.traces = subEnv.traces + + return nil +} + +// buildTrace processes the passed execution trace and updates the environment, if necessary. +// +// On success, it returns a trace to add (or nil to skip) and the trace recurse into (or nil to skip). +func buildTrace(env *environment, addr []int, et *types.ExecutionTrace) (*types.EthTrace, *types.ExecutionTrace, error) { + // This function first assumes that the call is a "native" call, then handles all the "not + // native" cases. If we get any unexpected results in any of these special cases, we just + // keep the "native" interpretation and move on. + // + // 1. If we're invoking a contract (even if the caller is a native account/actor), we + // attempt to decode the params/return value as a contract invocation. + // 2. If we're calling the EAM and/or init actor, we try to treat the call as a CREATE. + // 3. Finally, if the caller is an EVM smart contract and it's calling a "private" (1-1023) + // method, we know something special is going on. We look for calls related to + // DELEGATECALL and drop everything else (everything else includes calls triggered by, + // e.g., EXTCODEHASH). + + // If we don't have sufficient funds, or we have a fatal error, or we have some + // other syscall error: skip the entire trace to mimic Ethereum (Ethereum records + // traces _after_ checking things like this). + // + // NOTE: The FFI currently folds all unknown syscall errors into "sys assertion + // failed" which is turned into SysErrFatal. + if len(addr) > 0 { + switch et.MsgRct.ExitCode { + case exitcode.SysErrInsufficientFunds, exitcode.SysErrFatal: + return nil, nil, nil + } + } + + // We may fail before we can even invoke the actor. In that case, we have no 100% reliable + // way of getting its address (e.g., due to reverts) so we're just going to drop the entire + // trace. This is OK (ish) because the call never really "happened". + if et.InvokedActor == nil { + return nil, nil, nil + } + + // Step 2: Decode as a contract invocation + // + // Normal EVM calls. We don't care if the caller/receiver are actually EVM actors, we only + // care if the call _looks_ like an EVM call. If we fail to decode it as an EVM call, we + // fallback on interpreting it as a native call. + if et.Msg.Method == builtin.MethodsEVM.InvokeContract { + return traceEVMCall(env, addr, et) + } + + // Step 3: Decode as a contract deployment + switch et.Msg.To { + // NOTE: this will only catch _direct_ calls to the init actor. Calls through the EAM will + // be caught and _skipped_ below in the next case. + case builtin.InitActorAddr: + switch et.Msg.Method { + case builtin.MethodsInit.Exec, builtin.MethodsInit.Exec4: + return traceNativeCreate(env, addr, et) + } + case builtin.EthereumAddressManagerActorAddr: + switch et.Msg.Method { + case builtin.MethodsEAM.Create, builtin.MethodsEAM.Create2, builtin.MethodsEAM.CreateExternal: + return traceEthCreate(env, addr, et) + } + } + + // Step 4: Handle DELEGATECALL + // + // EVM contracts cannot call methods in the range 1-1023, only the EVM itself can. So, if we + // see a call in this range, we know it's an implementation detail of the EVM and not an + // explicit call by the user. + // + // While the EVM calls several methods in this range (some we've already handled above with + // respect to the EAM), we only care about the ones relevant DELEGATECALL and can _ignore_ + // all the others. + if env.isEVM && et.Msg.Method > 0 && et.Msg.Method < 1024 { + return traceEVMPrivate(env, addr, et) + } + + return traceNativeCall(env, addr, et), et, nil +} - FilecoinFrom: et.Msg.From, - FilecoinTo: et.Msg.To, - FilecoinMethod: et.Msg.Method, - FilecoinCodeCid: et.Msg.CodeCid, +// Build an EthTrace for a "call" with the given input & output. +func traceCall(env *environment, addr []int, et *types.ExecutionTrace, input, output types.EthBytes) *types.EthTrace { + to := traceToAddress(et.InvokedActor) + callType := "call" + if et.Msg.ReadOnly { + callType = "staticcall" + } + return &types.EthTrace{ + Type: "call", + Action: &types.EthCallTraceAction{ + CallType: callType, + From: env.caller, + To: to, + Gas: types.EthUint64(et.Msg.GasLimit), + Value: types.EthBigInt(et.Msg.Value), + Input: input, }, - Result: types.EthTraceResult{ + Result: &types.EthCallTraceResult{ GasUsed: types.EthUint64(et.SumGas().TotalGas), - Output: nil, + Output: output, }, - Subtraces: 0, // will be updated by the children once they are added to the trace TraceAddress: addr, + Error: traceErrMsg(et), + } +} + +// Build an EthTrace for a "call", parsing the inputs & outputs as a "native" FVM call. +func traceNativeCall(env *environment, addr []int, et *types.ExecutionTrace) *types.EthTrace { + return traceCall(env, addr, et, + encodeFilecoinParamsAsABI(et.Msg.Method, et.Msg.ParamsCodec, et.Msg.Params), + encodeFilecoinReturnAsABI(et.MsgRct.ExitCode, et.MsgRct.ReturnCodec, et.MsgRct.Return), + ) +} - Parent: parent, - LastByteCode: nil, +// Build an EthTrace for a "call", parsing the inputs & outputs as an EVM call (falling back on +// treating it as a native call). +func traceEVMCall(env *environment, addr []int, et *types.ExecutionTrace) (*types.EthTrace, *types.ExecutionTrace, error) { + input, err := decodePayload(et.Msg.Params, et.Msg.ParamsCodec) + if err != nil { + log.Debugf("failed to decode contract invocation payload: %w", err) + return traceNativeCall(env, addr, et), et, nil + } + output, err := decodePayload(et.MsgRct.Return, et.MsgRct.ReturnCodec) + if err != nil { + log.Debugf("failed to decode contract invocation return: %w", err) + return traceNativeCall(env, addr, et), et, nil } + return traceCall(env, addr, et, input, output), et, nil +} - trace.SetCallType("call") +// Build an EthTrace for a native "create" operation. This should only be called with an +// ExecutionTrace is an Exec or Exec4 method invocation on the Init actor. +func traceNativeCreate(env *environment, addr []int, et *types.ExecutionTrace) (*types.EthTrace, *types.ExecutionTrace, error) { + if et.Msg.ReadOnly { + // "create" isn't valid in a staticcall, so we just skip this trace + // (couldn't have created an actor anyways). + // This mimic's the EVM: it doesn't trace CREATE calls when in + // read-only mode. + return nil, nil, nil + } - if et.Msg.Method == builtin.MethodsEVM.InvokeContract { - log.Debugf("COND1 found InvokeContract call at height: %d", height) + subTrace := find(et.Subcalls, func(c *types.ExecutionTrace) *types.ExecutionTrace { + if c.Msg.Method == builtin.MethodConstructor { + return c + } + return nil + }) + if subTrace == nil { + // If we succeed in calling Exec/Exec4 but don't even try to construct + // something, we have a bug in our tracing logic or a mismatch between our + // tracing logic and the actors. + if et.MsgRct.ExitCode.IsSuccess() { + return nil, nil, fmt.Errorf("successful Exec/Exec4 call failed to call a constructor") + } + // Otherwise, this can happen if creation fails early (bad params, + // out of gas, contract already exists, etc.). The EVM wouldn't + // trace such cases, so we don't either. + // + // NOTE: It's actually impossible to run out of gas before calling + // initcode in the EVM (without running out of gas in the calling + // contract), but this is an equivalent edge-case to InvokedActor + // being nil, so we treat it the same way and skip the entire + // operation. + return nil, nil, nil + } + + // Native actors that aren't the EAM can attempt to call Exec4, but such + // call should fail immediately without ever attempting to construct an + // actor. I'm catching this here because it likely means that there's a bug + // in our trace-conversion logic. + if et.Msg.Method == builtin.MethodsInit.Exec4 { + return nil, nil, fmt.Errorf("direct call to Exec4 successfully called a constructor") + } - // TODO: ignore return errors since actors can send gibberish and we don't want - // to fail the whole trace in that case - trace.Action.Input, err = decodePayload(et.Msg.Params, et.Msg.ParamsCodec) + var output types.EthBytes + var createdAddr *types.EthAddress + if et.MsgRct.ExitCode.IsSuccess() { + // We're supposed to put the "installed bytecode" here. But this + // isn't an EVM actor, so we just put some invalid bytecode (this is + // the answer you'd get if you called EXTCODECOPY on a native + // non-account actor, anyways). + output = []byte{0xFE} + + // Extract the address of the created actor from the return value. + initReturn, err := decodeReturn[init12.ExecReturn](&et.MsgRct) if err != nil { - return fmt.Errorf("buildTraces: %w", err) + return nil, nil, fmt.Errorf("failed to decode init params after a successful Init.Exec call: %w", err) } - trace.Result.Output, err = decodePayload(et.MsgRct.Return, et.MsgRct.ReturnCodec) + actorID, err := address.IDFromAddress(initReturn.IDAddress) if err != nil { - return fmt.Errorf("buildTraces: %w", err) + return nil, nil, fmt.Errorf("failed to extract created actor ID from address: %w", err) } - } else if et.Msg.To == builtin.EthereumAddressManagerActorAddr && - et.Msg.Method == builtin.MethodsEAM.CreateExternal { - log.Debugf("COND2 found CreateExternal call at height: %d", height) - trace.Action.Input, err = decodePayload(et.Msg.Params, et.Msg.ParamsCodec) + ethAddr := types.EthAddressFromActorID(abi.ActorID(actorID)) + createdAddr = ðAddr + } + + return &types.EthTrace{ + Type: "create", + Action: &types.EthCreateTraceAction{ + From: env.caller, + Gas: types.EthUint64(et.Msg.GasLimit), + Value: types.EthBigInt(et.Msg.Value), + // If we get here, this isn't a native EVM create. Those always go through + // the EAM. So we have no "real" initcode and must use the sentinel value + // for "invalid" initcode. + Init: []byte{0xFE}, + }, + Result: &types.EthCreateTraceResult{ + GasUsed: types.EthUint64(et.SumGas().TotalGas), + Address: createdAddr, + Code: output, + }, + TraceAddress: addr, + Error: traceErrMsg(et), + }, subTrace, nil +} + +// Assert that these are all identical so we can simplify the below code and decode once. +var _ *eam12.Return = (*eam12.Return)((*eam12.CreateReturn)(nil)) +var _ *eam12.Return = (*eam12.Return)((*eam12.Create2Return)(nil)) +var _ *eam12.Return = (*eam12.Return)((*eam12.CreateExternalReturn)(nil)) + +// Decode the parameters and return value of an EVM smart contract creation through the EAM. This +// should only be called with an ExecutionTrace for a Create, Create2, or CreateExternal method +// invocation on the EAM. +func decodeCreateViaEAM(et *types.ExecutionTrace) (initcode []byte, addr *types.EthAddress, err error) { + switch et.Msg.Method { + case builtin.MethodsEAM.Create: + params, err := decodeParams[eam12.CreateParams](&et.Msg) if err != nil { - return fmt.Errorf("buildTraces: %w", err) + return nil, nil, err } - - if et.MsgRct.ExitCode.IsSuccess() { - // ignore return value - trace.Result.Output = nil - } else { - // return value is the error message - trace.Result.Output, err = decodePayload(et.MsgRct.Return, et.MsgRct.ReturnCodec) - if err != nil { - return fmt.Errorf("buildTraces: %w", err) - } + initcode = params.Initcode + case builtin.MethodsEAM.Create2: + params, err := decodeParams[eam12.Create2Params](&et.Msg) + if err != nil { + return nil, nil, err } - - // treat this as a contract creation - trace.SetCallType("create") - } else { - // we are going to assume a native method, but we may change it in one of the edge cases below - // TODO: only do this if we know it's a native method (optimization) - trace.Action.Input = encodeFilecoinParamsAsABI(et.Msg.Method, et.Msg.ParamsCodec, et.Msg.Params) - trace.Result.Output = encodeFilecoinReturnAsABI(et.MsgRct.ExitCode, et.MsgRct.ReturnCodec, et.MsgRct.Return) + initcode = params.Initcode + case builtin.MethodsEAM.CreateExternal: + input, err := decodePayload(et.Msg.Params, et.Msg.ParamsCodec) + if err != nil { + return nil, nil, err + } + initcode = input + default: + return nil, nil, fmt.Errorf("unexpected CREATE method %d", et.Msg.Method) + } + ret, err := decodeReturn[eam12.CreateReturn](&et.MsgRct) + if err != nil { + return nil, (*types.EthAddress)(&ret.EthAddress), err } + return initcode, (*types.EthAddress)(&ret.EthAddress), nil +} - // TODO: is it OK to check this here or is this only specific to certain edge case (evm to evm)? +// Build an EthTrace for an EVM "create" operation. This should only be called with an +// ExecutionTrace for a Create, Create2, or CreateExternal method invocation on the EAM. +func traceEthCreate(env *environment, addr []int, et *types.ExecutionTrace) (*types.EthTrace, *types.ExecutionTrace, error) { + // Same as the Init actor case above, see the comment there. if et.Msg.ReadOnly { - trace.SetCallType("staticcall") + return nil, nil, nil } - // there are several edge cases that require special handling when displaying the traces. Note that while iterating over - // the traces we update the trace backwards (through the parent pointer) - if parent != nil { - // Handle Native actor creation - // - // Actor A calls to the init actor on method 2 and The init actor creates the target actor B then calls it on method 1 - if parent.Action.FilecoinTo == builtin.InitActorAddr && - parent.Action.FilecoinMethod == builtin.MethodsInit.Exec && - et.Msg.Method == builtin.MethodConstructor { - log.Debugf("COND3 Native actor creation! method:%d, code:%s, height:%d", et.Msg.Method, et.Msg.CodeCid.String(), height) - parent.SetCallType("create") - parent.Action.To = to - parent.Action.Input = []byte{0xFE} - parent.Result.Output = nil - - // there should never be any subcalls when creating a native actor - // - // TODO: add support for native actors calling another when created - return nil - } - - // Handle EVM contract creation - // - // To detect EVM contract creation we need to check for the following sequence of events: - // - // 1) EVM contract A calls the EAM (Ethereum Address Manager) on method 2 (create) or 3 (create2). - // 2) The EAM calls the init actor on method 3 (Exec4). - // 3) The init actor creates the target actor B then calls it on method 1. - if parent.Parent != nil { - calledCreateOnEAM := parent.Parent.Action.FilecoinTo == builtin.EthereumAddressManagerActorAddr && - (parent.Parent.Action.FilecoinMethod == builtin.MethodsEAM.Create || parent.Parent.Action.FilecoinMethod == builtin.MethodsEAM.Create2) - eamCalledInitOnExec4 := parent.Action.FilecoinTo == builtin.InitActorAddr && - parent.Action.FilecoinMethod == builtin.MethodsInit.Exec4 - initCreatedActor := trace.Action.FilecoinMethod == builtin.MethodConstructor - // TODO: We need to handle failures in contract creations and support resurrections on an existing but dead EVM actor) - if calledCreateOnEAM && eamCalledInitOnExec4 && initCreatedActor { - log.Debugf("COND4 EVM contract creation method:%d, code:%s, height:%d", et.Msg.Method, et.Msg.CodeCid.String(), height) - - if parent.Parent.Action.FilecoinMethod == builtin.MethodsEAM.Create { - parent.Parent.SetCallType("create") - } else { - parent.Parent.SetCallType("create2") + // Look for a call to either a constructor or the EVM's resurrect method. + subTrace := find(et.Subcalls, func(et *types.ExecutionTrace) *types.ExecutionTrace { + if et.Msg.To == builtinactors.InitActorAddr { + return find(et.Subcalls, func(et *types.ExecutionTrace) *types.ExecutionTrace { + if et.Msg.Method == builtinactors.MethodConstructor { + return et } - - // update the parent.parent to make this - parent.Parent.Action.To = trace.Action.To - parent.Parent.Subtraces = 0 - - // delete the parent (the EAM) and skip the current trace (init) - *traces = (*traces)[:len(*traces)-1] - return nil - } - } - - if builtinactors.IsEvmActor(parent.Action.FilecoinCodeCid) { - // Handle delegate calls - // - // 1) Look for trace from an EVM actor to itself on InvokeContractDelegate, method 6. - // 2) Check that the previous trace calls another actor on method 3 (GetByteCode) and they are at the same level (same parent) - // 3) Treat this as a delegate call to actor A. - if parent.LastByteCode != nil && trace.Action.From == trace.Action.To && - trace.Action.FilecoinMethod == builtin.MethodsEVM.InvokeContractDelegate { - log.Debugf("COND7 found delegate call, height: %d", height) - prev := parent.LastByteCode - if prev.Action.From == trace.Action.From && prev.Action.FilecoinMethod == builtin.MethodsEVM.GetBytecode && prev.Parent == trace.Parent { - trace.SetCallType("delegatecall") - trace.Action.To = prev.Action.To - - var dp evm.DelegateCallParams - err := dp.UnmarshalCBOR(bytes.NewReader(et.Msg.Params)) - if err != nil { - return fmt.Errorf("failed UnmarshalCBOR: %w", err) - } - trace.Action.Input = dp.Input - - trace.Result.Output, err = decodePayload(et.MsgRct.Return, et.MsgRct.ReturnCodec) - if err != nil { - return fmt.Errorf("failed decodePayload: %w", err) - } - } - } else { - // Handle EVM call special casing - // - // Any outbound call from an EVM actor on methods 1-1023 are side-effects from EVM instructions - // and should be dropped from the trace. - if et.Msg.Method > 0 && - et.Msg.Method <= 1023 { - log.Debugf("Infof found outbound call from an EVM actor on method 1-1023 method:%d, code:%s, height:%d", et.Msg.Method, parent.Action.FilecoinCodeCid.String(), height) - - if et.Msg.Method == builtin.MethodsEVM.GetBytecode { - // save the last bytecode trace to handle delegate calls - parent.LastByteCode = trace - } - - return nil - } - } + }) + } + if et.Msg.Method == builtin.MethodsEVM.Resurrect { + return et } + return nil + }) + + // Same as the Init actor case above, see the comment there. + if subTrace == nil { + if et.MsgRct.ExitCode.IsSuccess() { + return nil, nil, fmt.Errorf("successful Create/Create2 call failed to call a constructor") + } + return nil, nil, nil } - // we are adding trace to the traces so update the parent subtraces count as it was originally set to zero - if parent != nil { - parent.Subtraces++ + // Decode inputs & determine create type. + initcode, createdAddr, err := decodeCreateViaEAM(et) + if err != nil { + return nil, nil, fmt.Errorf("EAM called with invalid params or returned an invalid result, but it still tried to construct the contract: %w", err) } - *traces = append(*traces, trace) + var output types.EthBytes + // Handle the output. + switch et.MsgRct.ExitCode { + case 0: // success + // We're _supposed_ to include the contracts bytecode here, but we + // can't do that reliably (e.g., if some part of the trace reverts). + // So we don't try and include a sentinel "impossible bytecode" + // value (the value specified by EIP-3541). + output = []byte{0xFE} + case 33: // Reverted, parse the revert message. + // If we managed to call the constructor, parse/return its revert message. If we + // fail, we just return no output. + output, _ = decodePayload(subTrace.MsgRct.Return, subTrace.MsgRct.ReturnCodec) + } + + return &types.EthTrace{ + Type: "create", + Action: &types.EthCreateTraceAction{ + From: env.caller, + Gas: types.EthUint64(et.Msg.GasLimit), + Value: types.EthBigInt(et.Msg.Value), + Init: initcode, + }, + Result: &types.EthCreateTraceResult{ + GasUsed: types.EthUint64(et.SumGas().TotalGas), + Address: createdAddr, + Code: output, + }, + TraceAddress: addr, + Error: traceErrMsg(et), + }, subTrace, nil +} + +// Build an EthTrace for an EVM "create" operation. This should only be called with an +// an ExecutionTrace from an EVM instance and on a method between 1 and 1023 inclusive. +func traceEVMPrivate(env *environment, addr []int, et *types.ExecutionTrace) (*types.EthTrace, *types.ExecutionTrace, error) { + // The EVM actor implements DELEGATECALL by: + // + // 1. Asking the callee for its bytecode by calling it on the GetBytecode method. + // 2. Recursively invoking the currently executing contract on the + // InvokeContractDelegate method. + // + // The code below "reconstructs" that delegate call by: + // + // 1. Remembering the last contract on which we called GetBytecode. + // 2. Treating the contract invoked in step 1 as the DELEGATECALL receiver. + // + // Note, however: GetBytecode will be called, e.g., if the user invokes the + // EXTCODECOPY instruction. It's not an error to see multiple GetBytecode calls + // before we see an InvokeContractDelegate. + switch et.Msg.Method { + case builtin.MethodsEVM.GetBytecode: + // NOTE: I'm not checking anything about the receiver here. The EVM won't + // DELEGATECALL any non-EVM actor, but there's no need to encode that fact + // here in case we decide to loosen this up in the future. + if et.MsgRct.ExitCode.IsSuccess() { + to := traceToAddress(et.InvokedActor) + env.lastByteCode = &to + } else { + env.lastByteCode = nil + } + return nil, nil, nil + case builtin.MethodsEVM.InvokeContractDelegate: + // NOTE: We return errors in all the failure cases below instead of trying + // to continue because the caller is an EVM actor. If something goes wrong + // here, there's a bug in our EVM implementation. - for i, call := range et.Subcalls { - err := buildTraces(ctx, traces, trace, append(addr, i), call, height, ca) + // Handle delegate calls + // + // 1) Look for trace from an EVM actor to itself on InvokeContractDelegate, + // method 6. + // 2) Check that the previous trace calls another actor on method 3 + // (GetByteCode) and they are at the same level (same parent) + // 3) Treat this as a delegate call to actor A. + if env.lastByteCode == nil { + return nil, nil, fmt.Errorf("unknown bytecode for delegate call") + } + + if to := traceToAddress(et.InvokedActor); env.caller != to { + return nil, nil, fmt.Errorf("delegate-call not from & to self: %s != %s", env.caller, to) + } + + dp, err := decodeParams[evm12.DelegateCallParams](&et.Msg) if err != nil { - return err + return nil, nil, fmt.Errorf("failed to decode delegate-call params: %w", err) } - } - return nil + output, err := decodePayload(et.MsgRct.Return, et.MsgRct.ReturnCodec) + if err != nil { + return nil, nil, fmt.Errorf("failed to decode delegate-call return: %w", err) + } + + return &types.EthTrace{ + Type: "call", + Action: &types.EthCallTraceAction{ + CallType: "delegatecall", + From: env.caller, + To: *env.lastByteCode, + Gas: types.EthUint64(et.Msg.GasLimit), + Value: types.EthBigInt(et.Msg.Value), + Input: dp.Input, + }, + Result: &types.EthCallTraceResult{ + GasUsed: types.EthUint64(et.SumGas().TotalGas), + Output: output, + }, + TraceAddress: addr, + Error: traceErrMsg(et), + }, et, nil + } + // We drop all other "private" calls from FEVM. We _forbid_ explicit calls between 0 and + // 1024 (exclusive), so any calls in this range must be implementation details. + return nil, nil, nil } diff --git a/app/submodule/eth/eth_utils.go b/app/submodule/eth/eth_utils.go index 8dcb86ca88..3e63c767d4 100644 --- a/app/submodule/eth/eth_utils.go +++ b/app/submodule/eth/eth_utils.go @@ -362,36 +362,35 @@ func parseEthRevert(ret []byte) string { // 3. Otherwise, we fall back to returning a masked ID Ethereum address. If the supplied address is an f0 address, we // use that ID to form the masked ID address. // 4. Otherwise, we fetch the actor's ID from the state tree and form the masked ID with it. +// +// If the actor doesn't exist in the state-tree but we have its ID, we use a masked ID address. It could have been deleted. func lookupEthAddress(ctx context.Context, addr address.Address, ca v1.IChain) (types.EthAddress, error) { - // BLOCK A: We are trying to get an actual Ethereum address from an f410 address. // Attempt to convert directly, if it's an f4 address. ethAddr, err := types.EthAddressFromFilecoinAddress(addr) if err == nil && !ethAddr.IsMaskedID() { return ethAddr, nil } - // Lookup on the target actor and try to get an f410 address. - actor, err := ca.StateGetActor(ctx, addr, types.EmptyTSK) + // Otherwise, resolve the ID addr. + idAddr, err := ca.StateLookupID(ctx, addr, types.EmptyTSK) if err != nil { return types.EthAddress{}, err } - if actor.Address != nil { - if ethAddr, err := types.EthAddressFromFilecoinAddress(*actor.Address); err == nil && !ethAddr.IsMaskedID() { - return ethAddr, nil - } - } - // BLOCK B: We gave up on getting an actual Ethereum address and are falling back to a Masked ID address. - // Check if we already have an ID addr, and use it if possible. - if err == nil && ethAddr.IsMaskedID() { + // Lookup on the target actor and try to get an f410 address. + if actor, err := ca.GetActor(ctx, idAddr); errors.Is(err, types.ErrActorNotFound) { + // Not found -> use a masked ID address + } else if err != nil { + // Any other error -> fail. + return types.EthAddress{}, err + } else if actor.Address == nil { + // No delegated address -> use masked ID address. + } else if ethAddr, err := types.EthAddressFromFilecoinAddress(*actor.Address); err == nil && !ethAddr.IsMaskedID() { + // Conversable into an eth address, use it. return ethAddr, nil } - // Otherwise, resolve the ID addr. - idAddr, err := ca.StateLookupID(ctx, addr, types.EmptyTSK) - if err != nil { - return types.EthAddress{}, err - } + // Otherwise, use the masked address. return types.EthAddressFromFilecoinAddress(idAddr) } diff --git a/app/submodule/mining/mining_api.go b/app/submodule/mining/mining_api.go index 880e14be0f..a1e5064e6d 100644 --- a/app/submodule/mining/mining_api.go +++ b/app/submodule/mining/mining_api.go @@ -249,7 +249,7 @@ func (miningAPI *MiningAPI) minerCreateBlock(ctx context.Context, bt *types.Bloc next.BLSAggregate = aggSig - pweight, err := miningAPI.Ming.SyncModule.ChainSelector.Weight(ctx, pts) + pweight, err := miningAPI.Ming.ChainModule.ChainReader.Weight(ctx, pts) if err != nil { return nil, err } diff --git a/app/submodule/syncer/syncer_api.go b/app/submodule/syncer/syncer_api.go index c3beea90df..1dbefde0b7 100644 --- a/app/submodule/syncer/syncer_api.go +++ b/app/submodule/syncer/syncer_api.go @@ -85,7 +85,7 @@ func (sa *syncerAPI) ChainTipSetWeight(ctx context.Context, tsk types.TipSetKey) if err != nil { return big.Int{}, err } - return sa.syncer.ChainSelector.Weight(ctx, ts) + return sa.syncer.ChainModule.ChainReader.Weight(ctx, ts) } // ChainSyncHandleNewTipSet submits a chain head to the syncer for processing. diff --git a/app/submodule/syncer/syncer_submodule.go b/app/submodule/syncer/syncer_submodule.go index 5de977107d..2f7f42ec7a 100644 --- a/app/submodule/syncer/syncer_submodule.go +++ b/app/submodule/syncer/syncer_submodule.go @@ -15,7 +15,6 @@ import ( v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1" cbor "github.com/ipfs/go-ipld-cbor" - fbig "github.com/filecoin-project/go-state-types/big" "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" "github.com/pkg/errors" @@ -50,7 +49,6 @@ type SyncerSubmodule struct { //nolint // 'venus/pkg/net/pubsub/topic.go' BlockTopic *pubsub.Topic BlockSub pubsub.Subscription - ChainSelector nodeChainSelector Stmgr *statemanger.Stmgr ChainSyncManager *chainsync.Manager Drand beacon.Schedule @@ -70,11 +68,6 @@ type syncerConfig interface { Verifier() ffiwrapper.Verifier } -type nodeChainSelector interface { - Weight(context.Context, *types.TipSet) (fbig.Int, error) - IsHeavier(ctx context.Context, a, b *types.TipSet) (bool, error) -} - // NewSyncerSubmodule creates a new chain submodule. func NewSyncerSubmodule(ctx context.Context, config syncerConfig, @@ -89,7 +82,6 @@ func NewSyncerSubmodule(ctx context.Context, tickets := consensus.NewTicketMachine(chn.ChainReader) cborStore := cbor.NewCborStore(config.Repo().Datastore()) stateViewer := consensus.AsDefaultStateViewer(state.NewViewer(cborStore)) - nodeChainSelector := consensus.NewChainSelector(cborStore, &stateViewer) blkValid := consensus.NewBlockValidator(tickets, blockstore.Blockstore, @@ -99,7 +91,6 @@ func NewSyncerSubmodule(ctx context.Context, config.Verifier(), &stateViewer, chn.ChainReader, - nodeChainSelector, chn.Fork, config.Repo().Config().NetworkParams, gasPriceSchedule) @@ -134,7 +125,7 @@ func NewSyncerSubmodule(ctx context.Context, chn.Stmgr = stmgr chn.Waiter.Stmgr = stmgr - chainSyncManager, err := chainsync.NewManager(stmgr, blkValid, chn, nodeChainSelector, + chainSyncManager, err := chainsync.NewManager(stmgr, blkValid, chn, blockstore.Blockstore, network.ExchangeClient, config.ChainClock(), chn.Fork) if err != nil { return nil, err @@ -150,13 +141,15 @@ func NewSyncerSubmodule(ctx context.Context, } } - network.HelloHandler.Register(func(ci *types.ChainInfo) { + if err := network.HelloHandler.Register(ctx, func(ci *types.ChainInfo) { err := chainSyncManager.BlockProposer().SendHello(ci) if err != nil { log.Errorf("error receiving chain info from hello %s: %s", ci, err) return } - }) + }); err != nil { + return nil, err + } return &SyncerSubmodule{ Stmgr: stmgr, @@ -164,7 +157,6 @@ func NewSyncerSubmodule(ctx context.Context, ChainModule: chn, NetworkModule: network, SlashFilter: slashFilter, - ChainSelector: nodeChainSelector, ChainSyncManager: &chainSyncManager, Drand: chn.Drand, SyncProvider: *NewChainSyncProvider(&chainSyncManager), diff --git a/cmd/import.go b/cmd/import.go index 53953f2535..2280eba407 100644 --- a/cmd/import.go +++ b/cmd/import.go @@ -8,6 +8,7 @@ import ( "os" "strings" + "github.com/filecoin-project/venus/pkg/consensus/chainselector" "github.com/filecoin-project/venus/pkg/httpreader" "github.com/DataDog/zstd" @@ -61,7 +62,7 @@ func importChain(ctx context.Context, r repo.Repo, fname string) error { bs := r.Datastore() // setup a ipldCbor on top of the local store - chainStore := chain.NewStore(r.ChainDatastore(), bs, cid.Undef, chain.NewMockCirculatingSupplyCalculator()) + chainStore := chain.NewStore(r.ChainDatastore(), bs, cid.Undef, chain.NewMockCirculatingSupplyCalculator(), chainselector.Weight) bufr := bufio.NewReaderSize(rd, 1<<20) diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi index fa64b55373..b715c9403f 160000 --- a/extern/filecoin-ffi +++ b/extern/filecoin-ffi @@ -1 +1 @@ -Subproject commit fa64b5537320dbdcf8456bb6ca9e82adb07b7747 +Subproject commit b715c9403faf919e95fdc702cd651e842f18d890 diff --git a/fixtures/networks/butterfly.go b/fixtures/networks/butterfly.go index 2ac8a71e5f..1582dd645b 100644 --- a/fixtures/networks/butterfly.go +++ b/fixtures/networks/butterfly.go @@ -9,7 +9,7 @@ import ( ) func ButterflySnapNet() *NetworkConf { - return &NetworkConf{ + nc := &NetworkConf{ Bootstrap: config.BootstrapConfig{ Addresses: []string{ "/dns4/bootstrap-0.butterfly.fildev.network/tcp/1347/p2p/12D3KooWNwAkUtWuLtKCyyFP2vBzmpTHSrQao7KQx7Xfa8YvSg1N", @@ -20,7 +20,7 @@ func ButterflySnapNet() *NetworkConf { Network: config.NetworkParamsConfig{ DevNet: true, NetworkType: types.NetworkButterfly, - GenesisNetworkVersion: network.Version20, + GenesisNetworkVersion: network.Version21, ReplaceProofTypes: []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg512MiBV1, abi.RegisteredSealProof_StackedDrg32GiBV1, @@ -55,9 +55,10 @@ func ButterflySnapNet() *NetworkConf { UpgradeHyggeHeight: -21, UpgradeLightningHeight: -22, UpgradeThunderHeight: -23, - UpgradeWatermelonHeight: 400, + UpgradeWatermelonHeight: -24, UpgradeWatermelonFixHeight: -100, // This fix upgrade only ran on calibrationnet UpgradeWatermelonFix2Height: -101, // This fix upgrade only ran on calibrationnet + UpgradeDragonHeight: 5760, }, DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1}, AddressNetwork: address.Testnet, @@ -67,4 +68,9 @@ func ButterflySnapNet() *NetworkConf { ActorDebugging: false, }, } + + nc.Network.ForkUpgradeParam.UpgradePhoenixHeight = nc.Network.ForkUpgradeParam.UpgradeDragonHeight + 120 + nc.Network.DrandSchedule[nc.Network.ForkUpgradeParam.UpgradePhoenixHeight] = config.DrandQuicknet + + return nc } diff --git a/fixtures/networks/calibration.go b/fixtures/networks/calibration.go index bd3d25b783..d0dca98f33 100644 --- a/fixtures/networks/calibration.go +++ b/fixtures/networks/calibration.go @@ -15,7 +15,7 @@ type NetworkConf struct { } func Calibration() *NetworkConf { - return &NetworkConf{ + nc := &NetworkConf{ Bootstrap: config.BootstrapConfig{ Addresses: []string{ "/dns4/bootstrap-0.calibration.fildev.network/tcp/1347/p2p/12D3KooWCi2w8U4DDB9xqrejb5KYHaQv2iA2AJJ6uzG3iQxNLBMy", @@ -23,6 +23,9 @@ func Calibration() *NetworkConf { "/dns4/bootstrap-2.calibration.fildev.network/tcp/1347/p2p/12D3KooWNRxTHUn8bf7jz1KEUPMc2dMgGfa4f8ZJTsquVSn3vHCG", "/dns4/bootstrap-3.calibration.fildev.network/tcp/1347/p2p/12D3KooWFWUqE9jgXvcKHWieYs9nhyp6NF4ftwLGAHm4sCv73jjK", "/dns4/calibration.node.glif.io/tcp/1237/p2p/12D3KooWQPYouEAsUQKzvFUA9sQ8tz4rfpqtTzh2eL6USd9bwg7x", + "/dns4/bootstrap-calibnet-0.chainsafe-fil.io/tcp/34000/p2p/12D3KooWABQ5gTDHPWyvhJM7jPhtNwNJruzTEo32Lo4gcS5ABAMm", + "/dns4/bootstrap-calibnet-1.chainsafe-fil.io/tcp/34000/p2p/12D3KooWS3ZRhMYL67b4bD5XQ6fcpTyVQXnDe8H89LvwrDqaSbiT", + "/dns4/bootstrap-calibnet-2.chainsafe-fil.io/tcp/34000/p2p/12D3KooWEiBN8jBX8EBoM3M47pVRLRWV812gDRUJhMxgyVkUoR48", }, Period: "30s", }, @@ -66,6 +69,7 @@ func Calibration() *NetworkConf { UpgradeWatermelonHeight: 1013134, // 2023-10-19T13:00:00Z UpgradeWatermelonFixHeight: 1070494, // 2023-11-07T13:00:00Z UpgradeWatermelonFix2Height: 1108174, // 2023-11-21T13:00:00Z + UpgradeDragonHeight: 1427974, // 2024-03-11T14:00:00Z }, DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1}, AddressNetwork: address.Testnet, @@ -75,4 +79,9 @@ func Calibration() *NetworkConf { ActorDebugging: false, }, } + + nc.Network.ForkUpgradeParam.UpgradePhoenixHeight = nc.Network.ForkUpgradeParam.UpgradeDragonHeight + 120 + nc.Network.DrandSchedule[nc.Network.ForkUpgradeParam.UpgradePhoenixHeight] = config.DrandQuicknet + + return nc } diff --git a/fixtures/networks/forcenet.go b/fixtures/networks/forcenet.go index 0210179d2a..e7a8f6edb2 100644 --- a/fixtures/networks/forcenet.go +++ b/fixtures/networks/forcenet.go @@ -9,7 +9,7 @@ import ( ) func ForceNet() *NetworkConf { - return &NetworkConf{ + nc := &NetworkConf{ Bootstrap: config.BootstrapConfig{ Addresses: []string{}, @@ -18,7 +18,7 @@ func ForceNet() *NetworkConf { Network: config.NetworkParamsConfig{ DevNet: true, NetworkType: types.NetworkForce, - GenesisNetworkVersion: network.Version20, + GenesisNetworkVersion: network.Version21, ReplaceProofTypes: []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg8MiBV1, abi.RegisteredSealProof_StackedDrg512MiBV1, @@ -57,9 +57,10 @@ func ForceNet() *NetworkConf { UpgradeHyggeHeight: -21, UpgradeLightningHeight: -22, UpgradeThunderHeight: -23, - UpgradeWatermelonHeight: 200, + UpgradeWatermelonHeight: -24, UpgradeWatermelonFixHeight: -100, // This fix upgrade only ran on calibrationnet UpgradeWatermelonFix2Height: -101, // This fix upgrade only ran on calibrationnet + UpgradeDragonHeight: 20, }, DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: config.DrandMainnet}, AddressNetwork: address.Testnet, @@ -69,4 +70,8 @@ func ForceNet() *NetworkConf { ActorDebugging: true, }, } + nc.Network.ForkUpgradeParam.UpgradePhoenixHeight = nc.Network.ForkUpgradeParam.UpgradeDragonHeight + 120 + nc.Network.DrandSchedule[nc.Network.ForkUpgradeParam.UpgradePhoenixHeight] = config.DrandQuicknet + + return nc } diff --git a/fixtures/networks/integrationtestnet.go b/fixtures/networks/integrationtestnet.go index ffd8d6aa80..669002bc51 100644 --- a/fixtures/networks/integrationtestnet.go +++ b/fixtures/networks/integrationtestnet.go @@ -9,7 +9,7 @@ import ( ) func IntegrationNet() *NetworkConf { - return &NetworkConf{ + nc := &NetworkConf{ Bootstrap: config.BootstrapConfig{ Addresses: []string{}, Period: "30s", @@ -53,6 +53,7 @@ func IntegrationNet() *NetworkConf { UpgradeWatermelonHeight: 3431940, UpgradeWatermelonFixHeight: -100, // This fix upgrade only ran on calibrationnet UpgradeWatermelonFix2Height: -101, // This fix upgrade only ran on calibrationnet + UpgradeDragonHeight: 9999999999999, }, DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 5, 51000: 1}, AddressNetwork: address.Testnet, @@ -62,4 +63,9 @@ func IntegrationNet() *NetworkConf { ActorDebugging: false, }, } + + nc.Network.ForkUpgradeParam.UpgradePhoenixHeight = nc.Network.ForkUpgradeParam.UpgradeDragonHeight + 10 + nc.Network.DrandSchedule[nc.Network.ForkUpgradeParam.UpgradePhoenixHeight] = config.DrandQuicknet + + return nc } diff --git a/fixtures/networks/interopnet.go b/fixtures/networks/interopnet.go index bae776d8b0..1208195edc 100644 --- a/fixtures/networks/interopnet.go +++ b/fixtures/networks/interopnet.go @@ -9,7 +9,7 @@ import ( ) func InteropNet() *NetworkConf { - return &NetworkConf{ + nc := &NetworkConf{ Bootstrap: config.BootstrapConfig{ Addresses: []string{ "/dns4/bootstrap-0.interop.fildev.network/tcp/1347/p2p/12D3KooWDpppr8csCNvEPnD2Z83KTPdBTM7iJhL66qK8LK3bB5NU", @@ -55,9 +55,10 @@ func InteropNet() *NetworkConf { UpgradeHyggeHeight: -21, UpgradeLightningHeight: -22, UpgradeThunderHeight: -23, - UpgradeWatermelonHeight: 50, + UpgradeWatermelonHeight: -24, UpgradeWatermelonFixHeight: -100, // This fix upgrade only ran on calibrationnet UpgradeWatermelonFix2Height: -101, // This fix upgrade only ran on calibrationnet + UpgradeDragonHeight: 50, }, DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1}, AddressNetwork: address.Testnet, @@ -67,4 +68,9 @@ func InteropNet() *NetworkConf { ActorDebugging: false, }, } + + nc.Network.ForkUpgradeParam.UpgradePhoenixHeight = nc.Network.ForkUpgradeParam.UpgradeDragonHeight + 100 + nc.Network.DrandSchedule[nc.Network.ForkUpgradeParam.UpgradePhoenixHeight] = config.DrandQuicknet + + return nc } diff --git a/fixtures/networks/mainnet.go b/fixtures/networks/mainnet.go index e4b6ee2fbf..484577d048 100644 --- a/fixtures/networks/mainnet.go +++ b/fixtures/networks/mainnet.go @@ -10,15 +10,9 @@ import ( ) func Mainnet() *NetworkConf { - return &NetworkConf{ + nc := &NetworkConf{ Bootstrap: config.BootstrapConfig{ Addresses: []string{ - "/dns4/bootstrap-0.mainnet.filops.net/tcp/1347/p2p/12D3KooWCVe8MmsEMes2FzgTpt9fXtmCY7wrq91GRiaC8PHSCCBj", - "/dns4/bootstrap-1.mainnet.filops.net/tcp/1347/p2p/12D3KooWCwevHg1yLCvktf2nvLu7L9894mcrJR4MsBCcm4syShVc", - "/dns4/bootstrap-2.mainnet.filops.net/tcp/1347/p2p/12D3KooWEWVwHGn2yR36gKLozmb4YjDJGerotAPGxmdWZx2nxMC4", - "/dns4/bootstrap-6.mainnet.filops.net/tcp/1347/p2p/12D3KooWP5MwCiqdMETF9ub1P3MbCvQCcfconnYHbWg6sUJcDRQQ", - "/dns4/bootstrap-7.mainnet.filops.net/tcp/1347/p2p/12D3KooWRs3aY1p3juFjPy8gPN95PEQChm2QKGUCAdcDCC4EBMKf", - "/dns4/bootstrap-8.mainnet.filops.net/tcp/1347/p2p/12D3KooWScFR7385LTyR4zU1bYdzSiiAb5rnNABfVahPvVSzyTkR", "/dns4/lotus-bootstrap.forceup.cn/tcp/41778/p2p/12D3KooWFQsv3nRMUevZNWWsY1Wu6NUzUbawnWU5NcRhgKuJA37C", "/dns4/bootstrap-0.starpool.in/tcp/12757/p2p/12D3KooWGHpBMeZbestVEWkfdnC9u7p6uFHXL1n7m1ZBqsEmiUzz", "/dns4/bootstrap-1.starpool.in/tcp/12757/p2p/12D3KooWQZrGH1PxSNZPum99M1zNvjNFM33d1AAu5DcvdHptuU7u", @@ -27,6 +21,9 @@ func Mainnet() *NetworkConf { "/dns4/bootstrap-1.ipfsmain.cn/tcp/34723/p2p/12D3KooWMKxMkD5DMpSWsW7dBddKxKT7L2GgbNuckz9otxvkvByP", "/dns4/bootstarp-0.1475.io/tcp/61256/p2p/12D3KooWRzCVDwHUkgdK7eRgnoXbjDAELhxPErjHzbRLguSV1aRt", "/dns4/bootstrap-venus.mainnet.filincubator.com/tcp/8888/p2p/QmQu8C6deXwKvJP2D8B6QGyhngc3ZiDnFzEHBDx8yeBXST", + "/dns4/bootstrap-mainnet-0.chainsafe-fil.io/tcp/34000/p2p/12D3KooWKKkCZbcigsWTEu1cgNetNbZJqeNtysRtFpq7DTqw3eqH", + "/dns4/bootstrap-mainnet-1.chainsafe-fil.io/tcp/34000/p2p/12D3KooWGnkd9GQKo3apkShQDaq1d6cKJJmsVe6KiQkacUk1T8oZ", + "/dns4/bootstrap-mainnet-2.chainsafe-fil.io/tcp/34000/p2p/12D3KooWHQRSDFv4FvAjtU32shQ7znz7oRbLBryXzZ9NMK2feyyH", }, Period: "30s", }, @@ -73,6 +70,7 @@ func Mainnet() *NetworkConf { UpgradeWatermelonHeight: 3469380, // 2023-12-12T13:30:00Z UpgradeWatermelonFixHeight: -100, // This fix upgrade only ran on calibrationnet UpgradeWatermelonFix2Height: -101, // This fix upgrade only ran on calibrationnet + UpgradeDragonHeight: 3792000, // 2024-04-02T14:00:00Z }, DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 5, 51000: 1}, AddressNetwork: address.Mainnet, @@ -82,4 +80,11 @@ func Mainnet() *NetworkConf { ActorDebugging: false, }, } + + // This epoch, 120 epochs after the "rest" of the nv22 upgrade, is when we switch to Drand quicknet + // 2024-04-02T15:00:00Z + nc.Network.ForkUpgradeParam.UpgradePhoenixHeight = nc.Network.ForkUpgradeParam.UpgradeDragonHeight + 120 + nc.Network.DrandSchedule[nc.Network.ForkUpgradeParam.UpgradePhoenixHeight] = config.DrandQuicknet + + return nc } diff --git a/fixtures/networks/net_2k.go b/fixtures/networks/net_2k.go index 5d586120c9..17fdff960f 100644 --- a/fixtures/networks/net_2k.go +++ b/fixtures/networks/net_2k.go @@ -9,7 +9,7 @@ import ( ) func Net2k() *NetworkConf { - return &NetworkConf{ + nc := &NetworkConf{ Bootstrap: config.BootstrapConfig{ Addresses: []string{}, Period: "30s", @@ -17,7 +17,7 @@ func Net2k() *NetworkConf { Network: config.NetworkParamsConfig{ DevNet: true, NetworkType: types.Network2k, - GenesisNetworkVersion: network.Version20, + GenesisNetworkVersion: network.Version21, ReplaceProofTypes: []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg2KiBV1, abi.RegisteredSealProof_StackedDrg8MiBV1, @@ -51,9 +51,10 @@ func Net2k() *NetworkConf { UpgradeHyggeHeight: -21, UpgradeLightningHeight: -22, UpgradeThunderHeight: -23, - UpgradeWatermelonHeight: 200, + UpgradeWatermelonHeight: -24, UpgradeWatermelonFixHeight: -100, // This fix upgrade only ran on calibrationnet UpgradeWatermelonFix2Height: -101, // This fix upgrade only ran on calibrationnet + UpgradeDragonHeight: 20, }, DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1}, AddressNetwork: address.Testnet, @@ -63,4 +64,9 @@ func Net2k() *NetworkConf { ActorDebugging: true, }, } + + nc.Network.ForkUpgradeParam.UpgradePhoenixHeight = nc.Network.ForkUpgradeParam.UpgradeDragonHeight + 120 + nc.Network.DrandSchedule[nc.Network.ForkUpgradeParam.UpgradePhoenixHeight] = config.DrandQuicknet + + return nc } diff --git a/go.mod b/go.mod index 076cb0c22d..1bae085524 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( contrib.go.opencensus.io/exporter/prometheus v0.4.2 - github.com/BurntSushi/toml v1.1.0 + github.com/BurntSushi/toml v1.3.0 github.com/DataDog/zstd v1.4.5 github.com/Gurpartap/async v0.0.0-20180927173644-4f7f499dd9ee github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d @@ -15,11 +15,11 @@ require ( github.com/detailyang/go-fallocate v0.0.0-20180908115635-432fa640bd2e github.com/dgraph-io/badger/v2 v2.2007.4 github.com/docker/go-units v0.5.0 - github.com/drand/drand v1.4.9 - github.com/drand/kyber v1.1.15 + github.com/drand/drand v1.5.7 + github.com/drand/kyber v1.2.0 github.com/dustin/go-humanize v1.0.1 github.com/etherlabsio/healthcheck/v2 v2.0.0 - github.com/fatih/color v1.13.0 + github.com/fatih/color v1.15.0 github.com/filecoin-project/filecoin-ffi v0.30.4-0.20200910194244-f640612a1a1f github.com/filecoin-project/go-address v1.1.0 github.com/filecoin-project/go-amt-ipld/v4 v4.2.0 @@ -32,7 +32,7 @@ require ( github.com/filecoin-project/go-fil-markets v1.28.2 github.com/filecoin-project/go-jsonrpc v0.1.5 github.com/filecoin-project/go-paramfetch v0.0.4 - github.com/filecoin-project/go-state-types v0.12.8 + github.com/filecoin-project/go-state-types v0.13.0-rc.2 github.com/filecoin-project/pubsub v1.0.0 github.com/filecoin-project/specs-actors v0.9.15 github.com/filecoin-project/specs-actors/v2 v2.3.6 @@ -76,37 +76,37 @@ require ( github.com/ipld/go-car v0.6.1 github.com/ipld/go-car/v2 v2.10.1 github.com/jbenet/goprocess v0.1.4 - github.com/libp2p/go-libp2p v0.27.8 + github.com/libp2p/go-libp2p v0.31.1 github.com/libp2p/go-libp2p-kad-dht v0.21.1 github.com/libp2p/go-libp2p-pubsub v0.9.3 github.com/libp2p/go-msgio v0.3.0 github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 github.com/mitchellh/go-homedir v1.1.0 - github.com/multiformats/go-multiaddr v0.9.0 + github.com/multiformats/go-multiaddr v0.12.2 github.com/multiformats/go-multiaddr-dns v0.3.1 github.com/multiformats/go-multihash v0.2.3 github.com/multiformats/go-varint v0.0.7 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pborman/uuid v1.2.0 github.com/pkg/errors v0.9.1 - github.com/prometheus/client_golang v1.14.0 + github.com/prometheus/client_golang v1.16.0 github.com/raulk/clock v1.1.0 github.com/streadway/handy v0.0.0-20200128134331-0f66f006fb2e github.com/stretchr/testify v1.8.4 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 - github.com/whyrusleeping/cbor-gen v0.0.0-20230923211252-36a87e1ba72f + github.com/whyrusleeping/cbor-gen v0.1.0 github.com/whyrusleeping/go-sysinfo v0.0.0-20190219211824-4a357d4b90b1 github.com/zyedidia/generic v1.2.1 go.opencensus.io v0.24.0 go.opentelemetry.io/otel/bridge/opencensus v0.39.0 go.opentelemetry.io/otel/exporters/jaeger v1.14.0 go.opentelemetry.io/otel/sdk v1.16.0 - go.uber.org/zap v1.24.0 - golang.org/x/crypto v0.17.0 + go.uber.org/zap v1.25.0 + golang.org/x/crypto v0.18.0 golang.org/x/net v0.17.0 - golang.org/x/oauth2 v0.5.0 - golang.org/x/sync v0.1.0 - golang.org/x/sys v0.15.0 + golang.org/x/oauth2 v0.8.0 + golang.org/x/sync v0.3.0 + golang.org/x/sys v0.16.0 golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 gopkg.in/cheggaaa/pb.v1 v1.0.28 gorm.io/driver/mysql v1.1.1 @@ -124,6 +124,7 @@ require ( github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9 // indirect github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 // indirect github.com/whyrusleeping/go-logging v0.0.1 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect ) require ( @@ -131,7 +132,7 @@ require ( github.com/Kubuxu/go-os-helper v0.0.1 // indirect github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect github.com/awnumar/memcall v0.0.0-20191004114545-73db50fd9f80 // indirect - github.com/benbjohnson/clock v1.3.0 // indirect + github.com/benbjohnson/clock v1.3.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bep/debounce v1.2.1 // indirect github.com/bytedance/sonic v1.9.1 // indirect @@ -145,12 +146,12 @@ require ( github.com/cskr/pubsub v1.0.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/deepmap/oapi-codegen v1.3.13 // indirect github.com/dgraph-io/badger/v3 v3.2103.5 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect - github.com/drand/kyber-bls12381 v0.2.3 // indirect + github.com/drand/kyber-bls12381 v0.3.1 // indirect github.com/elastic/gosigar v0.14.2 // indirect github.com/filecoin-project/go-amt-ipld/v2 v2.1.1-0.20201006184820-924ee87a1349 // indirect github.com/filecoin-project/go-amt-ipld/v3 v3.1.0 // indirect @@ -192,12 +193,12 @@ require ( github.com/google/go-cmp v0.5.9 // indirect github.com/google/go-querystring v1.0.0 // indirect github.com/google/gopacket v1.1.19 // indirect - github.com/google/pprof v0.0.0-20230405160723-4a4c7d95572b // indirect + github.com/google/pprof v0.0.0-20230817174616-7a8ec2ada47b // indirect github.com/hannahhoward/cbor-gen-for v0.0.0-20230214144701-5d17c9d5243c // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/huin/goupnp v1.1.0 // indirect + github.com/huin/goupnp v1.2.0 // indirect github.com/influxdata/influxdb-client-go/v2 v2.2.2 // indirect github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839 // indirect github.com/ipfs/bbloom v0.0.4 // indirect @@ -225,8 +226,8 @@ require ( github.com/jpillora/backoff v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kilic/bls12-381 v0.1.0 // indirect - github.com/klauspost/compress v1.16.6 // indirect - github.com/klauspost/cpuid/v2 v2.2.5 // indirect + github.com/klauspost/compress v1.16.7 // indirect + github.com/klauspost/cpuid/v2 v2.2.6 // indirect github.com/koron/go-ssdp v0.0.4 // indirect github.com/leodido/go-urn v1.2.4 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect @@ -235,19 +236,19 @@ require ( github.com/libp2p/go-libp2p-asn-util v0.3.0 // indirect github.com/libp2p/go-libp2p-kbucket v0.5.0 // indirect github.com/libp2p/go-libp2p-record v0.2.0 // indirect - github.com/libp2p/go-nat v0.1.0 // indirect + github.com/libp2p/go-nat v0.2.0 // indirect github.com/libp2p/go-netroute v0.2.1 // indirect - github.com/libp2p/go-reuseport v0.2.0 // indirect - github.com/libp2p/go-yamux/v4 v4.0.0 // indirect + github.com/libp2p/go-reuseport v0.4.0 // indirect + github.com/libp2p/go-yamux/v4 v4.0.1 // indirect github.com/magefile/mage v1.11.0 // indirect github.com/magiconair/properties v1.8.6 // indirect github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/mattn/go-runewidth v0.0.10 // indirect - github.com/mattn/go-sqlite3 v1.14.16 + github.com/mattn/go-sqlite3 v1.14.22 github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/miekg/dns v1.1.53 // indirect + github.com/miekg/dns v1.1.55 // indirect github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect github.com/minio/sha256-simd v1.0.1 // indirect @@ -262,29 +263,28 @@ require ( github.com/multiformats/go-multicodec v0.9.0 github.com/multiformats/go-multistream v0.4.1 // indirect github.com/nikkolasg/hexjson v0.1.0 // indirect - github.com/onsi/ginkgo/v2 v2.9.2 // indirect - github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect + github.com/onsi/ginkgo/v2 v2.11.0 // indirect + github.com/opencontainers/runtime-spec v1.1.0 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/polydawn/refmt v0.89.0 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.42.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect + github.com/prometheus/client_model v0.4.0 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.10.1 // indirect github.com/prometheus/statsd_exporter v0.23.0 // indirect github.com/puzpuzpuz/xsync/v2 v2.4.1 github.com/quic-go/qpack v0.4.0 // indirect - github.com/quic-go/qtls-go1-19 v0.3.3 // indirect - github.com/quic-go/qtls-go1-20 v0.2.3 // indirect - github.com/quic-go/quic-go v0.33.0 // indirect - github.com/quic-go/webtransport-go v0.5.2 // indirect + github.com/quic-go/qtls-go1-20 v0.3.3 // indirect + github.com/quic-go/quic-go v0.38.2 // indirect + github.com/quic-go/webtransport-go v0.5.3 // indirect github.com/raulk/go-watchdog v1.3.0 // indirect github.com/rivo/uniseg v0.1.0 // indirect github.com/rs/cors v1.7.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/sirupsen/logrus v1.9.0 // indirect + github.com/sirupsen/logrus v1.9.2 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/afero v1.8.2 // indirect github.com/spf13/cast v1.5.0 // indirect @@ -296,7 +296,7 @@ require ( github.com/texttheater/golang-levenshtein v0.0.0-20180516184445-d188e65d659e // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect - github.com/urfave/cli/v2 v2.16.3 // indirect + github.com/urfave/cli/v2 v2.25.5 // indirect github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect github.com/x448/float16 v0.8.4 // indirect @@ -305,28 +305,26 @@ require ( go.opentelemetry.io/otel/metric v1.16.0 // indirect go.opentelemetry.io/otel/sdk/metric v0.39.0 // indirect go.opentelemetry.io/otel/trace v1.16.0 // indirect - go.uber.org/atomic v1.10.0 // indirect - go.uber.org/dig v1.16.1 // indirect - go.uber.org/fx v1.19.2 // indirect + go.uber.org/atomic v1.11.0 // indirect + go.uber.org/dig v1.17.0 // indirect + go.uber.org/fx v1.20.0 // indirect go.uber.org/multierr v1.11.0 go4.org v0.0.0-20200411211856-f5505b9728dd // indirect golang.org/x/arch v0.3.0 // indirect - golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect - golang.org/x/mod v0.10.0 // indirect - golang.org/x/term v0.15.0 // indirect + golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect + golang.org/x/mod v0.12.0 // indirect + golang.org/x/term v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect - golang.org/x/tools v0.7.0 // indirect + golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect google.golang.org/api v0.81.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect - google.golang.org/grpc v1.53.0 // indirect + google.golang.org/grpc v1.55.0 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.66.6 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect lukechampine.com/blake3 v1.2.1 // indirect - nhooyr.io/websocket v1.8.7 // indirect ) replace ( diff --git a/go.sum b/go.sum index 16d26942c3..49e1a64b32 100644 --- a/go.sum +++ b/go.sum @@ -67,8 +67,8 @@ dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I= -github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.3.0 h1:Ws8e5YmnrGEHzZEzg0YvK/7COGYtTC5PbaH9oSSbgfA= +github.com/BurntSushi/toml v1.3.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= @@ -95,14 +95,16 @@ github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAu github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/ardanlabs/darwin/v2 v2.0.0 h1:XCisQMgQ5EG+ZvSEcADEo+pyfIMKyWAGnn5o2TgriYE= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/awnumar/memcall v0.0.0-20191004114545-73db50fd9f80 h1:8kObYoBO4LNmQ+fLiScBfxEdxF1w2MHlvH/lr9MLaTg= github.com/awnumar/memcall v0.0.0-20191004114545-73db50fd9f80/go.mod h1:S911igBPR9CThzd/hYQQmTc9SWNu3ZHIlCGaWsWsoJo= github.com/awnumar/memguard v0.22.2 h1:tMxcq1WamhG13gigK8Yaj9i/CHNUO3fFlpS9ABBQAxw= github.com/awnumar/memguard v0.22.2/go.mod h1:33OwJBHC+T4eEfFcDrQb78TMlBMBvcOPCXWU9xE34gM= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= +github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -181,9 +183,9 @@ github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U= github.com/dchest/blake2b v1.0.0 h1:KK9LimVmE0MjRl9095XJmKqZ+iLxWATvlcpVFRtaw6s= github.com/dchest/blake2b v1.0.0/go.mod h1:U034kXgbJpCle2wSk5ybGIVhOSHCVLMDqOzcPEA0F7s= -github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= +github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/deepmap/oapi-codegen v1.3.13 h1:9HKGCsdJqE4dnrQ8VerFS0/1ZOJPmAhN+g8xgp8y3K4= github.com/deepmap/oapi-codegen v1.3.13/go.mod h1:WAmG5dWY8/PYHt4vKxlt90NsbHMAOCiteYKZMiIRfOo= github.com/detailyang/go-fallocate v0.0.0-20180908115635-432fa640bd2e h1:lj77EKYUpYXTd8CD/+QMIf8b6OIOTsfEBSXiAzuEHTU= @@ -205,19 +207,12 @@ github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUn github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/drand/bls12-381 v0.3.2/go.mod h1:dtcLgPtYT38L3NO6mPDYH0nbpc5tjPassDqiniuAt4Y= -github.com/drand/drand v1.4.9 h1:WE8Jf/l+7B/rheCMCLZTp5xk0/a05t+ciwBvORq9jXM= -github.com/drand/drand v1.4.9/go.mod h1:vsmJ/kDoVLv1NC0nFihzBPmIFvMGmYtgJewzRBBRVSc= -github.com/drand/kyber v1.0.1-0.20200110225416-8de27ed8c0e2/go.mod h1:UpXoA0Upd1N9l4TvRPHr1qAUBBERj6JQ/mnKI3BPEmw= -github.com/drand/kyber v1.0.2/go.mod h1:x6KOpK7avKj0GJ4emhXFP5n7M7W7ChAPmnQh/OL6vRw= -github.com/drand/kyber v1.1.4/go.mod h1:9+IgTq7kadePhZg7eRwSD7+bA+bmvqRK+8DtmoV5a3U= -github.com/drand/kyber v1.1.10/go.mod h1:UkHLsI4W6+jT5PvNxmc0cvQAgppjTUpX+XCsN9TXmRo= -github.com/drand/kyber v1.1.15 h1:YNL02FPOA98GmlIhh5FuEJWhz1ZCp6tOUVFN7ujBJPE= -github.com/drand/kyber v1.1.15/go.mod h1:tw0l70U6aWCkc4vDr8u/canpOOOiUNJlzsmeElhBfe0= -github.com/drand/kyber-bls12381 v0.2.0/go.mod h1:zQip/bHdeEB6HFZSU3v+d3cQE0GaBVQw9aR2E7AdoeI= -github.com/drand/kyber-bls12381 v0.2.1/go.mod h1:JwWn4nHO9Mp4F5qCie5sVIPQZ0X6cw8XAeMRvc/GXBE= -github.com/drand/kyber-bls12381 v0.2.3 h1:wueWtqjj71wnwm6fYR8MAQk4q8bKVK9WukrGGcaVxzk= -github.com/drand/kyber-bls12381 v0.2.3/go.mod h1:FsudUZf6Xu61u/gYrDHEHf6lKIKluJdnX7WJe4hkMh4= +github.com/drand/drand v1.5.7 h1:5f2D5aH1nEfVI9S6tl2p9bgIDMZ92oltmiY12Kh+eYU= +github.com/drand/drand v1.5.7/go.mod h1:jrJ0244yOHNL5V04vazk3mFatjAWm3i6dg6URWwgbXk= +github.com/drand/kyber v1.2.0 h1:22SbBxsKbgQnJUoyYKIfG909PhBsj0vtANeu4BX5xgE= +github.com/drand/kyber v1.2.0/go.mod h1:6TqFlCc7NGOiNVTF9pF2KcDRfllPd9XOkExuG5Xtwfo= +github.com/drand/kyber-bls12381 v0.3.1 h1:KWb8l/zYTP5yrvKTgvhOrk2eNPscbMiUOIeWBnmUxGo= +github.com/drand/kyber-bls12381 v0.3.1/go.mod h1:H4y9bLPu7KZA/1efDg+jtJ7emKx+ro3PU7/jWUVt140= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= @@ -237,8 +232,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/etherlabsio/healthcheck/v2 v2.0.0 h1:oKq8cbpwM/yNGPXf2Sff6MIjVUjx/pGYFydWzeK2MpA= github.com/etherlabsio/healthcheck/v2 v2.0.0/go.mod h1:huNVOjKzu6FI1eaO1CGD3ZjhrmPWf5Obu/pzpI6/wog= github.com/fatih/color v1.8.0/go.mod h1:3l45GVGkyrnYNl9HoIjnp2NnNWvh6hLAqD8yTfGjnw8= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= +github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= github.com/filecoin-project/dagstore v0.5.2 h1:Nd6oXdnolbbVhpMpkYT5PJHOjQp4OBSntHpMV5pxj3c= github.com/filecoin-project/go-address v0.0.3/go.mod h1:jr8JxKsYx+lQlQZmF5i2U0Z+cGQ59wMIps/8YW/lDj8= @@ -298,8 +293,8 @@ github.com/filecoin-project/go-state-types v0.1.4/go.mod h1:xCA/WfKlC2zcn3fUmDv4 github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.11.2-0.20230712101859-8f37624fa540/go.mod h1:SyNPwTsU7I22gL2r0OAPcImvLoTVfgRwdK/Y5rR1zz8= -github.com/filecoin-project/go-state-types v0.12.8 h1:W/UObdAsv+LbB9EfyLg92DSYoatzUWmlfV8FGyh30VA= -github.com/filecoin-project/go-state-types v0.12.8/go.mod h1:gR2NV0CSGSQwopxF+3In9nDh1sqvoYukLcs5vK0AHCA= +github.com/filecoin-project/go-state-types v0.13.0-rc.2 h1:JHyDDx/nV8sbQNgjUfhumiGWh8Dedc8psbiVtD0YOh0= +github.com/filecoin-project/go-state-types v0.13.0-rc.2/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= github.com/filecoin-project/go-statemachine v1.0.3 h1:N07o6alys+V1tNoSTi4WuuoeNC4erS/6jE74+NsgQuk= github.com/filecoin-project/go-statemachine v1.0.3/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= @@ -352,7 +347,6 @@ github.com/getkin/kin-openapi v0.13.0/go.mod h1:WGRs2ZMM1Q8LR1QBEwUxC6RJEfaBcD0s github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= @@ -382,15 +376,11 @@ github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= @@ -407,12 +397,6 @@ github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg78 github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0= -github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= -github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= -github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= -github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= -github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -497,7 +481,6 @@ github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+u github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gopacket v1.1.17/go.mod h1:UdDNZ1OO62aGYVnPhxT1U6aI7ukYtA/kB8vaU0diBUM= github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -520,8 +503,8 @@ github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20230405160723-4a4c7d95572b h1:Qcx5LM0fSiks9uCyFZwDBUasd3lxd1RM0GYpL+Li5o4= -github.com/google/pprof v0.0.0-20230405160723-4a4c7d95572b/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= +github.com/google/pprof v0.0.0-20230817174616-7a8ec2ada47b h1:h9U78+dx9a4BKdQkBBos92HalKpaGKHrp+3Uo6yTodo= +github.com/google/pprof v0.0.0-20230817174616-7a8ec2ada47b/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -544,11 +527,10 @@ github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f h1:KMlcu9X58lhTA github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= @@ -580,8 +562,8 @@ github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c h1:aY2hhxLhjEAbfXOx2 github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc= -github.com/huin/goupnp v1.1.0 h1:gEe0Dp/lZmPZiDFzJJaOfUpOvv2MKUkoBX8lDrn9vKU= -github.com/huin/goupnp v1.1.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= +github.com/huin/goupnp v1.2.0 h1:uOKW26NG1hsSSbXIZ1IR7XP9Gjd1U8pnLaCMgntmkmY= +github.com/huin/goupnp v1.2.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -778,13 +760,12 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.2 h1:eVKgfIdy9b6zbWBMgFpfDPoAMifwSZagU9HmEU6zgiI= github.com/jinzhu/now v1.1.2/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -796,9 +777,6 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/kilic/bls12-381 v0.0.0-20200607163746-32e1441c8a9f/go.mod h1:XXfR6YFCRSrkEXbNlIyDsgXVNJWVUV30m/ebkVy9n6s= -github.com/kilic/bls12-381 v0.0.0-20200731194930-64c428e1bff5/go.mod h1:XXfR6YFCRSrkEXbNlIyDsgXVNJWVUV30m/ebkVy9n6s= -github.com/kilic/bls12-381 v0.0.0-20200820230200-6b2c19996391/go.mod h1:XXfR6YFCRSrkEXbNlIyDsgXVNJWVUV30m/ebkVy9n6s= github.com/kilic/bls12-381 v0.1.0 h1:encrdjqKMEvabVQ7qYOKu1OvhqpK4s47wDYtNiPtlp4= github.com/kilic/bls12-381 v0.1.0/go.mod h1:vDTTHJONJ6G+P2R74EhnyotQDTliQDnFEwhdmfzw1ig= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= @@ -806,20 +784,17 @@ github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQL github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= -github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.16.6 h1:91SKEy4K37vkp255cJ8QesJhjyRO0hn9i9G0GoUwLsk= -github.com/klauspost/compress v1.16.6/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= +github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.1.1/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= -github.com/klauspost/cpuid/v2 v2.2.3/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= -github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= -github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= +github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/koron/go-ssdp v0.0.0-20180514024734-4a0ed625a78b/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk= -github.com/koron/go-ssdp v0.0.0-20191105050749-2e1c40ed0b5d/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk= github.com/koron/go-ssdp v0.0.4 h1:1IDwrghSKYM7yLf7XCzbByg2sJ/JcNOZRXS2jczTwz0= github.com/koron/go-ssdp v0.0.4/go.mod h1:oDXq+E5IL5q0U8uSBcoAXzTzInwy5lEgC91HoKtbmZk= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= @@ -837,9 +812,9 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/labstack/echo/v4 v4.1.11/go.mod h1:i541M3Fj6f76NZtHSj7TXnyM8n2gaodfvfxNnFqi74g= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/libp2p/go-addr-util v0.0.1/go.mod h1:4ac6O7n9rIAKB1dnd+s8IbbMXkt+oBpzX4/+RACcnlQ= github.com/libp2p/go-buffer-pool v0.0.1/go.mod h1:xtyIz9PMobb13WaxR6Zo1Pd1zXJKYg0a8KiIvDp3TzQ= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= @@ -853,8 +828,8 @@ github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFG github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro= github.com/libp2p/go-libp2p v0.1.0/go.mod h1:6D/2OBauqLUoqcADOJpn9WbKqvaM07tDw68qHM0BxUM= github.com/libp2p/go-libp2p v0.1.1/go.mod h1:I00BRo1UuUSdpuc8Q2mN7yDF/oTUTRAX6JWpTiK9Rp8= -github.com/libp2p/go-libp2p v0.27.8 h1:IX5x/4yKwyPQeVS2AXHZ3J4YATM9oHBGH1gBc23jBAI= -github.com/libp2p/go-libp2p v0.27.8/go.mod h1:eCFFtd0s5i/EVKR7+5Ki8bM7qwkNW3TPTTSSW9sz8NE= +github.com/libp2p/go-libp2p v0.31.1 h1:mUiFPwdzC2zMLIATKVddjCuPXVbtC3BsKKVPMs4+jzY= +github.com/libp2p/go-libp2p v0.31.1/go.mod h1:+9TCv+XySSOdaxPF1WIgTK8rXP9jBb8WbemlMCSXGsU= github.com/libp2p/go-libp2p-asn-util v0.3.0 h1:gMDcMyYiZKkocGXDQ5nsUQyquC9+H+iLEQHwOCZ7s8s= github.com/libp2p/go-libp2p-asn-util v0.3.0/go.mod h1:B1mcOrKUE35Xq/ASTmQ4tN3LNzVVaMNmq2NACuqyB9w= github.com/libp2p/go-libp2p-autonat v0.1.0/go.mod h1:1tLf2yXxiE/oKGtDwPYWTSYG3PtvYlJmg7NeVtPRqH8= @@ -898,16 +873,14 @@ github.com/libp2p/go-msgio v0.0.3/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+ github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0= github.com/libp2p/go-msgio v0.3.0/go.mod h1:nyRM819GmVaF9LX3l03RMh10QdOroF++NBbxAb0mmDM= github.com/libp2p/go-nat v0.0.3/go.mod h1:88nUEt0k0JD45Bk93NIwDqjlhiOwOoV36GchpcVc1yI= -github.com/libp2p/go-nat v0.1.0 h1:MfVsH6DLcpa04Xr+p8hmVRG4juse0s3J8HyNWYHffXg= -github.com/libp2p/go-nat v0.1.0/go.mod h1:X7teVkwRHNInVNWQiO/tAiAVRwSr5zoRz4YSTC3uRBM= -github.com/libp2p/go-netroute v0.1.2/go.mod h1:jZLDV+1PE8y5XxBySEBgbuVAXbhtuHSdmLPL2n9MKbk= +github.com/libp2p/go-nat v0.2.0 h1:Tyz+bUFAYqGyJ/ppPPymMGbIgNRH+WqC5QrT5fKrrGk= +github.com/libp2p/go-nat v0.2.0/go.mod h1:3MJr+GRpRkyT65EpVPBstXLvOlAPzUVlG6Pwg9ohLJk= github.com/libp2p/go-netroute v0.2.1 h1:V8kVrpD8GK0Riv15/7VN6RbUQ3URNZVosw7H2v9tksU= github.com/libp2p/go-netroute v0.2.1/go.mod h1:hraioZr0fhBjG0ZRXJJ6Zj2IVEVNx6tDTFQfSmcq7mQ= github.com/libp2p/go-reuseport v0.0.1/go.mod h1:jn6RmB1ufnQwl0Q1f+YxAj8isJgDCQzaaxIFYDhcYEA= -github.com/libp2p/go-reuseport v0.2.0 h1:18PRvIMlpY6ZK85nIAicSBuXXvrYoSw3dsBAR7zc560= -github.com/libp2p/go-reuseport v0.2.0/go.mod h1:bvVho6eLMm6Bz5hmU0LYN3ixd3nPPvtIlaURZZgOY4k= +github.com/libp2p/go-reuseport v0.4.0 h1:nR5KU7hD0WxXCJbmw7r2rhRYruNRl2koHw8fQscQm2s= +github.com/libp2p/go-reuseport v0.4.0/go.mod h1:ZtI03j/wO5hZVDFo2jKywN6bYKWLOy8Se6DrI2E1cLU= github.com/libp2p/go-reuseport-transport v0.0.2/go.mod h1:YkbSDrvjUVDL6b8XqriyA20obEtsW9BLkuOUyQAOCbs= -github.com/libp2p/go-sockaddr v0.0.2/go.mod h1:syPvOmNs24S3dFVGJA1/mrqdeijPxLV2Le3BRLKd68k= github.com/libp2p/go-stream-muxer v0.0.1/go.mod h1:bAo8x7YkSpadMTbtTaxGVHWUQsR/l5MEaHbKaliuT14= github.com/libp2p/go-stream-muxer-multistream v0.2.0/go.mod h1:j9eyPol/LLRqT+GPLSxvimPhNph4sfYfMoDPd7HkzIc= github.com/libp2p/go-tcp-transport v0.1.0/go.mod h1:oJ8I5VXryj493DEJ7OsBieu8fcg2nHGctwtInJVpipc= @@ -915,8 +888,8 @@ github.com/libp2p/go-testutil v0.1.0/go.mod h1:81b2n5HypcVyrCg/MJx4Wgfp/VHojytjV github.com/libp2p/go-ws-transport v0.1.0/go.mod h1:rjw1MG1LU9YDC6gzmwObkPd/Sqwhw7yT74kj3raBFuo= github.com/libp2p/go-yamux v1.2.2/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZwqQTcow= github.com/libp2p/go-yamux v1.2.3/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZwqQTcow= -github.com/libp2p/go-yamux/v4 v4.0.0 h1:+Y80dV2Yx/kv7Y7JKu0LECyVdMXm1VUoko+VQ9rBfZQ= -github.com/libp2p/go-yamux/v4 v4.0.0/go.mod h1:NWjl8ZTLOGlozrXSOZ/HlfG++39iKNnM5wwmtQP1YB4= +github.com/libp2p/go-yamux/v4 v4.0.1 h1:FfDR4S1wj6Bw2Pqbc8Uz7pCxeRBPbwsBbEdfwiCypkQ= +github.com/libp2p/go-yamux/v4 v4.0.1/go.mod h1:NWjl8ZTLOGlozrXSOZ/HlfG++39iKNnM5wwmtQP1YB4= github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= github.com/magefile/mage v1.9.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/magefile/mage v1.11.0 h1:C/55Ywp9BpgVVclD3lRnSYCwXTYxmSppIgLeDYlNuls= @@ -932,7 +905,6 @@ github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= @@ -940,7 +912,6 @@ github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -950,16 +921,16 @@ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg= github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= -github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= -github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= +github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= github.com/miekg/dns v1.1.12/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= -github.com/miekg/dns v1.1.53 h1:ZBkuHr5dxHtB1caEOlZTLPo7D3L3TWckgUUs/RHfDxw= -github.com/miekg/dns v1.1.53/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= +github.com/miekg/dns v1.1.55 h1:GoQ4hpsj0nFLYe+bWiCToyrBEJXkQfOOIvFGFy0lEgo= +github.com/miekg/dns v1.1.55/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= github.com/mikioh/tcp v0.0.0-20190314235350-803a9b46060c h1:bzE/A84HN25pxAuk9Eej1Kz9OUelF97nAc82bDquQI8= github.com/mikioh/tcp v0.0.0-20190314235350-803a9b46060c/go.mod h1:0SQS9kMwD2VsyFEB++InYyBJroV/FRmBgcydeSUcJms= github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b h1:z78hV3sbSMAUoyUMM0I83AUIT6Hu17AWfgjzIbtrYFc= @@ -1007,8 +978,8 @@ github.com/multiformats/go-multiaddr v0.0.4/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lg github.com/multiformats/go-multiaddr v0.1.1/go.mod h1:aMKBKNEYmzmDmxfX88/vz+J5IU55txyt0p4aiWVohjo= github.com/multiformats/go-multiaddr v0.2.0/go.mod h1:0nO36NvPpyV4QzvTLi/lafl2y95ncPj0vFwVF6k6wJ4= github.com/multiformats/go-multiaddr v0.8.0/go.mod h1:Fs50eBDWvZu+l3/9S6xAE7ZYj6yhxlvaVZjakWN7xRs= -github.com/multiformats/go-multiaddr v0.9.0 h1:3h4V1LHIk5w4hJHekMKWALPXErDfz/sggzwC/NcqbDQ= -github.com/multiformats/go-multiaddr v0.9.0/go.mod h1:mI67Lb1EeTOYb8GQfL/7wpIZwc46ElrvzhYnoJOmTT0= +github.com/multiformats/go-multiaddr v0.12.2 h1:9G9sTY/wCYajKa9lyfWPmpZAwe6oV+Wb1zcmMS1HG24= +github.com/multiformats/go-multiaddr v0.12.2/go.mod h1:GKyaTYjZRdcUhyOetrxTk9z0cW+jA/YrnqTOvKgi44M= github.com/multiformats/go-multiaddr-dns v0.0.1/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q= github.com/multiformats/go-multiaddr-dns v0.0.2/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q= github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A= @@ -1062,18 +1033,18 @@ github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vv github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= -github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU= -github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts= +github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= +github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= -github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E= +github.com/onsi/gomega v1.27.8 h1:gegWiwZjBsf2DgiSbf5hpokZ98JVDMcWkUiigk6/KXc= github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= -github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 h1:3snG66yBm59tKhhSPQrQ/0bCrv1LQbKt40LnUPiUxdc= -github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= +github.com/opencontainers/runtime-spec v1.1.0 h1:HHUyrt9mwHUjtasSbXSMvs4cyFxh+Bll4AjJ9odEGpg= +github.com/opencontainers/runtime-spec v1.1.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e h1:4cPxUYdgaGzZIT5/j0IfqOrrXmq6bG8AwvwisMXpdrg= github.com/opentracing-contrib/go-stdlib v1.0.0 h1:TBS7YuVotp8myLon4Pv7BtCBzOTo1DeZCld0Z63mW2w= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -1117,14 +1088,16 @@ github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqr github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= @@ -1133,8 +1106,8 @@ github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+ github.com/prometheus/common v0.35.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= -github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= -github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -1142,8 +1115,9 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= +github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/prometheus/statsd_exporter v0.22.7/go.mod h1:N/TevpjkIh9ccs6nuzY3jQn9dFqnUakOjnEuMPJJJnI= github.com/prometheus/statsd_exporter v0.23.0 h1:GEkriUCmARYh1gSA0gzpvmTg/oHMc5MfDFNlS/che4E= github.com/prometheus/statsd_exporter v0.23.0/go.mod h1:1itCY9XMa2p5pjO5HseGjs5cnaIA5qxLCYmn3OUna58= @@ -1151,14 +1125,12 @@ github.com/puzpuzpuz/xsync/v2 v2.4.1 h1:aGdE1C/HaR/QC6YAFdtZXi60Df8/qBIrs8PKrzkI github.com/puzpuzpuz/xsync/v2 v2.4.1/go.mod h1:gD2H2krq/w52MfPLE+Uy64TzJDVY7lP2znR9qmR35kU= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= -github.com/quic-go/qtls-go1-19 v0.3.3 h1:wznEHvJwd+2X3PqftRha0SUKmGsnb6dfArMhy9PeJVE= -github.com/quic-go/qtls-go1-19 v0.3.3/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= -github.com/quic-go/qtls-go1-20 v0.2.3 h1:m575dovXn1y2ATOb1XrRFcrv0F+EQmlowTkoraNkDPI= -github.com/quic-go/qtls-go1-20 v0.2.3/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= -github.com/quic-go/quic-go v0.33.0 h1:ItNoTDN/Fm/zBlq769lLJc8ECe9gYaW40veHCCco7y0= -github.com/quic-go/quic-go v0.33.0/go.mod h1:YMuhaAV9/jIu0XclDXwZPAsP/2Kgr5yMYhe9oxhhOFA= -github.com/quic-go/webtransport-go v0.5.2 h1:GA6Bl6oZY+g/flt00Pnu0XtivSD8vukOu3lYhJjnGEk= -github.com/quic-go/webtransport-go v0.5.2/go.mod h1:OhmmgJIzTTqXK5xvtuX0oBpLV2GkLWNDA+UeTGJXErU= +github.com/quic-go/qtls-go1-20 v0.3.3 h1:17/glZSLI9P9fDAeyCHBFSWSqJcwx1byhLwP5eUIDCM= +github.com/quic-go/qtls-go1-20 v0.3.3/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= +github.com/quic-go/quic-go v0.38.2 h1:VWv/6gxIoB8hROQJhx1JEyiegsUQ+zMN3em3kynTGdg= +github.com/quic-go/quic-go v0.38.2/go.mod h1:ijnZM7JsFIkp4cRyjxJNIzdSfCLmUMg9wdyhGmg+SN4= +github.com/quic-go/webtransport-go v0.5.3 h1:5XMlzemqB4qmOlgIus5zB45AcZ2kCgCy2EptUrfOPWU= +github.com/quic-go/webtransport-go v0.5.3/go.mod h1:OhmmgJIzTTqXK5xvtuX0oBpLV2GkLWNDA+UeTGJXErU= github.com/raulk/clock v1.1.0 h1:dpb29+UKMbLqiU/jqIJptgLR1nn23HLgMY0sTCDza5Y= github.com/raulk/clock v1.1.0/go.mod h1:3MpVxdZ/ODBQDxbN+kzshf5OSZwPjtMDx6BBXBmOeY0= github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk= @@ -1168,8 +1140,8 @@ github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= @@ -1177,7 +1149,7 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= -github.com/sercand/kuberesolver v2.4.0+incompatible h1:WE2OlRf6wjLxHwNkkFLQGaZcVLEXjMjBPjjEU5vksH8= +github.com/sercand/kuberesolver/v4 v4.0.0 h1:frL7laPDG/lFm5n98ODmWnn+cvPpzlkf3LhzuPhcHP4= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM= @@ -1206,8 +1178,8 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= -github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/sirupsen/logrus v1.9.2 h1:oxx1eChJGI6Uks2ZC4W1zpLlVgqB8ner4EuQwV4Ik1Y= +github.com/sirupsen/logrus v1.9.2/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= @@ -1256,7 +1228,6 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= @@ -1277,16 +1248,14 @@ github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2 github.com/twmb/murmur3 v1.1.6 h1:mqrRot1BRxm+Yct+vavLMou2/iJt0tNVTTC0QoIjaZg= github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o= github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg= -github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.0.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= -github.com/urfave/cli/v2 v2.16.3 h1:gHoFIwpPjoyIMbJp/VFd+/vuD0dAgFK4B6DpEMFJfQk= -github.com/urfave/cli/v2 v2.16.3/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= +github.com/urfave/cli/v2 v2.25.5 h1:d0NIAyhh5shGscroL7ek/Ya9QYQE0KNabJgiUinIQkc= +github.com/urfave/cli/v2 v2.25.5/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.1.0/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= @@ -1299,7 +1268,7 @@ github.com/warpfork/go-wish v0.0.0-20190328234359-8b3e70f8e830/go.mod h1:x6AKhvS github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSDJfjId/PEGEShv6ugrt4kYsC5UIDaQ= github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= -github.com/weaveworks/common v0.0.0-20220810113439-c65105d60b18 h1:JN4YR/TNWiZEAHHImrVA2u4DPI+aqPOar23ICUnYZTQ= +github.com/weaveworks/common v0.0.0-20230531151736-e2613bee6b73 h1:CMM9+/AgM77vaMXMQedzqPRMuNwjbI0EcdofPqxc9F8= github.com/weaveworks/promrus v1.2.0 h1:jOLf6pe6/vss4qGHjXmGz4oDJQA+AOCqEL3FvvZGz7M= github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 h1:5HZfQkwe0mIfyDmc1Em5GqlNRzcdtlv4HTNmdpt7XH0= github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11/go.mod h1:Wlo/SzPmxVp6vXpGt/zaXhHH0fn4IxgqZc82aKg6bpQ= @@ -1317,8 +1286,8 @@ github.com/whyrusleeping/cbor-gen v0.0.0-20200826160007-0b9f6c5fb163/go.mod h1:f github.com/whyrusleeping/cbor-gen v0.0.0-20210118024343-169e9d70c0c2/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20210303213153-67a261a1d291/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20220323183124-98fa8256a799/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= -github.com/whyrusleeping/cbor-gen v0.0.0-20230923211252-36a87e1ba72f h1:SBuSxXJL0/ZJMtTxbXZgHZkThl9dNrzyaNhlyaqscRo= -github.com/whyrusleeping/cbor-gen v0.0.0-20230923211252-36a87e1ba72f/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= +github.com/whyrusleeping/cbor-gen v0.1.0 h1:Jneeq3V5enErVcuL0NKEbD1Gi+iOvEeFhXOV1S1Fc6g= +github.com/whyrusleeping/cbor-gen v0.1.0/go.mod h1:pM99HXyEbSQHcosHc0iW7YFmwnscr+t9Te4ibko05so= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f/go.mod h1:p9UJB6dDgdPgMJZs7UjUOdulKyRr9fqkS+6JKAInPy8= github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k= @@ -1348,14 +1317,8 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t github.com/zyedidia/generic v1.2.1 h1:Zv5KS/N2m0XZZiuLS82qheRG4X1o5gsWreGb0hR7XDc= github.com/zyedidia/generic v1.2.1/go.mod h1:ly2RBz4mnz1yeuVbQA/VFwGjK3mnHGRj1JuoG336Bis= go.dedis.ch/fixbuf v1.0.3 h1:hGcV9Cd/znUxlusJ64eAlExS+5cJDIyTyEG+otu5wQs= -go.dedis.ch/fixbuf v1.0.3/go.mod h1:yzJMt34Wa5xD37V5RTdmp38cz3QhMagdGoem9anUalw= -go.dedis.ch/kyber/v3 v3.0.4/go.mod h1:OzvaEnPvKlyrWyp3kGXlFdp7ap1VC6RkZDTaPikqhsQ= -go.dedis.ch/kyber/v3 v3.0.9/go.mod h1:rhNjUUg6ahf8HEg5HUvVBYoWY4boAafX8tYxX+PS+qg= -go.dedis.ch/protobuf v1.0.5/go.mod h1:eIV4wicvi6JK0q/QnfIEGeSFNG0ZeB24kzut5+HaRLo= -go.dedis.ch/protobuf v1.0.7/go.mod h1:pv5ysfkDX/EawiPqcW3ikOxsL5t+BqnV6xHSmE79KI4= go.dedis.ch/protobuf v1.0.11 h1:FTYVIEzY/bfl37lu3pR4lIj+F9Vp1jE8oh91VmxKgLo= -go.dedis.ch/protobuf v1.0.11/go.mod h1:97QR256dnkimeNdfmURz0wAMNVbd1VmLXhG1CrTYrJ4= -go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= +go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= @@ -1389,19 +1352,20 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= +go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/dig v1.14.0/go.mod h1:jHAn/z1Ld1luVVyGKOAIFYz/uBFqKjjEEdIqVAqfQ2o= go.uber.org/dig v1.14.1/go.mod h1:52EKx/Vjdpz9EzeNcweC4YMsTrDdFn9mS/+Uw5ZnVTI= -go.uber.org/dig v1.16.1 h1:+alNIBsl0qfY0j6epRubp/9obgtrObRAc5aD+6jbWY8= -go.uber.org/dig v1.16.1/go.mod h1:557JTAUZT5bUK0SvCwikmLPPtdQhfvLYtO5tJgQSbnk= +go.uber.org/dig v1.17.0 h1:5Chju+tUvcC+N7N6EV08BJz41UZuO3BmHcN4A287ZLI= +go.uber.org/dig v1.17.0/go.mod h1:rTxpf7l5I0eBTlE6/9RL+lDybC7WFwY2QH55ZSjy1mU= go.uber.org/fx v1.17.1/go.mod h1:yO7KN5rhlARljyo4LR047AjaV6J+KFzd/Z7rnTbEn0A= -go.uber.org/fx v1.19.2 h1:SyFgYQFr1Wl0AYstE8vyYIzP4bFz2URrScjwC4cwUvY= -go.uber.org/fx v1.19.2/go.mod h1:43G1VcqSzbIv77y00p1DRAsyZS8WdzuYdhZXmEUkMyQ= +go.uber.org/fx v1.20.0 h1:ZMC/pnRvhsthOZh9MZjMq5U8Or3mA9zBSPaLnzs3ihQ= +go.uber.org/fx v1.20.0/go.mod h1:qCUj0btiR3/JnanEr1TYEePfSw6o/4qYJscgvzQ5Ub0= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.4.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= @@ -1415,8 +1379,8 @@ go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= +go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= go4.org v0.0.0-20200411211856-f5505b9728dd h1:BNJlw5kRTzdmyfh5U8F93HA2OwkP7ZGwA51eJ/0wKOU= go4.org v0.0.0-20200411211856-f5505b9728dd/go.mod h1:CIiUVy99QCPfoE13bO4EZaz5GZMZXMSBGhxRdsvzbkg= @@ -1428,7 +1392,6 @@ golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190225124518-7f87c0fbb88b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -1444,13 +1407,9 @@ golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200602180216-279210d13fed/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= @@ -1458,10 +1417,10 @@ golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1472,8 +1431,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ= +golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1501,8 +1460,9 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= -golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1562,11 +1522,12 @@ golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1591,8 +1552,8 @@ golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/oauth2 v0.3.0/go.mod h1:rQrIauxkUhJ6CuwEXwymO2/eh4xz2ZWF1nBkcxS+tGk= -golang.org/x/oauth2 v0.5.0 h1:HuArIo48skDwlrvM3sEdHXElYslAMsf3KwRkkW4MC4s= -golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= +golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= +golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1608,8 +1569,9 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180202135801-37707fdb30a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1618,7 +1580,6 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190124100055-b90733256f2e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1626,7 +1587,6 @@ golang.org/x/sys v0.0.0-20190228124157-a34e9553db1e/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190302025703-b6889370fb10/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190405154228-4b34438f7a67/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1643,7 +1603,6 @@ golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191025090151-53bf42e6b339/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1669,10 +1628,8 @@ golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200812155832-6a926be9bd1d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200926100807-9d91bd62050c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1713,7 +1670,6 @@ golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1721,23 +1677,24 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= +golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= +golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1747,10 +1704,10 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1823,8 +1780,9 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 h1:Vve/L0v7CXXuxUmaMGIEK/dEeq7uiqb5qBgQrZzIE7E= +golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1965,8 +1923,10 @@ google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= -google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= +google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc h1:8DyZCyvI8mE1IdLy/60bS+52xfymkE72wv1asokgtao= +google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc h1:kVKPf/IiYSBWEWtkIn6wZXwWGCnLKcC8oWfZvXjsGnM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc h1:XSJ8Vk1SWuNr8S18z1NZSziL0CPIXLCCMDOEFtHBOFc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= @@ -2000,8 +1960,8 @@ google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ5 google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= -google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= +google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= +google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -2046,6 +2006,7 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gorm.io/driver/mysql v1.1.1 h1:yr1bpyqiwuSPJ4aGGUX9nu46RHXlF8RASQVb1QQNcvo= @@ -2068,8 +2029,6 @@ lukechampine.com/blake3 v1.1.6/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA= lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= -nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= -nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= diff --git a/pkg/beacon/beacon.go b/pkg/beacon/beacon.go index 193caefa59..abf27c9f59 100644 --- a/pkg/beacon/beacon.go +++ b/pkg/beacon/beacon.go @@ -29,33 +29,34 @@ type BeaconPoint struct { //nolint // been posted on chain. type RandomBeacon interface { Entry(context.Context, uint64) <-chan Response - VerifyEntry(types.BeaconEntry, types.BeaconEntry) error + // VerifyEntry(types.BeaconEntry, types.BeaconEntry) error + VerifyEntry(entry types.BeaconEntry, prevEntrySig []byte) error MaxBeaconRoundForEpoch(network.Version, abi.ChainEpoch) uint64 + IsChained() bool } // ValidateBlockValues Verify that the beacon in the block header is correct, first get beacon server at block epoch and parent block epoch in schedule. // if paraent beacon is the same beacon server. value beacon normally but if not equal, means that the pre entry in another beacon chain, so just validate // beacon value in current block header. the first values is parent beacon the the second value is current beacon. func ValidateBlockValues(bSchedule Schedule, nv network.Version, h *types.BlockHeader, parentEpoch abi.ChainEpoch, prevEntry *types.BeaconEntry) error { - { - parentBeacon := bSchedule.BeaconForEpoch(parentEpoch) - currBeacon := bSchedule.BeaconForEpoch(h.Height) - if parentBeacon != currBeacon { - if len(h.BeaconEntries) != 2 { - return fmt.Errorf("expected two beacon entries at beacon fork, got %d", len(h.BeaconEntries)) - } - err := currBeacon.VerifyEntry(h.BeaconEntries[1], h.BeaconEntries[0]) - if err != nil { - return fmt.Errorf("beacon at fork point invalid: (%v, %v): %w", - h.BeaconEntries[1], h.BeaconEntries[0], err) - } - return nil + parentBeacon := bSchedule.BeaconForEpoch(parentEpoch) + currBeacon := bSchedule.BeaconForEpoch(h.Height) + // When we have "chained" beacons, two entries at a fork are required. + if parentBeacon != currBeacon && currBeacon.IsChained() { + if len(h.BeaconEntries) != 2 { + return fmt.Errorf("expected two beacon entries at beacon fork, got %d", len(h.BeaconEntries)) + } + err := currBeacon.VerifyEntry(h.BeaconEntries[1], h.BeaconEntries[0].Data) + if err != nil { + return fmt.Errorf("beacon at fork point invalid: (%v, %v): %w", + h.BeaconEntries[1], h.BeaconEntries[0], err) } + return nil } - // TODO: fork logic - b := bSchedule.BeaconForEpoch(h.Height) - maxRound := b.MaxBeaconRoundForEpoch(nv, h.Height) + maxRound := currBeacon.MaxBeaconRoundForEpoch(nv, h.Height) + + // We don't expect to ever actually meet this condition if maxRound == prevEntry.Round { if len(h.BeaconEntries) != 0 { return fmt.Errorf("expected not to have any beacon entries in this block, got %d", len(h.BeaconEntries)) @@ -67,51 +68,66 @@ func ValidateBlockValues(bSchedule Schedule, nv network.Version, h *types.BlockH return fmt.Errorf("expected to have beacon entries in this block, but didn't find any") } + // We skip verifying the genesis entry when randomness is "chained". + if currBeacon.IsChained() && prevEntry.Round == 0 { + return nil + } + last := h.BeaconEntries[len(h.BeaconEntries)-1] if last.Round != maxRound { return fmt.Errorf("expected final beacon entry in block to be at round %d, got %d", maxRound, last.Round) } + // If the beacon is UNchained, verify that the block only includes the rounds we want for the epochs in between parentEpoch and h.Height + // For chained beacons, you must have all the rounds forming a valid chain with prevEntry, so we can skip this step + if !currBeacon.IsChained() { + // Verify that all other entries' rounds are as expected for the epochs in between parentEpoch and h.Height + for i, e := range h.BeaconEntries { + correctRound := currBeacon.MaxBeaconRoundForEpoch(nv, parentEpoch+abi.ChainEpoch(i)+1) + if e.Round != correctRound { + return fmt.Errorf("unexpected beacon round %d, expected %d for epoch %d", e.Round, correctRound, parentEpoch+abi.ChainEpoch(i)) + } + } + } + + // Verify the beacon entries themselves for i, e := range h.BeaconEntries { - if err := b.VerifyEntry(e, *prevEntry); err != nil { + if err := currBeacon.VerifyEntry(e, prevEntry.Data); err != nil { return fmt.Errorf("beacon entry %d (%d - %x (%d)) was invalid: %w", i, e.Round, e.Data, len(e.Data), err) } prevEntry = &h.BeaconEntries[i] - } return nil } func BeaconEntriesForBlock(ctx context.Context, bSchedule Schedule, nv network.Version, epoch abi.ChainEpoch, parentEpoch abi.ChainEpoch, prev types.BeaconEntry) ([]types.BeaconEntry, error) { //nolint - { - parentBeacon := bSchedule.BeaconForEpoch(parentEpoch) - currBeacon := bSchedule.BeaconForEpoch(epoch) - if parentBeacon != currBeacon { - // Fork logic - round := currBeacon.MaxBeaconRoundForEpoch(nv, epoch) - out := make([]types.BeaconEntry, 2) - rch := currBeacon.Entry(ctx, round-1) - res := <-rch - if res.Err != nil { - return nil, fmt.Errorf("getting entry %d returned error: %w", round-1, res.Err) - } - out[0] = res.Entry - rch = currBeacon.Entry(ctx, round) - res = <-rch - if res.Err != nil { - return nil, fmt.Errorf("getting entry %d returned error: %w", round, res.Err) - } - out[1] = res.Entry - return out, nil + // When we have "chained" beacons, two entries at a fork are required. + parentBeacon := bSchedule.BeaconForEpoch(parentEpoch) + currBeacon := bSchedule.BeaconForEpoch(epoch) + if parentBeacon != currBeacon && currBeacon.IsChained() { + // Fork logic + round := currBeacon.MaxBeaconRoundForEpoch(nv, epoch) + out := make([]types.BeaconEntry, 2) + rch := currBeacon.Entry(ctx, round-1) + res := <-rch + if res.Err != nil { + return nil, fmt.Errorf("getting entry %d returned error: %w", round-1, res.Err) } + out[0] = res.Entry + rch = currBeacon.Entry(ctx, round) + res = <-rch + if res.Err != nil { + return nil, fmt.Errorf("getting entry %d returned error: %w", round, res.Err) + } + out[1] = res.Entry + return out, nil } - beacon := bSchedule.BeaconForEpoch(epoch) - start := time.Now() - maxRound := beacon.MaxBeaconRoundForEpoch(nv, epoch) + maxRound := currBeacon.MaxBeaconRoundForEpoch(nv, epoch) + // We don't expect this to ever be the case if maxRound == prev.Round { return nil, nil } @@ -121,10 +137,10 @@ func BeaconEntriesForBlock(ctx context.Context, bSchedule Schedule, nv network.V prev.Round = maxRound - 1 } - cur := maxRound var out []types.BeaconEntry - for cur > prev.Round { - rch := beacon.Entry(ctx, cur) + for currEpoch := epoch; currEpoch > parentEpoch; currEpoch-- { + currRound := currBeacon.MaxBeaconRoundForEpoch(nv, currEpoch) + rch := currBeacon.Entry(ctx, currRound) select { case resp := <-rch: if resp.Err != nil { @@ -132,7 +148,6 @@ func BeaconEntriesForBlock(ctx context.Context, bSchedule Schedule, nv network.V } out = append(out, resp.Entry) - cur = resp.Entry.Round - 1 case <-ctx.Done(): return nil, fmt.Errorf("context timed out waiting on beacon entry to come back for epoch %d: %w", epoch, ctx.Err()) } diff --git a/pkg/beacon/drand.go b/pkg/beacon/drand.go index 355f67a781..5d8db40abd 100644 --- a/pkg/beacon/drand.go +++ b/pkg/beacon/drand.go @@ -3,14 +3,13 @@ package beacon import ( "bytes" "context" - "errors" "fmt" "time" dchain "github.com/drand/drand/chain" dclient "github.com/drand/drand/client" hclient "github.com/drand/drand/client/http" - "github.com/drand/drand/common/scheme" + dcrypto "github.com/drand/drand/crypto" dlog "github.com/drand/drand/log" "github.com/drand/kyber" lru "github.com/hashicorp/golang-lru/v2" @@ -32,7 +31,8 @@ import ( // // The root trust for the Drand chain is configured from build.DrandChain. type DrandBeacon struct { - client dclient.Client + isChained bool + client dclient.Client pubkey kyber.Point @@ -42,10 +42,15 @@ type DrandBeacon struct { drandGenTime uint64 filGenTime uint64 filRoundTime uint64 + scheme *dcrypto.Scheme localCache *lru.Cache[uint64, *types.BeaconEntry] } +func (db *DrandBeacon) IsChained() bool { + return db.isChained +} + // DrandHTTPClient interface overrides the user agent used by drand type DrandHTTPClient interface { SetUserAgent(string) @@ -63,6 +68,10 @@ func (l *logger) Named(s string) dlog.Logger { return &logger{l.SugaredLogger.Named(s)} } +func (l *logger) AddCallerSkip(skip int) dlog.Logger { + return &logger{l.SugaredLogger.With(zap.AddCallerSkip(skip))} +} + // NewDrandBeacon create new beacon client from config, genesis block time and block delay func NewDrandBeacon(genTimeStamp, interval uint64, config cfg.DrandConf) (*DrandBeacon, error) { drandChain, err := dchain.InfoFromJSON(bytes.NewReader([]byte(config.ChainInfoJSON))) @@ -100,10 +109,16 @@ func NewDrandBeacon(genTimeStamp, interval uint64, config cfg.DrandConf) (*Drand } db := &DrandBeacon{ + isChained: config.IsChained, client: client, localCache: lc, } + sch, err := dcrypto.GetSchemeByIDWithDefault(drandChain.Scheme) + if err != nil { + return nil, err + } + db.scheme = sch db.pubkey = drandChain.PublicKey db.interval = drandChain.Period db.drandGenTime = uint64(drandChain.GenesisTime) @@ -154,28 +169,28 @@ func (db *DrandBeacon) getCachedValue(round uint64) *types.BeaconEntry { return v } -func (db *DrandBeacon) VerifyEntry(curr types.BeaconEntry, prev types.BeaconEntry) error { - if prev.Round == 0 { - // TODO handle genesis better - return nil - } - if be := db.getCachedValue(curr.Round); be != nil { - if !bytes.Equal(curr.Data, be.Data) { - return errors.New("invalid beacon value, does not match cached good value") +func (db *DrandBeacon) VerifyEntry(entry types.BeaconEntry, prevEntrySig []byte) error { + if be := db.getCachedValue(entry.Round); be != nil { + if !bytes.Equal(entry.Data, be.Data) { + return fmt.Errorf("invalid beacon value, does not match cached good value") } // return no error if the value is in the cache already return nil } b := &dchain.Beacon{ - PreviousSig: prev.Data, - Round: curr.Round, - Signature: curr.Data, + PreviousSig: prevEntrySig, + Round: entry.Round, + Signature: entry.Data, } - err := dchain.NewVerifier(scheme.GetSchemeFromEnv()).VerifyBeacon(*b, db.pubkey) - if err == nil { - db.cacheValue(curr) + + err := db.scheme.VerifyBeacon(b, db.pubkey) + if err != nil { + return fmt.Errorf("failed to verify beacon: %w", err) } - return err + + db.cacheValue(entry) + + return nil } // MaxBeaconRoundForEpoch get the turn of beacon chain corresponding to chain height diff --git a/pkg/beacon/drand_test.go b/pkg/beacon/drand_test.go index e1fcb7a40e..e73a7bb6c1 100644 --- a/pkg/beacon/drand_test.go +++ b/pkg/beacon/drand_test.go @@ -36,7 +36,17 @@ func TestMaxBeaconRoundForEpoch(t *testing.T) { drandCfg := config.DrandConfigs[config.DrandDevnet] db, err := NewDrandBeacon(todayTS, config.NewDefaultConfig().NetworkParams.BlockDelay, drandCfg) assert.NoError(t, err) + assert.True(t, db.IsChained()) mbr15 := db.MaxBeaconRoundForEpoch(network.Version15, 100) mbr16 := db.MaxBeaconRoundForEpoch(network.Version16, 100) assert.Equal(t, mbr15+1, mbr16) } + +func TestQuicknetIsChained(t *testing.T) { + tf.UnitTest(t) + todayTS := uint64(1652222222) + drandCfg := config.DrandConfigs[config.DrandQuicknet] + db, err := NewDrandBeacon(todayTS, config.NewDefaultConfig().NetworkParams.BlockDelay, drandCfg) + assert.NoError(t, err) + assert.False(t, db.IsChained()) +} diff --git a/pkg/beacon/mock.go b/pkg/beacon/mock.go index 7c5556063f..83eb418223 100644 --- a/pkg/beacon/mock.go +++ b/pkg/beacon/mock.go @@ -31,6 +31,10 @@ func NewMockSchedule(interval time.Duration) Schedule { }} } +func (mb *mockBeacon) IsChained() bool { + return true +} + func (mb *mockBeacon) RoundTime() time.Duration { return mb.interval } @@ -52,7 +56,7 @@ func (mb *mockBeacon) Entry(ctx context.Context, index uint64) <-chan Response { return out } -func (mb *mockBeacon) VerifyEntry(from types.BeaconEntry, to types.BeaconEntry) error { +func (mb *mockBeacon) VerifyEntry(from types.BeaconEntry, _prevEntrySig []byte) error { // TODO: cache this, especially for bls oe := mb.entryForIndex(from.Round) if !bytes.Equal(from.Data, oe.Data) { diff --git a/pkg/chain/reorg_test.go b/pkg/chain/reorg_test.go index 65577815f4..b360dbf60d 100644 --- a/pkg/chain/reorg_test.go +++ b/pkg/chain/reorg_test.go @@ -73,7 +73,7 @@ func TestReorgDiffSubset(t *testing.T) { // This function returns the forked head, the main head and the common ancestor. func getForkOldNewCommon(ctx context.Context, t *testing.T, builder *chain.Builder, a, b, c int) (*types.TipSet, *types.TipSet, *types.TipSet) { // Add "a" tipsets to the head of the chainStore. - commonHead := builder.AppendManyOn(ctx, a, types.UndefTipSet) + commonHead := builder.AppendManyOn(ctx, a, builder.Genesis()) oldHead := commonHead if c > 0 { @@ -89,7 +89,7 @@ func getForkOldNewCommon(ctx context.Context, t *testing.T, builder *chain.Build // consists of this single block and another block together forming a tipset // that is a superset of the forked head. func getSubsetOldNewCommon(ctx context.Context, t *testing.T, builder *chain.Builder, a int) (*types.TipSet, *types.TipSet, *types.TipSet) { - commonHead := builder.AppendManyBlocksOnBlocks(ctx, a) + commonHead := builder.AppendManyBlocksOnBlocks(ctx, a, builder.Genesis().At(0)) block1 := builder.AppendBlockOnBlocks(ctx, commonHead) block2 := builder.AppendBlockOnBlocks(ctx, commonHead) diff --git a/pkg/chain/store.go b/pkg/chain/store.go index b4b7501b58..f24bf9dc0f 100644 --- a/pkg/chain/store.go +++ b/pkg/chain/store.go @@ -9,6 +9,7 @@ import ( "os" "runtime/debug" "sync" + "time" "github.com/hashicorp/golang-lru/arc/v2" "github.com/ipld/go-car" @@ -85,6 +86,8 @@ type TSState struct { Receipts cid.Cid } +type WeightFunc func(context.Context, cbor.IpldStore, *types.TipSet) (big.Int, error) + // Store is a generic implementation of the Store interface. // It works(tm) for now. type Store struct { @@ -129,6 +132,11 @@ type Store struct { reorgNotifeeCh chan ReorgNotifee tsCache *arc.ARCCache[types.TipSetKey, *types.TipSet] + + tstLk sync.Mutex + tipsets map[abi.ChainEpoch][]cid.Cid + + weight WeightFunc } // NewStore constructs a new default store. @@ -136,6 +144,7 @@ func NewStore(chainDs repo.Datastore, bsstore blockstoreutil.Blockstore, genesisCid cid.Cid, circulatiingSupplyCalculator ICirculatingSupplyCalcualtor, + weight WeightFunc, ) *Store { tsCache, _ := arc.NewARC[types.TipSetKey, *types.TipSet](DefaultTipsetLruCacheSize) store := &Store{ @@ -148,6 +157,8 @@ func NewStore(chainDs repo.Datastore, genesis: genesisCid, reorgNotifeeCh: make(chan ReorgNotifee), tsCache: tsCache, + tipsets: make(map[abi.ChainEpoch][]cid.Cid, constants.Finality), + weight: weight, } // todo cycle reference , may think a better idea store.tipIndex = NewTipStateCache(store) @@ -540,8 +551,44 @@ func (store *Store) walkBack(ctx context.Context, from *types.TipSet, to abi.Cha } } +// updateHead sets the passed in tipset as the new head of this chain. +func (store *Store) updateHead(ctx context.Context, newTS *types.TipSet) ([]*types.TipSet, []*types.TipSet, bool, error) { + var dropped []*types.TipSet + var added []*types.TipSet + var err error + + if store.head != nil { + if store.head.Equals(newTS) { + return nil, nil, false, nil + } + // reorg + oldHead := store.head + dropped, added, err = CollectTipsToCommonAncestor(ctx, store, oldHead, newTS) + if err != nil { + return nil, nil, false, err + } + } else { + added = []*types.TipSet{newTS} + } + + // Ensure consistency by storing this new head on disk. + if errInner := store.writeHead(ctx, newTS.Key()); errInner != nil { + return nil, nil, false, errors.Wrap(errInner, "failed to write new Head to datastore") + } + store.head = newTS + + return dropped, added, true, nil +} + // SetHead sets the passed in tipset as the new head of this chain. func (store *Store) SetHead(ctx context.Context, newTS *types.TipSet) error { + store.mu.Lock() + defer store.mu.Unlock() + + return store.setHead(ctx, newTS) +} + +func (store *Store) setHead(ctx context.Context, newTS *types.TipSet) error { log.Infof("SetHead %s %d", newTS.String(), newTS.Height()) // Add logging to debug sporadic test failure. if !newTS.Defined() { @@ -551,34 +598,7 @@ func (store *Store) SetHead(ctx context.Context, newTS *types.TipSet) error { } // reorg tipset - dropped, added, update, err := func() ([]*types.TipSet, []*types.TipSet, bool, error) { - var dropped []*types.TipSet - var added []*types.TipSet - var err error - store.mu.Lock() - defer store.mu.Unlock() - - if store.head != nil { - if store.head.Equals(newTS) { - return nil, nil, false, nil - } - // reorg - oldHead := store.head - dropped, added, err = CollectTipsToCommonAncestor(ctx, store, oldHead, newTS) - if err != nil { - return nil, nil, false, err - } - } else { - added = []*types.TipSet{newTS} - } - - // Ensure consistency by storing this new head on disk. - if errInner := store.writeHead(ctx, newTS.Key()); errInner != nil { - return nil, nil, false, errors.Wrap(errInner, "failed to write new Head to datastore") - } - store.head = newTS - return dropped, added, true, nil - }() + dropped, added, update, err := store.updateHead(ctx, newTS) if err != nil { return err } @@ -587,6 +607,8 @@ func (store *Store) SetHead(ctx context.Context, newTS *types.TipSet) error { return nil } + store.PersistTipSetKey(ctx, newTS.Key()) + // todo wrap by go function Reverse(added) @@ -608,6 +630,8 @@ func (store *Store) PersistTipSetKey(ctx context.Context, key types.TipSetKey) { _ = store.bsstore.Put(ctx, tskBlk) } +const reorgChBuf = 32 + func (store *Store) reorgWorker(ctx context.Context) chan reorg { headChangeNotifee := func(rev, app []*types.TipSet) error { notif := make([]*types.HeadChange, len(rev)+len(app)) @@ -630,7 +654,7 @@ func (store *Store) reorgWorker(ctx context.Context) chan reorg { return nil } - out := make(chan reorg, 32) + out := make(chan reorg, reorgChBuf) notifees := []ReorgNotifee{headChangeNotifee} go func() { @@ -1496,3 +1520,314 @@ func (store *Store) ParentStateView(ts *types.TipSet) (*state.View, error) { func (store *Store) Store(ctx context.Context) adt.Store { return adt.WrapStore(ctx, cbor.NewCborStore(store.bsstore)) } + +func (store *Store) Weight(ctx context.Context, ts *types.TipSet) (big.Int, error) { + return store.weight(ctx, store.stateAndBlockSource, ts) +} + +func (store *Store) AddToTipSetTracker(ctx context.Context, b *types.BlockHeader) error { + store.tstLk.Lock() + defer store.tstLk.Unlock() + + tss := store.tipsets[b.Height] + for _, oc := range tss { + if oc == b.Cid() { + log.Debug("tried to add block to tipset tracker that was already there") + return nil + } + h, err := store.GetBlock(ctx, oc) + if err == nil && h != nil { + if h.Miner == b.Miner { + log.Warnf("Have multiple blocks from miner %s at height %d in our tipset cache %s-%s", b.Miner, b.Height, b.Cid(), h.Cid()) + } + } + } + // This function is called 5 times per epoch on average + // It is also called with tipsets that are done with initial validation + // so they cannot be from the future. + // We are guaranteed not to use tipsets older than 900 epochs (fork limit) + // This means that we ideally want to keep only most recent 900 epochs in here + // Golang's map iteration starts at a random point in a map. + // With 5 tries per epoch, and 900 entries to keep, on average we will have + // ~136 garbage entries in the `store.tipsets` map. (solve for 1-(1-x/(900+x))^5 == 0.5) + // Seems good enough to me + + for height := range store.tipsets { + if height < b.Height-constants.Finality { + delete(store.tipsets, height) + } + break + } + + store.tipsets[b.Height] = append(tss, b.Cid()) + + return nil +} + +// RefreshHeaviestTipSet receives a newTsHeight at which a new tipset might exist. It then: +// - "refreshes" the heaviest tipset that can be formed at its current heaviest height +// - if equivocation is detected among the miners of the current heaviest tipset, the head is immediately updated to the heaviest tipset that can be formed in a range of 5 epochs +// +// - forms the best tipset that can be formed at the _input_ height +// - compares the three tipset weights: "current" heaviest tipset, "refreshed" tipset, and best tipset at newTsHeight +// - updates "current" heaviest to the heaviest of those 3 tipsets (if an update is needed), assuming it doesn't violate the maximum fork rule +func (store *Store) RefreshHeaviestTipSet(ctx context.Context, newTSHeight abi.ChainEpoch) error { + for { + store.mu.Lock() + if len(store.reorgCh) < reorgChBuf/2 { + break + } + store.mu.Unlock() + log.Errorf("reorg channel is heavily backlogged, waiting a bit before trying to take process new tipsets") + select { + case <-time.After(time.Second / 2): + case <-ctx.Done(): + return ctx.Err() + } + } + + defer store.mu.Unlock() + + heaviest := store.head + heaviestWeight, err := store.Weight(ctx, heaviest) + if err != nil { + return fmt.Errorf("failed to calculate currentHeaviest's weight: %w", err) + } + + heaviestHeight := abi.ChainEpoch(0) + if heaviest != nil { + heaviestHeight = heaviest.Height() + } + + // Before we look at newTs, let's refresh best tipset at current head's height -- this is done to detect equivocation + newHeaviest, newHeaviestWeight, err := store.FormHeaviestTipSetForHeight(ctx, heaviestHeight) + if err != nil { + return fmt.Errorf("failed to reform head at same height: %w", err) + } + + // Equivocation has occurred! We need a new head NOW! + if newHeaviest == nil || newHeaviestWeight.LessThan(heaviestWeight) { + log.Warnf("chainstore heaviest tipset's weight SHRANK from %d (%s) to %d (%s) due to equivocation", heaviestWeight, heaviest, newHeaviestWeight, newHeaviest) + // Unfortunately, we don't know what the right height to form a new heaviest tipset is. + // It is _probably_, but not _necessarily_, heaviestHeight. + // So, we need to explore a range of epochs, finding the heaviest tipset in that range. + // We thus try to form the heaviest tipset for 5 epochs above heaviestHeight (most of which will likely not exist), + // as well as for 5 below. + // This is slow, but we expect to almost-never be here (only if miners are equivocating, which carries a hefty penalty). + for i := heaviestHeight + 5; i > heaviestHeight-5; i-- { + possibleHeaviestTS, possibleHeaviestWeight, err := store.FormHeaviestTipSetForHeight(ctx, i) + if err != nil { + return fmt.Errorf("failed to produce head at height %d: %w", i, err) + } + + if possibleHeaviestWeight.GreaterThan(newHeaviestWeight) { + newHeaviestWeight = possibleHeaviestWeight + newHeaviest = possibleHeaviestTS + } + } + + // if we've found something, we know it's the heaviest equivocation-free head, take it IMMEDIATELY + if newHeaviest != nil { + errTake := store.setHead(ctx, newHeaviest) + if errTake != nil { + return fmt.Errorf("failed to take newHeaviest tipset as head: %w", err) + } + } else { + // if we haven't found something, just stay with our equivocation-y head + newHeaviest = heaviest + } + } + + // if the new height we were notified about isn't what we just refreshed at, see if we have a heavier tipset there + if newTSHeight != newHeaviest.Height() { + bestTS, bestTSWeight, err := store.FormHeaviestTipSetForHeight(ctx, newTSHeight) + if err != nil { + return fmt.Errorf("failed to form new heaviest tipset at height %d: %w", newTSHeight, err) + } + + heavier := bestTSWeight.GreaterThan(newHeaviestWeight) + if bestTSWeight.Equals(newHeaviestWeight) { + heavier = breakWeightTie(bestTS, newHeaviest) + } + + if heavier { + newHeaviest = bestTS + } + } + + // Everything's the same as before, exit early + if newHeaviest.Equals(heaviest) { + return nil + } + + // At this point, it MUST be true that newHeaviest is heavier than store.heaviest -- update if fork allows + exceeds, err := store.exceedsForkLength(ctx, heaviest, newHeaviest) + if err != nil { + return fmt.Errorf("failed to check fork length: %w", err) + } + + if exceeds { + return nil + } + + err = store.setHead(ctx, newHeaviest) + if err != nil { + return fmt.Errorf("failed to take heaviest tipset: %w", err) + } + + return nil +} + +// FormHeaviestTipSetForHeight looks up all valid blocks at a given height, and returns the heaviest tipset that can be made at that height +// It does not consider ANY blocks from miners that have "equivocated" (produced 2 blocks at the same height) +func (store *Store) FormHeaviestTipSetForHeight(ctx context.Context, height abi.ChainEpoch) (*types.TipSet, types.BigInt, error) { + store.tstLk.Lock() + defer store.tstLk.Unlock() + + blockCids, ok := store.tipsets[height] + if !ok { + return nil, types.NewInt(0), nil + } + + // First, identify "bad" miners for the height + + seenMiners := map[address.Address]struct{}{} + badMiners := map[address.Address]struct{}{} + blocks := make([]*types.BlockHeader, 0, len(blockCids)) + for _, bhc := range blockCids { + h, err := store.GetBlock(ctx, bhc) + if err != nil { + return nil, types.NewInt(0), fmt.Errorf("failed to load block (%s) for tipset expansion: %w", bhc, err) + } + + if _, seen := seenMiners[h.Miner]; seen { + badMiners[h.Miner] = struct{}{} + continue + } + seenMiners[h.Miner] = struct{}{} + blocks = append(blocks, h) + } + + // Next, group by parent tipset + + formableTipsets := make(map[types.TipSetKey][]*types.BlockHeader, 0) + for _, h := range blocks { + if _, bad := badMiners[h.Miner]; bad { + continue + } + ptsk := types.NewTipSetKey(h.Parents...) + formableTipsets[ptsk] = append(formableTipsets[ptsk], h) + } + + maxWeight := types.NewInt(0) + var maxTS *types.TipSet + for _, headers := range formableTipsets { + ts, err := types.NewTipSet(headers) + if err != nil { + return nil, types.NewInt(0), fmt.Errorf("unexpected error forming tipset: %w", err) + } + + weight, err := store.Weight(ctx, ts) + if err != nil { + return nil, types.NewInt(0), fmt.Errorf("failed to calculate weight: %w", err) + } + + heavier := weight.GreaterThan(maxWeight) + if weight.Equals(maxWeight) { + heavier = breakWeightTie(ts, maxTS) + } + + if heavier { + maxWeight = weight + maxTS = ts + } + } + + return maxTS, maxWeight, nil +} + +func breakWeightTie(ts1, ts2 *types.TipSet) bool { + s := len(ts1.Blocks()) + if s > len(ts2.Blocks()) { + s = len(ts2.Blocks()) + } + + // blocks are already sorted by ticket + for i := 0; i < s; i++ { + if ts1.Blocks()[i].Ticket.Less(ts2.Blocks()[i].Ticket) { + log.Infof("weight tie broken in favour of %s", ts1.Key()) + return true + } + } + + log.Infof("weight tie left unbroken, default to %s", ts2.Key()) + return false +} + +// Check if the two tipsets have a fork length above `ForkLengthThreshold`. +// `synced` is the head of the chain we are currently synced to and `external` +// is the incoming tipset potentially belonging to a forked chain. It assumes +// the external chain has already been validated and available in the ChainStore. +// The "fast forward" case is covered in this logic as a valid fork of length 0. +// +// FIXME: We may want to replace some of the logic in `syncFork()` with this. +// +// `syncFork()` counts the length on both sides of the fork at the moment (we +// need to settle on that) but here we just enforce it on the `synced` side. +func (store *Store) exceedsForkLength(ctx context.Context, synced, external *types.TipSet) (bool, error) { + if synced == nil || external == nil { + // FIXME: If `cs.heaviest` is nil we should just bypass the entire + // `MaybeTakeHeavierTipSet` logic (instead of each of the called + // functions having to handle the nil case on their own). + return false, nil + } + + var err error + // `forkLength`: number of tipsets we need to walk back from the our `synced` + // chain to the common ancestor with the new `external` head in order to + // adopt the fork. + for forkLength := 0; forkLength < int(constants.ForkLengthThreshold); forkLength++ { + // First walk back as many tipsets in the external chain to match the + // `synced` height to compare them. If we go past the `synced` height + // the subsequent match will fail but it will still be useful to get + // closer to the `synced` head parent's height in the next loop. + for external.Height() > synced.Height() { + if external.Height() == 0 { + // We reached the genesis of the external chain without a match; + // this is considered a fork outside the allowed limit (of "infinite" + // length). + return true, nil + } + + external, err = store.GetTipSet(ctx, external.Parents()) + if err != nil { + return false, fmt.Errorf("failed to load parent tipset in external chain: %w", err) + } + } + + // Now check if we arrived at the common ancestor. + if synced.Equals(external) { + return false, nil + } + + // Now check to see if we've walked back to the checkpoint. + if synced.Key().Equals(store.checkPoint) { + return true, nil + } + + // If we didn't, go back *one* tipset on the `synced` side (incrementing + // the `forkLength`). + if synced.Height() == 0 { + // Same check as the `external` side, if we reach the start (genesis) + // there is no common ancestor. + return true, nil + } + synced, err = store.GetTipSet(ctx, synced.Parents()) + if err != nil { + return false, fmt.Errorf("failed to load parent tipset in synced chain: %w", err) + } + } + + // We traversed the fork length allowed without finding a common ancestor. + return true, nil +} diff --git a/pkg/chain/store_test.go b/pkg/chain/store_test.go index 992f06b826..462bacc120 100644 --- a/pkg/chain/store_test.go +++ b/pkg/chain/store_test.go @@ -11,6 +11,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/venus/pkg/chain" + "github.com/filecoin-project/venus/pkg/consensus/chainselector" "github.com/filecoin-project/venus/pkg/repo" "github.com/filecoin-project/venus/pkg/testhelpers" tf "github.com/filecoin-project/venus/pkg/testhelpers/testflags" @@ -43,7 +44,7 @@ func newChainStore(r repo.Repo, genTS *types.TipSet) *CborBlockStore { tempBlock := r.Datastore() cborStore := cbor.NewCborStore(tempBlock) return &CborBlockStore{ - Store: chain.NewStore(r.ChainDatastore(), tempBlock, genTS.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator()), + Store: chain.NewStore(r.ChainDatastore(), tempBlock, genTS.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator(), chainselector.Weight), cborStore: cborStore, } } @@ -220,9 +221,9 @@ func TestHead(t *testing.T) { genTS := builder.Genesis() r := builder.Repo() bs := builder.BlockStore() - cs := chain.NewStore(r.ChainDatastore(), bs, genTS.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator()) + cs := chain.NewStore(r.ChainDatastore(), bs, genTS.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator(), chainselector.Weight) cboreStore := &CborBlockStore{ - Store: chain.NewStore(r.ChainDatastore(), bs, genTS.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator()), + Store: chain.NewStore(r.ChainDatastore(), bs, genTS.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator(), chainselector.Weight), } // Construct test chain data link1 := builder.AppendOn(ctx, genTS, 2) @@ -327,7 +328,7 @@ func TestLoadAndReboot(t *testing.T) { requirePutBlocksToCborStore(t, cst, link4.ToSlice()...) cborStore := &CborBlockStore{ - Store: chain.NewStore(ds, bs, genTS.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator()), + Store: chain.NewStore(ds, bs, genTS.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator(), chainselector.Weight), cborStore: cst, } requirePutTestChain(ctx, t, cborStore, link4.Key(), builder, 5) @@ -337,7 +338,7 @@ func TestLoadAndReboot(t *testing.T) { cborStore.Store.Stop() // rebuild chain with same datastore and cborstore - rebootChain := chain.NewStore(ds, bs, genTS.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator()) + rebootChain := chain.NewStore(ds, bs, genTS.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator(), chainselector.Weight) rebootCbore := &CborBlockStore{ Store: rebootChain, } @@ -356,7 +357,7 @@ func TestLoadAndReboot(t *testing.T) { { assert.NoError(t, rebootChain.Blockstore().DeleteBlock(ctx, link3.Blocks()[0].Cid())) - newStore := chain.NewStore(ds, bs, genTS.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator()) + newStore := chain.NewStore(ds, bs, genTS.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator(), chainselector.Weight) // error occurs while getting tipset identified by parent's cid block, // because block[0] has been deleted. // stm: @CHAIN_STORE_LOAD_003 @@ -365,7 +366,7 @@ func TestLoadAndReboot(t *testing.T) { { assert.NoError(t, ds.Put(ctx, chain.HeadKey, []byte("bad chain head data"))) - newStore := chain.NewStore(ds, bs, genTS.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator()) + newStore := chain.NewStore(ds, bs, genTS.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator(), chainselector.Weight) // error occurs while getting tipset identified by parent's cid block // stm: @CHAIN_STORE_LOAD_002 assert.Error(t, newStore.Load(ctx)) @@ -401,7 +402,7 @@ func TestLoadTipsetMeta(t *testing.T) { _ = os.Setenv("CHAIN_INDEX_CACHE", "2") chain.DefaultTipsetLruCacheSize = 2 - cs := chain.NewStore(ds, bs, genTS.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator()) + cs := chain.NewStore(ds, bs, genTS.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator(), chainselector.Weight) cborStore := &CborBlockStore{Store: cs, cborStore: cst} requirePutTestChain(ctx, t, cborStore, head.Key(), builder, 5) diff --git a/pkg/chain/testing.go b/pkg/chain/testing.go index aac7bb7b37..589af08b00 100644 --- a/pkg/chain/testing.go +++ b/pkg/chain/testing.go @@ -9,6 +9,7 @@ import ( "sync" "testing" + "github.com/filecoin-project/venus/pkg/consensus/chainselector" aexchange "github.com/filecoin-project/venus/pkg/net/exchange" "github.com/filecoin-project/venus/pkg/vm" blockstoreutil "github.com/filecoin-project/venus/venus-shared/blockstore" @@ -38,6 +39,8 @@ import ( "github.com/filecoin-project/venus/venus-shared/types" ) +const defaultMinerCount = 15 + // Builder builds fake chains and acts as a provider and fetcher for the chain thus generated. // All blocks are unique (even if they share parents) and form valid chains of parents and heights, // but do not carry valid tickets. Each block contributes a weight of 1. @@ -50,7 +53,7 @@ type Builder struct { t *testing.T genesis *types.TipSet store *Store - minerAddress address.Address + minerAddress []address.Address stateBuilder StateBuilder stamper TimeStamper repo repo.Repo @@ -175,6 +178,21 @@ func (f *Builder) MessageStore() *MessageStore { func (f *Builder) RemovePeer(peer peer.ID) {} +func (f *Builder) GenMiners(str string) []address.Address { + var miners []address.Address + for i := 0; i < defaultMinerCount; i++ { + miner, err := address.NewSecp256k1Address([]byte(fmt.Sprintf("%s%d", str, i))) + require.NoError(f.t, err) + miners = append(miners, miner) + } + + return miners +} + +func (f *Builder) ResetMiners() { + f.minerAddress = f.GenMiners("miner-") +} + var ( _ BlockProvider = (*Builder)(nil) _ TipSetProvider = (*Builder)(nil) @@ -198,17 +216,12 @@ var _ IStmgr = &fakeStmgr{} // NewBuilder builds a new chain faker with default fake state building. func NewBuilder(t *testing.T, miner address.Address) *Builder { - return NewBuilderWithDeps(t, miner, &FakeStateBuilder{}, &ZeroTimestamper{}) + return NewBuilderWithDeps(t, miner, &ZeroTimestamper{}) } // NewBuilderWithDeps builds a new chain faker. // Blocks will have `miner` set as the miner address, or a default if empty. -func NewBuilderWithDeps(t *testing.T, miner address.Address, sb StateBuilder, stamper TimeStamper) *Builder { - if miner.Empty() { - var err error - miner, err = address.NewSecp256k1Address([]byte("miner")) - require.NoError(t, err) - } +func NewBuilderWithDeps(t *testing.T, miner address.Address, stamper TimeStamper) *Builder { repo := repo.NewInMemoryRepo() bs := repo.Datastore() @@ -217,8 +230,6 @@ func NewBuilderWithDeps(t *testing.T, miner address.Address, sb StateBuilder, st b := &Builder{ t: t, - minerAddress: miner, - stateBuilder: sb, stamper: stamper, repo: repo, bs: bs, @@ -226,6 +237,13 @@ func NewBuilderWithDeps(t *testing.T, miner address.Address, sb StateBuilder, st mstore: NewMessageStore(bs, config.DefaultForkUpgradeParam), tipStateCids: make(map[string]cid.Cid), } + + if !miner.Empty() { + b.minerAddress = []address.Address{miner} + } else { + b.minerAddress = b.GenMiners("miner") + } + ctx := context.TODO() _, err := b.mstore.StoreMessages(ctx, []*types.SignedMessage{}, []*types.Message{}) require.NoError(t, err) @@ -237,12 +255,16 @@ func NewBuilderWithDeps(t *testing.T, miner address.Address, sb StateBuilder, st // create a fixed genesis b.genesis = b.GeneratorGenesis() - b.store = NewStore(ds, bs, b.genesis.At(0).Cid(), NewMockCirculatingSupplyCalculator()) + b.store = NewStore(ds, bs, b.genesis.At(0).Cid(), NewMockCirculatingSupplyCalculator(), chainselector.Weight) + b.stateBuilder = &FakeStateBuilder{b.store} for _, block := range b.genesis.Blocks() { // add block to cstore _, err := b.cstore.Put(context.TODO(), block) require.NoError(t, err) + + err = b.store.AddToTipSetTracker(ctx, b.genesis.At(0)) + require.NoError(t, err) } stateRoot, receiptRoot := b.genesis.Blocks()[0].ParentStateRoot, b.genesis.Blocks()[0].ParentMessageReceipts @@ -381,9 +403,13 @@ func (f *Builder) BuildOrphaTipset(parent *types.TipSet, width int, build func(b binary.BigEndian.PutUint64(ticket.VRFProof, f.seq) f.seq++ + if i > len(f.minerAddress) { + require.NoError(f.t, fmt.Errorf("width too large %d>%d", i, len(f.minerAddress))) + } + b := &types.BlockHeader{ Ticket: &ticket, - Miner: f.minerAddress, + Miner: f.minerAddress[i], BeaconEntries: nil, ParentWeight: parentWeight, Parents: parent.Key().Cids(), @@ -429,6 +455,8 @@ func (f *Builder) BuildOrphaTipset(parent *types.TipSet, width int, build func(b b.ParentStateRoot = stateRootRaw blocks = append(blocks, b) + + require.NoError(f.t, f.store.AddToTipSetTracker(ctx, b)) } return testhelpers.RequireNewTipSet(f.t, blocks...) } @@ -552,14 +580,16 @@ type StateBuilder interface { } // FakeStateBuilder computes a fake state CID by hashing the CIDs of a block's parents and messages. -type FakeStateBuilder struct{} +type FakeStateBuilder struct { + store *Store +} // ComputeState computes a fake state from a previous state root CID and the messages contained // in list-of-lists of messages in blocks. Note that if there are no messages, the resulting state // is the same as the input state. // This differs from the true state transition function in that messages that are duplicated // between blocks in the tipset are not ignored. -func (FakeStateBuilder) ComputeState(prev cid.Cid, blockmsg []types.BlockMessagesInfo) (cid.Cid, []types.MessageReceipt, error) { +func (f FakeStateBuilder) ComputeState(prev cid.Cid, blockmsg []types.BlockMessagesInfo) (cid.Cid, []types.MessageReceipt, error) { receipts := []types.MessageReceipt{} // Accumulate the cids of the previous state and of all messages in the tipset. @@ -589,13 +619,8 @@ func (FakeStateBuilder) ComputeState(prev cid.Cid, blockmsg []types.BlockMessage } // Weigh computes a tipset's weight as its parent weight plus one for each block in the tipset. -func (FakeStateBuilder) Weigh(context context.Context, tip *types.TipSet) (big.Int, error) { - parentWeight := big.Zero() - if tip.Defined() { - parentWeight = tip.ParentWeight() - } - - return big.Add(parentWeight, big.NewInt(int64(tip.Len()))), nil +func (f FakeStateBuilder) Weigh(ctx context.Context, tip *types.TipSet) (big.Int, error) { + return f.store.Weight(ctx, tip) } // /// Timestamper ///// diff --git a/pkg/chain/tip_index.go b/pkg/chain/tip_index.go index dbf44d4130..ee6599d1c7 100644 --- a/pkg/chain/tip_index.go +++ b/pkg/chain/tip_index.go @@ -73,7 +73,7 @@ func (ti *TipStateCache) Get(ctx context.Context, ts *types.TipSet) (TSState, er if !ok { tipSetMetadata, err := ti.loader.LoadTipsetMetadata(ctx, ts) if err != nil { - return TSState{}, errors.New("state not exit") + return TSState{}, fmt.Errorf("state not exit: %s", ts.Key()) } ti.Put(tipSetMetadata) diff --git a/pkg/chain/traversal_test.go b/pkg/chain/traversal_test.go index 71d79140fe..8ad259689f 100644 --- a/pkg/chain/traversal_test.go +++ b/pkg/chain/traversal_test.go @@ -13,7 +13,6 @@ import ( "github.com/filecoin-project/venus/pkg/chain" tf "github.com/filecoin-project/venus/pkg/testhelpers/testflags" - "github.com/filecoin-project/venus/venus-shared/types" ) func TestIterAncestors(t *testing.T) { @@ -25,7 +24,7 @@ func TestIterAncestors(t *testing.T) { ctx := context.Background() store := chain.NewBuilder(t, miner) - root := store.AppendBlockOnBlocks(ctx) + root := store.Genesis().At(0) b11 := store.AppendBlockOnBlocks(ctx, root) b12 := store.AppendBlockOnBlocks(ctx, root) b21 := store.AppendBlockOnBlocks(ctx, b11, b12) @@ -54,7 +53,7 @@ func TestIterAncestors(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) store := chain.NewBuilder(t, miner) - root := store.AppendBlockOnBlocks(ctx) + root := store.Genesis().At(0) b11 := store.AppendBlockOnBlocks(ctx, root) b12 := store.AppendBlockOnBlocks(ctx, root) b21 := store.AppendBlockOnBlocks(ctx, b11, b12) @@ -84,17 +83,17 @@ func TestCollectTipSetsOfHeightAtLeast(t *testing.T) { builder := chain.NewBuilder(t, address.Undef) chainLen := 15 - head := builder.AppendManyOn(ctx, chainLen, types.UndefTipSet) + head := builder.AppendManyOn(ctx, chainLen, builder.Genesis()) stopHeight := abi.ChainEpoch(4) iterator := chain.IterAncestors(ctx, builder, head) tipsets, err := chain.CollectTipSetsOfHeightAtLeast(ctx, iterator, stopHeight) assert.NoError(t, err) latestHeight := tipsets[0].Height() - assert.Equal(t, abi.ChainEpoch(14), latestHeight) + assert.Equal(t, abi.ChainEpoch(15), latestHeight) earliestHeight := tipsets[len(tipsets)-1].Height() assert.Equal(t, abi.ChainEpoch(4), earliestHeight) - assert.Equal(t, 11, len(tipsets)) + assert.Equal(t, 12, len(tipsets)) } // Height at least 0. @@ -104,17 +103,17 @@ func TestCollectTipSetsOfHeightAtLeastZero(t *testing.T) { builder := chain.NewBuilder(t, address.Undef) chainLen := 25 - head := builder.AppendManyOn(ctx, chainLen, types.UndefTipSet) + head := builder.AppendManyOn(ctx, chainLen, builder.Genesis()) stopHeight := abi.ChainEpoch(0) iterator := chain.IterAncestors(ctx, builder, head) tipsets, err := chain.CollectTipSetsOfHeightAtLeast(ctx, iterator, stopHeight) assert.NoError(t, err) latestHeight := tipsets[0].Height() - assert.Equal(t, abi.ChainEpoch(24), latestHeight) + assert.Equal(t, abi.ChainEpoch(25), latestHeight) earliestHeight := tipsets[len(tipsets)-1].Height() assert.Equal(t, abi.ChainEpoch(0), earliestHeight) - assert.Equal(t, chainLen, len(tipsets)) + assert.Equal(t, chainLen+1, len(tipsets)) } // The starting epoch is a null block. diff --git a/pkg/chainsync/chainsync.go b/pkg/chainsync/chainsync.go index 662050d7fd..f9e444308d 100644 --- a/pkg/chainsync/chainsync.go +++ b/pkg/chainsync/chainsync.go @@ -40,13 +40,12 @@ func NewManager( stmgr *statemanger.Stmgr, hv *consensus.BlockValidator, submodule *chain2.ChainSubmodule, - cs syncer.ChainSelector, bsstore blockstoreutil.Blockstore, exchangeClient exchange.Client, c clock.Clock, fork fork.IFork, ) (Manager, error) { - chainSyncer, err := syncer.NewSyncer(stmgr, hv, cs, submodule.ChainReader, + chainSyncer, err := syncer.NewSyncer(stmgr, hv, submodule.ChainReader, submodule.MessageStore, bsstore, exchangeClient, c, fork) if err != nil { diff --git a/pkg/chainsync/syncer/syncer.go b/pkg/chainsync/syncer/syncer.go index d225b755c3..3efc635ca1 100644 --- a/pkg/chainsync/syncer/syncer.go +++ b/pkg/chainsync/syncer/syncer.go @@ -130,15 +130,12 @@ type Syncer struct { stmgr *statemanger.Stmgr // Validates headers and message structure blockValidator BlockValidator - // Selects the heaviest of two chains - chainSelector ChainSelector // Provides and stores validated tipsets and their state roots. chainStore *chain.Store // Provides message collections given cids messageProvider messageStore - clock clock.Clock - headLock sync.Mutex + clock clock.Clock bsstore blockstoreutil.Blockstore checkPoint types.TipSetKey @@ -152,7 +149,6 @@ type Syncer struct { // head tipset to initialize the staging field. func NewSyncer(stmgr *statemanger.Stmgr, hv BlockValidator, - cs ChainSelector, s *chain.Store, m messageStore, bsstore blockstoreutil.Blockstore, @@ -170,7 +166,6 @@ func NewSyncer(stmgr *statemanger.Stmgr, exchangeClient: exchangeClient, badTipSets: syncTypes.NewBadTipSetCache(), blockValidator: hv, - chainSelector: cs, bsstore: bsstore, chainStore: s, messageProvider: m, @@ -212,7 +207,13 @@ func (syncer *Syncer) syncOne(ctx context.Context, parent, next *types.TipSet) e blk := next.At(i) wg.Go(func() error { // Fetch the URL. - return syncer.blockValidator.ValidateFullBlock(ctx, blk) + err := syncer.blockValidator.ValidateFullBlock(ctx, blk) + if err == nil { + if err := syncer.chainStore.AddToTipSetTracker(ctx, blk); err != nil { + return fmt.Errorf("failed to add validated header to tipset tracker: %w", err) + } + } + return err }) } err = wg.Wait() @@ -347,7 +348,7 @@ func (syncer *Syncer) syncSegement(ctx context.Context, target *syncTypes.Target } if !parent.Key().Equals(syncer.checkPoint) { logSyncer.Debugf("set chain head, height:%d, blocks:%d", parent.Height(), parent.Len()) - if err := syncer.SetHead(ctx, parent); err != nil { + if err := syncer.chainStore.RefreshHeaviestTipSet(ctx, parent.Height()); err != nil { errProcessChan <- err return } @@ -637,99 +638,6 @@ func (syncer *Syncer) Head() *types.TipSet { return syncer.chainStore.GetHead() } -// SetHead try to sethead after complete tipset syncing, -// if the current target weight is heavier than chain store. change a new head -func (syncer *Syncer) SetHead(ctx context.Context, ts *types.TipSet) error { - syncer.headLock.Lock() - defer syncer.headLock.Unlock() - head := syncer.chainStore.GetHead() - heavier, err := syncer.chainSelector.IsHeavier(ctx, ts, head) - if err != nil { - return err - } - - // If it is the heaviest update the chainStore. - if heavier { - exceeds, err := syncer.exceedsForkLength(ctx, head, ts) - if err != nil { - return err - } - if exceeds { - return nil - } - return syncer.chainStore.SetHead(ctx, ts) - } - return nil -} - -// Check if the two tipsets have a fork length above `ForkLengthThreshold`. -// `synced` is the head of the chain we are currently synced to and `external` -// is the incoming tipset potentially belonging to a forked chain. It assumes -// the external chain has already been validated and available in the ChainStore. -// The "fast forward" case is covered in this logic as a valid fork of length 0. -// -// FIXME: We may want to replace some of the logic in `syncFork()` with this. -// -// `syncFork()` counts the length on both sides of the fork at the moment (we -// need to settle on that) but here we just enforce it on the `synced` side. -func (syncer *Syncer) exceedsForkLength(ctx context.Context, synced, external *types.TipSet) (bool, error) { - if synced == nil || external == nil { - // FIXME: If `cs.heaviest` is nil we should just bypass the entire - // `MaybeTakeHeavierTipSet` logic (instead of each of the called - // functions having to handle the nil case on their own). - return false, nil - } - - var err error - // `forkLength`: number of tipsets we need to walk back from the our `synced` - // chain to the common ancestor with the new `external` head in order to - // adopt the fork. - for forkLength := 0; forkLength < int(constants.ForkLengthThreshold); forkLength++ { - // First walk back as many tipsets in the external chain to match the - // `synced` height to compare them. If we go past the `synced` height - // the subsequent match will fail but it will still be useful to get - // closer to the `synced` head parent's height in the next loop. - for external.Height() > synced.Height() { - if external.Height() == 0 { - // We reached the genesis of the external chain without a match; - // this is considered a fork outside the allowed limit (of "infinite" - // length). - return true, nil - } - - external, err = syncer.chainStore.GetTipSet(ctx, external.Parents()) - if err != nil { - return false, fmt.Errorf("failed to load parent tipset in external chain: %w", err) - } - } - - // Now check if we arrived at the common ancestor. - if synced.Equals(external) { - return false, nil - } - - // Now check to see if we've walked back to the checkpoint. - if synced.Key().Equals(syncer.checkPoint) { - return true, nil - } - - // If we didn't, go back *one* tipset on the `synced` side (incrementing - // the `forkLength`). - if synced.Height() == 0 { - // Same check as the `external` side, if we reach the start (genesis) - // there is no common ancestor. - return true, nil - } - synced, err = syncer.chainStore.GetTipSet(ctx, synced.Parents()) - if err != nil { - return false, fmt.Errorf("failed to load parent tipset in synced chain: %w", err) - } - } - - // We traversed the fork length allowed without finding a common ancestor. - return true, nil -} - // TODO: this function effectively accepts unchecked input from the network, // either validate it here, or ensure that its validated elsewhere (maybe make // sure the blocksync code checks it?) diff --git a/pkg/chainsync/syncer/syncer_integration_test.go b/pkg/chainsync/syncer/syncer_integration_test.go index 3c67cdf61e..ba59e69784 100644 --- a/pkg/chainsync/syncer/syncer_integration_test.go +++ b/pkg/chainsync/syncer/syncer_integration_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + "github.com/filecoin-project/venus/pkg/consensus/chainselector" "github.com/filecoin-project/venus/pkg/statemanger" "github.com/filecoin-project/venus/pkg/chainsync/types" @@ -37,13 +38,11 @@ func TestLoadFork(t *testing.T) { // Note: the chain builder is passed as the fetcher, from which blocks may be requested, but // *not* as the bsstore, to which the syncer must ensure to put blocks. - sel := &chain.FakeChainSelector{} - blockValidator := builder.FakeStateEvaluator() stmgr, err := statemanger.NewStateManager(builder.Store(), builder.MessageStore(), blockValidator, nil, nil, nil, nil, false) require.NoError(t, err) - s, err := syncer.NewSyncer(stmgr, blockValidator, sel, builder.Store(), + s, err := syncer.NewSyncer(stmgr, blockValidator, builder.Store(), builder.Mstore(), builder.BlockStore(), builder, clock.NewFake(time.Unix(1234567890, 0)), fork.NewMockFork()) require.NoError(t, err) @@ -91,12 +90,11 @@ func TestLoadFork(t *testing.T) { // Load a new chain bsstore on the underlying data. It will only compute state for the // left (heavy) branch. It has a fetcher that can't provide blocks. - newStore := chain.NewStore(builder.Repo().ChainDatastore(), builder.BlockStore(), genesis.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator()) + newStore := chain.NewStore(builder.Repo().ChainDatastore(), builder.BlockStore(), genesis.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator(), chainselector.Weight) newStore.SetCheckPoint(genesis.Key()) require.NoError(t, newStore.Load(ctx)) _, err = syncer.NewSyncer(stmgr, blockValidator, - sel, newStore, builder.Mstore(), builder.BlockStore(), diff --git a/pkg/chainsync/syncer/syncer_test.go b/pkg/chainsync/syncer/syncer_test.go index 42bae1a97d..21cc3c02e4 100644 --- a/pkg/chainsync/syncer/syncer_test.go +++ b/pkg/chainsync/syncer/syncer_test.go @@ -226,12 +226,6 @@ func TestAcceptHeavierFork(t *testing.T) { main3 := builder.AppendOn(ctx, main2, 1) main4 := builder.AppendOn(ctx, main3, 1) - // Fork is heavier with more blocks, despite shorter (with default fake weighing function - // from FakeStateEvaluator). - fork1 := builder.AppendOn(ctx, forkbase, 3) - fork2 := builder.AppendOn(ctx, fork1, 1) - fork3 := builder.AppendOn(ctx, fork2, 1) - main4Target := &syncTypes.Target{ Base: nil, Current: nil, @@ -245,6 +239,14 @@ func TestAcceptHeavierFork(t *testing.T) { verifyTip(t, builder.Store(), main4, builder.StateForKey(ctx, main4.Key())) verifyHead(t, builder.Store(), main4) + // Avoid miners having two blocks at the same height + builder.ResetMiners() + // Fork is heavier with more blocks, despite shorter (with default fake weighing function + // from FakeStateEvaluator). + fork1 := builder.AppendOn(ctx, forkbase, 3) + fork2 := builder.AppendOn(ctx, fork1, 1) + fork3 := builder.AppendOn(ctx, fork2, 1) + // Heavier fork updates head3 fork3Target := &syncTypes.Target{ Base: nil, @@ -322,7 +324,6 @@ func TestNoUncessesaryFetch(t *testing.T) { newSyncer, err := syncer.NewSyncer(stmgr, eval, - &chain.FakeChainSelector{}, builder.Store(), builder.Mstore(), builder.BlockStore(), @@ -592,10 +593,8 @@ func setupWithValidator(ctx context.Context, t *testing.T, builder *chain.Builde ) (*chain.Builder, *syncer.Syncer) { // Note: the chain builder is passed as the fetcher, from which blocks may be requested, but // *not* as the bsstore, to which the syncer must ensure to put blocks. - sel := &chain.FakeChainSelector{} syncer, err := syncer.NewSyncer(stmgr, headerVal, - sel, builder.Store(), builder.Mstore(), builder.BlockStore(), diff --git a/pkg/chainsync/types/target_tracker.go b/pkg/chainsync/types/target_tracker.go index 94fd166603..d782c455e4 100644 --- a/pkg/chainsync/types/target_tracker.go +++ b/pkg/chainsync/types/target_tracker.go @@ -151,7 +151,6 @@ func (tq *TargetTracker) checkBlock(block *types.BlockHeader) bool { } if b.Miner == block.Miner { log.Warnf("miner: %s packed more than none block in single tipset: %d, it's illegal.", b.Miner.String(), b.Height) - return false } } diff --git a/pkg/config/beacon_config.go b/pkg/config/beacon_config.go index 677baa65a9..b79e0d32aa 100644 --- a/pkg/config/beacon_config.go +++ b/pkg/config/beacon_config.go @@ -8,12 +8,14 @@ const ( DrandDevnet DrandLocalnet DrandIncentinet + DrandQuicknet ) type DrandConf struct { Servers []string Relays []string ChainInfoJSON string + IsChained bool } // DrandConfigs a set of drand config @@ -24,25 +26,42 @@ var DrandConfigs = map[DrandEnum]DrandConf{ "https://api2.drand.sh", "https://api3.drand.sh", "https://drand.cloudflare.com", + "https://api.drand.secureweb3.com:6875", // Storswift }, Relays: []string{ "/dnsaddr/api.drand.sh/", "/dnsaddr/api2.drand.sh/", "/dnsaddr/api3.drand.sh/", }, + IsChained: true, ChainInfoJSON: `{"public_key":"868f005eb8e6e4ca0a47c8a77ceaa5309a47978a7c71bc5cce96366b5d7a569937c529eeda66c7293784a9402801af31","period":30,"genesis_time":1595431050,"hash":"8990e7a9aaed2ffed73dbd7092123d6f289930540d7651336225dc172e51b2ce","groupHash":"176f93498eac9ca337150b46d21dd58673ea4e3581185f869672e59fa4cb390a"}`, }, + DrandQuicknet: { + Servers: []string{ + "https://api.drand.sh", + "https://api2.drand.sh", + "https://api3.drand.sh", + "https://drand.cloudflare.com", + "https://api.drand.secureweb3.com:6875", // Storswift + }, + Relays: []string{ + "/dnsaddr/api.drand.sh/", + "/dnsaddr/api2.drand.sh/", + "/dnsaddr/api3.drand.sh/", + }, + IsChained: false, + ChainInfoJSON: `{"public_key":"83cf0f2896adee7eb8b5f01fcad3912212c437e0073e911fb90022d3e760183c8c4b450b6a0a6c3ac6a5776a2d1064510d1fec758c921cc22b0e17e63aaf4bcb5ed66304de9cf809bd274ca73bab4af5a6e9c76a4bc09e76eae8991ef5ece45a","period":3,"genesis_time":1692803367,"hash":"52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971","groupHash":"f477d5c89f21a17c863a7f937c6a6d15859414d2be09cd448d4279af331c5d3e","schemeID":"bls-unchained-g1-rfc9380","metadata":{"beaconID":"quicknet"}}`, + }, DrandTestnet: { Servers: []string{ "https://pl-eu.testnet.drand.sh", "https://pl-us.testnet.drand.sh", - "https://pl-sin.testnet.drand.sh", }, Relays: []string{ "/dnsaddr/pl-eu.testnet.drand.sh/", "/dnsaddr/pl-us.testnet.drand.sh/", - "/dnsaddr/pl-sin.testnet.drand.sh/", }, + IsChained: true, ChainInfoJSON: `{"public_key":"922a2e93828ff83345bae533f5172669a26c02dc76d6bf59c80892e12ab1455c229211886f35bb56af6d5bea981024df","period":25,"genesis_time":1590445175,"hash":"84b2234fb34e835dccd048255d7ad3194b81af7d978c3bf157e3469592ae4e02","groupHash":"4dd408e5fdff9323c76a9b6f087ba8fdc5a6da907bd9217d9d10f2287d081957"}`, }, DrandDevnet: { @@ -54,6 +73,7 @@ var DrandConfigs = map[DrandEnum]DrandConf{ "/dnsaddr/dev1.drand.sh/", "/dnsaddr/dev2.drand.sh/", }, + IsChained: true, ChainInfoJSON: `{"public_key":"8cda589f88914aa728fd183f383980b35789ce81b274e5daee1f338b77d02566ef4d3fb0098af1f844f10f9c803c1827","period":25,"genesis_time":1595348225,"hash":"e73b7dc3c4f6a236378220c0dd6aa110eb16eed26c11259606e07ee122838d4f","groupHash":"567d4785122a5a3e75a9bc9911d7ea807dd85ff76b78dc4ff06b075712898607"}`, }, DrandIncentinet: { @@ -67,6 +87,7 @@ var DrandConfigs = map[DrandEnum]DrandConf{ "/dnsaddr/pl-us.incentinet.drand.sh/", "/dnsaddr/pl-sin.incentinet.drand.sh/", }, + IsChained: true, ChainInfoJSON: `{"public_key":"8cad0c72c606ab27d36ee06de1d5b2db1faf92e447025ca37575ab3a8aac2eaae83192f846fc9e158bc738423753d000","period":30,"genesis_time":1595873820,"hash":"80c8b872c714f4c00fdd3daa465d5514049f457f01f85a4caf68cdcd394ba039","groupHash":"d9406aaed487f7af71851b4399448e311f2328923d454e971536c05398ce2d9b"}`, }, } diff --git a/pkg/config/config.go b/pkg/config/config.go index a747ab9f83..e9ab5f707f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -40,6 +40,7 @@ type Config struct { SlashFilterDs *SlashFilterDsConfig `json:"slashFilter"` RateLimitCfg *RateLimitCfg `json:"rateLimit"` FevmConfig *FevmConfig `json:"fevm"` + EventsConfig *EventsConfig `json:"events"` PubsubConfig *PubsubConfig `json:"pubsub"` FaultReporter *FaultReporterConfig `json:"faultReporter"` } @@ -337,6 +338,8 @@ type ForkUpgradeConfig struct { UpgradeWatermelonHeight abi.ChainEpoch `json:"upgradeWatermelonHeight"` UpgradeWatermelonFixHeight abi.ChainEpoch `json:"upgradeWatermelonFixHeight"` UpgradeWatermelonFix2Height abi.ChainEpoch `json:"upgradeWatermelonFix2Height"` + UpgradeDragonHeight abi.ChainEpoch `json:"upgradeDragonHeight"` + UpgradePhoenixHeight abi.ChainEpoch `json:"upgradePhoenixHeight"` } func IsNearUpgrade(epoch, upgradeEpoch abi.ChainEpoch) bool { @@ -373,6 +376,8 @@ var DefaultForkUpgradeParam = &ForkUpgradeConfig{ UpgradeWatermelonFixHeight: -1, // This fix upgrade only ran on calibrationnet UpgradeWatermelonFix2Height: -2, + UpgradeDragonHeight: 3792000, + UpgradePhoenixHeight: 3792000 + 120, } func newDefaultNetworkParamsConfig() *NetworkParamsConfig { @@ -421,14 +426,13 @@ func newRateLimitConfig() *RateLimitCfg { } type EventConfig struct { - // EnableEthRPC enables APIs that // DisableRealTimeFilterAPI will disable the RealTimeFilterAPI that can create and query filters for actor events as they are emitted. - // The API is enabled when EnableEthRPC is true, but can be disabled selectively with this flag. + // The API is enabled when EnableEthRPC or Events.EnableActorEventsAPI is true, but can be disabled selectively with this flag. DisableRealTimeFilterAPI bool `json:"disableRealTimeFilterAPI"` // DisableHistoricFilterAPI will disable the HistoricFilterAPI that can create and query filters for actor events // that occurred in the past. HistoricFilterAPI maintains a queryable index of events. - // The API is enabled when EnableEthRPC is true, but can be disabled selectively with this flag. + // The API is enabled when EnableEthRPC or Events.EnableActorEventsAPI is true, but can be disabled selectively with this flag. DisableHistoricFilterAPI bool `json:"disableHistoricFilterAPI"` // FilterTTL specifies the time to live for actor event filters. Filters that haven't been accessed longer than @@ -467,6 +471,14 @@ type FevmConfig struct { Event EventConfig `json:"event"` } +type EventsConfig struct { + // EnableActorEventsAPI enables the Actor events API that enables clients to consume events + // emitted by (smart contracts + built-in Actors). + // This will also enable the RealTimeFilterAPI and HistoricFilterAPI by default, but they can be + // disabled by setting their respective Disable* options in Fevm.Event. + EnableActorEventsAPI bool `json:"enableActorEventsAPI"` +} + func newFevmConfig() *FevmConfig { return &FevmConfig{ EnableEthRPC: false, @@ -482,6 +494,12 @@ func newFevmConfig() *FevmConfig { } } +func newEventsConfig() *EventsConfig { + return &EventsConfig{ + EnableActorEventsAPI: false, + } +} + type PubsubConfig struct { // Run the node in bootstrap-node mode Bootstrapper bool `json:"bootstrapper"` @@ -530,6 +548,7 @@ func NewDefaultConfig() *Config { SlashFilterDs: newDefaultSlashFilterDsConfig(), RateLimitCfg: newRateLimitConfig(), FevmConfig: newFevmConfig(), + EventsConfig: newEventsConfig(), PubsubConfig: newPubsubConfig(), FaultReporter: newFaultReporterConfig(), } diff --git a/pkg/consensus/block_validator.go b/pkg/consensus/block_validator.go index 692016e2e0..1ff527905b 100644 --- a/pkg/consensus/block_validator.go +++ b/pkg/consensus/block_validator.go @@ -44,8 +44,11 @@ import ( "github.com/filecoin-project/venus/venus-shared/actors/builtin/miner" "github.com/filecoin-project/venus/venus-shared/actors/builtin/power" "github.com/filecoin-project/venus/venus-shared/types" + logging "github.com/ipfs/go-log/v2" ) +var log = logging.Logger("consensus") + var ( ErrTemporal = errors.New("temporal error") ErrSoftFailure = errors.New("soft validation failure") @@ -69,8 +72,6 @@ type BlockValidator struct { state StateViewer // Provides and stores validated tipsets and their state roots. chainState chainReader - // Selects the heaviest of two chains - chainSelector *ChainSelector // fork used to process fork code fork fork.IFork // network params @@ -92,7 +93,6 @@ func NewBlockValidator(tv TicketValidator, proofVerifier ProofVerifier, state StateViewer, chainState chainReader, - chainSelector *ChainSelector, fork fork.IFork, config *config.NetworkParamsConfig, gasPirceSchedule *gas.PricesSchedule, @@ -107,7 +107,6 @@ func NewBlockValidator(tv TicketValidator, proofVerifier: proofVerifier, state: state, chainState: chainState, - chainSelector: chainSelector, fork: fork, config: config, gasPirceSchedule: gasPirceSchedule, @@ -149,7 +148,7 @@ func (bv *BlockValidator) validateBlock(ctx context.Context, blk *types.BlockHea if err != nil { return fmt.Errorf("load parent tipset failed %w", err) } - parentWeight, err := bv.chainSelector.Weight(ctx, parent) + parentWeight, err := bv.chainState.Weight(ctx, parent) if err != nil { return fmt.Errorf("calc parent weight failed %w", err) } @@ -172,6 +171,7 @@ func (bv *BlockValidator) validateBlock(ctx context.Context, blk *types.BlockHea logExpect.Warn("Got block from the future, but within threshold ", blk.Timestamp, time.Now().Unix()) } + // TODO: Optimization: See https://github.com/filecoin-project/lotus/issues/11597 // get parent beacon prevBeacon, err := bv.chainState.GetLatestBeaconEntry(ctx, parent) if err != nil { diff --git a/pkg/consensus/chain_selector.go b/pkg/consensus/chain_selector.go deleted file mode 100644 index 7724cb71fe..0000000000 --- a/pkg/consensus/chain_selector.go +++ /dev/null @@ -1,120 +0,0 @@ -package consensus - -// This is to implement Expected Consensus protocol -// See: https://github.com/filecoin-project/specs/blob/master/expected-consensus.md - -import ( - "context" - "errors" - "fmt" - "math/big" - - logging "github.com/ipfs/go-log/v2" - - fbig "github.com/filecoin-project/go-state-types/big" - cbor "github.com/ipfs/go-ipld-cbor" - - "github.com/filecoin-project/venus/pkg/constants" - "github.com/filecoin-project/venus/pkg/state" - "github.com/filecoin-project/venus/venus-shared/types" -) - -var log = logging.Logger("chain_selector") - -// ChainSelector weighs and compares chains. -type ChainSelector struct { - cstore cbor.IpldStore - state StateViewer -} - -// NewChainSelector is the constructor for Chain selection module. -func NewChainSelector(cs cbor.IpldStore, state StateViewer) *ChainSelector { - return &ChainSelector{ - cstore: cs, - state: state, - } -} - -// Weight returns the EC weight of this TipSet as a filecoin big int. -func (c *ChainSelector) Weight(ctx context.Context, ts *types.TipSet) (fbig.Int, error) { - pStateID := ts.At(0).ParentStateRoot - // Retrieve parent weight. - if !pStateID.Defined() { - return fbig.Zero(), errors.New("undefined state passed to Chain selector new weight") - } - // todo change view version - powerTableView := state.NewPowerTableView(c.state.PowerStateView(pStateID), c.state.FaultStateView(pStateID)) - networkPower, err := powerTableView.NetworkTotalPower(ctx) - if err != nil { - return fbig.Zero(), err - } - - log2P := int64(0) - if networkPower.GreaterThan(fbig.NewInt(0)) { - log2P = int64(networkPower.BitLen() - 1) - } else { - // Not really expect to be here ... - return fbig.Zero(), fmt.Errorf("all power in the net is gone. You network might be disconnected, or the net is dead") - } - - weight := ts.ParentWeight() - out := new(big.Int).Set(weight.Int) - out.Add(out, big.NewInt(log2P<<8)) - - // (wFunction(totalPowerAtTipset(ts)) * sum(ts.blocks[].ElectionProof.WinCount) * wRatio_num * 2^8) / (e * wRatio_den) - - totalJ := int64(0) - for _, b := range ts.Blocks() { - totalJ += b.ElectionProof.WinCount - } - - eWeight := big.NewInt(log2P * constants.WRatioNum) - eWeight = eWeight.Lsh(eWeight, 8) - eWeight = eWeight.Mul(eWeight, new(big.Int).SetInt64(totalJ)) - eWeight = eWeight.Div(eWeight, big.NewInt(int64(uint64(constants.ExpectedLeadersPerEpoch)*constants.WRatioDen))) - - out = out.Add(out, eWeight) - - return fbig.Int{Int: out}, nil -} - -// IsHeavier returns true if tipset a is heavier than tipset b, and false -// vice versa. In the rare case where two tipsets have the same weight ties -// are broken by taking the tipset with more blocks. -func (c *ChainSelector) IsHeavier(ctx context.Context, a, b *types.TipSet) (bool, error) { - aW, err := c.Weight(ctx, a) - if err != nil { - return false, err - } - bW, err := c.Weight(ctx, b) - if err != nil { - return false, err - } - - heavier := aW.GreaterThan(bW) - if aW.Equals(bW) && !a.Equals(b) { - log.Errorw("weight draw", "currTs", a, "ts", b) - heavier = breakWeightTie(a, b) - } - - return heavier, nil -} - -// true if ts1 wins according to the filecoin tie-break rule -func breakWeightTie(ts1, ts2 *types.TipSet) bool { - s := len(ts1.Blocks()) - if s > len(ts2.Blocks()) { - s = len(ts2.Blocks()) - } - - // blocks are already sorted by ticket - for i := 0; i < s; i++ { - if ts1.Blocks()[i].Ticket.Less(ts2.Blocks()[i].Ticket) { - log.Infof("weight tie broken in favour of %s", ts1.Key()) - return true - } - } - - log.Infof("weight tie left unbroken, default to %s", ts2.Key()) - return false -} diff --git a/pkg/consensus/chainselector/weight.go b/pkg/consensus/chainselector/weight.go new file mode 100644 index 0000000000..ac021f83d2 --- /dev/null +++ b/pkg/consensus/chainselector/weight.go @@ -0,0 +1,67 @@ +package chainselector + +// This is to implement Expected Consensus protocol +// See: https://github.com/filecoin-project/specs/blob/master/expected-consensus.md + +import ( + "context" + "errors" + "fmt" + "math/big" + + fbig "github.com/filecoin-project/go-state-types/big" + cbor "github.com/ipfs/go-ipld-cbor" + + "github.com/filecoin-project/venus/pkg/constants" + "github.com/filecoin-project/venus/pkg/state" + "github.com/filecoin-project/venus/venus-shared/types" +) + +// Weight returns the EC weight of this TipSet as a filecoin big int. +func Weight(ctx context.Context, cborStore cbor.IpldStore, ts *types.TipSet) (fbig.Int, error) { + pStateID := ts.At(0).ParentStateRoot + // Retrieve parent weight. + if !pStateID.Defined() { + return fbig.Zero(), errors.New("undefined state passed to Chain selector new weight") + } + view := state.NewView(cborStore, pStateID) + + return weight(ctx, view, ts) +} + +// weight is easy for test +func weight(ctx context.Context, view state.PowerStateView, ts *types.TipSet) (fbig.Int, error) { + total, err := view.PowerNetworkTotal(ctx) + if err != nil { + return fbig.Zero(), err + } + networkPower := total.QualityAdjustedPower + + log2P := int64(0) + if networkPower.GreaterThan(fbig.NewInt(0)) { + log2P = int64(networkPower.BitLen() - 1) + } else { + // Not really expect to be here ... + return fbig.Zero(), fmt.Errorf("all power in the net is gone. You network might be disconnected, or the net is dead") + } + + weight := ts.ParentWeight() + out := new(big.Int).Set(weight.Int) + out.Add(out, big.NewInt(log2P<<8)) + + // (wFunction(totalPowerAtTipset(ts)) * sum(ts.blocks[].ElectionProof.WinCount) * wRatio_num * 2^8) / (e * wRatio_den) + + totalJ := int64(0) + for _, b := range ts.Blocks() { + totalJ += b.ElectionProof.WinCount + } + + eWeight := big.NewInt(log2P * constants.WRatioNum) + eWeight = eWeight.Lsh(eWeight, 8) + eWeight = eWeight.Mul(eWeight, new(big.Int).SetInt64(totalJ)) + eWeight = eWeight.Div(eWeight, big.NewInt(int64(uint64(constants.ExpectedLeadersPerEpoch)*constants.WRatioDen))) + + out = out.Add(out, eWeight) + + return fbig.Int{Int: out}, nil +} diff --git a/pkg/consensus/weight_test.go b/pkg/consensus/chainselector/weight_test.go similarity index 70% rename from pkg/consensus/weight_test.go rename to pkg/consensus/chainselector/weight_test.go index b9dd615ea8..26110b2a28 100644 --- a/pkg/consensus/weight_test.go +++ b/pkg/consensus/chainselector/weight_test.go @@ -1,5 +1,5 @@ // stm: #unit -package consensus_test +package chainselector import ( "context" @@ -11,12 +11,10 @@ import ( "github.com/filecoin-project/go-state-types/abi" fbig "github.com/filecoin-project/go-state-types/big" - "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/filecoin-project/venus/pkg/consensus" appstate "github.com/filecoin-project/venus/pkg/state" "github.com/filecoin-project/venus/pkg/state/tree" ) @@ -31,8 +29,10 @@ func TestWeight(t *testing.T) { minerAddr := addrGetter() // We only care about total power for the weight function // Total is 16, so bitlen is 5, log2b is 4 - viewer := makeStateViewer(fakeRoot, abi.NewStoragePower(16)) - ticket := consensus.MakeFakeTicketForTest() + viewer := appstate.NewFakeStateView(abi.NewStoragePower(16), abi.NewStoragePower(16), 0, 0) + ticket := &types.Ticket{ + VRFProof: types.VRFPi([]byte("xxxx")), + } toWeigh := testhelpers.RequireNewTipSet(t, &types.BlockHeader{ Miner: minerAddr, ParentWeight: fbig.Zero(), @@ -45,39 +45,32 @@ func TestWeight(t *testing.T) { ParentMessageReceipts: testhelpers.EmptyReceiptsCID, }) - sel := consensus.NewChainSelector(cst, &viewer) - // sel := consensus.NewChainSelector(cst, &viewer, types.CidFromString(t, "genesisCid")) - t.Run("basic happy path", func(t *testing.T) { // 0 + (4*256 + (4*1*1*256/5*2)) // 1024 + 102 = 1126 // stm: @CONSENSUS_CHAIN_SELECTOR_WEIGHT_001 - w, err := sel.Weight(ctx, toWeigh) - // w, err := sel.Weight(ctx, toWeigh, fakeRoot) + w, err := weight(ctx, viewer, toWeigh) assert.NoError(t, err) assert.Equal(t, fbig.NewInt(1126), w) }) t.Run("total power adjusts as expected", func(t *testing.T) { - asLowerX := makeStateViewer(fakeRoot, abi.NewStoragePower(15)) - asSameX := makeStateViewer(fakeRoot, abi.NewStoragePower(31)) - asHigherX := makeStateViewer(fakeRoot, abi.NewStoragePower(32)) + asLowerX := appstate.NewFakeStateView(abi.NewStoragePower(15), abi.NewStoragePower(15), 0, 0) + asSameX := appstate.NewFakeStateView(abi.NewStoragePower(31), abi.NewStoragePower(31), 0, 0) + asHigherX := appstate.NewFakeStateView(abi.NewStoragePower(32), abi.NewStoragePower(32), 0, 0) // 0 + (3*256) + (3*1*1*256/2*5) = 844 (truncating not rounding division) - selLower := consensus.NewChainSelector(cst, &asLowerX) - fixWeight, err := selLower.Weight(ctx, toWeigh) + fixWeight, err := weight(ctx, asLowerX, toWeigh) assert.NoError(t, err) assert.Equal(t, fbig.NewInt(844), fixWeight) // Weight is same when total bytes = 16 as when total bytes = 31 - selSame := consensus.NewChainSelector(cst, &asSameX) - fixWeight, err = selSame.Weight(ctx, toWeigh) + fixWeight, err = weight(ctx, asSameX, toWeigh) assert.NoError(t, err) assert.Equal(t, fbig.NewInt(1126), fixWeight) // 0 + (5*256) + (5*1*1*256/2*5) = 1408 - selHigher := consensus.NewChainSelector(cst, &asHigherX) - fixWeight, err = selHigher.Weight(ctx, toWeigh) + fixWeight, err = weight(ctx, asHigherX, toWeigh) assert.NoError(t, err) assert.Equal(t, fbig.NewInt(1408), fixWeight) }) @@ -97,7 +90,7 @@ func TestWeight(t *testing.T) { }) // 49 + (4*256) + (4*1*1*256/2*5) = 1175 - w, err := sel.Weight(ctx, toWeighWithParent) + w, err := weight(ctx, viewer, toWeighWithParent) assert.NoError(t, err) assert.Equal(t, fbig.NewInt(1175), w) }) @@ -142,22 +135,8 @@ func TestWeight(t *testing.T) { }, ) // 0 + (4*256) + (4*3*1*256/2*5) = 1331 - w, err := sel.Weight(ctx, toWeighThreeBlock) + w, err := weight(ctx, viewer, toWeighThreeBlock) assert.NoError(t, err) assert.Equal(t, fbig.NewInt(1331), w) - - // stm: @CONSENSUS_CHAIN_SELECTOR_WEIGHT_001 - toWeighTwoBlock := testhelpers.RequireNewTipSet(t, toWeighThreeBlock.At(0), toWeighThreeBlock.At(1)) - isHeavier, err := sel.IsHeavier(ctx, toWeighThreeBlock, toWeighTwoBlock) - assert.NoError(t, err) - assert.True(t, isHeavier) }) } - -func makeStateViewer(stateRoot cid.Cid, networkPower abi.StoragePower) consensus.FakeConsensusStateViewer { - return consensus.FakeConsensusStateViewer{ - Views: map[cid.Cid]*appstate.FakeStateView{ - stateRoot: appstate.NewFakeStateView(networkPower, networkPower, 0, 0), - }, - } -} diff --git a/pkg/consensus/expected.go b/pkg/consensus/expected.go index 1529d26a12..eb979b4080 100644 --- a/pkg/consensus/expected.go +++ b/pkg/consensus/expected.go @@ -7,6 +7,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/venus/pkg/beacon" "github.com/filecoin-project/venus/pkg/config" @@ -90,6 +91,7 @@ type chainReader interface { GetLookbackTipSetForRound(ctx context.Context, ts *types.TipSet, round abi.ChainEpoch, version network.Version) (*types.TipSet, cid.Cid, error) GetTipsetMetadata(context.Context, *types.TipSet) (*chain.TipSetMetadata, error) PutTipSetMetadata(context.Context, *chain.TipSetMetadata) error + Weight(context.Context, *types.TipSet) (big.Int, error) } var _ chainReader = (*chain.Store)(nil) diff --git a/pkg/consensus/testing.go b/pkg/consensus/testing.go index 45ba1eaa24..5d2400003f 100644 --- a/pkg/consensus/testing.go +++ b/pkg/consensus/testing.go @@ -7,10 +7,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" acrypto "github.com/filecoin-project/go-state-types/crypto" - "github.com/ipfs/go-cid" "github.com/stretchr/testify/require" - "github.com/filecoin-project/venus/pkg/state" "github.com/filecoin-project/venus/venus-shared/types" ) @@ -22,21 +20,6 @@ func RequireNewTipSet(require *require.Assertions, blks ...*types.BlockHeader) * return ts } -// FakeConsensusStateViewer is a fake power state viewer. -type FakeConsensusStateViewer struct { - Views map[cid.Cid]*state.FakeStateView -} - -// PowerStateView returns the state view for a root. -func (f *FakeConsensusStateViewer) PowerStateView(root cid.Cid) state.PowerStateView { - return f.Views[root] -} - -// FaultStateView returns the state view for a root. -func (f *FakeConsensusStateViewer) FaultStateView(root cid.Cid) state.FaultStateView { - return f.Views[root] -} - // FakeMessageValidator is a validator that doesn't validate to simplify message creation in tests. type FakeMessageValidator struct{} diff --git a/pkg/constants/shared_vals.go b/pkg/constants/shared_vals.go index 05016a4884..71e0685db3 100644 --- a/pkg/constants/shared_vals.go +++ b/pkg/constants/shared_vals.go @@ -16,7 +16,7 @@ const TestNetworkVersion = network.Version{{.latestNetworkVersion}} /* inline-gen start */ -const TestNetworkVersion = network.Version21 +const TestNetworkVersion = network.Version22 /* inline-gen end */ diff --git a/pkg/events/filter/event.go b/pkg/events/filter/event.go index b7dc1167c0..da2adfff49 100644 --- a/pkg/events/filter/event.go +++ b/pkg/events/filter/event.go @@ -30,14 +30,24 @@ func isIndexedValue(b uint8) bool { return b&(types.EventFlagIndexedKey|types.EventFlagIndexedValue) > 0 } -type EventFilter struct { - id types.FilterID - minHeight abi.ChainEpoch // minimum epoch to apply filter or -1 if no minimum - maxHeight abi.ChainEpoch // maximum epoch to apply filter or -1 if no maximum - tipsetCid cid.Cid - addresses []address.Address // list of f4 actor addresses that are extpected to emit the event - keys map[string][][]byte // map of key names to a list of alternate values that may match - maxResults int // maximum number of results to collect, 0 is unlimited +type AddressResolver func(context.Context, abi.ActorID, *types.TipSet) (address.Address, bool) + +type EventFilter interface { + Filter + + TakeCollectedEvents(context.Context) []*CollectedEvent + CollectEvents(context.Context, *TipSetEvents, bool, AddressResolver) error +} + +type eventFilter struct { + id types.FilterID + minHeight abi.ChainEpoch // minimum epoch to apply filter or -1 if no minimum + maxHeight abi.ChainEpoch // maximum epoch to apply filter or -1 if no maximum + tipsetCid cid.Cid + addresses []address.Address // list of actor addresses that are extpected to emit the event + + keysWithCodec map[string][]types.ActorEventBlock // map of key names to a list of alternate values that may match + maxResults int // maximum number of results to collect, 0 is unlimited mu sync.Mutex collected []*CollectedEvent @@ -45,11 +55,11 @@ type EventFilter struct { ch chan<- interface{} } -var _ Filter = (*EventFilter)(nil) +var _ Filter = (*eventFilter)(nil) type CollectedEvent struct { Entries []types.EventEntry - EmitterAddr address.Address // f4 address of emitter + EmitterAddr address.Address // address of emitter EventIdx int // index of the event within the list of emitted events Reverted bool Height abi.ChainEpoch @@ -58,24 +68,24 @@ type CollectedEvent struct { MsgCid cid.Cid // cid of message that produced event } -func (f *EventFilter) ID() types.FilterID { +func (f *eventFilter) ID() types.FilterID { return f.id } -func (f *EventFilter) SetSubChannel(ch chan<- interface{}) { +func (f *eventFilter) SetSubChannel(ch chan<- interface{}) { f.mu.Lock() defer f.mu.Unlock() f.ch = ch f.collected = nil } -func (f *EventFilter) ClearSubChannel() { +func (f *eventFilter) ClearSubChannel() { f.mu.Lock() defer f.mu.Unlock() f.ch = nil } -func (f *EventFilter) CollectEvents(ctx context.Context, te *TipSetEvents, revert bool, resolver func(ctx context.Context, emitter abi.ActorID, ts *types.TipSet) (address.Address, bool)) error { +func (f *eventFilter) CollectEvents(ctx context.Context, te *TipSetEvents, revert bool, resolver AddressResolver) error { if !f.matchTipset(te) { return nil } @@ -140,13 +150,13 @@ func (f *EventFilter) CollectEvents(ctx context.Context, te *TipSetEvents, rever return nil } -func (f *EventFilter) setCollectedEvents(ces []*CollectedEvent) { +func (f *eventFilter) setCollectedEvents(ces []*CollectedEvent) { f.mu.Lock() f.collected = ces f.mu.Unlock() } -func (f *EventFilter) TakeCollectedEvents(ctx context.Context) []*CollectedEvent { +func (f *eventFilter) TakeCollectedEvents(ctx context.Context) []*CollectedEvent { f.mu.Lock() collected := f.collected f.collected = nil @@ -156,14 +166,14 @@ func (f *EventFilter) TakeCollectedEvents(ctx context.Context) []*CollectedEvent return collected } -func (f *EventFilter) LastTaken() time.Time { +func (f *eventFilter) LastTaken() time.Time { f.mu.Lock() defer f.mu.Unlock() return f.lastTaken } // matchTipset reports whether this filter matches the given tipset -func (f *EventFilter) matchTipset(te *TipSetEvents) bool { +func (f *eventFilter) matchTipset(te *TipSetEvents) bool { if f.tipsetCid != cid.Undef { tsCid, err := te.Cid() if err != nil { @@ -181,7 +191,7 @@ func (f *EventFilter) matchTipset(te *TipSetEvents) bool { return true } -func (f *EventFilter) matchAddress(o address.Address) bool { +func (f *eventFilter) matchAddress(o address.Address) bool { if len(f.addresses) == 0 { return true } @@ -196,8 +206,8 @@ func (f *EventFilter) matchAddress(o address.Address) bool { return false } -func (f *EventFilter) matchKeys(ees []types.EventEntry) bool { - if len(f.keys) == 0 { +func (f *eventFilter) matchKeys(ees []types.EventEntry) bool { + if len(f.keysWithCodec) == 0 { return true } // TODO: optimize this naive algorithm @@ -219,19 +229,19 @@ func (f *EventFilter) matchKeys(ees []types.EventEntry) bool { continue } - wantlist, ok := f.keys[keyname] + wantlist, ok := f.keysWithCodec[keyname] if !ok || len(wantlist) == 0 { continue } for _, w := range wantlist { - if bytes.Equal(w, ee.Value) { + if bytes.Equal(w.Value, ee.Value) && w.Codec == ee.Codec { matched[keyname] = true break } } - if len(matched) == len(f.keys) { + if len(matched) == len(f.keysWithCodec) { // all keys have been matched return true } @@ -299,7 +309,7 @@ type EventFilterManager struct { EventIndex *EventIndex mu sync.Mutex // guards mutations to filters - filters map[types.FilterID]*EventFilter + filters map[types.FilterID]EventFilter currentHeight abi.ChainEpoch } @@ -365,7 +375,8 @@ func (m *EventFilterManager) Revert(ctx context.Context, from, to *types.TipSet) return nil } -func (m *EventFilterManager) Install(ctx context.Context, minHeight, maxHeight abi.ChainEpoch, tipsetCid cid.Cid, addresses []address.Address, keys map[string][][]byte) (*EventFilter, error) { +func (m *EventFilterManager) Install(ctx context.Context, minHeight, maxHeight abi.ChainEpoch, tipsetCid cid.Cid, addresses []address.Address, + keysWithCodec map[string][]types.ActorEventBlock, excludeReverted bool) (EventFilter, error) { m.mu.Lock() currentHeight := m.currentHeight m.mu.Unlock() @@ -379,26 +390,26 @@ func (m *EventFilterManager) Install(ctx context.Context, minHeight, maxHeight a return nil, xerrors.Errorf("new filter id: %w", err) } - f := &EventFilter{ - id: id, - minHeight: minHeight, - maxHeight: maxHeight, - tipsetCid: tipsetCid, - addresses: addresses, - keys: keys, - maxResults: m.MaxFilterResults, + f := &eventFilter{ + id: id, + minHeight: minHeight, + maxHeight: maxHeight, + tipsetCid: tipsetCid, + addresses: addresses, + keysWithCodec: keysWithCodec, + maxResults: m.MaxFilterResults, } if m.EventIndex != nil && minHeight != -1 && minHeight < currentHeight { // Filter needs historic events - if err := m.EventIndex.PrefillFilter(ctx, f); err != nil { + if err := m.EventIndex.prefillFilter(ctx, f, excludeReverted); err != nil { return nil, err } } m.mu.Lock() if m.filters == nil { - m.filters = make(map[types.FilterID]*EventFilter) + m.filters = make(map[types.FilterID]EventFilter) } m.filters[id] = f m.mu.Unlock() diff --git a/pkg/events/filter/event_test.go b/pkg/events/filter/event_test.go index 093616ea41..92601f2c79 100644 --- a/pkg/events/filter/event_test.go +++ b/pkg/events/filter/event_test.go @@ -21,6 +21,19 @@ import ( "github.com/filecoin-project/venus/venus-shared/types" ) +func keysToKeysWithCodec(keys map[string][][]byte) map[string][]types.ActorEventBlock { + keysWithCodec := make(map[string][]types.ActorEventBlock) + for k, v := range keys { + for _, vv := range v { + keysWithCodec[k] = append(keysWithCodec[k], types.ActorEventBlock{ + Codec: cid.Raw, + Value: vv, + }) + } + } + return keysWithCodec +} + func TestEventFilterCollectEvents(t *testing.T) { rng := pseudo.New(pseudo.NewSource(299792458)) a1 := randomF4Addr(t, rng) @@ -72,13 +85,13 @@ func TestEventFilterCollectEvents(t *testing.T) { testCases := []struct { name string - filter *EventFilter + filter *eventFilter te *TipSetEvents want []*CollectedEvent }{ { name: "nomatch tipset min height", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: 14001, maxHeight: -1, }, @@ -87,7 +100,7 @@ func TestEventFilterCollectEvents(t *testing.T) { }, { name: "nomatch tipset max height", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: 13999, }, @@ -96,7 +109,7 @@ func TestEventFilterCollectEvents(t *testing.T) { }, { name: "match tipset min height", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: 14000, maxHeight: -1, }, @@ -105,7 +118,7 @@ func TestEventFilterCollectEvents(t *testing.T) { }, { name: "match tipset cid", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, tipsetCid: cid14000, @@ -115,7 +128,7 @@ func TestEventFilterCollectEvents(t *testing.T) { }, { name: "nomatch address", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, addresses: []address.Address{a2}, @@ -125,7 +138,7 @@ func TestEventFilterCollectEvents(t *testing.T) { }, { name: "match address", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, addresses: []address.Address{a1}, @@ -135,124 +148,124 @@ func TestEventFilterCollectEvents(t *testing.T) { }, { name: "match one entry", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, - keys: map[string][][]byte{ + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ "type": { []byte("approval"), }, - }, + }), }, te: events14000, want: oneCollectedEvent, }, { name: "match one entry with alternate values", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, - keys: map[string][][]byte{ + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ "type": { []byte("cancel"), []byte("propose"), []byte("approval"), }, - }, + }), }, te: events14000, want: oneCollectedEvent, }, { name: "nomatch one entry by missing value", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, - keys: map[string][][]byte{ + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ "type": { []byte("cancel"), []byte("propose"), }, - }, + }), }, te: events14000, want: noCollectedEvents, }, { name: "nomatch one entry by missing key", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, - keys: map[string][][]byte{ + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ "method": { []byte("approval"), }, - }, + }), }, te: events14000, want: noCollectedEvents, }, { name: "match one entry with multiple keys", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, - keys: map[string][][]byte{ + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ "type": { []byte("approval"), }, "signer": { []byte("addr1"), }, - }, + }), }, te: events14000, want: oneCollectedEvent, }, { name: "nomatch one entry with one mismatching key", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, - keys: map[string][][]byte{ + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ "type": { []byte("approval"), }, "approver": { []byte("addr1"), }, - }, + }), }, te: events14000, want: noCollectedEvents, }, { name: "nomatch one entry with one mismatching value", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, - keys: map[string][][]byte{ + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ "type": { []byte("approval"), }, "signer": { []byte("addr2"), }, - }, + }), }, te: events14000, want: noCollectedEvents, }, { name: "nomatch one entry with one unindexed key", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, - keys: map[string][][]byte{ + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ "amount": { []byte("2988181"), }, - }, + }), }, te: events14000, want: noCollectedEvents, diff --git a/pkg/events/filter/index.go b/pkg/events/filter/index.go index 8cc4a6a259..a536ba1e57 100644 --- a/pkg/events/filter/index.go +++ b/pkg/events/filter/index.go @@ -483,8 +483,8 @@ func (ei *EventIndex) CollectEvents(ctx context.Context, te *TipSetEvents, rever return nil } -// PrefillFilter fills a filter's collection of events from the historic index -func (ei *EventIndex) PrefillFilter(ctx context.Context, f *EventFilter) error { +// prefillFilter fills a filter's collection of events from the historic index +func (ei *EventIndex) prefillFilter(ctx context.Context, f *eventFilter, excludeReverted bool) error { clauses := []string{} values := []any{} joins := []string{} @@ -512,9 +512,9 @@ func (ei *EventIndex) PrefillFilter(ctx context.Context, f *EventFilter) error { clauses = append(clauses, "("+strings.Join(subclauses, " OR ")+")") } - if len(f.keys) > 0 { + if len(f.keysWithCodec) > 0 { join := 0 - for key, vals := range f.keys { + for key, vals := range f.keysWithCodec { if len(vals) > 0 { join++ joinAlias := fmt.Sprintf("ee%d", join) @@ -523,8 +523,8 @@ func (ei *EventIndex) PrefillFilter(ctx context.Context, f *EventFilter) error { values = append(values, key) subclauses := []string{} for _, val := range vals { - subclauses = append(subclauses, fmt.Sprintf("%s.value=?", joinAlias)) - values = append(values, val) + subclauses = append(subclauses, fmt.Sprintf("(%s.value=? AND %[1]s.codec=?)", joinAlias)) + values = append(values, val.Value, val.Codec) } clauses = append(clauses, "("+strings.Join(subclauses, " OR ")+")") } diff --git a/pkg/events/filter/index_test.go b/pkg/events/filter/index_test.go index a2ac4f8339..e46395478e 100644 --- a/pkg/events/filter/index_test.go +++ b/pkg/events/filter/index_test.go @@ -11,6 +11,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/venus/venus-shared/types" ) @@ -81,13 +82,13 @@ func TestEventIndexPrefillFilter(t *testing.T) { testCases := []struct { name string - filter *EventFilter + filter *eventFilter te *TipSetEvents want []*CollectedEvent }{ { name: "nomatch tipset min height", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: 14001, maxHeight: -1, }, @@ -96,7 +97,7 @@ func TestEventIndexPrefillFilter(t *testing.T) { }, { name: "nomatch tipset max height", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: 13999, }, @@ -105,7 +106,7 @@ func TestEventIndexPrefillFilter(t *testing.T) { }, { name: "match tipset min height", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: 14000, maxHeight: -1, }, @@ -114,7 +115,7 @@ func TestEventIndexPrefillFilter(t *testing.T) { }, { name: "match tipset cid", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, tipsetCid: cid14000, @@ -124,7 +125,7 @@ func TestEventIndexPrefillFilter(t *testing.T) { }, { name: "nomatch address", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, addresses: []address.Address{a2}, @@ -134,7 +135,7 @@ func TestEventIndexPrefillFilter(t *testing.T) { }, { name: "match address", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, addresses: []address.Address{a1}, @@ -144,124 +145,124 @@ func TestEventIndexPrefillFilter(t *testing.T) { }, { name: "match one entry", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, - keys: map[string][][]byte{ + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ "type": { []byte("approval"), }, - }, + }), }, te: events14000, want: oneCollectedEvent, }, { name: "match one entry with alternate values", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, - keys: map[string][][]byte{ + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ "type": { []byte("cancel"), []byte("propose"), []byte("approval"), }, - }, + }), }, te: events14000, want: oneCollectedEvent, }, { name: "nomatch one entry by missing value", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, - keys: map[string][][]byte{ + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ "type": { []byte("cancel"), []byte("propose"), }, - }, + }), }, te: events14000, want: noCollectedEvents, }, { name: "nomatch one entry by missing key", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, - keys: map[string][][]byte{ + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ "method": { []byte("approval"), }, - }, + }), }, te: events14000, want: noCollectedEvents, }, { name: "match one entry with multiple keys", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, - keys: map[string][][]byte{ + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ "type": { []byte("approval"), }, "signer": { []byte("addr1"), }, - }, + }), }, te: events14000, want: oneCollectedEvent, }, { name: "nomatch one entry with one mismatching key", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, - keys: map[string][][]byte{ + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ "type": { []byte("approval"), }, "approver": { []byte("addr1"), }, - }, + }), }, te: events14000, want: noCollectedEvents, }, { name: "nomatch one entry with one mismatching value", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, - keys: map[string][][]byte{ + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ "type": { []byte("approval"), }, "signer": { []byte("addr2"), }, - }, + }), }, te: events14000, want: noCollectedEvents, }, { name: "nomatch one entry with one unindexed key", - filter: &EventFilter{ + filter: &eventFilter{ minHeight: -1, maxHeight: -1, - keys: map[string][][]byte{ + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ "amount": { []byte("2988181"), }, - }, + }), }, te: events14000, want: noCollectedEvents, @@ -271,7 +272,7 @@ func TestEventIndexPrefillFilter(t *testing.T) { for _, tc := range testCases { tc := tc // appease lint t.Run(tc.name, func(t *testing.T) { - if err := ei.PrefillFilter(context.Background(), tc.filter); err != nil { + if err := ei.prefillFilter(context.Background(), tc.filter, false); err != nil { require.NoError(t, err, "prefill filter events") } @@ -280,3 +281,619 @@ func TestEventIndexPrefillFilter(t *testing.T) { }) } } + +func TestEventIndexPrefillFilterExcludeReverted(t *testing.T) { + rng := pseudo.New(pseudo.NewSource(299792458)) + a1 := randomF4Addr(t, rng) + a2 := randomF4Addr(t, rng) + a3 := randomF4Addr(t, rng) + + a1ID := abi.ActorID(1) + a2ID := abi.ActorID(2) + + addrMap := addressMap{} + addrMap.add(a1ID, a1) + addrMap.add(a2ID, a2) + + ev1 := fakeEvent( + a1ID, + []kv{ + {k: "type", v: []byte("approval")}, + {k: "signer", v: []byte("addr1")}, + }, + []kv{ + {k: "amount", v: []byte("2988181")}, + }, + ) + ev2 := fakeEvent( + a2ID, + []kv{ + {k: "type", v: []byte("approval")}, + {k: "signer", v: []byte("addr2")}, + }, + []kv{ + {k: "amount", v: []byte("2988182")}, + }, + ) + + st := newStore() + events := []*types.Event{ev1} + revertedEvents := []*types.Event{ev2} + em := executedMessage{ + msg: fakeMessage(randomF4Addr(t, rng), randomF4Addr(t, rng)), + rct: fakeReceipt(t, rng, st, events), + evs: events, + } + revertedEm := executedMessage{ + msg: fakeMessage(randomF4Addr(t, rng), randomF4Addr(t, rng)), + rct: fakeReceipt(t, rng, st, revertedEvents), + evs: revertedEvents, + } + + events14000 := buildTipSetEvents(t, rng, 14000, em) + revertedEvents14000 := buildTipSetEvents(t, rng, 14000, revertedEm) + cid14000, err := events14000.msgTS.Key().Cid() + require.NoError(t, err, "tipset cid") + reveredCID14000, err := revertedEvents14000.msgTS.Key().Cid() + require.NoError(t, err, "tipset cid") + + noCollectedEvents := []*CollectedEvent{} + oneCollectedEvent := []*CollectedEvent{ + { + Entries: ev1.Entries, + EmitterAddr: a1, + EventIdx: 0, + Reverted: false, + Height: 14000, + TipSetKey: events14000.msgTS.Key(), + MsgIdx: 0, + MsgCid: em.msg.Cid(), + }, + } + twoCollectedEvent := []*CollectedEvent{ + { + Entries: ev1.Entries, + EmitterAddr: a1, + EventIdx: 0, + Reverted: false, + Height: 14000, + TipSetKey: events14000.msgTS.Key(), + MsgIdx: 0, + MsgCid: em.msg.Cid(), + }, + { + Entries: ev2.Entries, + EmitterAddr: a2, + EventIdx: 0, + Reverted: true, + Height: 14000, + TipSetKey: revertedEvents14000.msgTS.Key(), + MsgIdx: 0, + MsgCid: revertedEm.msg.Cid(), + }, + } + oneCollectedRevertedEvent := []*CollectedEvent{ + { + Entries: ev2.Entries, + EmitterAddr: a2, + EventIdx: 0, + Reverted: true, + Height: 14000, + TipSetKey: revertedEvents14000.msgTS.Key(), + MsgIdx: 0, + MsgCid: revertedEm.msg.Cid(), + }, + } + + workDir, err := os.MkdirTemp("", "lotusevents") + require.NoError(t, err, "create temporary work directory") + + defer func() { + _ = os.RemoveAll(workDir) + }() + t.Logf("using work dir %q", workDir) + + dbPath := filepath.Join(workDir, "actorevents.db") + + ei, err := NewEventIndex(context.Background(), dbPath, nil) + require.NoError(t, err, "create event index") + if err := ei.CollectEvents(context.Background(), revertedEvents14000, false, addrMap.ResolveAddress); err != nil { + require.NoError(t, err, "collect reverted events") + } + if err := ei.CollectEvents(context.Background(), revertedEvents14000, true, addrMap.ResolveAddress); err != nil { + require.NoError(t, err, "revert reverted events") + } + if err := ei.CollectEvents(context.Background(), events14000, false, addrMap.ResolveAddress); err != nil { + require.NoError(t, err, "collect events") + } + + inclusiveTestCases := []struct { + name string + filter *eventFilter + te *TipSetEvents + want []*CollectedEvent + }{ + { + name: "nomatch tipset min height", + filter: &eventFilter{ + minHeight: 14001, + maxHeight: -1, + }, + te: events14000, + want: noCollectedEvents, + }, + { + name: "nomatch tipset max height", + filter: &eventFilter{ + minHeight: -1, + maxHeight: 13999, + }, + te: events14000, + want: noCollectedEvents, + }, + // { + // name: "match tipset min height", + // filter: &eventFilter{ + // minHeight: 14000, + // maxHeight: -1, + // }, + // te: events14000, + // want: twoCollectedEvent, + // }, + { + name: "match tipset cid", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + tipsetCid: cid14000, + }, + te: events14000, + want: oneCollectedEvent, + }, + { + name: "match tipset cid", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + tipsetCid: reveredCID14000, + }, + te: revertedEvents14000, + want: oneCollectedRevertedEvent, + }, + { + name: "nomatch address", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + addresses: []address.Address{a3}, + }, + te: events14000, + want: noCollectedEvents, + }, + { + name: "match address 2", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + addresses: []address.Address{a2}, + }, + te: revertedEvents14000, + want: oneCollectedRevertedEvent, + }, + { + name: "match address 1", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + addresses: []address.Address{a1}, + }, + te: events14000, + want: oneCollectedEvent, + }, + { + name: "match one entry", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + "type": { + []byte("approval"), + }, + }), + }, + te: events14000, + want: twoCollectedEvent, + }, + { + name: "match one entry with alternate values", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + "type": { + []byte("cancel"), + []byte("propose"), + []byte("approval"), + }, + }), + }, + te: events14000, + want: twoCollectedEvent, + }, + { + name: "nomatch one entry by missing value", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + "type": { + []byte("cancel"), + []byte("propose"), + }, + }), + }, + te: events14000, + want: noCollectedEvents, + }, + { + name: "nomatch one entry by missing key", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + "method": { + []byte("approval"), + }, + }), + }, + te: events14000, + want: noCollectedEvents, + }, + { + name: "match one entry with multiple keys", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + "type": { + []byte("approval"), + }, + "signer": { + []byte("addr1"), + }, + }), + }, + te: events14000, + want: oneCollectedEvent, + }, + { + name: "match one entry with multiple keys", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + "type": { + []byte("approval"), + }, + "signer": { + []byte("addr2"), + }, + }), + }, + te: revertedEvents14000, + want: oneCollectedRevertedEvent, + }, + { + name: "nomatch one entry with one mismatching key", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + "type": { + []byte("approval"), + }, + "approver": { + []byte("addr1"), + }, + }), + }, + te: events14000, + want: noCollectedEvents, + }, + { + name: "nomatch one entry with one mismatching value", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + "type": { + []byte("approval"), + }, + "signer": { + []byte("addr3"), + }, + }), + }, + te: events14000, + want: noCollectedEvents, + }, + { + name: "nomatch one entry with one unindexed key", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + "amount": { + []byte("2988181"), + }, + }), + }, + te: events14000, + want: noCollectedEvents, + }, + { + name: "nomatch one entry with one unindexed key", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + "amount": { + []byte("2988182"), + }, + }), + }, + te: events14000, + want: noCollectedEvents, + }, + } + + exclusiveTestCases := []struct { + name string + filter *eventFilter + te *TipSetEvents + want []*CollectedEvent + }{ + { + name: "nomatch tipset min height", + filter: &eventFilter{ + minHeight: 14001, + maxHeight: -1, + }, + te: events14000, + want: noCollectedEvents, + }, + { + name: "nomatch tipset max height", + filter: &eventFilter{ + minHeight: -1, + maxHeight: 13999, + }, + te: events14000, + want: noCollectedEvents, + }, + // { + // name: "match tipset min height", + // filter: &eventFilter{ + // minHeight: 14000, + // maxHeight: -1, + // }, + // te: events14000, + // want: oneCollectedEvent, + // }, + { + name: "match tipset cid", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + tipsetCid: cid14000, + }, + te: events14000, + want: oneCollectedEvent, + }, + // { + // name: "match tipset cid but reverted", + // filter: &eventFilter{ + // minHeight: -1, + // maxHeight: -1, + // tipsetCid: reveredCID14000, + // }, + // te: revertedEvents14000, + // want: noCollectedEvents, + // }, + { + name: "nomatch address", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + addresses: []address.Address{a3}, + }, + te: events14000, + want: noCollectedEvents, + }, + // { + // name: "nomatch address 2 but reverted", + // filter: &eventFilter{ + // minHeight: -1, + // maxHeight: -1, + // addresses: []address.Address{a2}, + // }, + // te: revertedEvents14000, + // want: noCollectedEvents, + // }, + { + name: "match address", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + addresses: []address.Address{a1}, + }, + te: events14000, + want: oneCollectedEvent, + }, + // { + // name: "match one entry", + // filter: &eventFilter{ + // minHeight: -1, + // maxHeight: -1, + // keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + // "type": { + // []byte("approval"), + // }, + // }), + // }, + // te: events14000, + // want: oneCollectedEvent, + // }, + // { + // name: "match one entry with alternate values", + // filter: &eventFilter{ + // minHeight: -1, + // maxHeight: -1, + // keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + // "type": { + // []byte("cancel"), + // []byte("propose"), + // []byte("approval"), + // }, + // }), + // }, + // te: events14000, + // want: oneCollectedEvent, + // }, + { + name: "nomatch one entry by missing value", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + "type": { + []byte("cancel"), + []byte("propose"), + }, + }), + }, + te: events14000, + want: noCollectedEvents, + }, + { + name: "nomatch one entry by missing key", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + "method": { + []byte("approval"), + }, + }), + }, + te: events14000, + want: noCollectedEvents, + }, + { + name: "match one entry with multiple keys", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + "type": { + []byte("approval"), + }, + "signer": { + []byte("addr1"), + }, + }), + }, + te: events14000, + want: oneCollectedEvent, + }, + { + name: "nomatch one entry with one mismatching key", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + "type": { + []byte("approval"), + }, + "approver": { + []byte("addr1"), + }, + }), + }, + te: events14000, + want: noCollectedEvents, + }, + // { + // name: "nomatch one entry with matching reverted value", + // filter: &eventFilter{ + // minHeight: -1, + // maxHeight: -1, + // keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + // "type": { + // []byte("approval"), + // }, + // "signer": { + // []byte("addr2"), + // }, + // }), + // }, + // te: events14000, + // want: noCollectedEvents, + // }, + { + name: "nomatch one entry with one mismatching value", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + "type": { + []byte("approval"), + }, + "signer": { + []byte("addr3"), + }, + }), + }, + te: events14000, + want: noCollectedEvents, + }, + { + name: "nomatch one entry with one unindexed key", + filter: &eventFilter{ + minHeight: -1, + maxHeight: -1, + keysWithCodec: keysToKeysWithCodec(map[string][][]byte{ + "amount": { + []byte("2988181"), + }, + }), + }, + te: events14000, + want: noCollectedEvents, + }, + } + + for _, tc := range inclusiveTestCases { + tc := tc // appease lint + t.Run(tc.name, func(t *testing.T) { + if err := ei.prefillFilter(context.Background(), tc.filter, false); err != nil { + require.NoError(t, err, "prefill filter events") + } + + coll := tc.filter.TakeCollectedEvents(context.Background()) + require.ElementsMatch(t, coll, tc.want, tc.name) + }) + } + + for _, tc := range exclusiveTestCases { + tc := tc // appease lint + t.Run(tc.name, func(t *testing.T) { + if err := ei.prefillFilter(context.Background(), tc.filter, true); err != nil { + require.NoError(t, err, "prefill filter events") + } + + coll := tc.filter.TakeCollectedEvents(context.Background()) + require.ElementsMatch(t, coll, tc.want, tc.name) + }) + } +} diff --git a/pkg/events/state/predicates.go b/pkg/events/state/predicates.go index 55031d280e..5585fe7fba 100644 --- a/pkg/events/state/predicates.go +++ b/pkg/events/state/predicates.go @@ -243,7 +243,7 @@ func (sp *StatePredicates) DealStateChangedForIDs(dealIds []abi.DealID) DiffDeal } existenceChanged := oldFound != newFound - valueChanged := (oldFound && newFound) && *oldDeal != *newDeal + valueChanged := (oldFound && newFound) && !oldDeal.Equals(newDeal) if existenceChanged || valueChanged { changedDeals[dealID] = market.DealStateChange{ID: dealID, From: oldDeal, To: newDeal} } diff --git a/pkg/events/state/predicates_test.go b/pkg/events/state/predicates_test.go index 877b376d95..91f835d39c 100644 --- a/pkg/events/state/predicates_test.go +++ b/pkg/events/state/predicates_test.go @@ -172,11 +172,11 @@ func TestMarketPredicates(t *testing.T) { require.Contains(t, changedDealIDs, abi.DealID(1)) require.Contains(t, changedDealIDs, abi.DealID(2)) deal1 := changedDealIDs[abi.DealID(1)] - if deal1.From.LastUpdatedEpoch != 2 || deal1.To.LastUpdatedEpoch != 3 { + if deal1.From.LastUpdatedEpoch() != 2 || deal1.To.LastUpdatedEpoch() != 3 { t.Fatal("Unexpected change to LastUpdatedEpoch") } deal2 := changedDealIDs[abi.DealID(2)] - if deal2.From.LastUpdatedEpoch != 5 || deal2.To != nil { + if deal2.From.LastUpdatedEpoch() != 5 || deal2.To != nil { t.Fatal("Expected To to be nil") } @@ -238,8 +238,8 @@ func TestMarketPredicates(t *testing.T) { require.Len(t, changedDeals.Modified, 1) require.Equal(t, abi.DealID(1), changedDeals.Modified[0].ID) - require.True(t, dealEquality(*newDeal1, *changedDeals.Modified[0].To)) - require.True(t, dealEquality(*oldDeal1, *changedDeals.Modified[0].From)) + require.True(t, dealEquality(*newDeal1, changedDeals.Modified[0].To)) + require.True(t, dealEquality(*oldDeal1, changedDeals.Modified[0].From)) require.Equal(t, abi.DealID(2), changedDeals.Removed[0].ID) }) @@ -571,7 +571,7 @@ func newSectorPreCommitInfo(sectorNo abi.SectorNumber, sealed cid.Cid, expiratio } func dealEquality(expected market2.DealState, actual market.DealState) bool { - return expected.LastUpdatedEpoch == actual.LastUpdatedEpoch && - expected.SectorStartEpoch == actual.SectorStartEpoch && - expected.SlashEpoch == actual.SlashEpoch + return expected.LastUpdatedEpoch == actual.LastUpdatedEpoch() && + expected.SectorStartEpoch == actual.SectorStartEpoch() && + expected.SlashEpoch == actual.SlashEpoch() } diff --git a/pkg/fork/fork.go b/pkg/fork/fork.go index ccc15b68e2..9f57bbf840 100644 --- a/pkg/fork/fork.go +++ b/pkg/fork/fork.go @@ -38,6 +38,7 @@ import ( nv18 "github.com/filecoin-project/go-state-types/builtin/v10/migration" nv19 "github.com/filecoin-project/go-state-types/builtin/v11/migration" nv21 "github.com/filecoin-project/go-state-types/builtin/v12/migration" + nv22 "github.com/filecoin-project/go-state-types/builtin/v13/migration" nv17 "github.com/filecoin-project/go-state-types/builtin/v9/migration" "github.com/filecoin-project/go-state-types/migration" "github.com/filecoin-project/specs-actors/actors/migration/nv3" @@ -412,6 +413,18 @@ func DefaultUpgradeSchedule(cf *ChainFork, upgradeHeight *config.ForkUpgradeConf Network: network.Version21, Migration: cf.buildUpgradeActorsV12MinerFix(calibnetv12BuggyMinerCID2, calibnetv12CorrectManifestCID1), }, + { + Height: upgradeHeight.UpgradeDragonHeight, + Network: network.Version22, + Migration: cf.UpgradeActorsV13, + PreMigrations: []PreMigration{{ + PreMigration: cf.PreUpgradeActorsV13, + StartWithin: 120, + DontStartWithin: 15, + StopWithin: 10, + }}, + Expensive: true, + }, } for _, u := range updates { @@ -671,10 +684,7 @@ func (c *ChainFork) HandleStateForks(ctx context.Context, root cid.Cid, height a log.Errorw("FAILED migration", "height", height, "from", root, "error", err) return cid.Undef, err } - // Yes, we update the cache, even for the final upgrade epoch. Why? Reverts. This - // can save us a _lot_ of time because very few actors will have changed if we - // do a small revert then need to re-run the migration. - u.cache.Update(tmpCache) + log.Warnw("COMPLETED migration", "height", height, "from", root, @@ -2824,6 +2834,123 @@ func (c *ChainFork) upgradeActorsV12Common( return newRoot, nil } +func (c *ChainFork) PreUpgradeActorsV13(ctx context.Context, + cache MigrationCache, + root cid.Cid, + epoch abi.ChainEpoch, + ts *types.TipSet, +) error { + // Use half the CPUs for pre-migration, but leave at least 3. + workerCount := MigrationMaxWorkerCount + if workerCount <= 4 { + workerCount = 1 + } else { + workerCount /= 2 + } + + nv := c.GetNetworkVersion(ctx, epoch) + lbts, lbRoot, err := c.cr.GetLookbackTipSetForRound(ctx, ts, epoch, nv) + if err != nil { + return fmt.Errorf("error getting lookback ts for premigration: %w", err) + } + + config := migration.Config{ + MaxWorkers: uint(workerCount), + ProgressLogPeriod: time.Minute * 5, + UpgradeEpoch: c.forkUpgrade.UpgradeDragonHeight, + } + + _, err = c.upgradeActorsV13Common(ctx, cache, lbRoot, epoch, lbts, config) + return err +} + +func (c *ChainFork) UpgradeActorsV13(ctx context.Context, + cache MigrationCache, + root cid.Cid, + epoch abi.ChainEpoch, + ts *types.TipSet, +) (cid.Cid, error) { + // Use all the CPUs except 2. + workerCount := MigrationMaxWorkerCount - 3 + if workerCount <= 0 { + workerCount = 1 + } + config := migration.Config{ + MaxWorkers: uint(workerCount), + JobQueueSize: 1000, + ResultQueueSize: 100, + ProgressLogPeriod: 10 * time.Second, + UpgradeEpoch: c.forkUpgrade.UpgradeDragonHeight, + } + newRoot, err := c.upgradeActorsV13Common(ctx, cache, root, epoch, ts, config) + if err != nil { + return cid.Undef, fmt.Errorf("migrating actors v11 state: %w", err) + } + return newRoot, nil +} + +func (c *ChainFork) upgradeActorsV13Common(ctx context.Context, + cache MigrationCache, + root cid.Cid, + epoch abi.ChainEpoch, + ts *types.TipSet, + config migration.Config, +) (cid.Cid, error) { + writeStore := blockstoreutil.NewAutobatch(ctx, c.bs, units.GiB/4) + adtStore := adt.WrapStore(ctx, cbor.NewCborStore(writeStore)) + + // ensure that the manifest is loaded in the blockstore + if err := actors.LoadBundles(ctx, writeStore, actorstypes.Version13); err != nil { + return cid.Undef, fmt.Errorf("failed to load manifest bundle: %w", err) + } + + // Load the state root. + var stateRoot vmstate.StateRoot + if err := adtStore.Get(ctx, root, &stateRoot); err != nil { + return cid.Undef, fmt.Errorf("failed to decode state root: %w", err) + } + + if stateRoot.Version != vmstate.StateTreeVersion5 { + return cid.Undef, fmt.Errorf( + "expected state root version 5 for actors v13 upgrade, got %d", + stateRoot.Version, + ) + } + + manifest, ok := actors.GetManifest(actorstypes.Version13) + if !ok { + return cid.Undef, fmt.Errorf("no manifest CID for v13 upgrade") + } + + // Perform the migration + newHamtRoot, err := nv22.MigrateStateTree(ctx, adtStore, manifest, stateRoot.Actors, epoch, config, + migrationLogger{}, cache) + if err != nil { + return cid.Undef, fmt.Errorf("upgrading to actors v11: %w", err) + } + + // Persist the result. + newRoot, err := adtStore.Put(ctx, &vmstate.StateRoot{ + Version: vmstate.StateTreeVersion5, + Actors: newHamtRoot, + Info: stateRoot.Info, + }) + if err != nil { + return cid.Undef, fmt.Errorf("failed to persist new state root: %w", err) + } + + // Persists the new tree and shuts down the flush worker + if err := writeStore.Flush(ctx); err != nil { + return cid.Undef, fmt.Errorf("writeStore flush failed: %w", err) + } + + if err := writeStore.Shutdown(ctx); err != nil { + return cid.Undef, fmt.Errorf("writeStore shutdown failed: %w", err) + } + + return newRoot, nil +} + // //////////////////// func (c *ChainFork) buildUpgradeActorsV12MinerFix(oldBuggyMinerCID, newManifestCID cid.Cid) func(ctx context.Context, cache MigrationCache, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) { return func(ctx context.Context, cache MigrationCache, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) { diff --git a/pkg/gen/genesis/genesis.go b/pkg/gen/genesis/genesis.go index b67ba11a13..b27a14ed74 100644 --- a/pkg/gen/genesis/genesis.go +++ b/pkg/gen/genesis/genesis.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" + "github.com/filecoin-project/venus/pkg/consensus/chainselector" "github.com/filecoin-project/venus/pkg/consensusfault" "github.com/filecoin-project/venus/pkg/fork" "github.com/filecoin-project/venus/pkg/fvm" @@ -591,7 +592,7 @@ func MakeGenesisBlock(ctx context.Context, rep repo.Repo, bs bstore.Blockstore, } // temp chainstore - cs := chain.NewStore(rep.ChainDatastore(), bs, cid.Undef, chain.NewMockCirculatingSupplyCalculator()) + cs := chain.NewStore(rep.ChainDatastore(), bs, cid.Undef, chain.NewMockCirculatingSupplyCalculator(), chainselector.Weight) // Verify PreSealed Data stateroot, err = VerifyPreSealedData(ctx, cs, stateroot, template, keyIDs, template.NetworkVersion, para) diff --git a/pkg/gen/genesis/miners.go b/pkg/gen/genesis/miners.go index 77506838ed..d1759ddddd 100644 --- a/pkg/gen/genesis/miners.go +++ b/pkg/gen/genesis/miners.go @@ -410,13 +410,33 @@ func SetupStorageMiners(ctx context.Context, // Commit sectors { for pi, preseal := range m.Sectors { - params := &minertypes.SectorPreCommitInfo{ - SealProof: preseal.ProofType, - SectorNumber: preseal.SectorID, - SealedCID: preseal.CommR, - SealRandEpoch: -1, - DealIDs: []abi.DealID{minerInfos[i].dealIDs[pi]}, - Expiration: minerInfos[i].presealExp, // TODO: Allow setting externally! + var paramEnc []byte + var preCommitMethodNum abi.MethodNum + if nv >= network.Version22 { + paramEnc = mustEnc(&miner.PreCommitSectorBatchParams2{ + Sectors: []miner.SectorPreCommitInfo{ + { + SealProof: preseal.ProofType, + SectorNumber: preseal.SectorID, + SealedCID: preseal.CommR, + SealRandEpoch: -1, + DealIDs: []abi.DealID{minerInfos[i].dealIDs[pi]}, + Expiration: minerInfos[i].presealExp, // TODO: Allow setting externally! + UnsealedCid: &preseal.CommD, + }, + }, + }) + preCommitMethodNum = builtintypes.MethodsMiner.PreCommitSectorBatch2 + } else { + paramEnc = mustEnc(&minertypes.SectorPreCommitInfo{ + SealProof: preseal.ProofType, + SectorNumber: preseal.SectorID, + SealedCID: preseal.CommR, + SealRandEpoch: -1, + DealIDs: []abi.DealID{minerInfos[i].dealIDs[pi]}, + Expiration: minerInfos[i].presealExp, // TODO: Allow setting externally! + }) + preCommitMethodNum = builtintypes.MethodsMiner.PreCommitSector } sectorWeight := minerInfos[i].sectorWeight[pi] @@ -504,7 +524,7 @@ func SetupStorageMiners(ctx context.Context, pledge = big.Add(pcd, pledge) fmt.Println(types.FIL(pledge)) - _, err = doExecValue(ctx, genesisVM, minerInfos[i].maddr, m.Worker, pledge, builtintypes.MethodsMiner.PreCommitSector, mustEnc(params)) + _, err = doExecValue(ctx, genesisVM, minerInfos[i].maddr, m.Worker, pledge, preCommitMethodNum, paramEnc) if err != nil { return cid.Undef, fmt.Errorf("failed to confirm presealed sectors: %w", err) } diff --git a/pkg/genesis/init.go b/pkg/genesis/init.go index d1f19c36f2..fee9a3ca6a 100644 --- a/pkg/genesis/init.go +++ b/pkg/genesis/init.go @@ -5,6 +5,7 @@ import ( "github.com/filecoin-project/venus/pkg/chain" "github.com/filecoin-project/venus/pkg/config" + "github.com/filecoin-project/venus/pkg/consensus/chainselector" blockstoreutil "github.com/filecoin-project/venus/venus-shared/blockstore" "github.com/filecoin-project/venus/venus-shared/types" @@ -29,7 +30,7 @@ func Init(ctx context.Context, r repo.Repo, bs blockstoreutil.Blockstore, cst cb } // todo give fork params - chainStore := chain.NewStore(r.ChainDatastore(), bs, genesis.Cid(), chain.NewCirculatingSupplyCalculator(bs, genesis.Cid(), config.DefaultForkUpgradeParam)) + chainStore := chain.NewStore(r.ChainDatastore(), bs, genesis.Cid(), chain.NewCirculatingSupplyCalculator(bs, genesis.Cid(), config.DefaultForkUpgradeParam), chainselector.Weight) // Persist the genesis tipset to the repo. genTsas := &chain.TipSetMetadata{ diff --git a/pkg/net/blocksub/validator_test.go b/pkg/net/blocksub/validator_test.go index cc2a7ac88b..5b4efbb9a9 100644 --- a/pkg/net/blocksub/validator_test.go +++ b/pkg/net/blocksub/validator_test.go @@ -28,8 +28,8 @@ func TestBlockTopicValidator(t *testing.T) { builder := chain.NewBuilder(t, address.Undef) pid1 := th.RequireIntPeerID(t, 1) - goodBlk := builder.BuildOnBlock(ctx, nil, func(b *chain.BlockBuilder) {}) - badBlk := builder.BuildOnBlock(ctx, nil, func(b *chain.BlockBuilder) { + goodBlk := builder.BuildOnBlock(ctx, builder.Genesis().At(0), func(b *chain.BlockBuilder) {}) + badBlk := builder.BuildOnBlock(ctx, builder.Genesis().At(0), func(b *chain.BlockBuilder) { b.IncHeight(1) }) diff --git a/pkg/net/exchange/client.go b/pkg/net/exchange/client.go index ff6519584e..d4f6413ac9 100644 --- a/pkg/net/exchange/client.go +++ b/pkg/net/exchange/client.go @@ -376,7 +376,7 @@ func (c *client) sendRequestToPeer(ctx context.Context, peer peer.ID, req *excha defer span.End() if span.IsRecordingEvents() { span.AddAttributes( - trace.StringAttribute("peer", peer.Pretty()), + trace.StringAttribute("peer", peer.String()), ) } defer func() { diff --git a/pkg/net/helloprotocol/cbor_gen.go b/pkg/net/helloprotocol/cbor_gen.go index 64f737aa49..a7af23b9c0 100644 --- a/pkg/net/helloprotocol/cbor_gen.go +++ b/pkg/net/helloprotocol/cbor_gen.go @@ -34,7 +34,7 @@ func (t *HelloMessage) MarshalCBOR(w io.Writer) error { } // t.HeaviestTipSetCids ([]cid.Cid) (slice) - if len(t.HeaviestTipSetCids) > cbg.MaxLength { + if len(t.HeaviestTipSetCids) > 8192 { return xerrors.Errorf("Slice value in field t.HeaviestTipSetCids was too long") } @@ -104,7 +104,7 @@ func (t *HelloMessage) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.HeaviestTipSetCids: array too large (%d)", extra) } @@ -135,16 +135,16 @@ func (t *HelloMessage) UnmarshalCBOR(r io.Reader) (err error) { t.HeaviestTipSetCids[i] = c } + } } - // t.HeaviestTipSetHeight (abi.ChainEpoch) (int64) { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -222,6 +222,7 @@ func (t *LatencyMessage) MarshalCBOR(w io.Writer) error { return err } } + return nil } @@ -251,10 +252,10 @@ func (t *LatencyMessage) UnmarshalCBOR(r io.Reader) (err error) { // t.TArrival (int64) (int64) { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -276,10 +277,10 @@ func (t *LatencyMessage) UnmarshalCBOR(r io.Reader) (err error) { // t.TSent (int64) (int64) { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) diff --git a/pkg/net/helloprotocol/hello_protocol.go b/pkg/net/helloprotocol/hello_protocol.go index 5862840d8e..5325f2017c 100644 --- a/pkg/net/helloprotocol/hello_protocol.go +++ b/pkg/net/helloprotocol/hello_protocol.go @@ -9,8 +9,11 @@ import ( "github.com/filecoin-project/venus/pkg/chain" "github.com/filecoin-project/venus/pkg/net/exchange" "github.com/filecoin-project/venus/pkg/net/peermgr" + "github.com/filecoin-project/venus/venus-shared/libp2p/hello" "github.com/filecoin-project/venus/venus-shared/types" + "github.com/libp2p/go-libp2p/core/event" "github.com/libp2p/go-libp2p/core/peer" + "github.com/libp2p/go-libp2p/p2p/host/eventbus" "github.com/filecoin-project/go-state-types/abi" fbig "github.com/filecoin-project/go-state-types/big" @@ -18,7 +21,6 @@ import ( logging "github.com/ipfs/go-log/v2" "github.com/libp2p/go-libp2p/core/host" net "github.com/libp2p/go-libp2p/core/network" - ma "github.com/multiformats/go-multiaddr" "github.com/ipfs-force-community/metrics" ) @@ -28,6 +30,8 @@ var log = logging.Logger("/fil/hello") // helloProtocolID is the libp2p protocol identifier for the hello protocol. const helloProtocolID = "/fil/hello/1.0.0" +const helloTimeout = time.Second * 10 + var ( genesisErrCt = metrics.NewCounter("hello_genesis_error", "Number of errors encountered in hello protocol due to incorrect genesis block") helloMsgErrCt = metrics.NewCounter("hello_message_error", "Number of errors encountered in hello protocol due to malformed message") @@ -97,15 +101,41 @@ func NewHelloProtocolHandler(h host.Host, } // Register registers the handler with the network. -func (h *HelloProtocolHandler) Register(peerDiscoveredCallback PeerDiscoveredCallback) { +func (h *HelloProtocolHandler) Register(ctx context.Context, peerDiscoveredCallback PeerDiscoveredCallback) error { // register callbacks h.peerDiscovered = peerDiscoveredCallback // register a handle for when a new connection against someone is created h.host.SetStreamHandler(helloProtocolID, h.handleNewStream) - // register for connection notifications - h.host.Network().Notify((*helloProtocolNotifiee)(h)) + sub, err := h.host.EventBus().Subscribe(new(event.EvtPeerIdentificationCompleted), eventbus.BufSize(1024)) + if err != nil { + return fmt.Errorf("failed to subscribe to event bus: %w", err) + } + go func() { + // We want to get information on connected peers, we don't want to trigger new connections. + ctx := net.WithNoDial(ctx, "filecoin hello") + for evt := range sub.Out() { + pic := evt.(event.EvtPeerIdentificationCompleted) + // We just finished identifying the peer, that means we should know what + // protocols it speaks. Check if it speeks the Filecoin hello protocol + // before continuing. + if p, _ := h.host.Peerstore().FirstSupportedProtocol(pic.Peer, hello.ProtocolID); p != hello.ProtocolID { + continue + } + + go func() { + err := h.sayHello(ctx, pic.Peer) + if err != nil { + protos, _ := h.host.Peerstore().GetProtocols(pic.Peer) + agent, _ := h.host.Peerstore().Get(pic.Peer, "AgentVersion") + log.Warnw("failed to say hello", "error", err, "peer", pic.Peer, "supported", protos, "agent", agent) + } + }() + } + }() + + return nil } func (h *HelloProtocolHandler) handleNewStream(s net.Stream) { @@ -200,19 +230,6 @@ func (h *HelloProtocolHandler) loadLocalFullTipset(ctx context.Context, tsk type // ErrBadGenesis is the error returned when a mismatch in genesis blocks happens. var ErrBadGenesis = fmt.Errorf("bad genesis block") -func (h *HelloProtocolHandler) getOurHelloMessage() (*HelloMessage, error) { - heaviest := h.chainStore.GetHead() - height := heaviest.Height() - weight := heaviest.ParentWeight() - - return &HelloMessage{ - GenesisHash: h.genesis, - HeaviestTipSetCids: heaviest.Cids(), - HeaviestTipSetHeight: height, - HeaviestTipSetWeight: weight, - }, nil -} - func (h *HelloProtocolHandler) receiveHello(ctx context.Context, s net.Stream) (*HelloMessage, error) { var hello HelloMessage err := hello.UnmarshalCBOR(s) @@ -228,112 +245,99 @@ func (h *HelloProtocolHandler) receiveLatency(ctx context.Context, s net.Stream) return &latency, nil } -// sendHello send a hello message on stream `s`. -func (h *HelloProtocolHandler) sendHello(s net.Stream) error { - msg, err := h.getOurHelloMessage() - if err != nil { - return err - } +// responding to latency +func sendLatency(msg *LatencyMessage, s net.Stream) error { buf := new(bytes.Buffer) if err := msg.MarshalCBOR(buf); err != nil { return err } - n, err := s.Write(buf.Bytes()) if err != nil { return err } if n != buf.Len() { - return fmt.Errorf("could not write all hello message bytes") + return fmt.Errorf("could not write all latency message bytes") } return nil } -// responding to latency -func sendLatency(msg *LatencyMessage, s net.Stream) error { +func (h *HelloProtocolHandler) sayHello(ctx context.Context, peerID peer.ID) error { + // add timeout + ctx, cancel := context.WithTimeout(ctx, helloTimeout) + defer cancel() + + s, err := h.host.NewStream(ctx, peerID, helloProtocolID) + if err != nil { + // If peer does not do hello keep connection open + return err + } + defer func() { _ = s.Close() }() + + t0 := time.Now() + // send out the hello message + err = h.sendHello(s) + if err != nil { + // Don't close connection for failed hello protocol impl + return fmt.Errorf("failed to send hello handshake: %s", err) + } + // now receive latency message + lmsg, err := h.receiveLatency(ctx, s) + if err != nil { + return fmt.Errorf("failed to receive hello latency msg: %s", err) + } + + t3 := time.Now() + lat := t3.Sub(t0) + // add to peer tracker + h.peerMgr.SetPeerLatency(s.Conn().RemotePeer(), lat) + + if err == nil { + if lmsg.TArrival != 0 && lmsg.TSent != 0 { + t1 := time.Unix(0, lmsg.TArrival) + t2 := time.Unix(0, lmsg.TSent) + offset := t0.Sub(t1) + t3.Sub(t2) + offset /= 2 + if offset > 5*time.Second || offset < -5*time.Second { + log.Infow("time offset", "offset", offset.Seconds(), "peerid", peerID) + } + } + } + + return err +} + +// sendHello send a hello message on stream `s`. +func (h *HelloProtocolHandler) sendHello(s net.Stream) error { + msg, err := h.getOurHelloMessage() + if err != nil { + return err + } + log.Debug("Sending hello message: ", msg.HeaviestTipSetCids, msg.HeaviestTipSetHeight, msg.GenesisHash) + buf := new(bytes.Buffer) if err := msg.MarshalCBOR(buf); err != nil { return err } + n, err := s.Write(buf.Bytes()) if err != nil { return err } if n != buf.Len() { - return fmt.Errorf("could not write all latency message bytes") + return fmt.Errorf("could not write all hello message bytes") } return nil } -// Note: hide `net.Notifyee` impl using a new-type -type helloProtocolNotifiee HelloProtocolHandler - -const helloTimeout = time.Second * 10 - -func (hn *helloProtocolNotifiee) asHandler() *HelloProtocolHandler { - return (*HelloProtocolHandler)(hn) -} - -// -// `net.Notifyee` impl for `helloNotify` -// - -func (hn *helloProtocolNotifiee) Connected(n net.Network, c net.Conn) { - // Connected is invoked when a connection is made to a libp2p node. - // - // - open stream on connection - // - send HelloMessage` on stream - // - read LatencyMessage response on stream - // - // Terminate the connection if it has a different genesis block - go func() { - // add timeout - ctx, cancel := context.WithTimeout(context.Background(), helloTimeout) - defer cancel() - s, err := hn.asHandler().host.NewStream(ctx, c.RemotePeer(), helloProtocolID) - if err != nil { - // If peer does not do hello keep connection open - return - } - defer func() { _ = s.Close() }() - - t0 := time.Now() - // send out the hello message - err = hn.asHandler().sendHello(s) - if err != nil { - log.Debugf("failed to send hello handshake to peer %s: %s", c.RemotePeer(), err) - // Don't close connection for failed hello protocol impl - return - } - - // now receive latency message - lmsg, err := hn.asHandler().receiveLatency(ctx, s) - if err != nil { - log.Debugf("failed to receive hello latency msg from peer %s: %s", c.RemotePeer(), err) - return - } +func (h *HelloProtocolHandler) getOurHelloMessage() (*HelloMessage, error) { + heaviest := h.chainStore.GetHead() + height := heaviest.Height() + weight := heaviest.ParentWeight() - t3 := time.Now() - lat := t3.Sub(t0) - // add to peer tracker - hn.peerMgr.SetPeerLatency(s.Conn().RemotePeer(), lat) - - if err == nil { - if lmsg.TArrival != 0 && lmsg.TSent != 0 { - t1 := time.Unix(0, lmsg.TArrival) - t2 := time.Unix(0, lmsg.TSent) - offset := t0.Sub(t1) + t3.Sub(t2) - offset /= 2 - if offset > 5*time.Second || offset < -5*time.Second { - log.Infow("time offset", "offset", offset.Seconds(), "peerid", c.RemotePeer().String()) - } - } - } - }() + return &HelloMessage{ + GenesisHash: h.genesis, + HeaviestTipSetCids: heaviest.Cids(), + HeaviestTipSetHeight: height, + HeaviestTipSetWeight: weight, + }, nil } - -func (hn *helloProtocolNotifiee) Listen(n net.Network, a ma.Multiaddr) { /* empty */ } -func (hn *helloProtocolNotifiee) ListenClose(n net.Network, a ma.Multiaddr) { /* empty */ } -func (hn *helloProtocolNotifiee) Disconnected(n net.Network, c net.Conn) { /* empty */ } -func (hn *helloProtocolNotifiee) OpenedStream(n net.Network, s net.Stream) { /* empty */ } -func (hn *helloProtocolNotifiee) ClosedStream(n net.Network, s net.Stream) { /* empty */ } diff --git a/pkg/net/helloprotocol/hello_protocol_test.go b/pkg/net/helloprotocol/hello_protocol_test.go index 4230a59e7f..3644620105 100644 --- a/pkg/net/helloprotocol/hello_protocol_test.go +++ b/pkg/net/helloprotocol/hello_protocol_test.go @@ -66,8 +66,10 @@ func TestHelloHandshake(t *testing.T) { require.NoError(t, err) // stm: @DISCOVERY_HELLO_REGISTER_001 - helloprotocol.NewHelloProtocolHandler(a, aPeerMgr, nil, oldStore, mstore, genesisA.Blocks()[0].Cid(), time.Second*30).Register(msc1.HelloCallback) - helloprotocol.NewHelloProtocolHandler(b, aPeerMgr, nil, store, mstore, genesisA.Blocks()[0].Cid(), time.Second*30).Register(msc2.HelloCallback) + err = helloprotocol.NewHelloProtocolHandler(a, aPeerMgr, nil, oldStore, mstore, genesisA.Blocks()[0].Cid(), time.Second*30).Register(ctx, msc1.HelloCallback) + require.NoError(t, err) + err = helloprotocol.NewHelloProtocolHandler(b, aPeerMgr, nil, store, mstore, genesisA.Blocks()[0].Cid(), time.Second*30).Register(ctx, msc2.HelloCallback) + require.NoError(t, err) msc1.On("HelloCallback", b.ID(), heavy2.Key()).Return() msc2.On("HelloCallback", a.ID(), heavy1.Key()).Return() @@ -115,13 +117,13 @@ func TestHelloBadGenesis(t *testing.T) { store := builder.Store() mstore := builder.Mstore() - genesisA := builder.AppendOn(ctx, types.UndefTipSet, 1) + genesisA := builder.Genesis() heavy1 := builder.AppendOn(ctx, genesisA, 1) heavy2 := builder.AppendOn(ctx, heavy1, 1) _ = store.SetHead(ctx, heavy2) builder2 := chain.NewBuilder(t, address.Undef) - genesisB := builder2.Build(ctx, types.UndefTipSet, 1, func(b *chain.BlockBuilder, i int) { + genesisB := builder2.Build(ctx, builder2.Genesis(), 1, func(b *chain.BlockBuilder, i int) { b.SetTicket([]byte{1, 3, 4, 5, 6, 1, 3, 6, 7, 8}) }) @@ -132,8 +134,10 @@ func TestHelloBadGenesis(t *testing.T) { peerMgr, err := mockPeerMgr(ctx, t, a) require.NoError(t, err) - helloprotocol.NewHelloProtocolHandler(a, peerMgr, nil, store, mstore, genesisA.Blocks()[0].Cid(), time.Second*30).Register(msc1.HelloCallback) - helloprotocol.NewHelloProtocolHandler(b, peerMgr, nil, builder2.Store(), builder2.Mstore(), genesisB.Blocks()[0].Cid(), time.Second*30).Register(msc2.HelloCallback) + err = helloprotocol.NewHelloProtocolHandler(a, peerMgr, nil, store, mstore, genesisA.Blocks()[0].Cid(), time.Second*30).Register(ctx, msc1.HelloCallback) + require.NoError(t, err) + err = helloprotocol.NewHelloProtocolHandler(b, peerMgr, nil, builder2.Store(), builder2.Mstore(), genesisB.Blocks()[0].Cid(), time.Second*30).Register(ctx, msc2.HelloCallback) + require.NoError(t, err) msc1.On("HelloCallback", mock.Anything, mock.Anything, mock.Anything).Return() msc2.On("HelloCallback", mock.Anything, mock.Anything, mock.Anything).Return() @@ -178,8 +182,10 @@ func TestHelloMultiBlock(t *testing.T) { peerMgr, err := mockPeerMgr(ctx, t, a) require.NoError(t, err) - helloprotocol.NewHelloProtocolHandler(a, peerMgr, nil, oldStore, mstore, genesisTipset.At(0).Cid(), time.Second*30).Register(msc1.HelloCallback) - helloprotocol.NewHelloProtocolHandler(b, peerMgr, nil, store, mstore, genesisTipset.At(0).Cid(), time.Second*30).Register(msc2.HelloCallback) + err = helloprotocol.NewHelloProtocolHandler(a, peerMgr, nil, oldStore, mstore, genesisTipset.At(0).Cid(), time.Second*30).Register(ctx, msc1.HelloCallback) + require.NoError(t, err) + err = helloprotocol.NewHelloProtocolHandler(b, peerMgr, nil, store, mstore, genesisTipset.At(0).Cid(), time.Second*30).Register(ctx, msc2.HelloCallback) + require.NoError(t, err) msc1.On("HelloCallback", b.ID(), heavy2.Key()).Return() msc2.On("HelloCallback", a.ID(), heavy1.Key()).Return() diff --git a/pkg/paychmgr/paych_test.go b/pkg/paychmgr/paych_test.go index a12c562ccc..22e5423f15 100644 --- a/pkg/paychmgr/paych_test.go +++ b/pkg/paychmgr/paych_test.go @@ -14,9 +14,9 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/specs-actors/v2/actors/builtin" - paych2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/paych" tutils "github.com/filecoin-project/specs-actors/v6/support/testing" crypto2 "github.com/filecoin-project/venus/pkg/crypto" @@ -643,7 +643,7 @@ func TestCheckSpendable(t *testing.T) { // Check that the secret was passed through correctly lastCall := s.mock.getLastCall() - var p paych2.UpdateChannelStateParams + var p paychtypes.UpdateChannelStateParams err = p.UnmarshalCBOR(bytes.NewReader(lastCall.Params)) require.NoError(t, err) require.Equal(t, secret, p.Secret) @@ -698,7 +698,7 @@ func TestSubmitVoucher(t *testing.T) { // Check that the secret was passed through correctly msg := s.mock.pushedMessages(submitCid) - var p paych2.UpdateChannelStateParams + var p paychtypes.UpdateChannelStateParams err = p.UnmarshalCBOR(bytes.NewReader(msg.Message.Params)) require.NoError(t, err) @@ -710,7 +710,7 @@ func TestSubmitVoucher(t *testing.T) { require.NoError(t, err) msg = s.mock.pushedMessages(submitCid) - var p3 paych2.UpdateChannelStateParams + var p3 paychtypes.UpdateChannelStateParams err = p3.UnmarshalCBOR(bytes.NewReader(msg.Message.Params)) require.NoError(t, err) diff --git a/pkg/state/tree/state.go b/pkg/state/tree/state.go index 6b58f7da57..91b0f40470 100644 --- a/pkg/state/tree/state.go +++ b/pkg/state/tree/state.go @@ -143,7 +143,7 @@ func VersionForNetwork(ver network.Version) (StateTreeVersion, error) { return StateTreeVersion3, nil case network.Version13, network.Version14, network.Version15, network.Version16, network.Version17: return StateTreeVersion4, nil - case network.Version18, network.Version19, network.Version20, network.Version21: + case network.Version18, network.Version19, network.Version20, network.Version21, network.Version22: return StateTreeVersion5, nil default: panic(fmt.Sprintf("unsupported network version %d", ver)) diff --git a/pkg/state/view.go b/pkg/state/view.go index 06c464e2c7..7b56ff0f28 100644 --- a/pkg/state/view.go +++ b/pkg/state/view.go @@ -343,7 +343,7 @@ func (v *View) MarketDealProposal(ctx context.Context, dealID abi.DealID) (marke } // NOTE: exposes on-chain structures directly for storage FSM and market module interfaces. -func (v *View) MarketDealState(ctx context.Context, dealID abi.DealID) (*market.DealState, bool, error) { +func (v *View) MarketDealState(ctx context.Context, dealID abi.DealID) (market.DealState, bool, error) { marketState, err := v.LoadMarketState(ctx) if err != nil { return nil, false, err @@ -439,7 +439,7 @@ func (v *View) StateMarketStorageDeal(ctx context.Context, dealID abi.DealID) (* return &types.MarketDeal{ Proposal: *dealProposal, - State: *dealState, + State: types.MakeDealState(dealState), }, nil } @@ -647,7 +647,7 @@ func (v *View) StateMarketDeals(ctx context.Context, tsk types.TipSetKey) (map[s } out[strconv.FormatInt(int64(dealID), 10)] = &types.MarketDeal{ Proposal: d, - State: *s, + State: types.MakeDealState(s), } return nil }); err != nil { diff --git a/pkg/testhelpers/test_daemon.go b/pkg/testhelpers/test_daemon.go index 5f05eff151..6e7942d2ec 100644 --- a/pkg/testhelpers/test_daemon.go +++ b/pkg/testhelpers/test_daemon.go @@ -396,9 +396,9 @@ func (td *TestDaemon) WaitForAPI() error { if err == nil { return nil } - time.Sleep(time.Millisecond * 100) + time.Sleep(time.Second * 20) } - return fmt.Errorf("filecoin node failed to come online in given time period (10 seconds); last err = %s", err) + return fmt.Errorf("filecoin node failed to come online in given time period (20 seconds); last err = %s", err) } // CreateStorageMinerAddr issues a new message to the network, mines the message diff --git a/pkg/vm/dispatch/cbor_gen.go b/pkg/vm/dispatch/cbor_gen.go index 2c91f74ca5..4744c3cef2 100644 --- a/pkg/vm/dispatch/cbor_gen.go +++ b/pkg/vm/dispatch/cbor_gen.go @@ -33,7 +33,7 @@ func (t *SimpleParams) MarshalCBOR(w io.Writer) error { } // t.Name (string) (string) - if len(t.Name) > cbg.MaxLength { + if len(t.Name) > 8192 { return xerrors.Errorf("Value in field t.Name was too long") } @@ -72,7 +72,7 @@ func (t *SimpleParams) UnmarshalCBOR(r io.Reader) (err error) { // t.Name (string) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } diff --git a/pkg/vm/register/default.go b/pkg/vm/register/default.go index 3e7cb48e71..c2b3a55eac 100644 --- a/pkg/vm/register/default.go +++ b/pkg/vm/register/default.go @@ -42,6 +42,7 @@ func GetDefaultActros() *dispatch.CodeLoader { DefaultActorBuilder.AddMany(actorstypes.Version10, dispatch.ActorsVersionPredicate(actorstypes.Version10), builtin.MakeRegistry(actorstypes.Version10)) DefaultActorBuilder.AddMany(actorstypes.Version11, dispatch.ActorsVersionPredicate(actorstypes.Version11), builtin.MakeRegistry(actorstypes.Version11)) DefaultActorBuilder.AddMany(actorstypes.Version12, dispatch.ActorsVersionPredicate(actorstypes.Version12), builtin.MakeRegistry(actorstypes.Version12)) + DefaultActorBuilder.AddMany(actorstypes.Version13, dispatch.ActorsVersionPredicate(actorstypes.Version13), builtin.MakeRegistry(actorstypes.Version13)) defaultActors = DefaultActorBuilder.Build() }) diff --git a/tools/conformance/driver.go b/tools/conformance/driver.go index 21b5941300..a1f6eb2a46 100644 --- a/tools/conformance/driver.go +++ b/tools/conformance/driver.go @@ -6,6 +6,7 @@ import ( "os" "github.com/filecoin-project/venus/pkg/consensus" + "github.com/filecoin-project/venus/pkg/consensus/chainselector" "github.com/filecoin-project/venus/pkg/fvm" "github.com/filecoin-project/venus/pkg/state" "github.com/filecoin-project/venus/pkg/util/ffiwrapper/impl" @@ -100,7 +101,7 @@ func (d *Driver) ExecuteTipset(bs blockstoreutil.Blockstore, chainDs ds.Batching mainNetParams := networks.Mainnet() node.SetNetParams(&mainNetParams.Network) // chainstore - chainStore := chain.NewStore(chainDs, bs, cid.Undef, chain.NewMockCirculatingSupplyCalculator()) // load genesis from car + chainStore := chain.NewStore(chainDs, bs, cid.Undef, chain.NewMockCirculatingSupplyCalculator(), chainselector.Weight) // load genesis from car // chain fork chainFork, err := fork.NewChainFork(context.TODO(), chainStore, ipldStore, bs, &mainNetParams.Network, chainDs) @@ -255,7 +256,7 @@ func (d *Driver) ExecuteMessage(bs blockstoreutil.Blockstore, params ExecuteMess ipldStore := cbor.NewCborStore(bs) chainDs := ds.NewMapDatastore() // just mock one // chainstore - chainStore := chain.NewStore(chainDs, bs, cid.Undef, chain.NewMockCirculatingSupplyCalculator()) // load genesis from car + chainStore := chain.NewStore(chainDs, bs, cid.Undef, chain.NewMockCirculatingSupplyCalculator(), chainselector.Weight) // load genesis from car // chain fork chainFork, err := fork.NewChainFork(context.TODO(), chainStore, ipldStore, bs, &mainNetParams.Network, chainDs) diff --git a/tools/gengen/util/generator.go b/tools/gengen/util/generator.go index 2d04bd5456..1b37e3c466 100644 --- a/tools/gengen/util/generator.go +++ b/tools/gengen/util/generator.go @@ -7,6 +7,7 @@ import ( "io" mrand "math/rand" + "github.com/filecoin-project/venus/pkg/consensus/chainselector" "github.com/filecoin-project/venus/pkg/fork" "github.com/filecoin-project/venus/pkg/util/ffiwrapper/impl" "github.com/filecoin-project/venus/pkg/vm/vmcontext" @@ -77,7 +78,7 @@ func NewGenesisGenerator(bs blockstore.Blockstore) *GenesisGenerator { chainRand := chain.NewGenesisRandomnessSource(genesis.Ticket.VRFProof) chainDs := ds.NewMapDatastore() // just mock one // chainstore - chainStore := chain.NewStore(chainDs, bs, cid.Undef, chain.NewMockCirculatingSupplyCalculator()) // load genesis from car + chainStore := chain.NewStore(chainDs, bs, cid.Undef, chain.NewMockCirculatingSupplyCalculator(), chainselector.Weight) // load genesis from car chainFork, err := fork.NewChainFork(context.TODO(), chainStore, cst, bs, config.NewDefaultConfig().NetworkParams, chainDs) if err != nil { panic(xerrors.Errorf("create chain fork error %v", err)) diff --git a/venus-component/libp2p/exchange/client/client.go b/venus-component/libp2p/exchange/client/client.go index f56b9577db..0a5d1b21a6 100644 --- a/venus-component/libp2p/exchange/client/client.go +++ b/venus-component/libp2p/exchange/client/client.go @@ -381,7 +381,7 @@ func (c *client) sendRequestToPeer(ctx context.Context, peer peer.ID, req *excha defer span.End() if span.IsRecordingEvents() { span.AddAttributes( - trace.StringAttribute("peer", peer.Pretty()), + trace.StringAttribute("peer", peer.String()), ) } defer func() { diff --git a/venus-devtool/api-gen/example.go b/venus-devtool/api-gen/example.go index 7f7b2ead11..ed2e307a44 100644 --- a/venus-devtool/api-gen/example.go +++ b/venus-devtool/api-gen/example.go @@ -155,6 +155,7 @@ func init() { Msg: ExampleValue("init", reflect.TypeOf(types.MessageTrace{}), nil).(types.MessageTrace), MsgRct: ExampleValue("init", reflect.TypeOf(types.ReturnTrace{}), nil).(types.ReturnTrace), }) + addExample(abi.ActorID(1000)) addExample(map[string]types.Actor{ "t01236": ExampleValue("init", reflect.TypeOf(types.Actor{}), nil).(types.Actor), }) @@ -295,6 +296,25 @@ func init() { Address: []types.EthAddress{ethaddr}, }) + addExample(&types.ActorEventBlock{ + Codec: 0x51, + Value: []byte("ddata"), + }) + + addExample(&types.ActorEventFilter{ + Addresses: []address.Address{addr}, + Fields: map[string][]types.ActorEventBlock{ + "abc": { + { + Codec: 0x51, + Value: []byte("ddata"), + }, + }, + }, + FromHeight: epochPtr(1010), + ToHeight: epochPtr(1020), + }) + percent := types.Percent(123) addExample(percent) addExample(&percent) @@ -385,3 +405,8 @@ func shouldIgnoreField(f reflect.StructField, parentType reflect.Type) bool { return strings.Split(jtag, ",")[0] == "-" } + +func epochPtr(ei int64) *abi.ChainEpoch { + ep := abi.ChainEpoch(ei) + return &ep +} diff --git a/venus-devtool/cborgen/main.go b/venus-devtool/cborgen/main.go index 8f1c0c1f05..405fe66bff 100644 --- a/venus-devtool/cborgen/main.go +++ b/venus-devtool/cborgen/main.go @@ -57,6 +57,7 @@ func main() { types.Event{}, types.EventEntry{}, types.GasTrace{}, + types.ActorTrace{}, types.MessageTrace{}, types.ReturnTrace{}, types.ExecutionTrace{}, diff --git a/venus-devtool/go.mod b/venus-devtool/go.mod index 593dd7ca80..63832cf359 100644 --- a/venus-devtool/go.mod +++ b/venus-devtool/go.mod @@ -8,26 +8,27 @@ require ( github.com/filecoin-project/go-data-transfer/v2 v2.0.0-rc7 github.com/filecoin-project/go-fil-markets v1.28.3 github.com/filecoin-project/go-jsonrpc v0.3.1 - github.com/filecoin-project/go-state-types v0.12.8 - github.com/filecoin-project/lotus v1.24.0 + github.com/filecoin-project/go-state-types v0.13.0-rc.2 + github.com/filecoin-project/lotus v1.26.0-rc1 github.com/filecoin-project/venus v0.0.0-00010101000000-000000000000 + github.com/golang/mock v1.6.0 github.com/google/uuid v1.3.0 github.com/ipfs/go-block-format v0.1.2 github.com/ipfs/go-cid v0.4.1 github.com/ipfs/go-graphsync v0.14.6 github.com/ipld/go-ipld-selector-text-lite v0.0.1 - github.com/libp2p/go-libp2p v0.30.0 + github.com/libp2p/go-libp2p v0.31.1 github.com/libp2p/go-libp2p-pubsub v0.9.3 - github.com/multiformats/go-multiaddr v0.11.0 + github.com/multiformats/go-multiaddr v0.12.2 github.com/urfave/cli/v2 v2.25.5 - github.com/whyrusleeping/cbor-gen v0.0.0-20230923211252-36a87e1ba72f + github.com/whyrusleeping/cbor-gen v0.1.0 golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 ) require ( contrib.go.opencensus.io/exporter/graphite v0.0.0-20200424223504-26b90655e0ce // indirect contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect - github.com/BurntSushi/toml v1.2.1 // indirect + github.com/BurntSushi/toml v1.3.0 // indirect github.com/DataDog/zstd v1.4.5 // indirect github.com/GeertJohan/go.incremental v1.0.0 // indirect github.com/GeertJohan/go.rice v1.0.3 // indirect @@ -51,9 +52,9 @@ require ( github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/docker/go-units v0.5.0 // indirect - github.com/drand/drand v1.4.9 // indirect - github.com/drand/kyber v1.1.15 // indirect - github.com/drand/kyber-bls12381 v0.2.3 // indirect + github.com/drand/drand v1.5.7 // indirect + github.com/drand/kyber v1.2.0 // indirect + github.com/drand/kyber-bls12381 v0.3.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/filecoin-project/filecoin-ffi v0.30.4-0.20220519234331-bfd1f5f9fe38 // indirect github.com/filecoin-project/go-amt-ipld/v2 v2.1.1-0.20201006184820-924ee87a1349 // indirect @@ -92,7 +93,6 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.1.1 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/gopacket v1.1.19 // indirect @@ -135,7 +135,7 @@ require ( github.com/jpillora/backoff v1.0.0 // indirect github.com/kilic/bls12-381 v0.1.0 // indirect github.com/klauspost/compress v1.16.7 // indirect - github.com/klauspost/cpuid/v2 v2.2.5 // indirect + github.com/klauspost/cpuid/v2 v2.2.6 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/libp2p/go-cidranger v1.1.0 // indirect github.com/libp2p/go-flow-metrics v0.1.0 // indirect @@ -170,10 +170,10 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/polydawn/refmt v0.89.0 // indirect - github.com/prometheus/client_golang v1.14.0 // indirect + github.com/prometheus/client_golang v1.16.0 // indirect github.com/prometheus/client_model v0.4.0 // indirect - github.com/prometheus/common v0.42.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.11.1 // indirect github.com/prometheus/statsd_exporter v0.23.0 // indirect github.com/puzpuzpuz/xsync/v2 v2.4.1 // indirect github.com/raulk/clock v1.1.0 // indirect @@ -204,17 +204,17 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.25.0 // indirect go4.org v0.0.0-20230225012048-214862532bf5 // indirect - golang.org/x/crypto v0.17.0 // indirect + golang.org/x/crypto v0.18.0 // indirect golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.17.0 // indirect golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.15.0 // indirect + golang.org/x/sys v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect gonum.org/v1/gonum v0.13.0 // indirect google.golang.org/api v0.81.0 // indirect - google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect google.golang.org/grpc v1.55.0 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/venus-devtool/go.sum b/venus-devtool/go.sum index ee8a2b8bac..47fb39129c 100644 --- a/venus-devtool/go.sum +++ b/venus-devtool/go.sum @@ -57,8 +57,8 @@ contrib.go.opencensus.io/exporter/prometheus v0.4.2/go.mod h1:dvEHbiKmgvbr5pjaF9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= -github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.3.0 h1:Ws8e5YmnrGEHzZEzg0YvK/7COGYtTC5PbaH9oSSbgfA= +github.com/BurntSushi/toml v1.3.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= @@ -86,6 +86,7 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5 github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc= github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/ardanlabs/darwin/v2 v2.0.0 h1:XCisQMgQ5EG+ZvSEcADEo+pyfIMKyWAGnn5o2TgriYE= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/awnumar/memcall v0.0.0-20191004114545-73db50fd9f80 h1:8kObYoBO4LNmQ+fLiScBfxEdxF1w2MHlvH/lr9MLaTg= github.com/awnumar/memcall v0.0.0-20191004114545-73db50fd9f80/go.mod h1:S911igBPR9CThzd/hYQQmTc9SWNu3ZHIlCGaWsWsoJo= @@ -174,19 +175,12 @@ github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WA github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/drand/bls12-381 v0.3.2/go.mod h1:dtcLgPtYT38L3NO6mPDYH0nbpc5tjPassDqiniuAt4Y= -github.com/drand/drand v1.4.9 h1:WE8Jf/l+7B/rheCMCLZTp5xk0/a05t+ciwBvORq9jXM= -github.com/drand/drand v1.4.9/go.mod h1:vsmJ/kDoVLv1NC0nFihzBPmIFvMGmYtgJewzRBBRVSc= -github.com/drand/kyber v1.0.1-0.20200110225416-8de27ed8c0e2/go.mod h1:UpXoA0Upd1N9l4TvRPHr1qAUBBERj6JQ/mnKI3BPEmw= -github.com/drand/kyber v1.0.2/go.mod h1:x6KOpK7avKj0GJ4emhXFP5n7M7W7ChAPmnQh/OL6vRw= -github.com/drand/kyber v1.1.4/go.mod h1:9+IgTq7kadePhZg7eRwSD7+bA+bmvqRK+8DtmoV5a3U= -github.com/drand/kyber v1.1.10/go.mod h1:UkHLsI4W6+jT5PvNxmc0cvQAgppjTUpX+XCsN9TXmRo= -github.com/drand/kyber v1.1.15 h1:YNL02FPOA98GmlIhh5FuEJWhz1ZCp6tOUVFN7ujBJPE= -github.com/drand/kyber v1.1.15/go.mod h1:tw0l70U6aWCkc4vDr8u/canpOOOiUNJlzsmeElhBfe0= -github.com/drand/kyber-bls12381 v0.2.0/go.mod h1:zQip/bHdeEB6HFZSU3v+d3cQE0GaBVQw9aR2E7AdoeI= -github.com/drand/kyber-bls12381 v0.2.1/go.mod h1:JwWn4nHO9Mp4F5qCie5sVIPQZ0X6cw8XAeMRvc/GXBE= -github.com/drand/kyber-bls12381 v0.2.3 h1:wueWtqjj71wnwm6fYR8MAQk4q8bKVK9WukrGGcaVxzk= -github.com/drand/kyber-bls12381 v0.2.3/go.mod h1:FsudUZf6Xu61u/gYrDHEHf6lKIKluJdnX7WJe4hkMh4= +github.com/drand/drand v1.5.7 h1:5f2D5aH1nEfVI9S6tl2p9bgIDMZ92oltmiY12Kh+eYU= +github.com/drand/drand v1.5.7/go.mod h1:jrJ0244yOHNL5V04vazk3mFatjAWm3i6dg6URWwgbXk= +github.com/drand/kyber v1.2.0 h1:22SbBxsKbgQnJUoyYKIfG909PhBsj0vtANeu4BX5xgE= +github.com/drand/kyber v1.2.0/go.mod h1:6TqFlCc7NGOiNVTF9pF2KcDRfllPd9XOkExuG5Xtwfo= +github.com/drand/kyber-bls12381 v0.3.1 h1:KWb8l/zYTP5yrvKTgvhOrk2eNPscbMiUOIeWBnmUxGo= +github.com/drand/kyber-bls12381 v0.3.1/go.mod h1:H4y9bLPu7KZA/1efDg+jtJ7emKx+ro3PU7/jWUVt140= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= @@ -260,8 +254,8 @@ github.com/filecoin-project/go-state-types v0.1.4/go.mod h1:xCA/WfKlC2zcn3fUmDv4 github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.11.2-0.20230712101859-8f37624fa540/go.mod h1:SyNPwTsU7I22gL2r0OAPcImvLoTVfgRwdK/Y5rR1zz8= -github.com/filecoin-project/go-state-types v0.12.8 h1:W/UObdAsv+LbB9EfyLg92DSYoatzUWmlfV8FGyh30VA= -github.com/filecoin-project/go-state-types v0.12.8/go.mod h1:gR2NV0CSGSQwopxF+3In9nDh1sqvoYukLcs5vK0AHCA= +github.com/filecoin-project/go-state-types v0.13.0-rc.2 h1:JHyDDx/nV8sbQNgjUfhumiGWh8Dedc8psbiVtD0YOh0= +github.com/filecoin-project/go-state-types v0.13.0-rc.2/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= github.com/filecoin-project/go-statemachine v1.0.3 h1:N07o6alys+V1tNoSTi4WuuoeNC4erS/6jE74+NsgQuk= github.com/filecoin-project/go-statemachine v1.0.3/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= @@ -270,8 +264,8 @@ github.com/filecoin-project/go-statestore v0.2.0 h1:cRRO0aPLrxKQCZ2UOQbzFGn4WDNd github.com/filecoin-project/go-statestore v0.2.0/go.mod h1:8sjBYbS35HwPzct7iT4lIXjLlYyPor80aU7t7a/Kspo= github.com/filecoin-project/kubo-api-client v0.0.1 h1:IR1b+sm+VYxSRvbgECVv9SbhIgygcXcSoN1Q7xsHDXg= github.com/filecoin-project/kubo-api-client v0.0.1/go.mod h1:c36PPMIVOkKfHDwDG5U05gUlPRY9wNuh/BePwo0e+6Y= -github.com/filecoin-project/lotus v1.24.0 h1:mamEoMdEmF9SKNboS6SWmYBwT62rkEtnntuXXROw74E= -github.com/filecoin-project/lotus v1.24.0/go.mod h1:8fj3yRE4+LSOtRbylbHgEErl1/ZFmoVZAACT8+fEhoE= +github.com/filecoin-project/lotus v1.26.0-rc1 h1:GpqEmM3J+BX9ZvNF/KTdrvNMWPZs6vKFR6l5kAHpUwk= +github.com/filecoin-project/lotus v1.26.0-rc1/go.mod h1:6FC17T8tgqFKiTGXNAuy4HdsHcksuk0HyjWDF8my+aA= github.com/filecoin-project/pubsub v1.0.0 h1:ZTmT27U07e54qV1mMiQo4HDr0buo8I1LDHBYLXlsNXM= github.com/filecoin-project/pubsub v1.0.0/go.mod h1:GkpB33CcUtUNrLPhJgfdy4FDx4OMNR9k+46DHx/Lqrg= github.com/filecoin-project/specs-actors v0.9.13/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao= @@ -302,6 +296,7 @@ github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0X github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= +github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88= github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/gbrlsnchs/jwt/v3 v3.0.1 h1:lbUmgAKpxnClrKloyIwpxm4OuWeDl5wLk52G91ODPw4= @@ -453,7 +448,7 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= @@ -658,7 +653,7 @@ github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZl github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= @@ -674,9 +669,6 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/kilic/bls12-381 v0.0.0-20200607163746-32e1441c8a9f/go.mod h1:XXfR6YFCRSrkEXbNlIyDsgXVNJWVUV30m/ebkVy9n6s= -github.com/kilic/bls12-381 v0.0.0-20200731194930-64c428e1bff5/go.mod h1:XXfR6YFCRSrkEXbNlIyDsgXVNJWVUV30m/ebkVy9n6s= -github.com/kilic/bls12-381 v0.0.0-20200820230200-6b2c19996391/go.mod h1:XXfR6YFCRSrkEXbNlIyDsgXVNJWVUV30m/ebkVy9n6s= github.com/kilic/bls12-381 v0.1.0 h1:encrdjqKMEvabVQ7qYOKu1OvhqpK4s47wDYtNiPtlp4= github.com/kilic/bls12-381 v0.1.0/go.mod h1:vDTTHJONJ6G+P2R74EhnyotQDTliQDnFEwhdmfzw1ig= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= @@ -690,9 +682,8 @@ github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQs github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.1.1/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= -github.com/klauspost/cpuid/v2 v2.2.3/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= -github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= -github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= +github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/koron/go-ssdp v0.0.0-20180514024734-4a0ed625a78b/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk= @@ -708,6 +699,7 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/libp2p/go-addr-util v0.0.1/go.mod h1:4ac6O7n9rIAKB1dnd+s8IbbMXkt+oBpzX4/+RACcnlQ= github.com/libp2p/go-buffer-pool v0.0.1/go.mod h1:xtyIz9PMobb13WaxR6Zo1Pd1zXJKYg0a8KiIvDp3TzQ= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= @@ -721,8 +713,8 @@ github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFG github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro= github.com/libp2p/go-libp2p v0.1.0/go.mod h1:6D/2OBauqLUoqcADOJpn9WbKqvaM07tDw68qHM0BxUM= github.com/libp2p/go-libp2p v0.1.1/go.mod h1:I00BRo1UuUSdpuc8Q2mN7yDF/oTUTRAX6JWpTiK9Rp8= -github.com/libp2p/go-libp2p v0.30.0 h1:9EZwFtJPFBcs/yJTnP90TpN1hgrT/EsFfM+OZuwV87U= -github.com/libp2p/go-libp2p v0.30.0/go.mod h1:nr2g5V7lfftwgiJ78/HrID+pwvayLyqKCEirT2Y3Byg= +github.com/libp2p/go-libp2p v0.31.1 h1:mUiFPwdzC2zMLIATKVddjCuPXVbtC3BsKKVPMs4+jzY= +github.com/libp2p/go-libp2p v0.31.1/go.mod h1:+9TCv+XySSOdaxPF1WIgTK8rXP9jBb8WbemlMCSXGsU= github.com/libp2p/go-libp2p-asn-util v0.3.0 h1:gMDcMyYiZKkocGXDQ5nsUQyquC9+H+iLEQHwOCZ7s8s= github.com/libp2p/go-libp2p-asn-util v0.3.0/go.mod h1:B1mcOrKUE35Xq/ASTmQ4tN3LNzVVaMNmq2NACuqyB9w= github.com/libp2p/go-libp2p-autonat v0.1.0/go.mod h1:1tLf2yXxiE/oKGtDwPYWTSYG3PtvYlJmg7NeVtPRqH8= @@ -840,8 +832,8 @@ github.com/multiformats/go-multiaddr v0.0.2/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lg github.com/multiformats/go-multiaddr v0.0.4/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= github.com/multiformats/go-multiaddr v0.2.0/go.mod h1:0nO36NvPpyV4QzvTLi/lafl2y95ncPj0vFwVF6k6wJ4= github.com/multiformats/go-multiaddr v0.8.0/go.mod h1:Fs50eBDWvZu+l3/9S6xAE7ZYj6yhxlvaVZjakWN7xRs= -github.com/multiformats/go-multiaddr v0.11.0 h1:XqGyJ8ufbCE0HmTDwx2kPdsrQ36AGPZNZX6s6xfJH10= -github.com/multiformats/go-multiaddr v0.11.0/go.mod h1:gWUm0QLR4thQ6+ZF6SXUw8YjtwQSPapICM+NmCkxHSM= +github.com/multiformats/go-multiaddr v0.12.2 h1:9G9sTY/wCYajKa9lyfWPmpZAwe6oV+Wb1zcmMS1HG24= +github.com/multiformats/go-multiaddr v0.12.2/go.mod h1:GKyaTYjZRdcUhyOetrxTk9z0cW+jA/YrnqTOvKgi44M= github.com/multiformats/go-multiaddr-dns v0.0.1/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q= github.com/multiformats/go-multiaddr-dns v0.0.2/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q= github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A= @@ -935,8 +927,9 @@ github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqr github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -951,24 +944,25 @@ github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+ github.com/prometheus/common v0.35.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= -github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= -github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= +github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY= github.com/prometheus/statsd_exporter v0.22.7/go.mod h1:N/TevpjkIh9ccs6nuzY3jQn9dFqnUakOjnEuMPJJJnI= github.com/prometheus/statsd_exporter v0.23.0 h1:GEkriUCmARYh1gSA0gzpvmTg/oHMc5MfDFNlS/che4E= github.com/prometheus/statsd_exporter v0.23.0/go.mod h1:1itCY9XMa2p5pjO5HseGjs5cnaIA5qxLCYmn3OUna58= github.com/puzpuzpuz/xsync/v2 v2.4.1 h1:aGdE1C/HaR/QC6YAFdtZXi60Df8/qBIrs8PKrzkItcM= github.com/puzpuzpuz/xsync/v2 v2.4.1/go.mod h1:gD2H2krq/w52MfPLE+Uy64TzJDVY7lP2znR9qmR35kU= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= -github.com/quic-go/qtls-go1-20 v0.3.2 h1:rRgN3WfnKbyik4dBV8A6girlJVxGand/d+jVKbQq5GI= -github.com/quic-go/quic-go v0.37.6 h1:2IIUmQzT5YNxAiaPGjs++Z4hGOtIR0q79uS5qE9ccfY= +github.com/quic-go/qtls-go1-20 v0.3.3 h1:17/glZSLI9P9fDAeyCHBFSWSqJcwx1byhLwP5eUIDCM= +github.com/quic-go/quic-go v0.38.2 h1:VWv/6gxIoB8hROQJhx1JEyiegsUQ+zMN3em3kynTGdg= github.com/quic-go/webtransport-go v0.5.3 h1:5XMlzemqB4qmOlgIus5zB45AcZ2kCgCy2EptUrfOPWU= github.com/raulk/clock v1.1.0 h1:dpb29+UKMbLqiU/jqIJptgLR1nn23HLgMY0sTCDza5Y= github.com/raulk/clock v1.1.0/go.mod h1:3MpVxdZ/ODBQDxbN+kzshf5OSZwPjtMDx6BBXBmOeY0= @@ -976,8 +970,8 @@ github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtB github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= @@ -985,14 +979,14 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= -github.com/sercand/kuberesolver v2.4.0+incompatible h1:WE2OlRf6wjLxHwNkkFLQGaZcVLEXjMjBPjjEU5vksH8= +github.com/sercand/kuberesolver/v4 v4.0.0 h1:frL7laPDG/lFm5n98ODmWnn+cvPpzlkf3LhzuPhcHP4= github.com/shirou/gopsutil v2.18.12+incompatible h1:1eaJvGomDnH74/5cF4CTmTbLHAriGFsTZppLXDX93OM= github.com/shirou/gopsutil v2.18.12+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.2 h1:oxx1eChJGI6Uks2ZC4W1zpLlVgqB8ner4EuQwV4Ik1Y= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= @@ -1027,7 +1021,6 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= @@ -1055,7 +1048,7 @@ github.com/warpfork/go-wish v0.0.0-20190328234359-8b3e70f8e830/go.mod h1:x6AKhvS github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSDJfjId/PEGEShv6ugrt4kYsC5UIDaQ= github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= -github.com/weaveworks/common v0.0.0-20220810113439-c65105d60b18 h1:JN4YR/TNWiZEAHHImrVA2u4DPI+aqPOar23ICUnYZTQ= +github.com/weaveworks/common v0.0.0-20230531151736-e2613bee6b73 h1:CMM9+/AgM77vaMXMQedzqPRMuNwjbI0EcdofPqxc9F8= github.com/weaveworks/promrus v1.2.0 h1:jOLf6pe6/vss4qGHjXmGz4oDJQA+AOCqEL3FvvZGz7M= github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba h1:X4n8JG2e2biEZZXdBKt9HX7DN3bYGFUqljqqy0DqgnY= github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba/go.mod h1:CHQnYnQUEPydYCwuy8lmTHfGmdw9TKrhWV0xLx8l0oM= @@ -1075,8 +1068,8 @@ github.com/whyrusleeping/cbor-gen v0.0.0-20200826160007-0b9f6c5fb163/go.mod h1:f github.com/whyrusleeping/cbor-gen v0.0.0-20210118024343-169e9d70c0c2/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20210303213153-67a261a1d291/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20220323183124-98fa8256a799/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= -github.com/whyrusleeping/cbor-gen v0.0.0-20230923211252-36a87e1ba72f h1:SBuSxXJL0/ZJMtTxbXZgHZkThl9dNrzyaNhlyaqscRo= -github.com/whyrusleeping/cbor-gen v0.0.0-20230923211252-36a87e1ba72f/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= +github.com/whyrusleeping/cbor-gen v0.1.0 h1:Jneeq3V5enErVcuL0NKEbD1Gi+iOvEeFhXOV1S1Fc6g= +github.com/whyrusleeping/cbor-gen v0.1.0/go.mod h1:pM99HXyEbSQHcosHc0iW7YFmwnscr+t9Te4ibko05so= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f/go.mod h1:p9UJB6dDgdPgMJZs7UjUOdulKyRr9fqkS+6JKAInPy8= github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k= @@ -1102,14 +1095,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.dedis.ch/fixbuf v1.0.3 h1:hGcV9Cd/znUxlusJ64eAlExS+5cJDIyTyEG+otu5wQs= -go.dedis.ch/fixbuf v1.0.3/go.mod h1:yzJMt34Wa5xD37V5RTdmp38cz3QhMagdGoem9anUalw= -go.dedis.ch/kyber/v3 v3.0.4/go.mod h1:OzvaEnPvKlyrWyp3kGXlFdp7ap1VC6RkZDTaPikqhsQ= -go.dedis.ch/kyber/v3 v3.0.9/go.mod h1:rhNjUUg6ahf8HEg5HUvVBYoWY4boAafX8tYxX+PS+qg= -go.dedis.ch/protobuf v1.0.5/go.mod h1:eIV4wicvi6JK0q/QnfIEGeSFNG0ZeB24kzut5+HaRLo= -go.dedis.ch/protobuf v1.0.7/go.mod h1:pv5ysfkDX/EawiPqcW3ikOxsL5t+BqnV6xHSmE79KI4= go.dedis.ch/protobuf v1.0.11 h1:FTYVIEzY/bfl37lu3pR4lIj+F9Vp1jE8oh91VmxKgLo= -go.dedis.ch/protobuf v1.0.11/go.mod h1:97QR256dnkimeNdfmURz0wAMNVbd1VmLXhG1CrTYrJ4= -go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= +go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -1177,7 +1164,6 @@ go4.org v0.0.0-20230225012048-214862532bf5/go.mod h1:F57wTi5Lrj6WLyswp5EYV1ncrEb golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190225124518-7f87c0fbb88b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -1189,20 +1175,16 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1241,6 +1223,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1296,11 +1279,12 @@ golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1345,7 +1329,6 @@ golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190124100055-b90733256f2e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1367,7 +1350,6 @@ golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191025090151-53bf42e6b339/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1376,7 +1358,6 @@ golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1387,13 +1368,10 @@ golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200812155832-6a926be9bd1d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200926100807-9d91bd62050c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1433,27 +1411,27 @@ golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1463,10 +1441,10 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1534,6 +1512,7 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 h1:Vve/L0v7CXXuxUmaMGIEK/dEeq7uiqb5qBgQrZzIE7E= golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1667,8 +1646,10 @@ google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT/emMP1BRJPHHKFi5akj/nbx/zNTA= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= +google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc h1:8DyZCyvI8mE1IdLy/60bS+52xfymkE72wv1asokgtao= +google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc h1:kVKPf/IiYSBWEWtkIn6wZXwWGCnLKcC8oWfZvXjsGnM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc h1:XSJ8Vk1SWuNr8S18z1NZSziL0CPIXLCCMDOEFtHBOFc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -1739,6 +1720,7 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= diff --git a/venus-devtool/inline-gen/inlinegen-data.json b/venus-devtool/inline-gen/inlinegen-data.json index cf72d24fa9..bee30099fb 100644 --- a/venus-devtool/inline-gen/inlinegen-data.json +++ b/venus-devtool/inline-gen/inlinegen-data.json @@ -1,7 +1,7 @@ { - "actorVersions": [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], - "latestActorsVersion": 12, + "actorVersions": [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], + "latestActorsVersion": 13, - "networkVersions": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21], - "latestNetworkVersion": 21 + "networkVersions": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22], + "latestNetworkVersion": 22 } diff --git a/venus-shared/actors/builtin-actors-code/v13.tar.zst b/venus-shared/actors/builtin-actors-code/v13.tar.zst new file mode 100644 index 0000000000..77565abc97 Binary files /dev/null and b/venus-shared/actors/builtin-actors-code/v13.tar.zst differ diff --git a/venus-shared/actors/builtin/account/actor.go b/venus-shared/actors/builtin/account/actor.go index 17b75c53d7..652d9deb41 100644 --- a/venus-shared/actors/builtin/account/actor.go +++ b/venus-shared/actors/builtin/account/actor.go @@ -30,10 +30,10 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" ) -var Methods = builtin12.MethodsAccount +var Methods = builtin13.MethodsAccount func Load(store adt.Store, act *types.Actor) (State, error) { if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { @@ -58,6 +58,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -128,6 +131,9 @@ func MakeState(store adt.Store, av actorstypes.Version, addr address.Address) (S case actorstypes.Version12: return make12(store, addr) + case actorstypes.Version13: + return make13(store, addr) + } return nil, fmt.Errorf("unknown actor version %d", av) } @@ -157,5 +163,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/venus-shared/actors/builtin/account/state.v13.go b/venus-shared/actors/builtin/account/state.v13.go new file mode 100644 index 0000000000..9eed19f661 --- /dev/null +++ b/venus-shared/actors/builtin/account/state.v13.go @@ -0,0 +1,65 @@ +// FETCHED FROM LOTUS: builtin/account/state.go.template + +package account + +import ( + "fmt" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + + "github.com/filecoin-project/go-address" + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/go-state-types/manifest" + "github.com/filecoin-project/venus/venus-shared/actors" + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + account13 "github.com/filecoin-project/go-state-types/builtin/v13/account" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, addr address.Address) (State, error) { + out := state13{store: store} + out.State = account13.State{Address: addr} + return &out, nil +} + +type state13 struct { + account13.State + store adt.Store +} + +func (s *state13) PubkeyAddress() (address.Address, error) { + return s.Address, nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) ActorKey() string { + return manifest.AccountKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/venus-shared/actors/builtin/cron/actor.go b/venus-shared/actors/builtin/cron/actor.go index 87e4eed220..713c0b9290 100644 --- a/venus-shared/actors/builtin/cron/actor.go +++ b/venus-shared/actors/builtin/cron/actor.go @@ -26,7 +26,7 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -52,6 +52,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -122,13 +125,16 @@ func MakeState(store adt.Store, av actorstypes.Version) (State, error) { case actorstypes.Version12: return make12(store) + case actorstypes.Version13: + return make13(store) + } return nil, fmt.Errorf("unknown actor version %d", av) } var ( - Address = builtin12.CronActorAddr - Methods = builtin12.MethodsCron + Address = builtin13.CronActorAddr + Methods = builtin13.MethodsCron ) type State interface { @@ -153,5 +159,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/venus-shared/actors/builtin/cron/state.v13.go b/venus-shared/actors/builtin/cron/state.v13.go new file mode 100644 index 0000000000..31f09ec37e --- /dev/null +++ b/venus-shared/actors/builtin/cron/state.v13.go @@ -0,0 +1,59 @@ +// FETCHED FROM LOTUS: builtin/cron/state.go.template + +package cron + +import ( + "fmt" + + "github.com/ipfs/go-cid" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/go-state-types/manifest" + "github.com/filecoin-project/venus/venus-shared/actors" + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + cron13 "github.com/filecoin-project/go-state-types/builtin/v13/cron" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store) (State, error) { + out := state13{store: store} + out.State = *cron13.ConstructState(cron13.BuiltInEntries()) + return &out, nil +} + +type state13 struct { + cron13.State + store adt.Store +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) ActorKey() string { + return manifest.CronKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/venus-shared/actors/builtin/datacap/actor.go b/venus-shared/actors/builtin/datacap/actor.go index 852f85d65b..083276a7d9 100644 --- a/venus-shared/actors/builtin/datacap/actor.go +++ b/venus-shared/actors/builtin/datacap/actor.go @@ -10,7 +10,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/manifest" @@ -20,8 +20,8 @@ import ( ) var ( - Address = builtin12.DatacapActorAddr - Methods = builtin12.MethodsDatacap + Address = builtin13.DatacapActorAddr + Methods = builtin13.MethodsDatacap ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -44,6 +44,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -65,6 +68,9 @@ func MakeState(store adt.Store, av actorstypes.Version, governor address.Address case actorstypes.Version12: return make12(store, governor, bitwidth) + case actorstypes.Version13: + return make13(store, governor, bitwidth) + default: return nil, fmt.Errorf("datacap actor only valid for actors v9 and above, got %d", av) } @@ -89,5 +95,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/venus-shared/actors/builtin/datacap/state.v13.go b/venus-shared/actors/builtin/datacap/state.v13.go new file mode 100644 index 0000000000..e714a21e2d --- /dev/null +++ b/venus-shared/actors/builtin/datacap/state.v13.go @@ -0,0 +1,84 @@ +// FETCHED FROM LOTUS: builtin/datacap/state.go.template + +package datacap + +import ( + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/venus/venus-shared/actors" + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + datacap13 "github.com/filecoin-project/go-state-types/builtin/v13/datacap" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" + "github.com/filecoin-project/go-state-types/manifest" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, governor address.Address, bitwidth uint64) (State, error) { + out := state13{store: store} + s, err := datacap13.ConstructState(store, governor, bitwidth) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state13 struct { + datacap13.State + store adt.Store +} + +func (s *state13) Governor() (address.Address, error) { + return s.State.Governor, nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error { + return forEachClient(s.store, actors.Version13, s.verifiedClients, cb) +} + +func (s *state13) verifiedClients() (adt.Map, error) { + return adt13.AsMap(s.store, s.Token.Balances, int(s.Token.HamtBitWidth)) +} + +func (s *state13) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) { + return getDataCap(s.store, actors.Version13, s.verifiedClients, addr) +} + +func (s *state13) ActorKey() string { + return manifest.DatacapKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/venus-shared/actors/builtin/evm/actor.go b/venus-shared/actors/builtin/evm/actor.go index e427369506..6875c09d38 100644 --- a/venus-shared/actors/builtin/evm/actor.go +++ b/venus-shared/actors/builtin/evm/actor.go @@ -10,15 +10,29 @@ import ( actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/cbor" - "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/venus/venus-shared/actors" "github.com/filecoin-project/venus/venus-shared/actors/adt" "github.com/filecoin-project/venus/venus-shared/actors/types" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/go-state-types/exitcode" + "github.com/filecoin-project/go-state-types/manifest" + + builtin13 "github.com/filecoin-project/go-state-types/builtin" ) -var Methods = builtin12.MethodsEVM +var Methods = builtin13.MethodsEVM + +// See https://github.com/filecoin-project/builtin-actors/blob/6e781444cee5965278c46ef4ffe1fb1970f18d7d/actors/evm/src/lib.rs#L35-L42 +const ( + ErrReverted exitcode.ExitCode = iota + 33 // EVM exit codes start at 33 + ErrInvalidInstruction + ErrUndefinedInstruction + ErrStackUnderflow + ErrStackOverflow + ErrIllegalMemoryAccess + ErrBadJumpdest + ErrSelfdestructFailed +) func Load(store adt.Store, act *types.Actor) (State, error) { if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { @@ -37,6 +51,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -55,6 +72,9 @@ func MakeState(store adt.Store, av actorstypes.Version, bytecode cid.Cid) (State case actorstypes.Version12: return make12(store, bytecode) + case actorstypes.Version13: + return make13(store, bytecode) + default: return nil, fmt.Errorf("evm actor only valid for actors v10 and above, got %d", av) } diff --git a/venus-shared/actors/builtin/evm/actor.go.template b/venus-shared/actors/builtin/evm/actor.go.template index 6d9a3ce92b..13d5ce27f0 100644 --- a/venus-shared/actors/builtin/evm/actor.go.template +++ b/venus-shared/actors/builtin/evm/actor.go.template @@ -12,6 +12,8 @@ import ( "github.com/filecoin-project/venus/venus-shared/actors" "github.com/filecoin-project/venus/venus-shared/actors/adt" "github.com/filecoin-project/venus/venus-shared/actors/types" + + "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/manifest" builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" @@ -19,6 +21,18 @@ import ( var Methods = builtin{{.latestVersion}}.MethodsEVM +// See https://github.com/filecoin-project/builtin-actors/blob/6e781444cee5965278c46ef4ffe1fb1970f18d7d/actors/evm/src/lib.rs#L35-L42 +const ( + ErrReverted exitcode.ExitCode = iota + 33 // EVM exit codes start at 33 + ErrInvalidInstruction + ErrUndefinedInstruction + ErrStackUnderflow + ErrStackOverflow + ErrIllegalMemoryAccess + ErrBadJumpdest + ErrSelfdestructFailed +) + func Load(store adt.Store, act *types.Actor) (State, error) { if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { if name != manifest.EvmKey { diff --git a/venus-shared/actors/builtin/evm/state.v13.go b/venus-shared/actors/builtin/evm/state.v13.go new file mode 100644 index 0000000000..45770ed067 --- /dev/null +++ b/venus-shared/actors/builtin/evm/state.v13.go @@ -0,0 +1,74 @@ +// FETCHED FROM LOTUS: builtin/evm/state.go.template + +package evm + +import ( + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + evm13 "github.com/filecoin-project/go-state-types/builtin/v13/evm" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, bytecode cid.Cid) (State, error) { + out := state13{store: store} + s, err := evm13.ConstructState(store, bytecode) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state13 struct { + evm13.State + store adt.Store +} + +func (s *state13) Nonce() (uint64, error) { + return s.State.Nonce, nil +} + +func (s *state13) IsAlive() (bool, error) { + return s.State.Tombstone == nil, nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) GetBytecodeCID() (cid.Cid, error) { + return s.State.Bytecode, nil +} + +func (s *state13) GetBytecodeHash() ([32]byte, error) { + return s.State.BytecodeHash, nil +} + +func (s *state13) GetBytecode() ([]byte, error) { + bc, err := s.GetBytecodeCID() + if err != nil { + return nil, err + } + + var byteCode abi.CborBytesTransparent + if err := s.store.Get(s.store.Context(), bc, &byteCode); err != nil { + return nil, err + } + + return byteCode, nil +} diff --git a/venus-shared/actors/builtin/init/actor.go b/venus-shared/actors/builtin/init/actor.go index a5dc525925..0b3ad58b0c 100644 --- a/venus-shared/actors/builtin/init/actor.go +++ b/venus-shared/actors/builtin/init/actor.go @@ -32,12 +32,12 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" ) var ( - Address = builtin12.InitActorAddr - Methods = builtin12.MethodsInit + Address = builtin13.InitActorAddr + Methods = builtin13.MethodsInit ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -63,6 +63,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -133,6 +136,9 @@ func MakeState(store adt.Store, av actorstypes.Version, networkName string) (Sta case actorstypes.Version12: return make12(store, networkName) + case actorstypes.Version13: + return make13(store, networkName) + } return nil, fmt.Errorf("unknown actor version %d", av) } @@ -185,5 +191,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/venus-shared/actors/builtin/init/state.v13.go b/venus-shared/actors/builtin/init/state.v13.go new file mode 100644 index 0000000000..3de98d2795 --- /dev/null +++ b/venus-shared/actors/builtin/init/state.v13.go @@ -0,0 +1,148 @@ +// FETCHED FROM LOTUS: builtin/init/state.go.template + +package init + +import ( + "crypto/sha256" + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/venus/venus-shared/actors" + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + "github.com/filecoin-project/go-state-types/manifest" + + builtin13 "github.com/filecoin-project/go-state-types/builtin" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, networkName string) (State, error) { + out := state13{store: store} + + s, err := init13.ConstructState(store, networkName) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state13 struct { + init13.State + store adt.Store +} + +func (s *state13) ResolveAddress(address address.Address) (address.Address, bool, error) { + return s.State.ResolveAddress(s.store, address) +} + +func (s *state13) MapAddressToNewID(address address.Address) (address.Address, error) { + return s.State.MapAddressToNewID(s.store, address) +} + +func (s *state13) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error { + addrs, err := adt13.AsMap(s.store, s.State.AddressMap, builtin13.DefaultHamtBitwidth) + if err != nil { + return err + } + var actorID cbg.CborInt + return addrs.ForEach(&actorID, func(key string) error { + addr, err := address.NewFromBytes([]byte(key)) + if err != nil { + return err + } + return cb(abi.ActorID(actorID), addr) + }) +} + +func (s *state13) NetworkName() (string, error) { + return string(s.State.NetworkName), nil +} + +func (s *state13) SetNetworkName(name string) error { + s.State.NetworkName = name + return nil +} + +func (s *state13) SetNextID(id abi.ActorID) error { + s.State.NextID = id + return nil +} + +func (s *state13) Remove(addrs ...address.Address) (err error) { + m, err := adt13.AsMap(s.store, s.State.AddressMap, builtin13.DefaultHamtBitwidth) + if err != nil { + return err + } + for _, addr := range addrs { + if err = m.Delete(abi.AddrKey(addr)); err != nil { + return fmt.Errorf("failed to delete entry for address: %s; err: %w", addr, err) + } + } + amr, err := m.Root() + if err != nil { + return fmt.Errorf("failed to get address map root: %w", err) + } + s.State.AddressMap = amr + return nil +} + +func (s *state13) SetAddressMap(mcid cid.Cid) error { + s.State.AddressMap = mcid + return nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) AddressMap() (adt.Map, error) { + return adt13.AsMap(s.store, s.State.AddressMap, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) AddressMapBitWidth() int { + return builtin13.DefaultHamtBitwidth +} + +func (s *state13) AddressMapHashFunction() func(input []byte) []byte { + return func(input []byte) []byte { + res := sha256.Sum256(input) + return res[:] + } +} + +func (s *state13) ActorKey() string { + return manifest.InitKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/venus-shared/actors/builtin/market/actor.go b/venus-shared/actors/builtin/market/actor.go index 77701b996e..4ff8571274 100644 --- a/venus-shared/actors/builtin/market/actor.go +++ b/venus-shared/actors/builtin/market/actor.go @@ -71,6 +71,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -141,6 +144,9 @@ func MakeState(store adt.Store, av actorstypes.Version) (State, error) { case actorstypes.Version12: return make12(store) + case actorstypes.Version13: + return make13(store) + } return nil, fmt.Errorf("unknown actor version %d", av) } @@ -175,10 +181,10 @@ type BalanceTable interface { type DealStates interface { ForEach(cb func(id abi.DealID, ds DealState) error) error - Get(id abi.DealID) (*DealState, bool, error) + Get(id abi.DealID) (DealState, bool, error) array() adt.Array - decode(*cbg.Deferred) (*DealState, error) + decode(*cbg.Deferred) (DealState, error) } type DealProposals interface { @@ -239,6 +245,9 @@ func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStora case actorstypes.Version12: return decodePublishStorageDealsReturn12(b) + case actorstypes.Version13: + return decodePublishStorageDealsReturn13(b) + } return nil, fmt.Errorf("unknown actor version %d", av) } @@ -246,7 +255,17 @@ func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStora type DealProposal = markettypes.DealProposal type DealLabel = markettypes.DealLabel -type DealState = markettypes.DealState +type DealState interface { + SectorStartEpoch() abi.ChainEpoch // -1 if not yet included in proven sector + LastUpdatedEpoch() abi.ChainEpoch // -1 if deal state never updated + SlashEpoch() abi.ChainEpoch // -1 if deal never slashed + + Equals(other DealState) bool +} + +func DealStatesEqual(a, b DealState) bool { + return DealStatesEqual(a, b) +} type DealStateChanges struct { Added []DealIDState @@ -262,8 +281,8 @@ type DealIDState struct { // DealStateChange is a change in deal state from -> to type DealStateChange struct { ID abi.DealID - From *DealState - To *DealState + From DealState + To DealState } type DealProposalChanges struct { @@ -276,12 +295,35 @@ type ProposalIDState struct { Proposal markettypes.DealProposal } -func EmptyDealState() *DealState { - return &DealState{ - SectorStartEpoch: -1, - SlashEpoch: -1, - LastUpdatedEpoch: -1, +type emptyDealState struct{} + +func (e *emptyDealState) SectorStartEpoch() abi.ChainEpoch { + return -1 +} + +func (e *emptyDealState) LastUpdatedEpoch() abi.ChainEpoch { + return -1 +} + +func (e *emptyDealState) SlashEpoch() abi.ChainEpoch { + return -1 +} + +func (e *emptyDealState) Equals(other DealState) bool { + if e.SectorStartEpoch() != other.SectorStartEpoch() { + return false } + if e.LastUpdatedEpoch() != other.LastUpdatedEpoch() { + return false + } + if e.SlashEpoch() != other.SlashEpoch() { + return false + } + return true +} + +func EmptyDealState() DealState { + return &emptyDealState{} } // returns the earned fees and pending fees for a given deal @@ -300,8 +342,8 @@ func GetDealFees(deal markettypes.DealProposal, height abi.ChainEpoch) (abi.Toke return ef, big.Sub(tf, ef) } -func IsDealActive(state markettypes.DealState) bool { - return state.SectorStartEpoch > -1 && state.SlashEpoch == -1 +func IsDealActive(state DealState) bool { + return state.SectorStartEpoch() > -1 && state.SlashEpoch() == -1 } func labelFromGoString(s string) (markettypes.DealLabel, error) { @@ -326,5 +368,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/venus-shared/actors/builtin/market/actor.go.template b/venus-shared/actors/builtin/market/actor.go.template index aa2a6df833..b1073535f9 100644 --- a/venus-shared/actors/builtin/market/actor.go.template +++ b/venus-shared/actors/builtin/market/actor.go.template @@ -105,10 +105,10 @@ type BalanceTable interface { type DealStates interface { ForEach(cb func(id abi.DealID, ds DealState) error) error - Get(id abi.DealID) (*DealState, bool, error) + Get(id abi.DealID) (DealState, bool, error) array() adt.Array - decode(*cbg.Deferred) (*DealState, error) + decode(*cbg.Deferred) (DealState, error) } type DealProposals interface { @@ -144,7 +144,17 @@ func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStora type DealProposal = markettypes.DealProposal type DealLabel = markettypes.DealLabel -type DealState = markettypes.DealState +type DealState interface { + SectorStartEpoch() abi.ChainEpoch // -1 if not yet included in proven sector + LastUpdatedEpoch() abi.ChainEpoch // -1 if deal state never updated + SlashEpoch() abi.ChainEpoch // -1 if deal never slashed + + Equals(other DealState) bool +} + +func DealStatesEqual(a, b DealState) bool { + return DealStatesEqual(a, b) +} type DealStateChanges struct { Added []DealIDState @@ -160,8 +170,8 @@ type DealIDState struct { // DealStateChange is a change in deal state from -> to type DealStateChange struct { ID abi.DealID - From *DealState - To *DealState + From DealState + To DealState } type DealProposalChanges struct { @@ -174,12 +184,36 @@ type ProposalIDState struct { Proposal markettypes.DealProposal } -func EmptyDealState() *DealState { - return &DealState{ - SectorStartEpoch: -1, - SlashEpoch: -1, - LastUpdatedEpoch: -1, + +type emptyDealState struct{} + +func (e *emptyDealState) SectorStartEpoch() abi.ChainEpoch { + return -1 +} + +func (e *emptyDealState) LastUpdatedEpoch() abi.ChainEpoch { + return -1 +} + +func (e *emptyDealState) SlashEpoch() abi.ChainEpoch { + return -1 +} + +func (e *emptyDealState) Equals(other DealState) bool { + if e.SectorStartEpoch() != other.SectorStartEpoch() { + return false } + if e.LastUpdatedEpoch() != other.LastUpdatedEpoch() { + return false + } + if e.SlashEpoch() != other.SlashEpoch() { + return false + } + return true +} + +func EmptyDealState() DealState { + return &emptyDealState{} } // returns the earned fees and pending fees for a given deal @@ -198,8 +232,8 @@ func GetDealFees(deal markettypes.DealProposal, height abi.ChainEpoch) (abi.Toke return ef, big.Sub(tf, ef) } -func IsDealActive(state markettypes.DealState) bool { - return state.SectorStartEpoch > -1 && state.SlashEpoch == -1 +func IsDealActive(state DealState) bool { + return state.SectorStartEpoch() > -1 && state.SlashEpoch() == -1 } func labelFromGoString(s string) (markettypes.DealLabel, error) { diff --git a/venus-shared/actors/builtin/market/diff.go b/venus-shared/actors/builtin/market/diff.go index 894dac6f65..fa4e3f0a2d 100644 --- a/venus-shared/actors/builtin/market/diff.go +++ b/venus-shared/actors/builtin/market/diff.go @@ -66,7 +66,7 @@ func (d *marketStatesDiffer) Add(key uint64, val *cbg.Deferred) error { if err != nil { return err } - d.Results.Added = append(d.Results.Added, DealIDState{abi.DealID(key), *ds}) + d.Results.Added = append(d.Results.Added, DealIDState{abi.DealID(key), ds}) return nil } @@ -79,7 +79,7 @@ func (d *marketStatesDiffer) Modify(key uint64, from, to *cbg.Deferred) error { if err != nil { return err } - if *dsFrom != *dsTo { + if !dsFrom.Equals(dsTo) { d.Results.Modified = append(d.Results.Modified, DealStateChange{abi.DealID(key), dsFrom, dsTo}) } return nil @@ -90,6 +90,6 @@ func (d *marketStatesDiffer) Remove(key uint64, val *cbg.Deferred) error { if err != nil { return err } - d.Results.Removed = append(d.Results.Removed, DealIDState{abi.DealID(key), *ds}) + d.Results.Removed = append(d.Results.Removed, DealIDState{abi.DealID(key), ds}) return nil } diff --git a/venus-shared/actors/builtin/market/state.sep.go.template b/venus-shared/actors/builtin/market/state.sep.go.template index 85faeccea4..98785b5de3 100644 --- a/venus-shared/actors/builtin/market/state.sep.go.template +++ b/venus-shared/actors/builtin/market/state.sep.go.template @@ -176,7 +176,7 @@ type dealStates{{.v}} struct { adt.Array } -func (s *dealStates{{.v}}) Get(dealID abi.DealID) (*DealState, bool, error) { +func (s *dealStates{{.v}}) Get(dealID abi.DealID) (DealState, bool, error) { var deal{{.v}} market{{.v}}.DealState found, err := s.Array.Get(uint64(dealID), &deal{{.v}}) if err != nil { @@ -186,7 +186,7 @@ func (s *dealStates{{.v}}) Get(dealID abi.DealID) (*DealState, bool, error) { return nil, false, nil } deal := fromV{{.v}}DealState(deal{{.v}}) - return &deal, true, nil + return deal, true, nil } func (s *dealStates{{.v}}) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { @@ -196,31 +196,57 @@ func (s *dealStates{{.v}}) ForEach(cb func(dealID abi.DealID, ds DealState) erro }) } -func (s *dealStates{{.v}}) decode(val *cbg.Deferred) (*DealState, error) { +func (s *dealStates{{.v}}) decode(val *cbg.Deferred) (DealState, error) { var ds{{.v}} market{{.v}}.DealState if err := ds{{.v}}.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } ds := fromV{{.v}}DealState(ds{{.v}}) - return &ds, nil + return ds, nil } func (s *dealStates{{.v}}) array() adt.Array { return s.Array } -func fromV{{.v}}DealState(v{{.v}} market{{.v}}.DealState) DealState { - ret := DealState{ - SectorStartEpoch: v{{.v}}.SectorStartEpoch, - LastUpdatedEpoch: v{{.v}}.LastUpdatedEpoch, - SlashEpoch: v{{.v}}.SlashEpoch, - VerifiedClaim: 0, - } - {{if (ge .v 9)}} - ret.VerifiedClaim = verifregtypes.AllocationId(v{{.v}}.VerifiedClaim) - {{end}} +type dealStateV{{.v}} struct { + ds{{.v}} market{{.v}}.DealState +} + +func (d dealStateV{{.v}}) SectorStartEpoch() abi.ChainEpoch { + return d.ds{{.v}}.SectorStartEpoch +} + +func (d dealStateV{{.v}}) LastUpdatedEpoch() abi.ChainEpoch { + return d.ds{{.v}}.LastUpdatedEpoch +} + +func (d dealStateV{{.v}}) SlashEpoch() abi.ChainEpoch { + return d.ds{{.v}}.SlashEpoch +} - return ret +func (d dealStateV{{.v}}) Equals(other DealState) bool { + if ov{{.v}}, ok := other.(dealStateV{{.v}}); ok { + return d.ds{{.v}} == ov{{.v}}.ds{{.v}} + } + + if d.SectorStartEpoch() != other.SectorStartEpoch() { + return false + } + if d.LastUpdatedEpoch() != other.LastUpdatedEpoch() { + return false + } + if d.SlashEpoch() != other.SlashEpoch() { + return false + } + + return true +} + +var _ DealState = (*dealStateV{{.v}})(nil) + +func fromV{{.v}}DealState(v{{.v}} market{{.v}}.DealState) DealState { + return dealStateV{{.v}}{v{{.v}}} } type dealProposals{{.v}} struct { diff --git a/venus-shared/actors/builtin/market/state.v0.go b/venus-shared/actors/builtin/market/state.v0.go index 2211d1c28f..f50e0c6bf8 100644 --- a/venus-shared/actors/builtin/market/state.v0.go +++ b/venus-shared/actors/builtin/market/state.v0.go @@ -155,7 +155,7 @@ type dealStates0 struct { adt.Array } -func (s *dealStates0) Get(dealID abi.DealID) (*DealState, bool, error) { +func (s *dealStates0) Get(dealID abi.DealID) (DealState, bool, error) { var deal0 market0.DealState found, err := s.Array.Get(uint64(dealID), &deal0) if err != nil { @@ -165,7 +165,7 @@ func (s *dealStates0) Get(dealID abi.DealID) (*DealState, bool, error) { return nil, false, nil } deal := fromV0DealState(deal0) - return &deal, true, nil + return deal, true, nil } func (s *dealStates0) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { @@ -175,28 +175,57 @@ func (s *dealStates0) ForEach(cb func(dealID abi.DealID, ds DealState) error) er }) } -func (s *dealStates0) decode(val *cbg.Deferred) (*DealState, error) { +func (s *dealStates0) decode(val *cbg.Deferred) (DealState, error) { var ds0 market0.DealState if err := ds0.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } ds := fromV0DealState(ds0) - return &ds, nil + return ds, nil } func (s *dealStates0) array() adt.Array { return s.Array } -func fromV0DealState(v0 market0.DealState) DealState { - ret := DealState{ - SectorStartEpoch: v0.SectorStartEpoch, - LastUpdatedEpoch: v0.LastUpdatedEpoch, - SlashEpoch: v0.SlashEpoch, - VerifiedClaim: 0, +type dealStateV0 struct { + ds0 market0.DealState +} + +func (d dealStateV0) SectorStartEpoch() abi.ChainEpoch { + return d.ds0.SectorStartEpoch +} + +func (d dealStateV0) LastUpdatedEpoch() abi.ChainEpoch { + return d.ds0.LastUpdatedEpoch +} + +func (d dealStateV0) SlashEpoch() abi.ChainEpoch { + return d.ds0.SlashEpoch +} + +func (d dealStateV0) Equals(other DealState) bool { + if ov0, ok := other.(dealStateV0); ok { + return d.ds0 == ov0.ds0 } - return ret + if d.SectorStartEpoch() != other.SectorStartEpoch() { + return false + } + if d.LastUpdatedEpoch() != other.LastUpdatedEpoch() { + return false + } + if d.SlashEpoch() != other.SlashEpoch() { + return false + } + + return true +} + +var _ DealState = (*dealStateV0)(nil) + +func fromV0DealState(v0 market0.DealState) DealState { + return dealStateV0{v0} } type dealProposals0 struct { diff --git a/venus-shared/actors/builtin/market/state.v10.go b/venus-shared/actors/builtin/market/state.v10.go index 91e1b2e3f3..98b6e600b6 100644 --- a/venus-shared/actors/builtin/market/state.v10.go +++ b/venus-shared/actors/builtin/market/state.v10.go @@ -156,7 +156,7 @@ type dealStates10 struct { adt.Array } -func (s *dealStates10) Get(dealID abi.DealID) (*DealState, bool, error) { +func (s *dealStates10) Get(dealID abi.DealID) (DealState, bool, error) { var deal10 market10.DealState found, err := s.Array.Get(uint64(dealID), &deal10) if err != nil { @@ -166,7 +166,7 @@ func (s *dealStates10) Get(dealID abi.DealID) (*DealState, bool, error) { return nil, false, nil } deal := fromV10DealState(deal10) - return &deal, true, nil + return deal, true, nil } func (s *dealStates10) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { @@ -176,30 +176,57 @@ func (s *dealStates10) ForEach(cb func(dealID abi.DealID, ds DealState) error) e }) } -func (s *dealStates10) decode(val *cbg.Deferred) (*DealState, error) { +func (s *dealStates10) decode(val *cbg.Deferred) (DealState, error) { var ds10 market10.DealState if err := ds10.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } ds := fromV10DealState(ds10) - return &ds, nil + return ds, nil } func (s *dealStates10) array() adt.Array { return s.Array } -func fromV10DealState(v10 market10.DealState) DealState { - ret := DealState{ - SectorStartEpoch: v10.SectorStartEpoch, - LastUpdatedEpoch: v10.LastUpdatedEpoch, - SlashEpoch: v10.SlashEpoch, - VerifiedClaim: 0, +type dealStateV10 struct { + ds10 market10.DealState +} + +func (d dealStateV10) SectorStartEpoch() abi.ChainEpoch { + return d.ds10.SectorStartEpoch +} + +func (d dealStateV10) LastUpdatedEpoch() abi.ChainEpoch { + return d.ds10.LastUpdatedEpoch +} + +func (d dealStateV10) SlashEpoch() abi.ChainEpoch { + return d.ds10.SlashEpoch +} + +func (d dealStateV10) Equals(other DealState) bool { + if ov10, ok := other.(dealStateV10); ok { + return d.ds10 == ov10.ds10 + } + + if d.SectorStartEpoch() != other.SectorStartEpoch() { + return false + } + if d.LastUpdatedEpoch() != other.LastUpdatedEpoch() { + return false } + if d.SlashEpoch() != other.SlashEpoch() { + return false + } + + return true +} - ret.VerifiedClaim = verifregtypes.AllocationId(v10.VerifiedClaim) +var _ DealState = (*dealStateV10)(nil) - return ret +func fromV10DealState(v10 market10.DealState) DealState { + return dealStateV10{v10} } type dealProposals10 struct { diff --git a/venus-shared/actors/builtin/market/state.v11.go b/venus-shared/actors/builtin/market/state.v11.go index 801c53a860..fbee2f346d 100644 --- a/venus-shared/actors/builtin/market/state.v11.go +++ b/venus-shared/actors/builtin/market/state.v11.go @@ -156,7 +156,7 @@ type dealStates11 struct { adt.Array } -func (s *dealStates11) Get(dealID abi.DealID) (*DealState, bool, error) { +func (s *dealStates11) Get(dealID abi.DealID) (DealState, bool, error) { var deal11 market11.DealState found, err := s.Array.Get(uint64(dealID), &deal11) if err != nil { @@ -166,7 +166,7 @@ func (s *dealStates11) Get(dealID abi.DealID) (*DealState, bool, error) { return nil, false, nil } deal := fromV11DealState(deal11) - return &deal, true, nil + return deal, true, nil } func (s *dealStates11) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { @@ -176,30 +176,57 @@ func (s *dealStates11) ForEach(cb func(dealID abi.DealID, ds DealState) error) e }) } -func (s *dealStates11) decode(val *cbg.Deferred) (*DealState, error) { +func (s *dealStates11) decode(val *cbg.Deferred) (DealState, error) { var ds11 market11.DealState if err := ds11.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } ds := fromV11DealState(ds11) - return &ds, nil + return ds, nil } func (s *dealStates11) array() adt.Array { return s.Array } -func fromV11DealState(v11 market11.DealState) DealState { - ret := DealState{ - SectorStartEpoch: v11.SectorStartEpoch, - LastUpdatedEpoch: v11.LastUpdatedEpoch, - SlashEpoch: v11.SlashEpoch, - VerifiedClaim: 0, +type dealStateV11 struct { + ds11 market11.DealState +} + +func (d dealStateV11) SectorStartEpoch() abi.ChainEpoch { + return d.ds11.SectorStartEpoch +} + +func (d dealStateV11) LastUpdatedEpoch() abi.ChainEpoch { + return d.ds11.LastUpdatedEpoch +} + +func (d dealStateV11) SlashEpoch() abi.ChainEpoch { + return d.ds11.SlashEpoch +} + +func (d dealStateV11) Equals(other DealState) bool { + if ov11, ok := other.(dealStateV11); ok { + return d.ds11 == ov11.ds11 + } + + if d.SectorStartEpoch() != other.SectorStartEpoch() { + return false + } + if d.LastUpdatedEpoch() != other.LastUpdatedEpoch() { + return false } + if d.SlashEpoch() != other.SlashEpoch() { + return false + } + + return true +} - ret.VerifiedClaim = verifregtypes.AllocationId(v11.VerifiedClaim) +var _ DealState = (*dealStateV11)(nil) - return ret +func fromV11DealState(v11 market11.DealState) DealState { + return dealStateV11{v11} } type dealProposals11 struct { diff --git a/venus-shared/actors/builtin/market/state.v12.go b/venus-shared/actors/builtin/market/state.v12.go index a78c9ac471..0dcfa38699 100644 --- a/venus-shared/actors/builtin/market/state.v12.go +++ b/venus-shared/actors/builtin/market/state.v12.go @@ -156,7 +156,7 @@ type dealStates12 struct { adt.Array } -func (s *dealStates12) Get(dealID abi.DealID) (*DealState, bool, error) { +func (s *dealStates12) Get(dealID abi.DealID) (DealState, bool, error) { var deal12 market12.DealState found, err := s.Array.Get(uint64(dealID), &deal12) if err != nil { @@ -166,7 +166,7 @@ func (s *dealStates12) Get(dealID abi.DealID) (*DealState, bool, error) { return nil, false, nil } deal := fromV12DealState(deal12) - return &deal, true, nil + return deal, true, nil } func (s *dealStates12) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { @@ -176,30 +176,57 @@ func (s *dealStates12) ForEach(cb func(dealID abi.DealID, ds DealState) error) e }) } -func (s *dealStates12) decode(val *cbg.Deferred) (*DealState, error) { +func (s *dealStates12) decode(val *cbg.Deferred) (DealState, error) { var ds12 market12.DealState if err := ds12.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } ds := fromV12DealState(ds12) - return &ds, nil + return ds, nil } func (s *dealStates12) array() adt.Array { return s.Array } -func fromV12DealState(v12 market12.DealState) DealState { - ret := DealState{ - SectorStartEpoch: v12.SectorStartEpoch, - LastUpdatedEpoch: v12.LastUpdatedEpoch, - SlashEpoch: v12.SlashEpoch, - VerifiedClaim: 0, +type dealStateV12 struct { + ds12 market12.DealState +} + +func (d dealStateV12) SectorStartEpoch() abi.ChainEpoch { + return d.ds12.SectorStartEpoch +} + +func (d dealStateV12) LastUpdatedEpoch() abi.ChainEpoch { + return d.ds12.LastUpdatedEpoch +} + +func (d dealStateV12) SlashEpoch() abi.ChainEpoch { + return d.ds12.SlashEpoch +} + +func (d dealStateV12) Equals(other DealState) bool { + if ov12, ok := other.(dealStateV12); ok { + return d.ds12 == ov12.ds12 + } + + if d.SectorStartEpoch() != other.SectorStartEpoch() { + return false + } + if d.LastUpdatedEpoch() != other.LastUpdatedEpoch() { + return false } + if d.SlashEpoch() != other.SlashEpoch() { + return false + } + + return true +} - ret.VerifiedClaim = verifregtypes.AllocationId(v12.VerifiedClaim) +var _ DealState = (*dealStateV12)(nil) - return ret +func fromV12DealState(v12 market12.DealState) DealState { + return dealStateV12{v12} } type dealProposals12 struct { diff --git a/venus-shared/actors/builtin/market/state.v13.go b/venus-shared/actors/builtin/market/state.v13.go new file mode 100644 index 0000000000..c70b8f7eee --- /dev/null +++ b/venus-shared/actors/builtin/market/state.v13.go @@ -0,0 +1,407 @@ +// FETCHED FROM LOTUS: builtin/market/state.go.template + +package market + +import ( + "bytes" + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + "github.com/filecoin-project/go-bitfield" + rlepluslazy "github.com/filecoin-project/go-bitfield/rle" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/go-state-types/manifest" + "github.com/filecoin-project/venus/venus-shared/actors" + "github.com/filecoin-project/venus/venus-shared/actors/adt" + verifregtypes "github.com/filecoin-project/venus/venus-shared/actors/builtin/verifreg" + "github.com/filecoin-project/venus/venus-shared/actors/types" + + market13 "github.com/filecoin-project/go-state-types/builtin/v13/market" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" + markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market" + + "github.com/filecoin-project/go-state-types/builtin" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store) (State, error) { + out := state13{store: store} + + s, err := market13.ConstructState(store) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state13 struct { + market13.State + store adt.Store +} + +func (s *state13) TotalLocked() (abi.TokenAmount, error) { + fml := types.BigAdd(s.TotalClientLockedCollateral, s.TotalProviderLockedCollateral) + fml = types.BigAdd(fml, s.TotalClientStorageFee) + return fml, nil +} + +func (s *state13) BalancesChanged(otherState State) (bool, error) { + otherState13, ok := otherState.(*state13) + if !ok { + // there's no way to compare different versions of the state, so let's + // just say that means the state of balances has changed + return true, nil + } + return !s.State.EscrowTable.Equals(otherState13.State.EscrowTable) || !s.State.LockedTable.Equals(otherState13.State.LockedTable), nil +} + +func (s *state13) StatesChanged(otherState State) (bool, error) { + otherState13, ok := otherState.(*state13) + if !ok { + // there's no way to compare different versions of the state, so let's + // just say that means the state of balances has changed + return true, nil + } + return !s.State.States.Equals(otherState13.State.States), nil +} + +func (s *state13) States() (DealStates, error) { + stateArray, err := adt13.AsArray(s.store, s.State.States, market13.StatesAmtBitwidth) + if err != nil { + return nil, err + } + return &dealStates13{stateArray}, nil +} + +func (s *state13) ProposalsChanged(otherState State) (bool, error) { + otherState13, ok := otherState.(*state13) + if !ok { + // there's no way to compare different versions of the state, so let's + // just say that means the state of balances has changed + return true, nil + } + return !s.State.Proposals.Equals(otherState13.State.Proposals), nil +} + +func (s *state13) Proposals() (DealProposals, error) { + proposalArray, err := adt13.AsArray(s.store, s.State.Proposals, market13.ProposalsAmtBitwidth) + if err != nil { + return nil, err + } + return &dealProposals13{proposalArray}, nil +} + +func (s *state13) EscrowTable() (BalanceTable, error) { + bt, err := adt13.AsBalanceTable(s.store, s.State.EscrowTable) + if err != nil { + return nil, err + } + return &balanceTable13{bt}, nil +} + +func (s *state13) LockedTable() (BalanceTable, error) { + bt, err := adt13.AsBalanceTable(s.store, s.State.LockedTable) + if err != nil { + return nil, err + } + return &balanceTable13{bt}, nil +} + +func (s *state13) VerifyDealsForActivation( + minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch, +) (weight, verifiedWeight abi.DealWeight, err error) { + w, vw, _, err := market13.ValidateDealsForActivation(&s.State, s.store, deals, minerAddr, sectorExpiry, currEpoch) + return w, vw, err +} + +func (s *state13) NextID() (abi.DealID, error) { + return s.State.NextID, nil +} + +type balanceTable13 struct { + *adt13.BalanceTable +} + +func (bt *balanceTable13) ForEach(cb func(address.Address, abi.TokenAmount) error) error { + asMap := (*adt13.Map)(bt.BalanceTable) + var ta abi.TokenAmount + return asMap.ForEach(&ta, func(key string) error { + a, err := address.NewFromBytes([]byte(key)) + if err != nil { + return err + } + return cb(a, ta) + }) +} + +type dealStates13 struct { + adt.Array +} + +func (s *dealStates13) Get(dealID abi.DealID) (DealState, bool, error) { + var deal13 market13.DealState + found, err := s.Array.Get(uint64(dealID), &deal13) + if err != nil { + return nil, false, err + } + if !found { + return nil, false, nil + } + deal := fromV13DealState(deal13) + return deal, true, nil +} + +func (s *dealStates13) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { + var ds13 market13.DealState + return s.Array.ForEach(&ds13, func(idx int64) error { + return cb(abi.DealID(idx), fromV13DealState(ds13)) + }) +} + +func (s *dealStates13) decode(val *cbg.Deferred) (DealState, error) { + var ds13 market13.DealState + if err := ds13.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return nil, err + } + ds := fromV13DealState(ds13) + return ds, nil +} + +func (s *dealStates13) array() adt.Array { + return s.Array +} + +type dealStateV13 struct { + ds13 market13.DealState +} + +func (d dealStateV13) SectorStartEpoch() abi.ChainEpoch { + return d.ds13.SectorStartEpoch +} + +func (d dealStateV13) LastUpdatedEpoch() abi.ChainEpoch { + return d.ds13.LastUpdatedEpoch +} + +func (d dealStateV13) SlashEpoch() abi.ChainEpoch { + return d.ds13.SlashEpoch +} + +func (d dealStateV13) Equals(other DealState) bool { + if ov13, ok := other.(dealStateV13); ok { + return d.ds13 == ov13.ds13 + } + + if d.SectorStartEpoch() != other.SectorStartEpoch() { + return false + } + if d.LastUpdatedEpoch() != other.LastUpdatedEpoch() { + return false + } + if d.SlashEpoch() != other.SlashEpoch() { + return false + } + + return true +} + +var _ DealState = (*dealStateV13)(nil) + +func fromV13DealState(v13 market13.DealState) DealState { + return dealStateV13{v13} +} + +type dealProposals13 struct { + adt.Array +} + +func (s *dealProposals13) Get(dealID abi.DealID) (*DealProposal, bool, error) { + var proposal13 market13.DealProposal + found, err := s.Array.Get(uint64(dealID), &proposal13) + if err != nil { + return nil, false, err + } + if !found { + return nil, false, nil + } + + proposal, err := fromV13DealProposal(proposal13) + if err != nil { + return nil, true, fmt.Errorf("decoding proposal: %w", err) + } + + return &proposal, true, nil +} + +func (s *dealProposals13) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error { + var dp13 market13.DealProposal + return s.Array.ForEach(&dp13, func(idx int64) error { + dp, err := fromV13DealProposal(dp13) + if err != nil { + return fmt.Errorf("decoding proposal: %w", err) + } + + return cb(abi.DealID(idx), dp) + }) +} + +func (s *dealProposals13) decode(val *cbg.Deferred) (*DealProposal, error) { + var dp13 market13.DealProposal + if err := dp13.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return nil, err + } + + dp, err := fromV13DealProposal(dp13) + if err != nil { + return nil, err + } + + return &dp, nil +} + +func (s *dealProposals13) array() adt.Array { + return s.Array +} + +func fromV13DealProposal(v13 market13.DealProposal) (DealProposal, error) { + + label, err := fromV13Label(v13.Label) + + if err != nil { + return DealProposal{}, fmt.Errorf("error setting deal label: %w", err) + } + + return DealProposal{ + PieceCID: v13.PieceCID, + PieceSize: v13.PieceSize, + VerifiedDeal: v13.VerifiedDeal, + Client: v13.Client, + Provider: v13.Provider, + + Label: label, + + StartEpoch: v13.StartEpoch, + EndEpoch: v13.EndEpoch, + StoragePricePerEpoch: v13.StoragePricePerEpoch, + + ProviderCollateral: v13.ProviderCollateral, + ClientCollateral: v13.ClientCollateral, + }, nil +} + +func fromV13Label(v13 market13.DealLabel) (DealLabel, error) { + if v13.IsString() { + str, err := v13.ToString() + if err != nil { + return markettypes.EmptyDealLabel, fmt.Errorf("failed to convert string label to string: %w", err) + } + return markettypes.NewLabelFromString(str) + } + + bs, err := v13.ToBytes() + if err != nil { + return markettypes.EmptyDealLabel, fmt.Errorf("failed to convert bytes label to bytes: %w", err) + } + return markettypes.NewLabelFromBytes(bs) +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +var _ PublishStorageDealsReturn = (*publishStorageDealsReturn13)(nil) + +func decodePublishStorageDealsReturn13(b []byte) (PublishStorageDealsReturn, error) { + var retval market13.PublishStorageDealsReturn + if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil { + return nil, fmt.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err) + } + + return &publishStorageDealsReturn13{retval}, nil +} + +type publishStorageDealsReturn13 struct { + market13.PublishStorageDealsReturn +} + +func (r *publishStorageDealsReturn13) IsDealValid(index uint64) (bool, int, error) { + + set, err := r.ValidDeals.IsSet(index) + if err != nil || !set { + return false, -1, err + } + maskBf, err := bitfield.NewFromIter(&rlepluslazy.RunSliceIterator{ + Runs: []rlepluslazy.Run{rlepluslazy.Run{Val: true, Len: index}}}) + if err != nil { + return false, -1, err + } + before, err := bitfield.IntersectBitField(maskBf, r.ValidDeals) + if err != nil { + return false, -1, err + } + outIdx, err := before.Count() + if err != nil { + return false, -1, err + } + return set, int(outIdx), nil + +} + +func (r *publishStorageDealsReturn13) DealIDs() ([]abi.DealID, error) { + return r.IDs, nil +} + +func (s *state13) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) { + + allocations, err := adt13.AsMap(s.store, s.PendingDealAllocationIds, builtin.DefaultHamtBitwidth) + if err != nil { + return verifregtypes.NoAllocationID, fmt.Errorf("failed to load allocation id for %d: %w", dealId, err) + } + + var allocationId cbg.CborInt + found, err := allocations.Get(abi.UIntKey(uint64(dealId)), &allocationId) + if err != nil { + return verifregtypes.NoAllocationID, fmt.Errorf("failed to load allocation id for %d: %w", dealId, err) + } + if !found { + return verifregtypes.NoAllocationID, nil + } + + return verifregtypes.AllocationId(allocationId), nil + +} + +func (s *state13) ActorKey() string { + return manifest.MarketKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/venus-shared/actors/builtin/market/state.v2.go b/venus-shared/actors/builtin/market/state.v2.go index 0f36414732..8663f746c4 100644 --- a/venus-shared/actors/builtin/market/state.v2.go +++ b/venus-shared/actors/builtin/market/state.v2.go @@ -155,7 +155,7 @@ type dealStates2 struct { adt.Array } -func (s *dealStates2) Get(dealID abi.DealID) (*DealState, bool, error) { +func (s *dealStates2) Get(dealID abi.DealID) (DealState, bool, error) { var deal2 market2.DealState found, err := s.Array.Get(uint64(dealID), &deal2) if err != nil { @@ -165,7 +165,7 @@ func (s *dealStates2) Get(dealID abi.DealID) (*DealState, bool, error) { return nil, false, nil } deal := fromV2DealState(deal2) - return &deal, true, nil + return deal, true, nil } func (s *dealStates2) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { @@ -175,28 +175,57 @@ func (s *dealStates2) ForEach(cb func(dealID abi.DealID, ds DealState) error) er }) } -func (s *dealStates2) decode(val *cbg.Deferred) (*DealState, error) { +func (s *dealStates2) decode(val *cbg.Deferred) (DealState, error) { var ds2 market2.DealState if err := ds2.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } ds := fromV2DealState(ds2) - return &ds, nil + return ds, nil } func (s *dealStates2) array() adt.Array { return s.Array } -func fromV2DealState(v2 market2.DealState) DealState { - ret := DealState{ - SectorStartEpoch: v2.SectorStartEpoch, - LastUpdatedEpoch: v2.LastUpdatedEpoch, - SlashEpoch: v2.SlashEpoch, - VerifiedClaim: 0, +type dealStateV2 struct { + ds2 market2.DealState +} + +func (d dealStateV2) SectorStartEpoch() abi.ChainEpoch { + return d.ds2.SectorStartEpoch +} + +func (d dealStateV2) LastUpdatedEpoch() abi.ChainEpoch { + return d.ds2.LastUpdatedEpoch +} + +func (d dealStateV2) SlashEpoch() abi.ChainEpoch { + return d.ds2.SlashEpoch +} + +func (d dealStateV2) Equals(other DealState) bool { + if ov2, ok := other.(dealStateV2); ok { + return d.ds2 == ov2.ds2 } - return ret + if d.SectorStartEpoch() != other.SectorStartEpoch() { + return false + } + if d.LastUpdatedEpoch() != other.LastUpdatedEpoch() { + return false + } + if d.SlashEpoch() != other.SlashEpoch() { + return false + } + + return true +} + +var _ DealState = (*dealStateV2)(nil) + +func fromV2DealState(v2 market2.DealState) DealState { + return dealStateV2{v2} } type dealProposals2 struct { diff --git a/venus-shared/actors/builtin/market/state.v3.go b/venus-shared/actors/builtin/market/state.v3.go index e987d2a176..8252adf7f6 100644 --- a/venus-shared/actors/builtin/market/state.v3.go +++ b/venus-shared/actors/builtin/market/state.v3.go @@ -150,7 +150,7 @@ type dealStates3 struct { adt.Array } -func (s *dealStates3) Get(dealID abi.DealID) (*DealState, bool, error) { +func (s *dealStates3) Get(dealID abi.DealID) (DealState, bool, error) { var deal3 market3.DealState found, err := s.Array.Get(uint64(dealID), &deal3) if err != nil { @@ -160,7 +160,7 @@ func (s *dealStates3) Get(dealID abi.DealID) (*DealState, bool, error) { return nil, false, nil } deal := fromV3DealState(deal3) - return &deal, true, nil + return deal, true, nil } func (s *dealStates3) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { @@ -170,28 +170,57 @@ func (s *dealStates3) ForEach(cb func(dealID abi.DealID, ds DealState) error) er }) } -func (s *dealStates3) decode(val *cbg.Deferred) (*DealState, error) { +func (s *dealStates3) decode(val *cbg.Deferred) (DealState, error) { var ds3 market3.DealState if err := ds3.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } ds := fromV3DealState(ds3) - return &ds, nil + return ds, nil } func (s *dealStates3) array() adt.Array { return s.Array } -func fromV3DealState(v3 market3.DealState) DealState { - ret := DealState{ - SectorStartEpoch: v3.SectorStartEpoch, - LastUpdatedEpoch: v3.LastUpdatedEpoch, - SlashEpoch: v3.SlashEpoch, - VerifiedClaim: 0, +type dealStateV3 struct { + ds3 market3.DealState +} + +func (d dealStateV3) SectorStartEpoch() abi.ChainEpoch { + return d.ds3.SectorStartEpoch +} + +func (d dealStateV3) LastUpdatedEpoch() abi.ChainEpoch { + return d.ds3.LastUpdatedEpoch +} + +func (d dealStateV3) SlashEpoch() abi.ChainEpoch { + return d.ds3.SlashEpoch +} + +func (d dealStateV3) Equals(other DealState) bool { + if ov3, ok := other.(dealStateV3); ok { + return d.ds3 == ov3.ds3 } - return ret + if d.SectorStartEpoch() != other.SectorStartEpoch() { + return false + } + if d.LastUpdatedEpoch() != other.LastUpdatedEpoch() { + return false + } + if d.SlashEpoch() != other.SlashEpoch() { + return false + } + + return true +} + +var _ DealState = (*dealStateV3)(nil) + +func fromV3DealState(v3 market3.DealState) DealState { + return dealStateV3{v3} } type dealProposals3 struct { diff --git a/venus-shared/actors/builtin/market/state.v4.go b/venus-shared/actors/builtin/market/state.v4.go index 97e305c6ce..afb08f75e8 100644 --- a/venus-shared/actors/builtin/market/state.v4.go +++ b/venus-shared/actors/builtin/market/state.v4.go @@ -150,7 +150,7 @@ type dealStates4 struct { adt.Array } -func (s *dealStates4) Get(dealID abi.DealID) (*DealState, bool, error) { +func (s *dealStates4) Get(dealID abi.DealID) (DealState, bool, error) { var deal4 market4.DealState found, err := s.Array.Get(uint64(dealID), &deal4) if err != nil { @@ -160,7 +160,7 @@ func (s *dealStates4) Get(dealID abi.DealID) (*DealState, bool, error) { return nil, false, nil } deal := fromV4DealState(deal4) - return &deal, true, nil + return deal, true, nil } func (s *dealStates4) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { @@ -170,28 +170,57 @@ func (s *dealStates4) ForEach(cb func(dealID abi.DealID, ds DealState) error) er }) } -func (s *dealStates4) decode(val *cbg.Deferred) (*DealState, error) { +func (s *dealStates4) decode(val *cbg.Deferred) (DealState, error) { var ds4 market4.DealState if err := ds4.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } ds := fromV4DealState(ds4) - return &ds, nil + return ds, nil } func (s *dealStates4) array() adt.Array { return s.Array } -func fromV4DealState(v4 market4.DealState) DealState { - ret := DealState{ - SectorStartEpoch: v4.SectorStartEpoch, - LastUpdatedEpoch: v4.LastUpdatedEpoch, - SlashEpoch: v4.SlashEpoch, - VerifiedClaim: 0, +type dealStateV4 struct { + ds4 market4.DealState +} + +func (d dealStateV4) SectorStartEpoch() abi.ChainEpoch { + return d.ds4.SectorStartEpoch +} + +func (d dealStateV4) LastUpdatedEpoch() abi.ChainEpoch { + return d.ds4.LastUpdatedEpoch +} + +func (d dealStateV4) SlashEpoch() abi.ChainEpoch { + return d.ds4.SlashEpoch +} + +func (d dealStateV4) Equals(other DealState) bool { + if ov4, ok := other.(dealStateV4); ok { + return d.ds4 == ov4.ds4 } - return ret + if d.SectorStartEpoch() != other.SectorStartEpoch() { + return false + } + if d.LastUpdatedEpoch() != other.LastUpdatedEpoch() { + return false + } + if d.SlashEpoch() != other.SlashEpoch() { + return false + } + + return true +} + +var _ DealState = (*dealStateV4)(nil) + +func fromV4DealState(v4 market4.DealState) DealState { + return dealStateV4{v4} } type dealProposals4 struct { diff --git a/venus-shared/actors/builtin/market/state.v5.go b/venus-shared/actors/builtin/market/state.v5.go index 05940ae7a5..ce9bb3374f 100644 --- a/venus-shared/actors/builtin/market/state.v5.go +++ b/venus-shared/actors/builtin/market/state.v5.go @@ -150,7 +150,7 @@ type dealStates5 struct { adt.Array } -func (s *dealStates5) Get(dealID abi.DealID) (*DealState, bool, error) { +func (s *dealStates5) Get(dealID abi.DealID) (DealState, bool, error) { var deal5 market5.DealState found, err := s.Array.Get(uint64(dealID), &deal5) if err != nil { @@ -160,7 +160,7 @@ func (s *dealStates5) Get(dealID abi.DealID) (*DealState, bool, error) { return nil, false, nil } deal := fromV5DealState(deal5) - return &deal, true, nil + return deal, true, nil } func (s *dealStates5) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { @@ -170,28 +170,57 @@ func (s *dealStates5) ForEach(cb func(dealID abi.DealID, ds DealState) error) er }) } -func (s *dealStates5) decode(val *cbg.Deferred) (*DealState, error) { +func (s *dealStates5) decode(val *cbg.Deferred) (DealState, error) { var ds5 market5.DealState if err := ds5.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } ds := fromV5DealState(ds5) - return &ds, nil + return ds, nil } func (s *dealStates5) array() adt.Array { return s.Array } -func fromV5DealState(v5 market5.DealState) DealState { - ret := DealState{ - SectorStartEpoch: v5.SectorStartEpoch, - LastUpdatedEpoch: v5.LastUpdatedEpoch, - SlashEpoch: v5.SlashEpoch, - VerifiedClaim: 0, +type dealStateV5 struct { + ds5 market5.DealState +} + +func (d dealStateV5) SectorStartEpoch() abi.ChainEpoch { + return d.ds5.SectorStartEpoch +} + +func (d dealStateV5) LastUpdatedEpoch() abi.ChainEpoch { + return d.ds5.LastUpdatedEpoch +} + +func (d dealStateV5) SlashEpoch() abi.ChainEpoch { + return d.ds5.SlashEpoch +} + +func (d dealStateV5) Equals(other DealState) bool { + if ov5, ok := other.(dealStateV5); ok { + return d.ds5 == ov5.ds5 } - return ret + if d.SectorStartEpoch() != other.SectorStartEpoch() { + return false + } + if d.LastUpdatedEpoch() != other.LastUpdatedEpoch() { + return false + } + if d.SlashEpoch() != other.SlashEpoch() { + return false + } + + return true +} + +var _ DealState = (*dealStateV5)(nil) + +func fromV5DealState(v5 market5.DealState) DealState { + return dealStateV5{v5} } type dealProposals5 struct { diff --git a/venus-shared/actors/builtin/market/state.v6.go b/venus-shared/actors/builtin/market/state.v6.go index 093ec66eca..ae54986408 100644 --- a/venus-shared/actors/builtin/market/state.v6.go +++ b/venus-shared/actors/builtin/market/state.v6.go @@ -153,7 +153,7 @@ type dealStates6 struct { adt.Array } -func (s *dealStates6) Get(dealID abi.DealID) (*DealState, bool, error) { +func (s *dealStates6) Get(dealID abi.DealID) (DealState, bool, error) { var deal6 market6.DealState found, err := s.Array.Get(uint64(dealID), &deal6) if err != nil { @@ -163,7 +163,7 @@ func (s *dealStates6) Get(dealID abi.DealID) (*DealState, bool, error) { return nil, false, nil } deal := fromV6DealState(deal6) - return &deal, true, nil + return deal, true, nil } func (s *dealStates6) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { @@ -173,28 +173,57 @@ func (s *dealStates6) ForEach(cb func(dealID abi.DealID, ds DealState) error) er }) } -func (s *dealStates6) decode(val *cbg.Deferred) (*DealState, error) { +func (s *dealStates6) decode(val *cbg.Deferred) (DealState, error) { var ds6 market6.DealState if err := ds6.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } ds := fromV6DealState(ds6) - return &ds, nil + return ds, nil } func (s *dealStates6) array() adt.Array { return s.Array } -func fromV6DealState(v6 market6.DealState) DealState { - ret := DealState{ - SectorStartEpoch: v6.SectorStartEpoch, - LastUpdatedEpoch: v6.LastUpdatedEpoch, - SlashEpoch: v6.SlashEpoch, - VerifiedClaim: 0, +type dealStateV6 struct { + ds6 market6.DealState +} + +func (d dealStateV6) SectorStartEpoch() abi.ChainEpoch { + return d.ds6.SectorStartEpoch +} + +func (d dealStateV6) LastUpdatedEpoch() abi.ChainEpoch { + return d.ds6.LastUpdatedEpoch +} + +func (d dealStateV6) SlashEpoch() abi.ChainEpoch { + return d.ds6.SlashEpoch +} + +func (d dealStateV6) Equals(other DealState) bool { + if ov6, ok := other.(dealStateV6); ok { + return d.ds6 == ov6.ds6 } - return ret + if d.SectorStartEpoch() != other.SectorStartEpoch() { + return false + } + if d.LastUpdatedEpoch() != other.LastUpdatedEpoch() { + return false + } + if d.SlashEpoch() != other.SlashEpoch() { + return false + } + + return true +} + +var _ DealState = (*dealStateV6)(nil) + +func fromV6DealState(v6 market6.DealState) DealState { + return dealStateV6{v6} } type dealProposals6 struct { diff --git a/venus-shared/actors/builtin/market/state.v7.go b/venus-shared/actors/builtin/market/state.v7.go index e833f970ce..749237b3ac 100644 --- a/venus-shared/actors/builtin/market/state.v7.go +++ b/venus-shared/actors/builtin/market/state.v7.go @@ -153,7 +153,7 @@ type dealStates7 struct { adt.Array } -func (s *dealStates7) Get(dealID abi.DealID) (*DealState, bool, error) { +func (s *dealStates7) Get(dealID abi.DealID) (DealState, bool, error) { var deal7 market7.DealState found, err := s.Array.Get(uint64(dealID), &deal7) if err != nil { @@ -163,7 +163,7 @@ func (s *dealStates7) Get(dealID abi.DealID) (*DealState, bool, error) { return nil, false, nil } deal := fromV7DealState(deal7) - return &deal, true, nil + return deal, true, nil } func (s *dealStates7) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { @@ -173,28 +173,57 @@ func (s *dealStates7) ForEach(cb func(dealID abi.DealID, ds DealState) error) er }) } -func (s *dealStates7) decode(val *cbg.Deferred) (*DealState, error) { +func (s *dealStates7) decode(val *cbg.Deferred) (DealState, error) { var ds7 market7.DealState if err := ds7.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } ds := fromV7DealState(ds7) - return &ds, nil + return ds, nil } func (s *dealStates7) array() adt.Array { return s.Array } -func fromV7DealState(v7 market7.DealState) DealState { - ret := DealState{ - SectorStartEpoch: v7.SectorStartEpoch, - LastUpdatedEpoch: v7.LastUpdatedEpoch, - SlashEpoch: v7.SlashEpoch, - VerifiedClaim: 0, +type dealStateV7 struct { + ds7 market7.DealState +} + +func (d dealStateV7) SectorStartEpoch() abi.ChainEpoch { + return d.ds7.SectorStartEpoch +} + +func (d dealStateV7) LastUpdatedEpoch() abi.ChainEpoch { + return d.ds7.LastUpdatedEpoch +} + +func (d dealStateV7) SlashEpoch() abi.ChainEpoch { + return d.ds7.SlashEpoch +} + +func (d dealStateV7) Equals(other DealState) bool { + if ov7, ok := other.(dealStateV7); ok { + return d.ds7 == ov7.ds7 } - return ret + if d.SectorStartEpoch() != other.SectorStartEpoch() { + return false + } + if d.LastUpdatedEpoch() != other.LastUpdatedEpoch() { + return false + } + if d.SlashEpoch() != other.SlashEpoch() { + return false + } + + return true +} + +var _ DealState = (*dealStateV7)(nil) + +func fromV7DealState(v7 market7.DealState) DealState { + return dealStateV7{v7} } type dealProposals7 struct { diff --git a/venus-shared/actors/builtin/market/state.v8.go b/venus-shared/actors/builtin/market/state.v8.go index 8f8f078b65..78f9942c76 100644 --- a/venus-shared/actors/builtin/market/state.v8.go +++ b/venus-shared/actors/builtin/market/state.v8.go @@ -154,7 +154,7 @@ type dealStates8 struct { adt.Array } -func (s *dealStates8) Get(dealID abi.DealID) (*DealState, bool, error) { +func (s *dealStates8) Get(dealID abi.DealID) (DealState, bool, error) { var deal8 market8.DealState found, err := s.Array.Get(uint64(dealID), &deal8) if err != nil { @@ -164,7 +164,7 @@ func (s *dealStates8) Get(dealID abi.DealID) (*DealState, bool, error) { return nil, false, nil } deal := fromV8DealState(deal8) - return &deal, true, nil + return deal, true, nil } func (s *dealStates8) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { @@ -174,28 +174,57 @@ func (s *dealStates8) ForEach(cb func(dealID abi.DealID, ds DealState) error) er }) } -func (s *dealStates8) decode(val *cbg.Deferred) (*DealState, error) { +func (s *dealStates8) decode(val *cbg.Deferred) (DealState, error) { var ds8 market8.DealState if err := ds8.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } ds := fromV8DealState(ds8) - return &ds, nil + return ds, nil } func (s *dealStates8) array() adt.Array { return s.Array } -func fromV8DealState(v8 market8.DealState) DealState { - ret := DealState{ - SectorStartEpoch: v8.SectorStartEpoch, - LastUpdatedEpoch: v8.LastUpdatedEpoch, - SlashEpoch: v8.SlashEpoch, - VerifiedClaim: 0, +type dealStateV8 struct { + ds8 market8.DealState +} + +func (d dealStateV8) SectorStartEpoch() abi.ChainEpoch { + return d.ds8.SectorStartEpoch +} + +func (d dealStateV8) LastUpdatedEpoch() abi.ChainEpoch { + return d.ds8.LastUpdatedEpoch +} + +func (d dealStateV8) SlashEpoch() abi.ChainEpoch { + return d.ds8.SlashEpoch +} + +func (d dealStateV8) Equals(other DealState) bool { + if ov8, ok := other.(dealStateV8); ok { + return d.ds8 == ov8.ds8 } - return ret + if d.SectorStartEpoch() != other.SectorStartEpoch() { + return false + } + if d.LastUpdatedEpoch() != other.LastUpdatedEpoch() { + return false + } + if d.SlashEpoch() != other.SlashEpoch() { + return false + } + + return true +} + +var _ DealState = (*dealStateV8)(nil) + +func fromV8DealState(v8 market8.DealState) DealState { + return dealStateV8{v8} } type dealProposals8 struct { diff --git a/venus-shared/actors/builtin/market/state.v9.go b/venus-shared/actors/builtin/market/state.v9.go index ec10a64405..f45e5d0df0 100644 --- a/venus-shared/actors/builtin/market/state.v9.go +++ b/venus-shared/actors/builtin/market/state.v9.go @@ -156,7 +156,7 @@ type dealStates9 struct { adt.Array } -func (s *dealStates9) Get(dealID abi.DealID) (*DealState, bool, error) { +func (s *dealStates9) Get(dealID abi.DealID) (DealState, bool, error) { var deal9 market9.DealState found, err := s.Array.Get(uint64(dealID), &deal9) if err != nil { @@ -166,7 +166,7 @@ func (s *dealStates9) Get(dealID abi.DealID) (*DealState, bool, error) { return nil, false, nil } deal := fromV9DealState(deal9) - return &deal, true, nil + return deal, true, nil } func (s *dealStates9) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { @@ -176,30 +176,57 @@ func (s *dealStates9) ForEach(cb func(dealID abi.DealID, ds DealState) error) er }) } -func (s *dealStates9) decode(val *cbg.Deferred) (*DealState, error) { +func (s *dealStates9) decode(val *cbg.Deferred) (DealState, error) { var ds9 market9.DealState if err := ds9.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } ds := fromV9DealState(ds9) - return &ds, nil + return ds, nil } func (s *dealStates9) array() adt.Array { return s.Array } -func fromV9DealState(v9 market9.DealState) DealState { - ret := DealState{ - SectorStartEpoch: v9.SectorStartEpoch, - LastUpdatedEpoch: v9.LastUpdatedEpoch, - SlashEpoch: v9.SlashEpoch, - VerifiedClaim: 0, +type dealStateV9 struct { + ds9 market9.DealState +} + +func (d dealStateV9) SectorStartEpoch() abi.ChainEpoch { + return d.ds9.SectorStartEpoch +} + +func (d dealStateV9) LastUpdatedEpoch() abi.ChainEpoch { + return d.ds9.LastUpdatedEpoch +} + +func (d dealStateV9) SlashEpoch() abi.ChainEpoch { + return d.ds9.SlashEpoch +} + +func (d dealStateV9) Equals(other DealState) bool { + if ov9, ok := other.(dealStateV9); ok { + return d.ds9 == ov9.ds9 + } + + if d.SectorStartEpoch() != other.SectorStartEpoch() { + return false + } + if d.LastUpdatedEpoch() != other.LastUpdatedEpoch() { + return false } + if d.SlashEpoch() != other.SlashEpoch() { + return false + } + + return true +} - ret.VerifiedClaim = verifregtypes.AllocationId(v9.VerifiedClaim) +var _ DealState = (*dealStateV9)(nil) - return ret +func fromV9DealState(v9 market9.DealState) DealState { + return dealStateV9{v9} } type dealProposals9 struct { diff --git a/venus-shared/actors/builtin/miner/actor.go b/venus-shared/actors/builtin/miner/actor.go index 9da0583921..21ada6398e 100644 --- a/venus-shared/actors/builtin/miner/actor.go +++ b/venus-shared/actors/builtin/miner/actor.go @@ -18,6 +18,7 @@ import ( "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/proof" + minertypes13 "github.com/filecoin-project/go-state-types/builtin/v13/miner" minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/venus/venus-shared/actors/adt" @@ -61,6 +62,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -131,6 +135,9 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { case actors.Version12: return make12(store) + case actors.Version13: + return make13(store) + } return nil, fmt.Errorf("unknown actor version %d", av) } @@ -309,7 +316,9 @@ type DeclareFaultsParams = minertypes.DeclareFaultsParams type ProveCommitAggregateParams = minertypes.ProveCommitAggregateParams type ProveCommitSectorParams = minertypes.ProveCommitSectorParams type ProveReplicaUpdatesParams = minertypes.ProveReplicaUpdatesParams +type ProveReplicaUpdatesParams2 = minertypes.ProveReplicaUpdatesParams2 type ReplicaUpdate = minertypes.ReplicaUpdate +type ReplicaUpdate2 = minertypes.ReplicaUpdate2 type PreCommitSectorBatchParams = minertypes.PreCommitSectorBatchParams type PreCommitSectorBatchParams2 = minertypes.PreCommitSectorBatchParams2 type ExtendSectorExpiration2Params = minertypes.ExtendSectorExpiration2Params @@ -318,6 +327,12 @@ type ExpirationExtension2 = minertypes.ExpirationExtension2 type CompactPartitionsParams = minertypes.CompactPartitionsParams type WithdrawBalanceParams = minertypes.WithdrawBalanceParams +type PieceActivationManifest = minertypes13.PieceActivationManifest +type ProveCommitSectors3Params = minertypes13.ProveCommitSectors3Params +type SectorActivationManifest = minertypes13.SectorActivationManifest +type ProveReplicaUpdates3Params = minertypes13.ProveReplicaUpdates3Params +type SectorUpdateManifest = minertypes13.SectorUpdateManifest + var QAPowerMax = minertypes.QAPowerMax type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo @@ -384,5 +399,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/venus-shared/actors/builtin/miner/actor.go.template b/venus-shared/actors/builtin/miner/actor.go.template index b8b125b838..d59cfd9bd2 100644 --- a/venus-shared/actors/builtin/miner/actor.go.template +++ b/venus-shared/actors/builtin/miner/actor.go.template @@ -19,6 +19,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/actors/adt" "github.com/filecoin-project/venus/venus-shared/actors/types" + minertypes13 "github.com/filecoin-project/go-state-types/builtin/v13/miner" minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/manifest" @@ -241,7 +242,9 @@ type DeclareFaultsParams = minertypes.DeclareFaultsParams type ProveCommitAggregateParams = minertypes.ProveCommitAggregateParams type ProveCommitSectorParams = minertypes.ProveCommitSectorParams type ProveReplicaUpdatesParams = minertypes.ProveReplicaUpdatesParams +type ProveReplicaUpdatesParams2 = minertypes.ProveReplicaUpdatesParams2 type ReplicaUpdate = minertypes.ReplicaUpdate +type ReplicaUpdate2 = minertypes.ReplicaUpdate2 type PreCommitSectorBatchParams = minertypes.PreCommitSectorBatchParams type PreCommitSectorBatchParams2 = minertypes.PreCommitSectorBatchParams2 type ExtendSectorExpiration2Params = minertypes.ExtendSectorExpiration2Params @@ -250,6 +253,12 @@ type ExpirationExtension2 = minertypes.ExpirationExtension2 type CompactPartitionsParams = minertypes.CompactPartitionsParams type WithdrawBalanceParams = minertypes.WithdrawBalanceParams +type PieceActivationManifest = minertypes13.PieceActivationManifest +type ProveCommitSectors3Params = minertypes13.ProveCommitSectors3Params +type SectorActivationManifest = minertypes13.SectorActivationManifest +type ProveReplicaUpdates3Params = minertypes13.ProveReplicaUpdates3Params +type SectorUpdateManifest = minertypes13.SectorUpdateManifest + var QAPowerMax = minertypes.QAPowerMax type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo diff --git a/venus-shared/actors/builtin/miner/state.sep.go.template b/venus-shared/actors/builtin/miner/state.sep.go.template index 811b3099ae..5a57d98a22 100644 --- a/venus-shared/actors/builtin/miner/state.sep.go.template +++ b/venus-shared/actors/builtin/miner/state.sep.go.template @@ -73,7 +73,7 @@ func (s *state{{.v}}) AvailableBalance(bal abi.TokenAmount) (available abi.Token available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available{{if (ge .v 2)}}, err{{end}} = s.GetAvailableBalance(bal) return available, err } diff --git a/venus-shared/actors/builtin/miner/state.v0.go b/venus-shared/actors/builtin/miner/state.v0.go index 61f6b469f5..370133e573 100644 --- a/venus-shared/actors/builtin/miner/state.v0.go +++ b/venus-shared/actors/builtin/miner/state.v0.go @@ -64,7 +64,7 @@ func (s *state0) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available = s.GetAvailableBalance(bal) return available, err } diff --git a/venus-shared/actors/builtin/miner/state.v10.go b/venus-shared/actors/builtin/miner/state.v10.go index eacffe4969..a5cb088ca3 100644 --- a/venus-shared/actors/builtin/miner/state.v10.go +++ b/venus-shared/actors/builtin/miner/state.v10.go @@ -63,7 +63,7 @@ func (s *state10) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmou available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/venus-shared/actors/builtin/miner/state.v11.go b/venus-shared/actors/builtin/miner/state.v11.go index e390e9aae3..32af6d047a 100644 --- a/venus-shared/actors/builtin/miner/state.v11.go +++ b/venus-shared/actors/builtin/miner/state.v11.go @@ -63,7 +63,7 @@ func (s *state11) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmou available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/venus-shared/actors/builtin/miner/state.v12.go b/venus-shared/actors/builtin/miner/state.v12.go index aa8e03b911..0042965c92 100644 --- a/venus-shared/actors/builtin/miner/state.v12.go +++ b/venus-shared/actors/builtin/miner/state.v12.go @@ -63,7 +63,7 @@ func (s *state12) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmou available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/venus-shared/actors/builtin/miner/state.v13.go b/venus-shared/actors/builtin/miner/state.v13.go new file mode 100644 index 0000000000..debce530c1 --- /dev/null +++ b/venus-shared/actors/builtin/miner/state.v13.go @@ -0,0 +1,592 @@ +// FETCHED FROM LOTUS: builtin/miner/state.go.template + +package miner + +import ( + "bytes" + "errors" + "fmt" + + "github.com/filecoin-project/go-bitfield" + rle "github.com/filecoin-project/go-bitfield/rle" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/dline" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/go-state-types/manifest" + "github.com/filecoin-project/venus/venus-shared/actors" + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + builtin13 "github.com/filecoin-project/go-state-types/builtin" + miner13 "github.com/filecoin-project/go-state-types/builtin/v13/miner" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store) (State, error) { + out := state13{store: store} + out.State = miner13.State{} + return &out, nil +} + +type state13 struct { + miner13.State + store adt.Store +} + +type deadline13 struct { + miner13.Deadline + store adt.Store +} + +type partition13 struct { + miner13.Partition + store adt.Store +} + +func (s *state13) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmount, err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("failed to get available balance: %v", r) + available = abi.NewTokenAmount(0) + } + }() + // this panics if the miner doesn't have enough funds to cover their locked pledge + available, err = s.GetAvailableBalance(bal) + return available, err +} + +func (s *state13) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) { + return s.CheckVestedFunds(s.store, epoch) +} + +func (s *state13) LockedFunds() (LockedFunds, error) { + return LockedFunds{ + VestingFunds: s.State.LockedFunds, + InitialPledgeRequirement: s.State.InitialPledge, + PreCommitDeposits: s.State.PreCommitDeposits, + }, nil +} + +func (s *state13) FeeDebt() (abi.TokenAmount, error) { + return s.State.FeeDebt, nil +} + +func (s *state13) InitialPledge() (abi.TokenAmount, error) { + return s.State.InitialPledge, nil +} + +func (s *state13) PreCommitDeposits() (abi.TokenAmount, error) { + return s.State.PreCommitDeposits, nil +} + +// Returns nil, nil if sector is not found +func (s *state13) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { + info, ok, err := s.State.GetSector(s.store, num) + if !ok || err != nil { + return nil, err + } + + ret := fromV13SectorOnChainInfo(*info) + return &ret, nil +} + +func (s *state13) FindSector(num abi.SectorNumber) (*SectorLocation, error) { + dlIdx, partIdx, err := s.State.FindSector(s.store, num) + if err != nil { + return nil, err + } + return &SectorLocation{ + Deadline: dlIdx, + Partition: partIdx, + }, nil +} + +func (s *state13) NumLiveSectors() (uint64, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return 0, err + } + var total uint64 + if err := dls.ForEach(s.store, func(dlIdx uint64, dl *miner13.Deadline) error { + total += dl.LiveSectors + return nil + }); err != nil { + return 0, err + } + return total, nil +} + +// GetSectorExpiration returns the effective expiration of the given sector. +// +// If the sector does not expire early, the Early expiration field is 0. +func (s *state13) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return nil, err + } + // NOTE: this can be optimized significantly. + // 1. If the sector is non-faulty, it will expire on-time (can be + // learned from the sector info). + // 2. If it's faulty, it will expire early within the first 42 entries + // of the expiration queue. + + stopErr := errors.New("stop") + out := SectorExpiration{} + err = dls.ForEach(s.store, func(dlIdx uint64, dl *miner13.Deadline) error { + partitions, err := dl.PartitionsArray(s.store) + if err != nil { + return err + } + quant := s.State.QuantSpecForDeadline(dlIdx) + var part miner13.Partition + return partitions.ForEach(&part, func(partIdx int64) error { + if found, err := part.Sectors.IsSet(uint64(num)); err != nil { + return err + } else if !found { + return nil + } + if found, err := part.Terminated.IsSet(uint64(num)); err != nil { + return err + } else if found { + // already terminated + return stopErr + } + + q, err := miner13.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant, miner13.PartitionExpirationAmtBitwidth) + if err != nil { + return err + } + var exp miner13.ExpirationSet + return q.ForEach(&exp, func(epoch int64) error { + if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil { + return err + } else if early { + out.Early = abi.ChainEpoch(epoch) + return nil + } + if onTime, err := exp.OnTimeSectors.IsSet(uint64(num)); err != nil { + return err + } else if onTime { + out.OnTime = abi.ChainEpoch(epoch) + return stopErr + } + return nil + }) + }) + }) + if err == stopErr { + err = nil + } + if err != nil { + return nil, err + } + if out.Early == 0 && out.OnTime == 0 { + return nil, fmt.Errorf("failed to find sector %d", num) + } + return &out, nil +} + +func (s *state13) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) { + info, ok, err := s.State.GetPrecommittedSector(s.store, num) + if !ok || err != nil { + return nil, err + } + + ret := fromV13SectorPreCommitOnChainInfo(*info) + + return &ret, nil +} + +func (s *state13) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error { + precommitted, err := adt13.AsMap(s.store, s.State.PreCommittedSectors, builtin13.DefaultHamtBitwidth) + if err != nil { + return err + } + + var info miner13.SectorPreCommitOnChainInfo + if err := precommitted.ForEach(&info, func(_ string) error { + return cb(fromV13SectorPreCommitOnChainInfo(info)) + }); err != nil { + return err + } + + return nil +} + +func (s *state13) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) { + sectors, err := miner13.LoadSectors(s.store, s.State.Sectors) + if err != nil { + return nil, err + } + + // If no sector numbers are specified, load all. + if snos == nil { + infos := make([]*SectorOnChainInfo, 0, sectors.Length()) + var info13 miner13.SectorOnChainInfo + if err := sectors.ForEach(&info13, func(_ int64) error { + info := fromV13SectorOnChainInfo(info13) + infos = append(infos, &info) + return nil + }); err != nil { + return nil, err + } + return infos, nil + } + + // Otherwise, load selected. + infos13, err := sectors.Load(*snos) + if err != nil { + return nil, err + } + infos := make([]*SectorOnChainInfo, len(infos13)) + for i, info13 := range infos13 { + info := fromV13SectorOnChainInfo(*info13) + infos[i] = &info + } + return infos, nil +} + +func (s *state13) loadAllocatedSectorNumbers() (bitfield.BitField, error) { + var allocatedSectors bitfield.BitField + err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors) + return allocatedSectors, err +} + +func (s *state13) IsAllocated(num abi.SectorNumber) (bool, error) { + allocatedSectors, err := s.loadAllocatedSectorNumbers() + if err != nil { + return false, err + } + + return allocatedSectors.IsSet(uint64(num)) +} + +func (s *state13) GetProvingPeriodStart() (abi.ChainEpoch, error) { + return s.State.ProvingPeriodStart, nil +} + +func (s *state13) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error) { + allocatedSectors, err := s.loadAllocatedSectorNumbers() + if err != nil { + return nil, err + } + + allocatedRuns, err := allocatedSectors.RunIterator() + if err != nil { + return nil, err + } + + unallocatedRuns, err := rle.Subtract( + &rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}}, + allocatedRuns, + ) + if err != nil { + return nil, err + } + + iter, err := rle.BitsFromRuns(unallocatedRuns) + if err != nil { + return nil, err + } + + sectors := make([]abi.SectorNumber, 0, count) + for iter.HasNext() && len(sectors) < count { + nextNo, err := iter.Next() + if err != nil { + return nil, err + } + sectors = append(sectors, abi.SectorNumber(nextNo)) + } + + return sectors, nil +} + +func (s *state13) GetAllocatedSectors() (*bitfield.BitField, error) { + var allocatedSectors bitfield.BitField + if err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors); err != nil { + return nil, err + } + + return &allocatedSectors, nil +} + +func (s *state13) LoadDeadline(idx uint64) (Deadline, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return nil, err + } + dl, err := dls.LoadDeadline(s.store, idx) + if err != nil { + return nil, err + } + return &deadline13{*dl, s.store}, nil +} + +func (s *state13) ForEachDeadline(cb func(uint64, Deadline) error) error { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return err + } + return dls.ForEach(s.store, func(i uint64, dl *miner13.Deadline) error { + return cb(i, &deadline13{*dl, s.store}) + }) +} + +func (s *state13) NumDeadlines() (uint64, error) { + return miner13.WPoStPeriodDeadlines, nil +} + +func (s *state13) DeadlinesChanged(other State) (bool, error) { + other13, ok := other.(*state13) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + + return !s.State.Deadlines.Equals(other13.Deadlines), nil +} + +func (s *state13) MinerInfoChanged(other State) (bool, error) { + other0, ok := other.(*state13) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.Info.Equals(other0.State.Info), nil +} + +func (s *state13) Info() (MinerInfo, error) { + info, err := s.State.GetInfo(s.store) + if err != nil { + return MinerInfo{}, err + } + + mi := MinerInfo{ + Owner: info.Owner, + Worker: info.Worker, + ControlAddresses: info.ControlAddresses, + + PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey), + + PeerId: info.PeerId, + Multiaddrs: info.Multiaddrs, + WindowPoStProofType: info.WindowPoStProofType, + SectorSize: info.SectorSize, + WindowPoStPartitionSectors: info.WindowPoStPartitionSectors, + ConsensusFaultElapsed: info.ConsensusFaultElapsed, + + Beneficiary: info.Beneficiary, + BeneficiaryTerm: BeneficiaryTerm(info.BeneficiaryTerm), + PendingBeneficiaryTerm: (*PendingBeneficiaryChange)(info.PendingBeneficiaryTerm), + } + + return mi, nil +} + +func (s *state13) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) { + return s.State.RecordedDeadlineInfo(epoch), nil +} + +func (s *state13) DeadlineCronActive() (bool, error) { + return s.State.DeadlineCronActive, nil +} + +func (s *state13) sectors() (adt.Array, error) { + return adt13.AsArray(s.store, s.Sectors, miner13.SectorsAmtBitwidth) +} + +func (s *state13) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) { + var si miner13.SectorOnChainInfo + err := si.UnmarshalCBOR(bytes.NewReader(val.Raw)) + if err != nil { + return SectorOnChainInfo{}, err + } + + return fromV13SectorOnChainInfo(si), nil +} + +func (s *state13) precommits() (adt.Map, error) { + return adt13.AsMap(s.store, s.PreCommittedSectors, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) { + var sp miner13.SectorPreCommitOnChainInfo + err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw)) + if err != nil { + return SectorPreCommitOnChainInfo{}, err + } + + return fromV13SectorPreCommitOnChainInfo(sp), nil +} + +func (s *state13) EraseAllUnproven() error { + + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return err + } + + err = dls.ForEach(s.store, func(dindx uint64, dl *miner13.Deadline) error { + ps, err := dl.PartitionsArray(s.store) + if err != nil { + return err + } + + var part miner13.Partition + err = ps.ForEach(&part, func(pindx int64) error { + _ = part.ActivateUnproven() + err = ps.Set(uint64(pindx), &part) + return nil + }) + + if err != nil { + return err + } + + dl.Partitions, err = ps.Root() + if err != nil { + return err + } + + return dls.UpdateDeadline(s.store, dindx, dl) + }) + if err != nil { + return err + } + + return s.State.SaveDeadlines(s.store, dls) + +} + +func (d *deadline13) LoadPartition(idx uint64) (Partition, error) { + p, err := d.Deadline.LoadPartition(d.store, idx) + if err != nil { + return nil, err + } + return &partition13{*p, d.store}, nil +} + +func (d *deadline13) ForEachPartition(cb func(uint64, Partition) error) error { + ps, err := d.Deadline.PartitionsArray(d.store) + if err != nil { + return err + } + var part miner13.Partition + return ps.ForEach(&part, func(i int64) error { + return cb(uint64(i), &partition13{part, d.store}) + }) +} + +func (d *deadline13) PartitionsChanged(other Deadline) (bool, error) { + other13, ok := other.(*deadline13) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + + return !d.Deadline.Partitions.Equals(other13.Deadline.Partitions), nil +} + +func (d *deadline13) PartitionsPoSted() (bitfield.BitField, error) { + return d.Deadline.PartitionsPoSted, nil +} + +func (d *deadline13) DisputableProofCount() (uint64, error) { + + ops, err := d.OptimisticProofsSnapshotArray(d.store) + if err != nil { + return 0, err + } + + return ops.Length(), nil + +} + +func (p *partition13) AllSectors() (bitfield.BitField, error) { + return p.Partition.Sectors, nil +} + +func (p *partition13) FaultySectors() (bitfield.BitField, error) { + return p.Partition.Faults, nil +} + +func (p *partition13) RecoveringSectors() (bitfield.BitField, error) { + return p.Partition.Recoveries, nil +} + +func (p *partition13) UnprovenSectors() (bitfield.BitField, error) { + return p.Partition.Unproven, nil +} + +func fromV13SectorOnChainInfo(v13 miner13.SectorOnChainInfo) SectorOnChainInfo { + info := SectorOnChainInfo{ + SectorNumber: v13.SectorNumber, + SealProof: v13.SealProof, + SealedCID: v13.SealedCID, + DealIDs: v13.DealIDs, + Activation: v13.Activation, + Expiration: v13.Expiration, + DealWeight: v13.DealWeight, + VerifiedDealWeight: v13.VerifiedDealWeight, + InitialPledge: v13.InitialPledge, + ExpectedDayReward: v13.ExpectedDayReward, + ExpectedStoragePledge: v13.ExpectedStoragePledge, + + SectorKeyCID: v13.SectorKeyCID, + } + return info +} + +func fromV13SectorPreCommitOnChainInfo(v13 miner13.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo { + ret := SectorPreCommitOnChainInfo{ + Info: SectorPreCommitInfo{ + SealProof: v13.Info.SealProof, + SectorNumber: v13.Info.SectorNumber, + SealedCID: v13.Info.SealedCID, + SealRandEpoch: v13.Info.SealRandEpoch, + DealIDs: v13.Info.DealIDs, + Expiration: v13.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v13.PreCommitDeposit, + PreCommitEpoch: v13.PreCommitEpoch, + } + + ret.Info.UnsealedCid = v13.Info.UnsealedCid + + return ret +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) ActorKey() string { + return manifest.MinerKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/venus-shared/actors/builtin/miner/state.v2.go b/venus-shared/actors/builtin/miner/state.v2.go index 56c5e9ac8f..e8e25fe3c2 100644 --- a/venus-shared/actors/builtin/miner/state.v2.go +++ b/venus-shared/actors/builtin/miner/state.v2.go @@ -62,7 +62,7 @@ func (s *state2) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/venus-shared/actors/builtin/miner/state.v3.go b/venus-shared/actors/builtin/miner/state.v3.go index 9e46bad2f7..6f710613ee 100644 --- a/venus-shared/actors/builtin/miner/state.v3.go +++ b/venus-shared/actors/builtin/miner/state.v3.go @@ -64,7 +64,7 @@ func (s *state3) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/venus-shared/actors/builtin/miner/state.v4.go b/venus-shared/actors/builtin/miner/state.v4.go index e397d3f0c6..ed38322a2a 100644 --- a/venus-shared/actors/builtin/miner/state.v4.go +++ b/venus-shared/actors/builtin/miner/state.v4.go @@ -64,7 +64,7 @@ func (s *state4) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/venus-shared/actors/builtin/miner/state.v5.go b/venus-shared/actors/builtin/miner/state.v5.go index 52bdcf2dcf..cf69f10d16 100644 --- a/venus-shared/actors/builtin/miner/state.v5.go +++ b/venus-shared/actors/builtin/miner/state.v5.go @@ -64,7 +64,7 @@ func (s *state5) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/venus-shared/actors/builtin/miner/state.v6.go b/venus-shared/actors/builtin/miner/state.v6.go index 62978950c0..2b26997ff9 100644 --- a/venus-shared/actors/builtin/miner/state.v6.go +++ b/venus-shared/actors/builtin/miner/state.v6.go @@ -64,7 +64,7 @@ func (s *state6) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/venus-shared/actors/builtin/miner/state.v7.go b/venus-shared/actors/builtin/miner/state.v7.go index 60cfd8fa78..ff94f623d2 100644 --- a/venus-shared/actors/builtin/miner/state.v7.go +++ b/venus-shared/actors/builtin/miner/state.v7.go @@ -64,7 +64,7 @@ func (s *state7) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/venus-shared/actors/builtin/miner/state.v8.go b/venus-shared/actors/builtin/miner/state.v8.go index cfe7fe87e0..f994ceb0e3 100644 --- a/venus-shared/actors/builtin/miner/state.v8.go +++ b/venus-shared/actors/builtin/miner/state.v8.go @@ -63,7 +63,7 @@ func (s *state8) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/venus-shared/actors/builtin/miner/state.v9.go b/venus-shared/actors/builtin/miner/state.v9.go index 68be53d2dd..4e3b574450 100644 --- a/venus-shared/actors/builtin/miner/state.v9.go +++ b/venus-shared/actors/builtin/miner/state.v9.go @@ -63,7 +63,7 @@ func (s *state9) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/venus-shared/actors/builtin/multisig/actor.go b/venus-shared/actors/builtin/multisig/actor.go index 28d5e4fe72..e5af442637 100644 --- a/venus-shared/actors/builtin/multisig/actor.go +++ b/venus-shared/actors/builtin/multisig/actor.go @@ -15,7 +15,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/cbor" - msig12 "github.com/filecoin-project/go-state-types/builtin/v12/multisig" + msig13 "github.com/filecoin-project/go-state-types/builtin/v13/multisig" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -62,6 +62,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -132,6 +135,9 @@ func MakeState(store adt.Store, av actorstypes.Version, signers []address.Addres case actorstypes.Version12: return make12(store, signers, threshold, startEpoch, unlockDuration, initialBalance) + case actorstypes.Version13: + return make13(store, signers, threshold, startEpoch, unlockDuration, initialBalance) + } return nil, fmt.Errorf("unknown actor version %d", av) } @@ -158,7 +164,7 @@ type State interface { GetState() interface{} } -type Transaction = msig12.Transaction +type Transaction = msig13.Transaction var Methods = builtintypes.MethodsMultisig @@ -200,6 +206,9 @@ func Message(version actorstypes.Version, from address.Address) MessageBuilder { case actorstypes.Version12: return message12{message0{from}} + + case actorstypes.Version13: + return message13{message0{from}} default: panic(fmt.Sprintf("unsupported actors version: %d", version)) } @@ -223,13 +232,13 @@ type MessageBuilder interface { } // this type is the same between v0 and v2 -type ProposalHashData = msig12.ProposalHashData -type ProposeReturn = msig12.ProposeReturn -type ProposeParams = msig12.ProposeParams -type ApproveReturn = msig12.ApproveReturn +type ProposalHashData = msig13.ProposalHashData +type ProposeReturn = msig13.ProposeReturn +type ProposeParams = msig13.ProposeParams +type ApproveReturn = msig13.ApproveReturn func txnParams(id uint64, data *ProposalHashData) ([]byte, error) { - params := msig12.TxnIDParams{ID: msig12.TxnID(id)} + params := msig13.TxnIDParams{ID: msig13.TxnID(id)} if data != nil { if data.Requester.Protocol() != address.ID { return nil, fmt.Errorf("proposer address must be an ID address, was %s", data.Requester) @@ -265,5 +274,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/venus-shared/actors/builtin/multisig/message.v10.go b/venus-shared/actors/builtin/multisig/message.v10.go index 87c9e7deb5..4a9ed5ad60 100644 --- a/venus-shared/actors/builtin/multisig/message.v10.go +++ b/venus-shared/actors/builtin/multisig/message.v10.go @@ -10,7 +10,7 @@ import ( actorstypes "github.com/filecoin-project/go-state-types/actors" multisig10 "github.com/filecoin-project/go-state-types/builtin/v10/multisig" - init12 "github.com/filecoin-project/go-state-types/builtin/v12/init" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" "github.com/filecoin-project/go-state-types/manifest" builtintypes "github.com/filecoin-project/go-state-types/builtin" @@ -60,7 +60,7 @@ func (m message10) Create( } // new actors are created by invoking 'exec' on the init actor with the constructor params - execParams := &init12.ExecParams{ + execParams := &init13.ExecParams{ CodeCID: code, ConstructorParams: enc, } diff --git a/venus-shared/actors/builtin/multisig/message.v11.go b/venus-shared/actors/builtin/multisig/message.v11.go index 25819c19ab..9e3519c635 100644 --- a/venus-shared/actors/builtin/multisig/message.v11.go +++ b/venus-shared/actors/builtin/multisig/message.v11.go @@ -10,7 +10,7 @@ import ( actorstypes "github.com/filecoin-project/go-state-types/actors" multisig11 "github.com/filecoin-project/go-state-types/builtin/v11/multisig" - init12 "github.com/filecoin-project/go-state-types/builtin/v12/init" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" "github.com/filecoin-project/go-state-types/manifest" builtintypes "github.com/filecoin-project/go-state-types/builtin" @@ -60,7 +60,7 @@ func (m message11) Create( } // new actors are created by invoking 'exec' on the init actor with the constructor params - execParams := &init12.ExecParams{ + execParams := &init13.ExecParams{ CodeCID: code, ConstructorParams: enc, } diff --git a/venus-shared/actors/builtin/multisig/message.v12.go b/venus-shared/actors/builtin/multisig/message.v12.go index da83c8647d..3ed46fc340 100644 --- a/venus-shared/actors/builtin/multisig/message.v12.go +++ b/venus-shared/actors/builtin/multisig/message.v12.go @@ -9,8 +9,8 @@ import ( "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - init12 "github.com/filecoin-project/go-state-types/builtin/v12/init" multisig12 "github.com/filecoin-project/go-state-types/builtin/v12/multisig" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" "github.com/filecoin-project/go-state-types/manifest" builtintypes "github.com/filecoin-project/go-state-types/builtin" @@ -60,7 +60,7 @@ func (m message12) Create( } // new actors are created by invoking 'exec' on the init actor with the constructor params - execParams := &init12.ExecParams{ + execParams := &init13.ExecParams{ CodeCID: code, ConstructorParams: enc, } diff --git a/venus-shared/actors/builtin/multisig/message.v13.go b/venus-shared/actors/builtin/multisig/message.v13.go new file mode 100644 index 0000000000..0025a3b176 --- /dev/null +++ b/venus-shared/actors/builtin/multisig/message.v13.go @@ -0,0 +1,80 @@ +// FETCHED FROM LOTUS: builtin/multisig/message.go.template + +package multisig + +import ( + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" + multisig13 "github.com/filecoin-project/go-state-types/builtin/v13/multisig" + "github.com/filecoin-project/go-state-types/manifest" + + builtintypes "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/venus/venus-shared/actors" + init_ "github.com/filecoin-project/venus/venus-shared/actors/builtin/init" + "github.com/filecoin-project/venus/venus-shared/actors/types" +) + +type message13 struct{ message0 } + +func (m message13) Create( + signers []address.Address, threshold uint64, + unlockStart, unlockDuration abi.ChainEpoch, + initialAmount abi.TokenAmount, +) (*types.Message, error) { + + lenAddrs := uint64(len(signers)) + + if lenAddrs < threshold { + return nil, fmt.Errorf("cannot require signing of more addresses than provided for multisig") + } + + if threshold == 0 { + threshold = lenAddrs + } + + if m.from == address.Undef { + return nil, fmt.Errorf("must provide source address") + } + + // Set up constructor parameters for multisig + msigParams := &multisig13.ConstructorParams{ + Signers: signers, + NumApprovalsThreshold: threshold, + UnlockDuration: unlockDuration, + StartEpoch: unlockStart, + } + + enc, actErr := actors.SerializeParams(msigParams) + if actErr != nil { + return nil, actErr + } + + code, ok := actors.GetActorCodeID(actorstypes.Version13, manifest.MultisigKey) + if !ok { + return nil, fmt.Errorf("failed to get multisig code ID") + } + + // new actors are created by invoking 'exec' on the init actor with the constructor params + execParams := &init13.ExecParams{ + CodeCID: code, + ConstructorParams: enc, + } + + enc, actErr = actors.SerializeParams(execParams) + if actErr != nil { + return nil, actErr + } + + return &types.Message{ + To: init_.Address, + From: m.from, + Method: builtintypes.MethodsInit.Exec, + Params: enc, + Value: initialAmount, + }, nil +} diff --git a/venus-shared/actors/builtin/multisig/message.v8.go b/venus-shared/actors/builtin/multisig/message.v8.go index 74227fc36b..48a60a13cf 100644 --- a/venus-shared/actors/builtin/multisig/message.v8.go +++ b/venus-shared/actors/builtin/multisig/message.v8.go @@ -9,7 +9,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - init12 "github.com/filecoin-project/go-state-types/builtin/v12/init" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" multisig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig" "github.com/filecoin-project/go-state-types/manifest" @@ -60,7 +60,7 @@ func (m message8) Create( } // new actors are created by invoking 'exec' on the init actor with the constructor params - execParams := &init12.ExecParams{ + execParams := &init13.ExecParams{ CodeCID: code, ConstructorParams: enc, } diff --git a/venus-shared/actors/builtin/multisig/message.v9.go b/venus-shared/actors/builtin/multisig/message.v9.go index 640b401b13..e2434e6561 100644 --- a/venus-shared/actors/builtin/multisig/message.v9.go +++ b/venus-shared/actors/builtin/multisig/message.v9.go @@ -9,7 +9,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - init12 "github.com/filecoin-project/go-state-types/builtin/v12/init" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" multisig9 "github.com/filecoin-project/go-state-types/builtin/v9/multisig" "github.com/filecoin-project/go-state-types/manifest" @@ -60,7 +60,7 @@ func (m message9) Create( } // new actors are created by invoking 'exec' on the init actor with the constructor params - execParams := &init12.ExecParams{ + execParams := &init13.ExecParams{ CodeCID: code, ConstructorParams: enc, } diff --git a/venus-shared/actors/builtin/multisig/state.v13.go b/venus-shared/actors/builtin/multisig/state.v13.go new file mode 100644 index 0000000000..765b8b00e4 --- /dev/null +++ b/venus-shared/actors/builtin/multisig/state.v13.go @@ -0,0 +1,140 @@ +// FETCHED FROM LOTUS: builtin/multisig/state.go.template + +package multisig + +import ( + "bytes" + "encoding/binary" + "fmt" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + "github.com/filecoin-project/go-state-types/manifest" + "github.com/filecoin-project/venus/venus-shared/actors" + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + builtin13 "github.com/filecoin-project/go-state-types/builtin" + msig13 "github.com/filecoin-project/go-state-types/builtin/v13/multisig" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { + out := state13{store: store} + out.State = msig13.State{} + out.State.Signers = signers + out.State.NumApprovalsThreshold = threshold + out.State.StartEpoch = startEpoch + out.State.UnlockDuration = unlockDuration + out.State.InitialBalance = initialBalance + + em, err := adt13.StoreEmptyMap(store, builtin13.DefaultHamtBitwidth) + if err != nil { + return nil, err + } + + out.State.PendingTxns = em + + return &out, nil +} + +type state13 struct { + msig13.State + store adt.Store +} + +func (s *state13) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) { + return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil +} + +func (s *state13) StartEpoch() (abi.ChainEpoch, error) { + return s.State.StartEpoch, nil +} + +func (s *state13) UnlockDuration() (abi.ChainEpoch, error) { + return s.State.UnlockDuration, nil +} + +func (s *state13) InitialBalance() (abi.TokenAmount, error) { + return s.State.InitialBalance, nil +} + +func (s *state13) Threshold() (uint64, error) { + return s.State.NumApprovalsThreshold, nil +} + +func (s *state13) Signers() ([]address.Address, error) { + return s.State.Signers, nil +} + +func (s *state13) ForEachPendingTxn(cb func(id int64, txn Transaction) error) error { + arr, err := adt13.AsMap(s.store, s.State.PendingTxns, builtin13.DefaultHamtBitwidth) + if err != nil { + return err + } + var out msig13.Transaction + return arr.ForEach(&out, func(key string) error { + txid, n := binary.Varint([]byte(key)) + if n <= 0 { + return fmt.Errorf("invalid pending transaction key: %v", key) + } + return cb(txid, (Transaction)(out)) //nolint:unconvert + }) +} + +func (s *state13) PendingTxnChanged(other State) (bool, error) { + other13, ok := other.(*state13) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.PendingTxns.Equals(other13.PendingTxns), nil +} + +func (s *state13) transactions() (adt.Map, error) { + return adt13.AsMap(s.store, s.PendingTxns, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) decodeTransaction(val *cbg.Deferred) (Transaction, error) { + var tx msig13.Transaction + if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return Transaction{}, err + } + return Transaction(tx), nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) ActorKey() string { + return manifest.MultisigKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/venus-shared/actors/builtin/paych/actor.go b/venus-shared/actors/builtin/paych/actor.go index b2bf25f268..1a86c3102d 100644 --- a/venus-shared/actors/builtin/paych/actor.go +++ b/venus-shared/actors/builtin/paych/actor.go @@ -38,7 +38,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/actors/types" ) -// Load returns an abstract copy of payment channel state, irregardless of actor version +// Load returns an abstract copy of payment channel state, regardless of actor version func Load(store adt.Store, act *types.Actor) (State, error) { if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { if name != manifest.PaychKey { @@ -62,6 +62,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -182,6 +185,9 @@ func Message(version actorstypes.Version, from address.Address) MessageBuilder { case actorstypes.Version12: return message12{from} + case actorstypes.Version13: + return message13{from} + default: panic(fmt.Sprintf("unsupported actors version: %d", version)) } @@ -224,5 +230,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/venus-shared/actors/builtin/paych/actor.go.template b/venus-shared/actors/builtin/paych/actor.go.template index d9eb0e5836..fc0a429979 100644 --- a/venus-shared/actors/builtin/paych/actor.go.template +++ b/venus-shared/actors/builtin/paych/actor.go.template @@ -29,7 +29,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/actors/types" ) -// Load returns an abstract copy of payment channel state, irregardless of actor version +// Load returns an abstract copy of payment channel state, regardless of actor version func Load(store adt.Store, act *types.Actor) (State, error) { if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { if name != manifest.PaychKey { diff --git a/venus-shared/actors/builtin/paych/message.v13.go b/venus-shared/actors/builtin/paych/message.v13.go new file mode 100644 index 0000000000..cde57ae202 --- /dev/null +++ b/venus-shared/actors/builtin/paych/message.v13.go @@ -0,0 +1,113 @@ +// FETCHED FROM LOTUS: builtin/paych/message.go.template + +package paych + +import ( + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + builtin13 "github.com/filecoin-project/go-state-types/builtin" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" + paych13 "github.com/filecoin-project/go-state-types/builtin/v13/paych" + + "github.com/filecoin-project/venus/venus-shared/actors" + init_ "github.com/filecoin-project/venus/venus-shared/actors/builtin/init" + "github.com/filecoin-project/venus/venus-shared/actors/types" +) + +type message13 struct{ from address.Address } + +func (m message13) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) { + + actorCodeID, ok := actors.GetActorCodeID(actorstypes.Version13, "paymentchannel") + if !ok { + return nil, fmt.Errorf("error getting actor paymentchannel code id for actor version %d", 13) + } + + params, aerr := actors.SerializeParams(&paych13.ConstructorParams{From: m.from, To: to}) + if aerr != nil { + return nil, aerr + } + enc, aerr := actors.SerializeParams(&init13.ExecParams{ + CodeCID: actorCodeID, + ConstructorParams: params, + }) + if aerr != nil { + return nil, aerr + } + + return &types.Message{ + To: init_.Address, + From: m.from, + Value: initialAmount, + Method: builtin13.MethodsInit.Exec, + Params: enc, + }, nil +} + +func (m message13) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) { + params, aerr := actors.SerializeParams(&paych13.UpdateChannelStateParams{ + + Sv: toV13SignedVoucher(*sv), + + Secret: secret, + }) + if aerr != nil { + return nil, aerr + } + + return &types.Message{ + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), + Method: builtin13.MethodsPaych.UpdateChannelState, + Params: params, + }, nil +} + +func toV13SignedVoucher(sv paychtypes.SignedVoucher) paych13.SignedVoucher { + merges := make([]paych13.Merge, len(sv.Merges)) + for i := range sv.Merges { + merges[i] = paych13.Merge{ + Lane: sv.Merges[i].Lane, + Nonce: sv.Merges[i].Nonce, + } + } + + return paych13.SignedVoucher{ + ChannelAddr: sv.ChannelAddr, + TimeLockMin: sv.TimeLockMin, + TimeLockMax: sv.TimeLockMax, + SecretHash: sv.SecretHash, + Extra: (*paych13.ModVerifyParams)(sv.Extra), + Lane: sv.Lane, + Nonce: sv.Nonce, + Amount: sv.Amount, + MinSettleHeight: sv.MinSettleHeight, + Merges: merges, + Signature: sv.Signature, + } +} + +func (m message13) Settle(paych address.Address) (*types.Message, error) { + return &types.Message{ + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), + Method: builtin13.MethodsPaych.Settle, + }, nil +} + +func (m message13) Collect(paych address.Address) (*types.Message, error) { + return &types.Message{ + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), + Method: builtin13.MethodsPaych.Collect, + }, nil +} diff --git a/venus-shared/actors/builtin/paych/state.v13.go b/venus-shared/actors/builtin/paych/state.v13.go new file mode 100644 index 0000000000..48abb0db3a --- /dev/null +++ b/venus-shared/actors/builtin/paych/state.v13.go @@ -0,0 +1,138 @@ +// FETCHED FROM LOTUS: builtin/paych/state.go.template + +package paych + +import ( + "fmt" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/big" + + "github.com/filecoin-project/go-state-types/manifest" + "github.com/filecoin-project/venus/venus-shared/actors" + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + paych13 "github.com/filecoin-project/go-state-types/builtin/v13/paych" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store) (State, error) { + out := state13{store: store} + out.State = paych13.State{} + return &out, nil +} + +type state13 struct { + paych13.State + store adt.Store + lsAmt *adt13.Array +} + +// Channel owner, who has funded the actor +func (s *state13) From() (address.Address, error) { + return s.State.From, nil +} + +// Recipient of payouts from channel +func (s *state13) To() (address.Address, error) { + return s.State.To, nil +} + +// Height at which the channel can be `Collected` +func (s *state13) SettlingAt() (abi.ChainEpoch, error) { + return s.State.SettlingAt, nil +} + +// Amount successfully redeemed through the payment channel, paid out on `Collect()` +func (s *state13) ToSend() (abi.TokenAmount, error) { + return s.State.ToSend, nil +} + +func (s *state13) getOrLoadLsAmt() (*adt13.Array, error) { + if s.lsAmt != nil { + return s.lsAmt, nil + } + + // Get the lane state from the chain + lsamt, err := adt13.AsArray(s.store, s.State.LaneStates, paych13.LaneStatesAmtBitwidth) + if err != nil { + return nil, err + } + + s.lsAmt = lsamt + return lsamt, nil +} + +// Get total number of lanes +func (s *state13) LaneCount() (uint64, error) { + lsamt, err := s.getOrLoadLsAmt() + if err != nil { + return 0, err + } + return lsamt.Length(), nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +// Iterate lane states +func (s *state13) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error { + // Get the lane state from the chain + lsamt, err := s.getOrLoadLsAmt() + if err != nil { + return err + } + + // Note: we use a map instead of an array to store laneStates because the + // client sets the lane ID (the index) and potentially they could use a + // very large index. + var ls paych13.LaneState + return lsamt.ForEach(&ls, func(i int64) error { + return cb(uint64(i), &laneState13{ls}) + }) +} + +type laneState13 struct { + paych13.LaneState +} + +func (ls *laneState13) Redeemed() (big.Int, error) { + return ls.LaneState.Redeemed, nil +} + +func (ls *laneState13) Nonce() (uint64, error) { + return ls.LaneState.Nonce, nil +} + +func (s *state13) ActorKey() string { + return manifest.PaychKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/venus-shared/actors/builtin/power/actor.go b/venus-shared/actors/builtin/power/actor.go index dbbe64152b..f8b6114bf5 100644 --- a/venus-shared/actors/builtin/power/actor.go +++ b/venus-shared/actors/builtin/power/actor.go @@ -34,12 +34,12 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" ) var ( - Address = builtin12.StoragePowerActorAddr - Methods = builtin12.MethodsPower + Address = builtin13.StoragePowerActorAddr + Methods = builtin13.MethodsPower ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -65,6 +65,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -135,6 +138,9 @@ func MakeState(store adt.Store, av actorstypes.Version) (State, error) { case actorstypes.Version12: return make12(store) + case actorstypes.Version13: + return make13(store) + } return nil, fmt.Errorf("unknown actor version %d", av) } @@ -201,5 +207,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/venus-shared/actors/builtin/power/state.v13.go b/venus-shared/actors/builtin/power/state.v13.go new file mode 100644 index 0000000000..f7549f01ed --- /dev/null +++ b/venus-shared/actors/builtin/power/state.v13.go @@ -0,0 +1,210 @@ +// FETCHED FROM LOTUS: builtin/power/state.go.template + +package power + +import ( + "bytes" + "fmt" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + "github.com/filecoin-project/go-state-types/manifest" + "github.com/filecoin-project/venus/venus-shared/actors" + "github.com/filecoin-project/venus/venus-shared/actors/adt" + "github.com/filecoin-project/venus/venus-shared/actors/builtin" + + builtin13 "github.com/filecoin-project/go-state-types/builtin" + power13 "github.com/filecoin-project/go-state-types/builtin/v13/power" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store) (State, error) { + out := state13{store: store} + + s, err := power13.ConstructState(store) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state13 struct { + power13.State + store adt.Store +} + +func (s *state13) TotalLocked() (abi.TokenAmount, error) { + return s.TotalPledgeCollateral, nil +} + +func (s *state13) TotalPower() (Claim, error) { + return Claim{ + RawBytePower: s.TotalRawBytePower, + QualityAdjPower: s.TotalQualityAdjPower, + }, nil +} + +// Committed power to the network. Includes miners below the minimum threshold. +func (s *state13) TotalCommitted() (Claim, error) { + return Claim{ + RawBytePower: s.TotalBytesCommitted, + QualityAdjPower: s.TotalQABytesCommitted, + }, nil +} + +func (s *state13) MinerPower(addr address.Address) (Claim, bool, error) { + claims, err := s.claims() + if err != nil { + return Claim{}, false, err + } + var claim power13.Claim + ok, err := claims.Get(abi.AddrKey(addr), &claim) + if err != nil { + return Claim{}, false, err + } + return Claim{ + RawBytePower: claim.RawBytePower, + QualityAdjPower: claim.QualityAdjPower, + }, ok, nil +} + +func (s *state13) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool, error) { + return s.State.MinerNominalPowerMeetsConsensusMinimum(s.store, a) +} + +func (s *state13) TotalPowerSmoothed() (builtin.FilterEstimate, error) { + return builtin.FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil +} + +func (s *state13) MinerCounts() (uint64, uint64, error) { + return uint64(s.State.MinerAboveMinPowerCount), uint64(s.State.MinerCount), nil +} + +func (s *state13) ListAllMiners() ([]address.Address, error) { + claims, err := s.claims() + if err != nil { + return nil, err + } + + var miners []address.Address + err = claims.ForEach(nil, func(k string) error { + a, err := address.NewFromBytes([]byte(k)) + if err != nil { + return err + } + miners = append(miners, a) + return nil + }) + if err != nil { + return nil, err + } + + return miners, nil +} + +func (s *state13) ForEachClaim(cb func(miner address.Address, claim Claim) error) error { + claims, err := s.claims() + if err != nil { + return err + } + + var claim power13.Claim + return claims.ForEach(&claim, func(k string) error { + a, err := address.NewFromBytes([]byte(k)) + if err != nil { + return err + } + return cb(a, Claim{ + RawBytePower: claim.RawBytePower, + QualityAdjPower: claim.QualityAdjPower, + }) + }) +} + +func (s *state13) ClaimsChanged(other State) (bool, error) { + other13, ok := other.(*state13) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.Claims.Equals(other13.State.Claims), nil +} + +func (s *state13) SetTotalQualityAdjPower(p abi.StoragePower) error { + s.State.TotalQualityAdjPower = p + return nil +} + +func (s *state13) SetTotalRawBytePower(p abi.StoragePower) error { + s.State.TotalRawBytePower = p + return nil +} + +func (s *state13) SetThisEpochQualityAdjPower(p abi.StoragePower) error { + s.State.ThisEpochQualityAdjPower = p + return nil +} + +func (s *state13) SetThisEpochRawBytePower(p abi.StoragePower) error { + s.State.ThisEpochRawBytePower = p + return nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) claims() (adt.Map, error) { + return adt13.AsMap(s.store, s.Claims, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) decodeClaim(val *cbg.Deferred) (Claim, error) { + var ci power13.Claim + if err := ci.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return Claim{}, err + } + return fromV13Claim(ci), nil +} + +func fromV13Claim(v13 power13.Claim) Claim { + return Claim{ + RawBytePower: v13.RawBytePower, + QualityAdjPower: v13.QualityAdjPower, + } +} + +func (s *state13) ActorKey() string { + return manifest.PowerKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/venus-shared/actors/builtin/registry.go b/venus-shared/actors/builtin/registry.go index bccd008f24..f0c211f4d7 100644 --- a/venus-shared/actors/builtin/registry.go +++ b/venus-shared/actors/builtin/registry.go @@ -95,6 +95,25 @@ import ( evm12 "github.com/filecoin-project/go-state-types/builtin/v12/evm" placeholder12 "github.com/filecoin-project/go-state-types/builtin/v12/placeholder" + account13 "github.com/filecoin-project/go-state-types/builtin/v13/account" + cron13 "github.com/filecoin-project/go-state-types/builtin/v13/cron" + _init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" + market13 "github.com/filecoin-project/go-state-types/builtin/v13/market" + miner13 "github.com/filecoin-project/go-state-types/builtin/v13/miner" + multisig13 "github.com/filecoin-project/go-state-types/builtin/v13/multisig" + paych13 "github.com/filecoin-project/go-state-types/builtin/v13/paych" + power13 "github.com/filecoin-project/go-state-types/builtin/v13/power" + reward13 "github.com/filecoin-project/go-state-types/builtin/v13/reward" + system13 "github.com/filecoin-project/go-state-types/builtin/v13/system" + verifreg13 "github.com/filecoin-project/go-state-types/builtin/v13/verifreg" + + datacap13 "github.com/filecoin-project/go-state-types/builtin/v13/datacap" + + eam13 "github.com/filecoin-project/go-state-types/builtin/v13/eam" + ethaccount13 "github.com/filecoin-project/go-state-types/builtin/v13/ethaccount" + evm13 "github.com/filecoin-project/go-state-types/builtin/v13/evm" + placeholder13 "github.com/filecoin-project/go-state-types/builtin/v13/placeholder" + "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/manifest" @@ -631,6 +650,110 @@ func MakeRegistry(av actorstypes.Version) []RegistryEntry { } } + case actorstypes.Version13: + for key, codeID := range codeIDs { + switch key { + case manifest.AccountKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: account13.Methods, + state: new(account13.State), + }) + case manifest.CronKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: cron13.Methods, + state: new(cron13.State), + }) + case manifest.InitKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: _init13.Methods, + state: new(_init13.State), + }) + case manifest.MarketKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: market13.Methods, + state: new(market13.State), + }) + case manifest.MinerKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: miner13.Methods, + state: new(miner13.State), + }) + case manifest.MultisigKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: multisig13.Methods, + state: new(multisig13.State), + }) + case manifest.PaychKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: paych13.Methods, + state: new(paych13.State), + }) + case manifest.PowerKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: power13.Methods, + state: new(power13.State), + }) + case manifest.RewardKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: reward13.Methods, + state: new(reward13.State), + }) + case manifest.SystemKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: system13.Methods, + state: new(system13.State), + }) + case manifest.VerifregKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: verifreg13.Methods, + state: new(verifreg13.State), + }) + case manifest.DatacapKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: datacap13.Methods, + state: new(datacap13.State), + }) + + case manifest.EvmKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: evm13.Methods, + state: new(evm13.State), + }) + case manifest.EamKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: eam13.Methods, + state: nil, + }) + case manifest.PlaceholderKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: placeholder13.Methods, + state: nil, + }) + case manifest.EthAccountKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: ethaccount13.Methods, + state: nil, + }) + + } + } + default: panic("expected version v8 and up only, use specs-actors for v0-7") } diff --git a/venus-shared/actors/builtin/reward/actor.go b/venus-shared/actors/builtin/reward/actor.go index 1382e02be6..0e47f169fc 100644 --- a/venus-shared/actors/builtin/reward/actor.go +++ b/venus-shared/actors/builtin/reward/actor.go @@ -27,7 +27,7 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/venus/venus-shared/actors/adt" @@ -36,8 +36,8 @@ import ( ) var ( - Address = builtin12.RewardActorAddr - Methods = builtin12.MethodsReward + Address = builtin13.RewardActorAddr + Methods = builtin13.MethodsReward ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -63,6 +63,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -133,6 +136,9 @@ func MakeState(store adt.Store, av actorstypes.Version, currRealizedPower abi.St case actorstypes.Version12: return make12(store, currRealizedPower) + case actorstypes.Version13: + return make13(store, currRealizedPower) + } return nil, fmt.Errorf("unknown actor version %d", av) } @@ -177,5 +183,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/venus-shared/actors/builtin/reward/state.v13.go b/venus-shared/actors/builtin/reward/state.v13.go new file mode 100644 index 0000000000..a628837f6d --- /dev/null +++ b/venus-shared/actors/builtin/reward/state.v13.go @@ -0,0 +1,122 @@ +// FETCHED FROM LOTUS: builtin/reward/state.go.template + +package reward + +import ( + "fmt" + + "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/go-state-types/manifest" + "github.com/filecoin-project/venus/venus-shared/actors" + "github.com/filecoin-project/venus/venus-shared/actors/adt" + "github.com/filecoin-project/venus/venus-shared/actors/builtin" + + miner13 "github.com/filecoin-project/go-state-types/builtin/v13/miner" + reward13 "github.com/filecoin-project/go-state-types/builtin/v13/reward" + smoothing13 "github.com/filecoin-project/go-state-types/builtin/v13/util/smoothing" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, currRealizedPower abi.StoragePower) (State, error) { + out := state13{store: store} + out.State = *reward13.ConstructState(currRealizedPower) + return &out, nil +} + +type state13 struct { + reward13.State + store adt.Store +} + +func (s *state13) ThisEpochReward() (abi.TokenAmount, error) { + return s.State.ThisEpochReward, nil +} + +func (s *state13) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) { + + return builtin.FilterEstimate{ + PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate, + VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate, + }, nil + +} + +func (s *state13) ThisEpochBaselinePower() (abi.StoragePower, error) { + return s.State.ThisEpochBaselinePower, nil +} + +func (s *state13) TotalStoragePowerReward() (abi.TokenAmount, error) { + return s.State.TotalStoragePowerReward, nil +} + +func (s *state13) EffectiveBaselinePower() (abi.StoragePower, error) { + return s.State.EffectiveBaselinePower, nil +} + +func (s *state13) EffectiveNetworkTime() (abi.ChainEpoch, error) { + return s.State.EffectiveNetworkTime, nil +} + +func (s *state13) CumsumBaseline() (reward13.Spacetime, error) { + return s.State.CumsumBaseline, nil +} + +func (s *state13) CumsumRealized() (reward13.Spacetime, error) { + return s.State.CumsumRealized, nil +} + +func (s *state13) InitialPledgeForPower(qaPower abi.StoragePower, networkTotalPledge abi.TokenAmount, networkQAPower *builtin.FilterEstimate, circSupply abi.TokenAmount) (abi.TokenAmount, error) { + return miner13.InitialPledgeForPower( + qaPower, + s.State.ThisEpochBaselinePower, + s.State.ThisEpochRewardSmoothed, + smoothing13.FilterEstimate{ + PositionEstimate: networkQAPower.PositionEstimate, + VelocityEstimate: networkQAPower.VelocityEstimate, + }, + circSupply, + ), nil +} + +func (s *state13) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, sectorWeight abi.StoragePower) (abi.TokenAmount, error) { + return miner13.PreCommitDepositForPower(s.State.ThisEpochRewardSmoothed, + smoothing13.FilterEstimate{ + PositionEstimate: networkQAPower.PositionEstimate, + VelocityEstimate: networkQAPower.VelocityEstimate, + }, + sectorWeight), nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) ActorKey() string { + return manifest.RewardKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/venus-shared/actors/builtin/system/actor.go b/venus-shared/actors/builtin/system/actor.go index b4ae56c0a5..f46d11eaf5 100644 --- a/venus-shared/actors/builtin/system/actor.go +++ b/venus-shared/actors/builtin/system/actor.go @@ -26,11 +26,11 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" ) var ( - Address = builtin12.SystemActorAddr + Address = builtin13.SystemActorAddr ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -56,6 +56,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -126,6 +129,9 @@ func MakeState(store adt.Store, av actorstypes.Version, builtinActors cid.Cid) ( case actorstypes.Version12: return make12(store, builtinActors) + case actorstypes.Version13: + return make13(store, builtinActors) + } return nil, fmt.Errorf("unknown actor version %d", av) } @@ -154,5 +160,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/venus-shared/actors/builtin/system/state.v13.go b/venus-shared/actors/builtin/system/state.v13.go new file mode 100644 index 0000000000..52ae283ede --- /dev/null +++ b/venus-shared/actors/builtin/system/state.v13.go @@ -0,0 +1,75 @@ +// FETCHED FROM LOTUS: builtin/system/state.go.template + +package system + +import ( + "fmt" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/go-state-types/manifest" + + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/venus/venus-shared/actors" + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + system13 "github.com/filecoin-project/go-state-types/builtin/v13/system" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, builtinActors cid.Cid) (State, error) { + out := state13{store: store} + out.State = system13.State{ + BuiltinActors: builtinActors, + } + return &out, nil +} + +type state13 struct { + system13.State + store adt.Store +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) GetBuiltinActors() cid.Cid { + + return s.State.BuiltinActors + +} + +func (s *state13) SetBuiltinActors(c cid.Cid) error { + + s.State.BuiltinActors = c + return nil + +} + +func (s *state13) ActorKey() string { + return manifest.SystemKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/venus-shared/actors/builtin/verifreg/actor.go b/venus-shared/actors/builtin/verifreg/actor.go index d21f80ffc5..d2591deba7 100644 --- a/venus-shared/actors/builtin/verifreg/actor.go +++ b/venus-shared/actors/builtin/verifreg/actor.go @@ -28,7 +28,7 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/venus/venus-shared/actors" @@ -37,8 +37,8 @@ import ( ) var ( - Address = builtin12.VerifiedRegistryActorAddr - Methods = builtin12.MethodsVerifiedRegistry + Address = builtin13.VerifiedRegistryActorAddr + Methods = builtin13.MethodsVerifiedRegistry ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -64,6 +64,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -134,6 +137,9 @@ func MakeState(store adt.Store, av actorstypes.Version, rootKeyAddress address.A case actorstypes.Version12: return make12(store, rootKeyAddress) + case actorstypes.Version13: + return make13(store, rootKeyAddress) + } return nil, fmt.Errorf("unknown actor version %d", av) } @@ -153,8 +159,10 @@ type State interface { ForEachClient(func(addr address.Address, dcap abi.StoragePower) error) error GetAllocation(clientIdAddr address.Address, allocationId AllocationId) (*Allocation, bool, error) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) + GetAllAllocations() (map[AllocationId]Allocation, error) GetClaim(providerIdAddr address.Address, claimId ClaimId) (*Claim, bool, error) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) + GetAllClaims() (map[ClaimId]Claim, error) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) GetState() interface{} } @@ -173,6 +181,7 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/venus-shared/actors/builtin/verifreg/actor.go.template b/venus-shared/actors/builtin/verifreg/actor.go.template index 1ed62f9a7e..4bdbe281d4 100644 --- a/venus-shared/actors/builtin/verifreg/actor.go.template +++ b/venus-shared/actors/builtin/verifreg/actor.go.template @@ -83,8 +83,10 @@ type State interface { ForEachClient(func(addr address.Address, dcap abi.StoragePower) error) error GetAllocation(clientIdAddr address.Address, allocationId AllocationId) (*Allocation, bool, error) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) + GetAllAllocations() (map[AllocationId]Allocation, error) GetClaim(providerIdAddr address.Address, claimId ClaimId) (*Claim, bool, error) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) + GetAllClaims() (map[ClaimId]Claim, error) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) GetState() interface{} } diff --git a/venus-shared/actors/builtin/verifreg/state.sep.go.template b/venus-shared/actors/builtin/verifreg/state.sep.go.template index 6de90a3398..8dbbdb5a95 100644 --- a/venus-shared/actors/builtin/verifreg/state.sep.go.template +++ b/venus-shared/actors/builtin/verifreg/state.sep.go.template @@ -146,6 +146,21 @@ func (s *state{{.v}}) GetAllocations(clientIdAddr address.Address) (map[Allocati {{end}} } +func (s *state{{.v}}) GetAllAllocations() (map[AllocationId]Allocation, error) { +{{if (le .v 8)}} + return nil, fmt.Errorf("unsupported in actors v{{.v}}") +{{else}} + v{{.v}}Map, err := s.State.GetAllAllocations(s.store) + + retMap := make(map[AllocationId]Allocation, len(v{{.v}}Map)) + for k, v := range v{{.v}}Map { + retMap[AllocationId(k)] = Allocation(v) + } + + return retMap, err +{{end}} +} + func (s *state{{.v}}) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { {{if (le .v 8)}} return nil, false, fmt.Errorf("unsupported in actors v{{.v}}") @@ -171,6 +186,22 @@ func (s *state{{.v}}) GetClaims(providerIdAddr address.Address) (map[ClaimId]Cla {{end}} } +func (s *state{{.v}}) GetAllClaims() (map[ClaimId]Claim, error) { +{{if (le .v 8)}} + return nil, fmt.Errorf("unsupported in actors v{{.v}}") +{{else}} + v{{.v}}Map, err := s.State.GetAllClaims(s.store) + + retMap := make(map[ClaimId]Claim, len(v{{.v}}Map)) + for k, v := range v{{.v}}Map { + retMap[ClaimId(k)] = Claim(v) + } + + return retMap, err + +{{end}} +} + func (s *state{{.v}}) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) { {{if (le .v 8)}} return nil, fmt.Errorf("unsupported in actors v{{.v}}") diff --git a/venus-shared/actors/builtin/verifreg/state.v0.go b/venus-shared/actors/builtin/verifreg/state.v0.go index f434645853..7304180050 100644 --- a/venus-shared/actors/builtin/verifreg/state.v0.go +++ b/venus-shared/actors/builtin/verifreg/state.v0.go @@ -108,6 +108,12 @@ func (s *state0) GetAllocations(clientIdAddr address.Address) (map[AllocationId] } +func (s *state0) GetAllAllocations() (map[AllocationId]Allocation, error) { + + return nil, fmt.Errorf("unsupported in actors v0") + +} + func (s *state0) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { return nil, false, fmt.Errorf("unsupported in actors v0") @@ -120,6 +126,12 @@ func (s *state0) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, e } +func (s *state0) GetAllClaims() (map[ClaimId]Claim, error) { + + return nil, fmt.Errorf("unsupported in actors v0") + +} + func (s *state0) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) { return nil, fmt.Errorf("unsupported in actors v0") diff --git a/venus-shared/actors/builtin/verifreg/state.v10.go b/venus-shared/actors/builtin/verifreg/state.v10.go index 63cedb944d..c5dea1aff3 100644 --- a/venus-shared/actors/builtin/verifreg/state.v10.go +++ b/venus-shared/actors/builtin/verifreg/state.v10.go @@ -117,6 +117,19 @@ func (s *state10) GetAllocations(clientIdAddr address.Address) (map[AllocationId } +func (s *state10) GetAllAllocations() (map[AllocationId]Allocation, error) { + + v10Map, err := s.State.GetAllAllocations(s.store) + + retMap := make(map[AllocationId]Allocation, len(v10Map)) + for k, v := range v10Map { + retMap[AllocationId(k)] = Allocation(v) + } + + return retMap, err + +} + func (s *state10) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { claim, ok, err := s.FindClaim(s.store, providerIdAddr, verifreg10.ClaimId(claimId)) @@ -137,6 +150,19 @@ func (s *state10) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, } +func (s *state10) GetAllClaims() (map[ClaimId]Claim, error) { + + v10Map, err := s.State.GetAllClaims(s.store) + + retMap := make(map[ClaimId]Claim, len(v10Map)) + for k, v := range v10Map { + retMap[ClaimId(k)] = Claim(v) + } + + return retMap, err + +} + func (s *state10) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) { v10Map, err := s.LoadClaimsToMap(s.store, providerIdAddr) diff --git a/venus-shared/actors/builtin/verifreg/state.v11.go b/venus-shared/actors/builtin/verifreg/state.v11.go index 8e139d3ec7..7f1e332680 100644 --- a/venus-shared/actors/builtin/verifreg/state.v11.go +++ b/venus-shared/actors/builtin/verifreg/state.v11.go @@ -117,6 +117,19 @@ func (s *state11) GetAllocations(clientIdAddr address.Address) (map[AllocationId } +func (s *state11) GetAllAllocations() (map[AllocationId]Allocation, error) { + + v11Map, err := s.State.GetAllAllocations(s.store) + + retMap := make(map[AllocationId]Allocation, len(v11Map)) + for k, v := range v11Map { + retMap[AllocationId(k)] = Allocation(v) + } + + return retMap, err + +} + func (s *state11) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { claim, ok, err := s.FindClaim(s.store, providerIdAddr, verifreg11.ClaimId(claimId)) @@ -137,6 +150,19 @@ func (s *state11) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, } +func (s *state11) GetAllClaims() (map[ClaimId]Claim, error) { + + v11Map, err := s.State.GetAllClaims(s.store) + + retMap := make(map[ClaimId]Claim, len(v11Map)) + for k, v := range v11Map { + retMap[ClaimId(k)] = Claim(v) + } + + return retMap, err + +} + func (s *state11) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) { v11Map, err := s.LoadClaimsToMap(s.store, providerIdAddr) diff --git a/venus-shared/actors/builtin/verifreg/state.v12.go b/venus-shared/actors/builtin/verifreg/state.v12.go index 787e7887f7..b9cc763242 100644 --- a/venus-shared/actors/builtin/verifreg/state.v12.go +++ b/venus-shared/actors/builtin/verifreg/state.v12.go @@ -117,6 +117,19 @@ func (s *state12) GetAllocations(clientIdAddr address.Address) (map[AllocationId } +func (s *state12) GetAllAllocations() (map[AllocationId]Allocation, error) { + + v12Map, err := s.State.GetAllAllocations(s.store) + + retMap := make(map[AllocationId]Allocation, len(v12Map)) + for k, v := range v12Map { + retMap[AllocationId(k)] = Allocation(v) + } + + return retMap, err + +} + func (s *state12) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { claim, ok, err := s.FindClaim(s.store, providerIdAddr, verifreg12.ClaimId(claimId)) @@ -137,6 +150,19 @@ func (s *state12) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, } +func (s *state12) GetAllClaims() (map[ClaimId]Claim, error) { + + v12Map, err := s.State.GetAllClaims(s.store) + + retMap := make(map[ClaimId]Claim, len(v12Map)) + for k, v := range v12Map { + retMap[ClaimId(k)] = Claim(v) + } + + return retMap, err + +} + func (s *state12) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) { v12Map, err := s.LoadClaimsToMap(s.store, providerIdAddr) diff --git a/venus-shared/actors/builtin/verifreg/state.v13.go b/venus-shared/actors/builtin/verifreg/state.v13.go new file mode 100644 index 0000000000..49ced07bdb --- /dev/null +++ b/venus-shared/actors/builtin/verifreg/state.v13.go @@ -0,0 +1,199 @@ +// FETCHED FROM LOTUS: builtin/verifreg/state.go.template + +package verifreg + +import ( + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/go-state-types/manifest" + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/venus/venus-shared/actors" + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + builtin13 "github.com/filecoin-project/go-state-types/builtin" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" + verifreg13 "github.com/filecoin-project/go-state-types/builtin/v13/verifreg" + + "github.com/filecoin-project/go-state-types/big" + + verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, rootKeyAddress address.Address) (State, error) { + out := state13{store: store} + + s, err := verifreg13.ConstructState(store, rootKeyAddress) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state13 struct { + verifreg13.State + store adt.Store +} + +func (s *state13) RootKey() (address.Address, error) { + return s.State.RootKey, nil +} + +func (s *state13) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) { + + return false, big.Zero(), fmt.Errorf("unsupported in actors v13") + +} + +func (s *state13) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) { + return getDataCap(s.store, actors.Version13, s.verifiers, addr) +} + +func (s *state13) RemoveDataCapProposalID(verifier address.Address, client address.Address) (bool, uint64, error) { + return getRemoveDataCapProposalID(s.store, actors.Version13, s.removeDataCapProposalIDs, verifier, client) +} + +func (s *state13) ForEachVerifier(cb func(addr address.Address, dcap abi.StoragePower) error) error { + return forEachCap(s.store, actors.Version13, s.verifiers, cb) +} + +func (s *state13) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error { + + return fmt.Errorf("unsupported in actors v13") + +} + +func (s *state13) verifiedClients() (adt.Map, error) { + + return nil, fmt.Errorf("unsupported in actors v13") + +} + +func (s *state13) verifiers() (adt.Map, error) { + return adt13.AsMap(s.store, s.Verifiers, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) removeDataCapProposalIDs() (adt.Map, error) { + return adt13.AsMap(s.store, s.RemoveDataCapProposalIDs, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*Allocation, bool, error) { + + alloc, ok, err := s.FindAllocation(s.store, clientIdAddr, verifreg13.AllocationId(allocationId)) + return (*Allocation)(alloc), ok, err +} + +func (s *state13) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) { + + v13Map, err := s.LoadAllocationsToMap(s.store, clientIdAddr) + + retMap := make(map[AllocationId]Allocation, len(v13Map)) + for k, v := range v13Map { + retMap[AllocationId(k)] = Allocation(v) + } + + return retMap, err + +} + +func (s *state13) GetAllAllocations() (map[AllocationId]Allocation, error) { + + v13Map, err := s.State.GetAllAllocations(s.store) + + retMap := make(map[AllocationId]Allocation, len(v13Map)) + for k, v := range v13Map { + retMap[AllocationId(k)] = Allocation(v) + } + + return retMap, err + +} + +func (s *state13) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { + + claim, ok, err := s.FindClaim(s.store, providerIdAddr, verifreg13.ClaimId(claimId)) + return (*Claim)(claim), ok, err + +} + +func (s *state13) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) { + + v13Map, err := s.LoadClaimsToMap(s.store, providerIdAddr) + + retMap := make(map[ClaimId]Claim, len(v13Map)) + for k, v := range v13Map { + retMap[ClaimId(k)] = Claim(v) + } + + return retMap, err + +} + +func (s *state13) GetAllClaims() (map[ClaimId]Claim, error) { + + v13Map, err := s.State.GetAllClaims(s.store) + + retMap := make(map[ClaimId]Claim, len(v13Map)) + for k, v := range v13Map { + retMap[ClaimId(k)] = Claim(v) + } + + return retMap, err + +} + +func (s *state13) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) { + + v13Map, err := s.LoadClaimsToMap(s.store, providerIdAddr) + + retMap := make(map[abi.SectorNumber][]ClaimId) + for k, v := range v13Map { + claims, ok := retMap[v.Sector] + if !ok { + retMap[v.Sector] = []ClaimId{ClaimId(k)} + } else { + retMap[v.Sector] = append(claims, ClaimId(k)) + } + } + + return retMap, err + +} + +func (s *state13) ActorKey() string { + return manifest.VerifregKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/venus-shared/actors/builtin/verifreg/state.v2.go b/venus-shared/actors/builtin/verifreg/state.v2.go index f8ba1c735b..b53fa61e9d 100644 --- a/venus-shared/actors/builtin/verifreg/state.v2.go +++ b/venus-shared/actors/builtin/verifreg/state.v2.go @@ -108,6 +108,12 @@ func (s *state2) GetAllocations(clientIdAddr address.Address) (map[AllocationId] } +func (s *state2) GetAllAllocations() (map[AllocationId]Allocation, error) { + + return nil, fmt.Errorf("unsupported in actors v2") + +} + func (s *state2) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { return nil, false, fmt.Errorf("unsupported in actors v2") @@ -120,6 +126,12 @@ func (s *state2) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, e } +func (s *state2) GetAllClaims() (map[ClaimId]Claim, error) { + + return nil, fmt.Errorf("unsupported in actors v2") + +} + func (s *state2) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) { return nil, fmt.Errorf("unsupported in actors v2") diff --git a/venus-shared/actors/builtin/verifreg/state.v3.go b/venus-shared/actors/builtin/verifreg/state.v3.go index 5d5f1928b5..a9b35c5bb2 100644 --- a/venus-shared/actors/builtin/verifreg/state.v3.go +++ b/venus-shared/actors/builtin/verifreg/state.v3.go @@ -110,6 +110,12 @@ func (s *state3) GetAllocations(clientIdAddr address.Address) (map[AllocationId] } +func (s *state3) GetAllAllocations() (map[AllocationId]Allocation, error) { + + return nil, fmt.Errorf("unsupported in actors v3") + +} + func (s *state3) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { return nil, false, fmt.Errorf("unsupported in actors v3") @@ -122,6 +128,12 @@ func (s *state3) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, e } +func (s *state3) GetAllClaims() (map[ClaimId]Claim, error) { + + return nil, fmt.Errorf("unsupported in actors v3") + +} + func (s *state3) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) { return nil, fmt.Errorf("unsupported in actors v3") diff --git a/venus-shared/actors/builtin/verifreg/state.v4.go b/venus-shared/actors/builtin/verifreg/state.v4.go index 26ea536a19..2985072b96 100644 --- a/venus-shared/actors/builtin/verifreg/state.v4.go +++ b/venus-shared/actors/builtin/verifreg/state.v4.go @@ -110,6 +110,12 @@ func (s *state4) GetAllocations(clientIdAddr address.Address) (map[AllocationId] } +func (s *state4) GetAllAllocations() (map[AllocationId]Allocation, error) { + + return nil, fmt.Errorf("unsupported in actors v4") + +} + func (s *state4) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { return nil, false, fmt.Errorf("unsupported in actors v4") @@ -122,6 +128,12 @@ func (s *state4) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, e } +func (s *state4) GetAllClaims() (map[ClaimId]Claim, error) { + + return nil, fmt.Errorf("unsupported in actors v4") + +} + func (s *state4) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) { return nil, fmt.Errorf("unsupported in actors v4") diff --git a/venus-shared/actors/builtin/verifreg/state.v5.go b/venus-shared/actors/builtin/verifreg/state.v5.go index 1e6d3a07ac..3441c763b8 100644 --- a/venus-shared/actors/builtin/verifreg/state.v5.go +++ b/venus-shared/actors/builtin/verifreg/state.v5.go @@ -110,6 +110,12 @@ func (s *state5) GetAllocations(clientIdAddr address.Address) (map[AllocationId] } +func (s *state5) GetAllAllocations() (map[AllocationId]Allocation, error) { + + return nil, fmt.Errorf("unsupported in actors v5") + +} + func (s *state5) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { return nil, false, fmt.Errorf("unsupported in actors v5") @@ -122,6 +128,12 @@ func (s *state5) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, e } +func (s *state5) GetAllClaims() (map[ClaimId]Claim, error) { + + return nil, fmt.Errorf("unsupported in actors v5") + +} + func (s *state5) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) { return nil, fmt.Errorf("unsupported in actors v5") diff --git a/venus-shared/actors/builtin/verifreg/state.v6.go b/venus-shared/actors/builtin/verifreg/state.v6.go index 5c76251a67..47c5922b82 100644 --- a/venus-shared/actors/builtin/verifreg/state.v6.go +++ b/venus-shared/actors/builtin/verifreg/state.v6.go @@ -110,6 +110,12 @@ func (s *state6) GetAllocations(clientIdAddr address.Address) (map[AllocationId] } +func (s *state6) GetAllAllocations() (map[AllocationId]Allocation, error) { + + return nil, fmt.Errorf("unsupported in actors v6") + +} + func (s *state6) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { return nil, false, fmt.Errorf("unsupported in actors v6") @@ -122,6 +128,12 @@ func (s *state6) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, e } +func (s *state6) GetAllClaims() (map[ClaimId]Claim, error) { + + return nil, fmt.Errorf("unsupported in actors v6") + +} + func (s *state6) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) { return nil, fmt.Errorf("unsupported in actors v6") diff --git a/venus-shared/actors/builtin/verifreg/state.v7.go b/venus-shared/actors/builtin/verifreg/state.v7.go index 19bb0c220e..ca89fca858 100644 --- a/venus-shared/actors/builtin/verifreg/state.v7.go +++ b/venus-shared/actors/builtin/verifreg/state.v7.go @@ -109,6 +109,12 @@ func (s *state7) GetAllocations(clientIdAddr address.Address) (map[AllocationId] } +func (s *state7) GetAllAllocations() (map[AllocationId]Allocation, error) { + + return nil, fmt.Errorf("unsupported in actors v7") + +} + func (s *state7) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { return nil, false, fmt.Errorf("unsupported in actors v7") @@ -121,6 +127,12 @@ func (s *state7) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, e } +func (s *state7) GetAllClaims() (map[ClaimId]Claim, error) { + + return nil, fmt.Errorf("unsupported in actors v7") + +} + func (s *state7) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) { return nil, fmt.Errorf("unsupported in actors v7") diff --git a/venus-shared/actors/builtin/verifreg/state.v8.go b/venus-shared/actors/builtin/verifreg/state.v8.go index 672970f7e4..5aae22e5b7 100644 --- a/venus-shared/actors/builtin/verifreg/state.v8.go +++ b/venus-shared/actors/builtin/verifreg/state.v8.go @@ -108,6 +108,12 @@ func (s *state8) GetAllocations(clientIdAddr address.Address) (map[AllocationId] } +func (s *state8) GetAllAllocations() (map[AllocationId]Allocation, error) { + + return nil, fmt.Errorf("unsupported in actors v8") + +} + func (s *state8) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { return nil, false, fmt.Errorf("unsupported in actors v8") @@ -120,6 +126,12 @@ func (s *state8) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, e } +func (s *state8) GetAllClaims() (map[ClaimId]Claim, error) { + + return nil, fmt.Errorf("unsupported in actors v8") + +} + func (s *state8) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) { return nil, fmt.Errorf("unsupported in actors v8") diff --git a/venus-shared/actors/builtin/verifreg/state.v9.go b/venus-shared/actors/builtin/verifreg/state.v9.go index c4080e37c3..a29055bc9d 100644 --- a/venus-shared/actors/builtin/verifreg/state.v9.go +++ b/venus-shared/actors/builtin/verifreg/state.v9.go @@ -115,6 +115,19 @@ func (s *state9) GetAllocations(clientIdAddr address.Address) (map[AllocationId] } +func (s *state9) GetAllAllocations() (map[AllocationId]Allocation, error) { + + v9Map, err := s.State.GetAllAllocations(s.store) + + retMap := make(map[AllocationId]Allocation, len(v9Map)) + for k, v := range v9Map { + retMap[AllocationId(k)] = Allocation(v) + } + + return retMap, err + +} + func (s *state9) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { claim, ok, err := s.FindClaim(s.store, providerIdAddr, verifreg9.ClaimId(claimId)) @@ -135,6 +148,19 @@ func (s *state9) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, e } +func (s *state9) GetAllClaims() (map[ClaimId]Claim, error) { + + v9Map, err := s.State.GetAllClaims(s.store) + + retMap := make(map[ClaimId]Claim, len(v9Map)) + for k, v := range v9Map { + retMap[ClaimId(k)] = Claim(v) + } + + return retMap, err + +} + func (s *state9) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) { v9Map, err := s.LoadClaimsToMap(s.store, providerIdAddr) diff --git a/venus-shared/actors/builtin_actors_gen.go b/venus-shared/actors/builtin_actors_gen.go index a719def318..b374562c3d 100644 --- a/venus-shared/actors/builtin_actors_gen.go +++ b/venus-shared/actors/builtin_actors_gen.go @@ -116,6 +116,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": mustParseCid("bafk2bzacec3vwj2chzaram3iqupkbfiein5h2l5qiltlrngbju2vg5umelclm"), "verifiedregistry": mustParseCid("bafk2bzacedv2irkql7nil3w5v3ohqq3e54w62pxeoppjmaktzokolaaoh5ksu"), }, +}, { + Network: "butterflynet", + Version: 13, + + ManifestCid: mustParseCid("bafy2bzaceaqx5xa4cwso24rjiu2ketjlztrqlac6dkyol7tlyuhzrle3zfbos"), + Actors: map[string]cid.Cid{ + "account": mustParseCid("bafk2bzacedl533kwbzouqxibejpwp6syfdekvmzy4vmmno6j4iaydbdmv4xek"), + "cron": mustParseCid("bafk2bzacecimv5xnuwyoqgxk26qt4xqpgntleret475pnh35s3vvhqtdct4ow"), + "datacap": mustParseCid("bafk2bzacebpdd4ctavhs7wkcykfahpifct3p4hbptgtf4jfrqcp2trtlygvow"), + "eam": mustParseCid("bafk2bzaceahw5rrgj7prgbnmn237di7ymjz2ssea32wr525jydpfrwpuhs67m"), + "ethaccount": mustParseCid("bafk2bzacebrslcbew5mq3le2zsn36xqxd4gt5hryeoslxnuqwgw3rhuwh6ygu"), + "evm": mustParseCid("bafk2bzaced5smz4lhpem4mbr7igcskv3e5qopbdp7dqshww2qs4ahacgzjzo4"), + "init": mustParseCid("bafk2bzacedgj6hawhdw2ot2ufisci374o2bq6bfkvlvdt6q7s3uoe5ffyv43k"), + "multisig": mustParseCid("bafk2bzacectnnnpwyqiccaymy3h6ghu74ghjrqyhtqv5odfd4opivzebjj6to"), + "paymentchannel": mustParseCid("bafk2bzaceckhx44jawhzhkz6k23gfnv2gcutgb4j4ekhonj2plwaent4b2tpk"), + "placeholder": mustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": mustParseCid("bafk2bzacebbs3rlg7y3wbvxrj4wgbsqmasw4ksbbr3lyqbkaxj2t25qz6zzuy"), + "storagemarket": mustParseCid("bafk2bzaced3zmxsmlhp2nsiwkxcp2ugonbsebcd53t7htzo2jcoidvu464xmm"), + "storageminer": mustParseCid("bafk2bzacebedx7iaa2ruspxvghkg46ez7un5b7oiijjtnvddq2aot5wk7p7ry"), + "storagepower": mustParseCid("bafk2bzacebvne7m2l3hxxw4xa6oujol75x35yqpnlqiwx74jilyrop4cs7cse"), + "system": mustParseCid("bafk2bzaceacjmlxrvydlud77ilpzbscez46yedx6zjsj6olxsdeuv6d4x4cwe"), + "verifiedregistry": mustParseCid("bafk2bzaceaf2po4fxf7gw7cdvulwxxtvnsvzfn4gff5w267qnz7r44ywk25c6"), + }, }, { Network: "calibrationnet", Version: 8, @@ -222,6 +245,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": mustParseCid("bafk2bzacecioupndtcnyw6iq2hbrxag3aufvczlv5nobnfbkbywqzcyfaa376"), "verifiedregistry": mustParseCid("bafk2bzaceavldupmf7bimeeacs67z5xdfdlfca6p7sn6bev3mt5ggepfqvhqo"), }, +}, { + Network: "calibrationnet", + Version: 13, + + ManifestCid: mustParseCid("bafy2bzacea4firkyvt2zzdwqjrws5pyeluaesh6uaid246tommayr4337xpmi"), + Actors: map[string]cid.Cid{ + "account": mustParseCid("bafk2bzaceb3j36ri5y5mfklgp5emlvrms6g4733ss2j3l7jismrxq6ng3tcc6"), + "cron": mustParseCid("bafk2bzaceaz6rocamdxehgpwcbku6wlapwpgzyyvkrploj66mlqptsulf52bs"), + "datacap": mustParseCid("bafk2bzacea22nv5g3yngpxvonqfj4r2nkfk64y6yw2malicm7odk77x7zuads"), + "eam": mustParseCid("bafk2bzaceatqtjzj7623i426noaslouvluhz6e3md3vvquqzku5qj3532uaxg"), + "ethaccount": mustParseCid("bafk2bzacean3hs7ga5csw6g3uu7watxfnqv5uvxviebn3ba6vg4sagwdur5pu"), + "evm": mustParseCid("bafk2bzacec5ibmbtzuzjgwjmksm2n6zfq3gkicxqywwu7tsscqgdzajpfctxk"), + "init": mustParseCid("bafk2bzaced5sq72oemz6qwi6yssxwlos2g54zfprslrx5qfhhx2vlgsbvdpcs"), + "multisig": mustParseCid("bafk2bzacedbgei6jkx36fwdgvoohce4aghvpohqdhoco7p4thszgssms7olv2"), + "paymentchannel": mustParseCid("bafk2bzaceasmgmfsi4mjanxlowsub65fmevhzky4toeqbtw4kp6tmu4kxjpgq"), + "placeholder": mustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": mustParseCid("bafk2bzacedjyp6ll5ez27dfgldjj4tntxfvyp4pa5zkk7s5uhipzqjyx2gmuc"), + "storagemarket": mustParseCid("bafk2bzaceabolct6qdnefwcrtati2us3sxtxfghyqk6aamfhl6byyefmtssqi"), + "storageminer": mustParseCid("bafk2bzaceckzw3v7wqliyggvjvihz4wywchnnsie4frfvkm3fm5znb64mofri"), + "storagepower": mustParseCid("bafk2bzacea7t4wynzjajl442mpdqbnh3wusjusqtnzgpvefvweh4n2tgzgqhu"), + "system": mustParseCid("bafk2bzacedjnrb5glewazsxpcx6rwiuhl4kwrfcqolyprn6rrjtlzmthlhdq6"), + "verifiedregistry": mustParseCid("bafk2bzacednskl3bykz5qpo54z2j2p4q44t5of4ktd6vs6ymmg2zebsbxazkm"), + }, }, { Network: "caterpillarnet", Version: 8, @@ -337,6 +383,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": mustParseCid("bafk2bzacedye5j5uxox7knb6zlnhseaadztyav76mjbyk5qslhhbpiy5cdtt2"), "verifiedregistry": mustParseCid("bafk2bzacecduww5pirr7dvaijjijw4gf6ygf7vipgxh4scvv6vseo46gueb46"), }, +}, { + Network: "caterpillarnet", + Version: 13, + + ManifestCid: mustParseCid("bafy2bzacecozgyaqlzq4qebq52uogmrk6ahk7z2i4qfkh5iv235bpqqv7w24m"), + Actors: map[string]cid.Cid{ + "account": mustParseCid("bafk2bzacecro3uo6ypqhfzwdhnamzcole5qmhrbkx7qny6t2qsrcpqxelt6s2"), + "cron": mustParseCid("bafk2bzaceam3kci46y4siltbw7f4itoap34kp7b7pvn2fco5s2bvnotomwdbe"), + "datacap": mustParseCid("bafk2bzacecmtdspcbqmmjtsaz4vucuqoqjqfsgxjonns7tom7eblkngbcm7bw"), + "eam": mustParseCid("bafk2bzaceaudqhrt7djewopqdnryvwxagfufyt7ja4gdvovrxbh6edh6evgrw"), + "ethaccount": mustParseCid("bafk2bzaced676ds3z6xe333wr7frwq3f2iq5kjwp4okl3te6rne3xf7kuqrwm"), + "evm": mustParseCid("bafk2bzacebeih4jt2s6mel6x4hje7xmnugh6twul2a5axx4iczu7fu4wcdi6k"), + "init": mustParseCid("bafk2bzaceba7vvuzzwj5wqnq2bvpbgtxup53mhr3qybezbllftnxvpqbfymxo"), + "multisig": mustParseCid("bafk2bzaceapkajhnqoczrgry5javqbl7uebgmsbpqqfemzc4yb5q2dqia2qog"), + "paymentchannel": mustParseCid("bafk2bzacebg7xq4ca22gafmdbkcq357x7v6slflib4h3fnj4amsovg6ulqg3o"), + "placeholder": mustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": mustParseCid("bafk2bzaceajt4idf26ffnyipybcib55fykjxnek7oszkqzi7lu7mbgijmkgos"), + "storagemarket": mustParseCid("bafk2bzaceadfmay7pyl7osjsdmrireafasnjnoziacljy5ewrcsxpp56kzqbw"), + "storageminer": mustParseCid("bafk2bzaceardbn5a7aq5jxl7efr4btmsbl7txnxm4hrrd3llyhujuc2cr5vcs"), + "storagepower": mustParseCid("bafk2bzacear4563jznjqyseoy42xl6kenyqk6umv6xl3bp5bsjb3hbs6sp6bm"), + "system": mustParseCid("bafk2bzacecc5oavxivfnvirx2g7megpdf6lugooyoc2wijloju247xzjcdezy"), + "verifiedregistry": mustParseCid("bafk2bzacecpqldvrs6i7xzbyizkpdvrick3cahrbdptmimdsrpnxu6k4xs4pm"), + }, }, { Network: "devnet", Version: 8, @@ -443,6 +512,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": mustParseCid("bafk2bzacecnau5wddulbsvwn75tc3w75jrlvkybgrlxs4ngonqab6xq3eowvg"), "verifiedregistry": mustParseCid("bafk2bzacec37mddea65nvh4htsagtryfa3sq6i67utcupslyhzbhjhoy6hopa"), }, +}, { + Network: "devnet", + Version: 13, + + ManifestCid: mustParseCid("bafy2bzaceap34qfq4emg4fp3xd7bxtzt7pvkaj37kunqm2ccvttchtlljw7d4"), + Actors: map[string]cid.Cid{ + "account": mustParseCid("bafk2bzacebev3fu5geeehpx577b3kvza4xsmmggmepjj7rlsnr27hpoq27q2i"), + "cron": mustParseCid("bafk2bzacedalzqahtuz2bmnf7uawbcujfhhe5xzv5ys5ufadu6ggs3tcu6lsy"), + "datacap": mustParseCid("bafk2bzaceb7ou2vn7ac4xidespoowq2q5w7ognr7s4ujy3xzzgiishajpe7le"), + "eam": mustParseCid("bafk2bzacedqic2qskattorj4svf6mbto2k76ej3ll3ugsyorqramrg7rpq3by"), + "ethaccount": mustParseCid("bafk2bzaceaoad7iknpywijigv2h3jyvkijff2oxvohzue533v5hby3iix5vdu"), + "evm": mustParseCid("bafk2bzacecjgiw26gagsn6a7tffkrgoor4zfgzfokp76u6cwervtmvjbopmwg"), + "init": mustParseCid("bafk2bzaced2obubqojxggeddr246cpwtyzi6knnq52jsvsc2fs3tuk2kh6dtg"), + "multisig": mustParseCid("bafk2bzacebquruzb6zho45orbdkku624t6w6jt4tudaqzraz4yh3li3jfstpg"), + "paymentchannel": mustParseCid("bafk2bzaceaydrilyxvflsuzr24hmw32qwz6sy4hgls73bhpveydcsqskdgpca"), + "placeholder": mustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": mustParseCid("bafk2bzaceb74owpuzdddqoj2tson6ymbyuguqrnqefyiaxqvwm4ygitpabjrq"), + "storagemarket": mustParseCid("bafk2bzaceaw6dslv6pfqha4ynghq2imij5khnnjrie22kmfgtpie3bvxho6jq"), + "storageminer": mustParseCid("bafk2bzacecsputz6xygjfyrvx2d7bxkpp7b5v4icrmpckec7gnbabx2w377qs"), + "storagepower": mustParseCid("bafk2bzaceceyaa5yjwhxvvcqouob4l746zp5nesivr6enhtpimakdtby6kafi"), + "system": mustParseCid("bafk2bzaceaxg6k5vuozxlemfi5hv663m6jcawzu5puboo4znj73i36e3tsovs"), + "verifiedregistry": mustParseCid("bafk2bzacebjwc4fp4n556agi5i4pccuzn4bhn2tl24l4cskgvmwgadycff3oo"), + }, }, { Network: "hyperspace", Version: 8, @@ -572,6 +664,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": mustParseCid("bafk2bzacebfqrja2hip7esf4eafxjmu6xcogoqu5xxtgdg7xa5szgvvdguchu"), "verifiedregistry": mustParseCid("bafk2bzacedudgflxc75c77c6zkmfyq4u2xuk7k6xw6dfdccarjrvxx453b77q"), }, +}, { + Network: "mainnet", + Version: 13, + + ManifestCid: mustParseCid("bafy2bzacecoplaet2m4kzueqgutjxpl76bhmuiq5hmo3ueighbnxas3rj4dvy"), + Actors: map[string]cid.Cid{ + "account": mustParseCid("bafk2bzacedxnbtlsqdk76fsfmnhyvsblwyfducerwwtp3mqtx2wbrvs5idl52"), + "cron": mustParseCid("bafk2bzacebbopddyn5csb3fsuhh2an4ttd23x6qnwixgohlirj5ahtcudphyc"), + "datacap": mustParseCid("bafk2bzaceah42tfnhd7xnztawgf46gbvc3m2gudoxshlba2ucmmo2vy67t7ci"), + "eam": mustParseCid("bafk2bzaceb23bhvvcjsth7cn7vp3gbaphrutsaz7v6hkls3ogotzs4bnhm4mk"), + "ethaccount": mustParseCid("bafk2bzaceautge6zhuy6jbj3uldwoxwhpywuon6z3xfvmdbzpbdribc6zzmei"), + "evm": mustParseCid("bafk2bzacedq6v2lyuhgywhlllwmudfj2zufzcauxcsvvd34m2ek5xr55mvh2q"), + "init": mustParseCid("bafk2bzacedr4xacm3fts4vilyeiacjr2hpmwzclyzulbdo24lrfxbtau2wbai"), + "multisig": mustParseCid("bafk2bzacecr5zqarfqak42xqcfeulsxlavcltawsx2fvc7zsjtby6ti4b3wqc"), + "paymentchannel": mustParseCid("bafk2bzacebntdhfmyc24e7tm52ggx5tnw4i3hrr3jmllsepv3mibez4hywsa2"), + "placeholder": mustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": mustParseCid("bafk2bzacedq4q2kwkruu4xm7rkyygumlbw2yt4nimna2ivea4qarvtkohnuwu"), + "storagemarket": mustParseCid("bafk2bzacebjtoltdviyznpj34hh5qp6u257jnnbjole5rhqfixm7ug3epvrfu"), + "storageminer": mustParseCid("bafk2bzacebf4rrqyk7gcfggggul6nfpzay7f2ordnkwm7z2wcf4mq6r7i77t2"), + "storagepower": mustParseCid("bafk2bzacecjy4dkulvxppg3ocbmeixe2wgg6yxoyjxrm4ko2fm3uhpvfvam6e"), + "system": mustParseCid("bafk2bzacecyf523quuq2kdjfdvyty446z2ounmamtgtgeqnr3ynlu5cqrlt6e"), + "verifiedregistry": mustParseCid("bafk2bzaceblqlrece7lezbp42lfba5ojlyxuv3vcbkldw45wpdadqwqslev3g"), + }, }, { Network: "testing", Version: 8, @@ -678,6 +793,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": mustParseCid("bafk2bzacecp4roanbxq3bflftlkipsoqqxio5etjjnzxus5pcu7lq43fnxb34"), "verifiedregistry": mustParseCid("bafk2bzaceandytrgcnuvizfi47sijbqh6c243vjtzlzumexm6kjv7s7hye45g"), }, +}, { + Network: "testing", + Version: 13, + + ManifestCid: mustParseCid("bafy2bzacedcrzpgb4jac75auzcjkh55bxipdiospgvjsivumnqlvg2rp2ahmg"), + Actors: map[string]cid.Cid{ + "account": mustParseCid("bafk2bzaceb3tncntgeqvzzr5fzhvpsc5ntv3tpqrsh4jst4irfyzpkdyigibc"), + "cron": mustParseCid("bafk2bzacecwwasmhixpgtshczm5cfspwciyawc25mrefknqhlxfrd6m57tqmc"), + "datacap": mustParseCid("bafk2bzaceckj66by6eohjrybazh5cymmovgl5bmikpvzki2q7huwk2fweoef2"), + "eam": mustParseCid("bafk2bzaceafzm65wvnaam3775homn4vzsv7odftn5tkifmn44wd2t6gupy63y"), + "ethaccount": mustParseCid("bafk2bzaced4q7m4mha2dsezhwub3ru64rgimkg52t25ul4gnekax6uq7hbkqu"), + "evm": mustParseCid("bafk2bzaceakpknw5cuizil3552jr5z35rs6ijaignjigciswtok67drhzdss6"), + "init": mustParseCid("bafk2bzacec7mbkemwugyg2p4oy2xgnovykk4dnsu5ym4wkreooujvxfsxbo3i"), + "multisig": mustParseCid("bafk2bzacebmftoql6dcyqf54xznwjg2bfgdsi67spqquwslpvvtvcx6qenhz2"), + "paymentchannel": mustParseCid("bafk2bzaceau57wpiiikea6pu5om4ryyqjrxjzfksfl4reqosnohydzv3pf4qq"), + "placeholder": mustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": mustParseCid("bafk2bzacecvlcdgbqlk3dyfzkcjrywg2th5bmn7ilijifikulpxr4ffcrw23o"), + "storagemarket": mustParseCid("bafk2bzacecgj53dwqla7eiubs2uiza7cgxkxtefxkfpjontj5jxefl3a4i2nq"), + "storageminer": mustParseCid("bafk2bzaceailclue4dba2edjethfjw6ycufcwsx4qjjmgsh77xcyprmogdjvu"), + "storagepower": mustParseCid("bafk2bzaceaqw6dhdjlqovhk3p4lb4sb25i5d6mhln2ir5m7tj6m4fegkgkinw"), + "system": mustParseCid("bafk2bzaceby6aiiosnrtb5kzlmrvd4k3o27oo3idmbd6llydz2uqibbp23pzq"), + "verifiedregistry": mustParseCid("bafk2bzacebqwmxch4np2nwzi2yt6vkciy2mp75otwoipulkmfxly3ifhj5g6i"), + }, }, { Network: "testing-fake-proofs", Version: 8, @@ -784,6 +922,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": mustParseCid("bafk2bzacecp4roanbxq3bflftlkipsoqqxio5etjjnzxus5pcu7lq43fnxb34"), "verifiedregistry": mustParseCid("bafk2bzaceandytrgcnuvizfi47sijbqh6c243vjtzlzumexm6kjv7s7hye45g"), }, +}, { + Network: "testing-fake-proofs", + Version: 13, + + ManifestCid: mustParseCid("bafy2bzaceaeepylii2u3lvuvrbdureocn6cuizhaq6o6ivmtzldweqf675w5s"), + Actors: map[string]cid.Cid{ + "account": mustParseCid("bafk2bzaceb3tncntgeqvzzr5fzhvpsc5ntv3tpqrsh4jst4irfyzpkdyigibc"), + "cron": mustParseCid("bafk2bzacecwwasmhixpgtshczm5cfspwciyawc25mrefknqhlxfrd6m57tqmc"), + "datacap": mustParseCid("bafk2bzaceckj66by6eohjrybazh5cymmovgl5bmikpvzki2q7huwk2fweoef2"), + "eam": mustParseCid("bafk2bzaceafzm65wvnaam3775homn4vzsv7odftn5tkifmn44wd2t6gupy63y"), + "ethaccount": mustParseCid("bafk2bzaced4q7m4mha2dsezhwub3ru64rgimkg52t25ul4gnekax6uq7hbkqu"), + "evm": mustParseCid("bafk2bzaceakpknw5cuizil3552jr5z35rs6ijaignjigciswtok67drhzdss6"), + "init": mustParseCid("bafk2bzacec7mbkemwugyg2p4oy2xgnovykk4dnsu5ym4wkreooujvxfsxbo3i"), + "multisig": mustParseCid("bafk2bzacedy4vldq4viv6bzzh4fueip3by3axsbgbh655lashddgumknc6pvs"), + "paymentchannel": mustParseCid("bafk2bzaceau57wpiiikea6pu5om4ryyqjrxjzfksfl4reqosnohydzv3pf4qq"), + "placeholder": mustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": mustParseCid("bafk2bzacecvlcdgbqlk3dyfzkcjrywg2th5bmn7ilijifikulpxr4ffcrw23o"), + "storagemarket": mustParseCid("bafk2bzacecgj53dwqla7eiubs2uiza7cgxkxtefxkfpjontj5jxefl3a4i2nq"), + "storageminer": mustParseCid("bafk2bzaceb6atn3k6yhmskgmc3lgfiwpzpfmaxzacohtnb2hivme2oroycqr6"), + "storagepower": mustParseCid("bafk2bzacedameh56mp2g4y7nprhax5sddbzcmpk5p7l523l45rtn2wjc6ah4e"), + "system": mustParseCid("bafk2bzaceby6aiiosnrtb5kzlmrvd4k3o27oo3idmbd6llydz2uqibbp23pzq"), + "verifiedregistry": mustParseCid("bafk2bzacebqwmxch4np2nwzi2yt6vkciy2mp75otwoipulkmfxly3ifhj5g6i"), + }, }} func mustParseCid(c string) cid.Cid { diff --git a/venus-shared/actors/params.go b/venus-shared/actors/params.go index c319233a7a..7a9937119a 100644 --- a/venus-shared/actors/params.go +++ b/venus-shared/actors/params.go @@ -15,7 +15,7 @@ import ( func SerializeParams(i cbg.CBORMarshaler) ([]byte, aerrors.ActorError) { buf := new(bytes.Buffer) if err := i.MarshalCBOR(buf); err != nil { - // TODO: shouldnt this be a fatal error? + // TODO: shouldn't this be a fatal error? return nil, aerrors.Absorb(err, exitcode.ErrSerialization, "failed to encode parameter") } return buf.Bytes(), nil diff --git a/venus-shared/actors/policy/policy.go b/venus-shared/actors/policy/policy.go index f43d85b827..518730589b 100644 --- a/venus-shared/actors/policy/policy.go +++ b/venus-shared/actors/policy/policy.go @@ -4,6 +4,7 @@ package policy import ( actorstypes "github.com/filecoin-project/go-state-types/actors" + "golang.org/x/xerrors" "fmt" @@ -79,18 +80,23 @@ import ( miner12 "github.com/filecoin-project/go-state-types/builtin/v12/miner" verifreg12 "github.com/filecoin-project/go-state-types/builtin/v12/verifreg" - paych12 "github.com/filecoin-project/go-state-types/builtin/v12/paych" + builtin13 "github.com/filecoin-project/go-state-types/builtin" + market13 "github.com/filecoin-project/go-state-types/builtin/v13/market" + miner13 "github.com/filecoin-project/go-state-types/builtin/v13/miner" + verifreg13 "github.com/filecoin-project/go-state-types/builtin/v13/verifreg" + + paych13 "github.com/filecoin-project/go-state-types/builtin/v13/paych" ) const ( - ChainFinality = miner12.ChainFinality + ChainFinality = miner13.ChainFinality SealRandomnessLookback = ChainFinality - PaychSettleDelay = paych12.SettleDelay - MaxPreCommitRandomnessLookback = builtin12.EpochsInDay + SealRandomnessLookback + PaychSettleDelay = paych13.SettleDelay + MaxPreCommitRandomnessLookback = builtin13.EpochsInDay + SealRandomnessLookback ) var ( - MarketDefaultAllocationTermBuffer = market12.MarketDefaultAllocationTermBuffer + MarketDefaultAllocationTermBuffer = market13.MarketDefaultAllocationTermBuffer ) // SetSupportedProofTypes sets supported proof types, across all actor versions. @@ -205,11 +211,13 @@ func SetPreCommitChallengeDelay(delay abi.ChainEpoch) { miner12.PreCommitChallengeDelay = delay + miner13.PreCommitChallengeDelay = delay + } // TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay. func GetPreCommitChallengeDelay() abi.ChainEpoch { - return miner12.PreCommitChallengeDelay + return miner13.PreCommitChallengeDelay } // SetConsensusMinerMinPower sets the minimum power of an individual miner must @@ -263,6 +271,10 @@ func SetConsensusMinerMinPower(p abi.StoragePower) { policy.ConsensusMinerMinPower = p } + for _, policy := range builtin13.PoStProofPolicies { + policy.ConsensusMinerMinPower = p + } + } // SetMinVerifiedDealSize sets the minimum size of a verified deal. This should @@ -293,6 +305,8 @@ func SetMinVerifiedDealSize(size abi.StoragePower) { verifreg12.MinVerifiedDealSize = size + verifreg13.MinVerifiedDealSize = size + } func GetMaxProveCommitDuration(ver actorstypes.Version, t abi.RegisteredSealProof) (abi.ChainEpoch, error) { @@ -346,6 +360,10 @@ func GetMaxProveCommitDuration(ver actorstypes.Version, t abi.RegisteredSealProo return miner12.MaxProveCommitDuration[t], nil + case actorstypes.Version13: + + return miner13.MaxProveCommitDuration[t], nil + default: return 0, fmt.Errorf("unsupported actors version") } @@ -411,6 +429,11 @@ func SetProviderCollateralSupplyTarget(num, denom big.Int) { Denominator: denom, } + market13.ProviderCollateralSupplyTarget = builtin13.BigFrac{ + Numerator: num, + Denominator: denom, + } + } func DealProviderCollateralBounds( @@ -484,13 +507,18 @@ func DealProviderCollateralBounds( min, max := market12.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil + case actorstypes.Version13: + + min, max := market13.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) + return min, max, nil + default: return big.Zero(), big.Zero(), fmt.Errorf("unsupported actors version") } } func DealDurationBounds(pieceSize abi.PaddedPieceSize) (min, max abi.ChainEpoch) { - return market12.DealDurationBounds(pieceSize) + return market13.DealDurationBounds(pieceSize) } // Sets the challenge window and scales the proving period to match (such that @@ -573,6 +601,13 @@ func SetWPoStChallengeWindow(period abi.ChainEpoch) { // scale it if we're scaling the challenge period. miner12.WPoStDisputeWindow = period * 30 + miner13.WPoStChallengeWindow = period + miner13.WPoStProvingPeriod = period * abi.ChainEpoch(miner13.WPoStPeriodDeadlines) + + // by default, this is 2x finality which is 30 periods. + // scale it if we're scaling the challenge period. + miner13.WPoStDisputeWindow = period * 30 + } func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch { @@ -627,6 +662,9 @@ func GetMaxSectorExpirationExtension(nv network.Version) (abi.ChainEpoch, error) case actorstypes.Version12: return miner12.MaxSectorExpirationExtension, nil + case actorstypes.Version13: + return miner13.MaxSectorExpirationExtension, nil + default: return 0, fmt.Errorf("unsupported network version") } @@ -634,11 +672,11 @@ func GetMaxSectorExpirationExtension(nv network.Version) (abi.ChainEpoch, error) } func GetMinSectorExpiration() abi.ChainEpoch { - return miner12.MinSectorExpiration + return miner13.MinSectorExpiration } func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, error) { - sectorsPerPart, err := builtin12.PoStProofWindowPoStPartitionSectors(p) + sectorsPerPart, err := builtin13.PoStProofWindowPoStPartitionSectors(p) if err != nil { return 0, err } @@ -647,7 +685,7 @@ func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, e return 0, err } - return min(miner12.PoStedPartitionsMax, int(uint64(maxSectors)/sectorsPerPart)), nil + return min(miner13.PoStedPartitionsMax, int(uint64(maxSectors)/sectorsPerPart)), nil } func GetDefaultAggregationProof() abi.RegisteredAggregationProof { @@ -659,7 +697,7 @@ func GetSectorMaxLifetime(proof abi.RegisteredSealProof, nwVer network.Version) return builtin4.SealProofPoliciesV0[proof].SectorMaxLifetime } - return builtin12.SealProofPoliciesV11[proof].SectorMaxLifetime + return builtin13.SealProofPoliciesV11[proof].SectorMaxLifetime } func GetAddressedSectorsMax(nwVer network.Version) (int, error) { @@ -705,6 +743,9 @@ func GetAddressedSectorsMax(nwVer network.Version) (int, error) { case actorstypes.Version12: return miner12.AddressedSectorsMax, nil + case actorstypes.Version13: + return miner13.AddressedSectorsMax, nil + default: return 0, fmt.Errorf("unsupported network version") } @@ -766,6 +807,10 @@ func GetDeclarationsMax(nwVer network.Version) (int, error) { return miner12.DeclarationsMax, nil + case actorstypes.Version13: + + return miner13.DeclarationsMax, nil + default: return 0, fmt.Errorf("unsupported network version") } @@ -826,6 +871,10 @@ func AggregateProveCommitNetworkFee(nwVer network.Version, aggregateSize int, ba return miner12.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil + case actorstypes.Version13: + + return miner13.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil + default: return big.Zero(), fmt.Errorf("unsupported network version") } @@ -886,11 +935,33 @@ func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, base return miner12.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil + case actorstypes.Version13: + + return miner13.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil + default: return big.Zero(), fmt.Errorf("unsupported network version") } } +var PoStToSealMap map[abi.RegisteredPoStProof]abi.RegisteredSealProof + +func init() { + PoStToSealMap = make(map[abi.RegisteredPoStProof]abi.RegisteredSealProof) + for sealProof, info := range abi.SealProofInfos { + PoStToSealMap[info.WinningPoStProof] = sealProof + PoStToSealMap[info.WindowPoStProof] = sealProof + } +} + +func GetSealProofFromPoStProof(postProof abi.RegisteredPoStProof) (abi.RegisteredSealProof, error) { + sealProof, exists := PoStToSealMap[postProof] + if !exists { + return 0, xerrors.New("no corresponding RegisteredSealProof for the given RegisteredPoStProof") + } + return sealProof, nil +} + func min(a, b int) int { if a < b { return a diff --git a/venus-shared/actors/policy/policy.go.template b/venus-shared/actors/policy/policy.go.template index fdec0e07ca..02a46c49b5 100644 --- a/venus-shared/actors/policy/policy.go.template +++ b/venus-shared/actors/policy/policy.go.template @@ -345,6 +345,23 @@ func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, base } } +var PoStToSealMap map[abi.RegisteredPoStProof]abi.RegisteredSealProof +func init() { + PoStToSealMap = make(map[abi.RegisteredPoStProof]abi.RegisteredSealProof) + for sealProof, info := range abi.SealProofInfos { + PoStToSealMap[info.WinningPoStProof] = sealProof + PoStToSealMap[info.WindowPoStProof] = sealProof + } +} + +func GetSealProofFromPoStProof(postProof abi.RegisteredPoStProof) (abi.RegisteredSealProof, error) { + sealProof, exists := PoStToSealMap[postProof] + if !exists { + return 0, xerrors.New("no corresponding RegisteredSealProof for the given RegisteredPoStProof") + } + return sealProof, nil +} + func min(a, b int) int { if a < b { return a diff --git a/venus-shared/actors/types/cbor_gen.go b/venus-shared/actors/types/cbor_gen.go index 10a878e9c6..921ecc9bca 100644 --- a/venus-shared/actors/types/cbor_gen.go +++ b/venus-shared/actors/types/cbor_gen.go @@ -89,7 +89,7 @@ func (t *Message) MarshalCBOR(w io.Writer) error { } // t.Params ([]uint8) (slice) - if len(t.Params) > cbg.ByteArrayMaxLen { + if len(t.Params) > 2097152 { return xerrors.Errorf("Byte array in field t.Params was too long") } @@ -97,9 +97,10 @@ func (t *Message) MarshalCBOR(w io.Writer) error { return err } - if _, err := cw.Write(t.Params[:]); err != nil { + if _, err := cw.Write(t.Params); err != nil { return err } + return nil } @@ -184,10 +185,10 @@ func (t *Message) UnmarshalCBOR(r io.Reader) (err error) { // t.GasLimit (int64) (int64) { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -245,7 +246,7 @@ func (t *Message) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.ByteArrayMaxLen { + if extra > 2097152 { return fmt.Errorf("t.Params: byte array too large (%d)", extra) } if maj != cbg.MajByteString { @@ -256,9 +257,10 @@ func (t *Message) UnmarshalCBOR(r io.Reader) (err error) { t.Params = make([]uint8, extra) } - if _, err := io.ReadFull(cr, t.Params[:]); err != nil { + if _, err := io.ReadFull(cr, t.Params); err != nil { return err } + return nil } diff --git a/venus-shared/actors/types/eth.go b/venus-shared/actors/types/eth.go index 73cb3e5e55..448527f13a 100644 --- a/venus-shared/actors/types/eth.go +++ b/venus-shared/actors/types/eth.go @@ -343,6 +343,13 @@ func IsEthAddress(addr address.Address) bool { return namespace == builtintypes.EthereumAddressManagerActorID && len(payload) == 20 && !bytes.HasPrefix(payload, maskedIDPrefix[:]) } +func EthAddressFromActorID(id abi.ActorID) EthAddress { + var ethaddr EthAddress + ethaddr[0] = 0xff + binary.BigEndian.PutUint64(ethaddr[12:], uint64(id)) + return ethaddr +} + func EthAddressFromFilecoinAddress(addr address.Address) (EthAddress, error) { switch addr.Protocol() { case address.ID: @@ -350,10 +357,7 @@ func EthAddressFromFilecoinAddress(addr address.Address) (EthAddress, error) { if err != nil { return EthAddress{}, err } - var ethaddr EthAddress - ethaddr[0] = 0xff - binary.BigEndian.PutUint64(ethaddr[12:], id) - return ethaddr, nil + return EthAddressFromActorID(abi.ActorID(id)), nil case address.Delegated: payload := addr.Payload() namespace, n, err := varint.FromUvarint(payload) @@ -651,7 +655,7 @@ type EthFilterSpec struct { Topics EthTopicSpec `json:"topics"` // Restricts event logs returned to those emitted from messages contained in this tipset. - // If BlockHash is present in in the filter criteria, then neither FromBlock nor ToBlock are allowed. + // If BlockHash is present in the filter criteria, then neither FromBlock nor ToBlock are allowed. // Added in EIP-234 BlockHash *EthHash `json:"blockHash,omitempty"` } @@ -856,6 +860,45 @@ func GetContractEthAddressFromCode(sender EthAddress, salt [32]byte, initcode [] return ethAddr, nil } +// EthEstimateGasParams handles raw jsonrpc params for eth_estimateGas +type EthEstimateGasParams struct { + Tx EthCall + BlkParam *EthBlockNumberOrHash +} + +func (e *EthEstimateGasParams) UnmarshalJSON(b []byte) error { + var params []json.RawMessage + err := json.Unmarshal(b, ¶ms) + if err != nil { + return err + } + + switch len(params) { + case 2: + err = json.Unmarshal(params[1], &e.BlkParam) + if err != nil { + return err + } + fallthrough + case 1: + err = json.Unmarshal(params[0], &e.Tx) + if err != nil { + return err + } + default: + return fmt.Errorf("expected 1 or 2 params, got %d", len(params)) + } + + return nil +} + +func (e EthEstimateGasParams) MarshalJSON() ([]byte, error) { + if e.BlkParam != nil { + return json.Marshal([]interface{}{e.Tx, e.BlkParam}) + } + return json.Marshal([]interface{}{e.Tx}) +} + // EthFeeHistoryParams handles raw jsonrpc params for eth_feeHistory type EthFeeHistoryParams struct { BlkCount EthUint64 @@ -989,11 +1032,12 @@ func (e *EthBlockNumberOrHash) UnmarshalJSON(b []byte) error { } type EthTrace struct { - Action EthTraceAction `json:"action"` - Result EthTraceResult `json:"result"` - Subtraces int `json:"subtraces"` - TraceAddress []int `json:"traceAddress"` - Type string `json:"Type"` + Type string `json:"type"` + Error string `json:"error,omitempty"` + Subtraces int `json:"subtraces"` + TraceAddress []int `json:"traceAddress"` + Action any `json:"action"` + Result any `json:"result"` Parent *EthTrace `json:"-"` @@ -1002,11 +1046,6 @@ type EthTrace struct { LastByteCode *EthTrace `json:"-"` } -func (t *EthTrace) SetCallType(callType string) { - t.Action.CallType = callType - t.Type = callType -} - type EthTraceBlock struct { *EthTrace BlockHash EthHash `json:"blockHash"` @@ -1023,21 +1062,29 @@ type EthTraceReplayBlockTransaction struct { VMTrace *string `json:"vmTrace"` } -type EthTraceAction struct { +type EthCallTraceAction struct { CallType string `json:"callType"` From EthAddress `json:"from"` To EthAddress `json:"to"` Gas EthUint64 `json:"gas"` - Input EthBytes `json:"input"` Value EthBigInt `json:"value"` - - FilecoinMethod abi.MethodNum `json:"-"` - FilecoinCodeCid cid.Cid `json:"-"` - FilecoinFrom address.Address `json:"-"` - FilecoinTo address.Address `json:"-"` + Input EthBytes `json:"input"` } -type EthTraceResult struct { +type EthCallTraceResult struct { GasUsed EthUint64 `json:"gasUsed"` Output EthBytes `json:"output"` } + +type EthCreateTraceAction struct { + From EthAddress `json:"from"` + Gas EthUint64 `json:"gas"` + Value EthBigInt `json:"value"` + Init EthBytes `json:"init"` +} + +type EthCreateTraceResult struct { + Address *EthAddress `json:"address,omitempty"` + GasUsed EthUint64 `json:"gasUsed"` + Code EthBytes `json:"code"` +} diff --git a/venus-shared/actors/version.go b/venus-shared/actors/version.go index 09d0363028..c793ecfb42 100644 --- a/venus-shared/actors/version.go +++ b/venus-shared/actors/version.go @@ -16,9 +16,9 @@ const ({{range .actorVersions}} /* inline-gen start */ -var LatestVersion = 12 +var LatestVersion = 13 -var Versions = []int{0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} +var Versions = []int{0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} const ( Version0 Version = 0 @@ -33,6 +33,7 @@ const ( Version10 Version = 10 Version11 Version = 11 Version12 Version = 12 + Version13 Version = 13 ) /* inline-gen end */ diff --git a/venus-shared/api/chain/v0/method.md b/venus-shared/api/chain/v0/method.md index 844a36ae2b..bb2b328d08 100644 --- a/venus-shared/api/chain/v0/method.md +++ b/venus-shared/api/chain/v0/method.md @@ -1221,7 +1221,7 @@ Perms: read Inputs: ```json [ - 21 + 22 ] ``` @@ -1236,7 +1236,7 @@ Perms: read Inputs: ```json [ - 21 + 22 ] ``` @@ -1331,16 +1331,27 @@ Response: "Params": "Ynl0ZSBhcnJheQ==", "ParamsCodec": 42, "GasLimit": 42, - "ReadOnly": true, - "CodeCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } + "ReadOnly": true }, "MsgRct": { "ExitCode": 0, "Return": "Ynl0ZSBhcnJheQ==", "ReturnCodec": 42 }, + "InvokedActor": { + "Id": 1000, + "State": { + "Code": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Head": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Nonce": 42, + "Balance": "0", + "Address": "f01234" + } + }, "GasCharges": [ { "Name": "string value", @@ -1360,16 +1371,27 @@ Response: "Params": "Ynl0ZSBhcnJheQ==", "ParamsCodec": 42, "GasLimit": 42, - "ReadOnly": true, - "CodeCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } + "ReadOnly": true }, "MsgRct": { "ExitCode": 0, "Return": "Ynl0ZSBhcnJheQ==", "ReturnCodec": 42 }, + "InvokedActor": { + "Id": 1000, + "State": { + "Code": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Head": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Nonce": 42, + "Balance": "0", + "Address": "f01234" + } + }, "GasCharges": [ { "Name": "string value", @@ -1512,16 +1534,27 @@ Response: "Params": "Ynl0ZSBhcnJheQ==", "ParamsCodec": 42, "GasLimit": 42, - "ReadOnly": true, - "CodeCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } + "ReadOnly": true }, "MsgRct": { "ExitCode": 0, "Return": "Ynl0ZSBhcnJheQ==", "ReturnCodec": 42 }, + "InvokedActor": { + "Id": 1000, + "State": { + "Code": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Head": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Nonce": 42, + "Balance": "0", + "Address": "f01234" + } + }, "GasCharges": [ { "Name": "string value", @@ -1541,16 +1574,27 @@ Response: "Params": "Ynl0ZSBhcnJheQ==", "ParamsCodec": 42, "GasLimit": 42, - "ReadOnly": true, - "CodeCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } + "ReadOnly": true }, "MsgRct": { "ExitCode": 0, "Return": "Ynl0ZSBhcnJheQ==", "ReturnCodec": 42 }, + "InvokedActor": { + "Id": 1000, + "State": { + "Code": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Head": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Nonce": 42, + "Balance": "0", + "Address": "f01234" + } + }, "GasCharges": [ { "Name": "string value", @@ -1614,7 +1658,9 @@ Response: "UpgradeHyggeHeight": 10101, "UpgradeLightningHeight": 10101, "UpgradeThunderHeight": 10101, - "UpgradeWatermelonHeight": 10101 + "UpgradeWatermelonHeight": 10101, + "UpgradeDragonHeight": 10101, + "UpgradePhoenixHeight": 10101 }, "Eip155ChainID": 123 } @@ -1732,7 +1778,7 @@ Inputs: ] ``` -Response: `21` +Response: `22` ### StateReplay @@ -1806,16 +1852,27 @@ Response: "Params": "Ynl0ZSBhcnJheQ==", "ParamsCodec": 42, "GasLimit": 42, - "ReadOnly": true, - "CodeCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } + "ReadOnly": true }, "MsgRct": { "ExitCode": 0, "Return": "Ynl0ZSBhcnJheQ==", "ReturnCodec": 42 }, + "InvokedActor": { + "Id": 1000, + "State": { + "Code": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Head": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Nonce": 42, + "Balance": "0", + "Address": "f01234" + } + }, "GasCharges": [ { "Name": "string value", @@ -1835,16 +1892,27 @@ Response: "Params": "Ynl0ZSBhcnJheQ==", "ParamsCodec": 42, "GasLimit": 42, - "ReadOnly": true, - "CodeCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } + "ReadOnly": true }, "MsgRct": { "ExitCode": 0, "Return": "Ynl0ZSBhcnJheQ==", "ReturnCodec": 42 }, + "InvokedActor": { + "Id": 1000, + "State": { + "Code": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Head": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Nonce": 42, + "Balance": "0", + "Address": "f01234" + } + }, "GasCharges": [ { "Name": "string value", @@ -3483,8 +3551,7 @@ Response: "State": { "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, - "SlashEpoch": 10101, - "VerifiedClaim": 0 + "SlashEpoch": 10101 } } } @@ -3531,8 +3598,7 @@ Response: "State": { "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, - "SlashEpoch": 10101, - "VerifiedClaim": 0 + "SlashEpoch": 10101 } } ``` diff --git a/venus-shared/api/chain/v1/actor_event.go b/venus-shared/api/chain/v1/actor_event.go new file mode 100644 index 0000000000..aa1472079e --- /dev/null +++ b/venus-shared/api/chain/v1/actor_event.go @@ -0,0 +1,36 @@ +package v1 + +import ( + "context" + + "github.com/filecoin-project/venus/venus-shared/types" +) + +type IActorEvent interface { + // Actor events + + // GetActorEvents returns all user-programmed and built-in actor events that match the given + // filter. + // This is a request/response API. + // Results available from this API may be limited by the MaxFilterResults and MaxFilterHeightRange + // configuration options and also the amount of historical data available in the node. + // + // This is an EXPERIMENTAL API and may be subject to change. + GetActorEvents(ctx context.Context, filter *types.ActorEventFilter) ([]*types.ActorEvent, error) //perm:read + + // SubscribeActorEvents returns a long-lived stream of all user-programmed and built-in actor + // events that match the given filter. + // Events that match the given filter are written to the stream in real-time as they are emitted + // from the FVM. + // The response stream is closed when the client disconnects, when a ToHeight is specified and is + // reached, or if there is an error while writing an event to the stream. + // This API also allows clients to read all historical events matching the given filter before any + // real-time events are written to the response stream if the filter specifies an earlier + // FromHeight. + // Results available from this API may be limited by the MaxFilterResults and MaxFilterHeightRange + // configuration options and also the amount of historical data available in the node. + // + // Note: this API is only available via websocket connections. + // This is an EXPERIMENTAL API and may be subject to change. + SubscribeActorEvents(ctx context.Context, filter *types.ActorEventFilter) (<-chan *types.ActorEvent, error) //perm:read +} diff --git a/venus-shared/api/chain/v1/chain.go b/venus-shared/api/chain/v1/chain.go index ee1504b53f..0fe3cf6d95 100644 --- a/venus-shared/api/chain/v1/chain.go +++ b/venus-shared/api/chain/v1/chain.go @@ -15,6 +15,7 @@ import ( "github.com/ipfs/go-cid" lminer "github.com/filecoin-project/venus/venus-shared/actors/builtin/miner" + "github.com/filecoin-project/venus/venus-shared/actors/builtin/verifreg" "github.com/filecoin-project/venus/venus-shared/types" ) @@ -185,14 +186,20 @@ type IMinerState interface { // StateGetAllocationForPendingDeal returns the allocation for a given deal ID of a pending deal. Returns nil if // pending allocation is not found. StateGetAllocationForPendingDeal(ctx context.Context, dealID abi.DealID, tsk types.TipSetKey) (*types.Allocation, error) //perm:read + // StateGetAllocationIdForPendingDeal is like StateGetAllocationForPendingDeal except it returns the allocation ID + StateGetAllocationIdForPendingDeal(ctx context.Context, dealID abi.DealID, tsk types.TipSetKey) (verifreg.AllocationId, error) //perm:read // StateGetAllocation returns the allocation for a given address and allocation ID. StateGetAllocation(ctx context.Context, clientAddr address.Address, allocationID types.AllocationId, tsk types.TipSetKey) (*types.Allocation, error) //perm:read + // StateGetAllAllocations returns the all the allocations available in verified registry actor. + StateGetAllAllocations(ctx context.Context, tsk types.TipSetKey) (map[types.AllocationId]types.Allocation, error) //perm:read // StateGetAllocations returns the all the allocations for a given client. StateGetAllocations(ctx context.Context, clientAddr address.Address, tsk types.TipSetKey) (map[types.AllocationId]types.Allocation, error) //perm:read // StateGetClaim returns the claim for a given address and claim ID. StateGetClaim(ctx context.Context, providerAddr address.Address, claimID types.ClaimId, tsk types.TipSetKey) (*types.Claim, error) //perm:read // StateGetClaims returns the all the claims for a given provider. StateGetClaims(ctx context.Context, providerAddr address.Address, tsk types.TipSetKey) (map[types.ClaimId]types.Claim, error) //perm:read + // StateGetAllClaims returns the all the claims available in verified registry actor. + StateGetAllClaims(ctx context.Context, tsk types.TipSetKey) (map[types.ClaimId]types.Claim, error) //perm:read // StateComputeDataCID computes DataCID from a set of on-chain deals StateComputeDataCID(ctx context.Context, maddr address.Address, sectorType abi.RegisteredSealProof, deals []abi.DealID, tsk types.TipSetKey) (cid.Cid, error) //perm:read StateMinerPreCommitDepositForPower(ctx context.Context, maddr address.Address, pci types.SectorPreCommitInfo, tsk types.TipSetKey) (big.Int, error) //perm:read diff --git a/venus-shared/api/chain/v1/eth.go b/venus-shared/api/chain/v1/eth.go index 68d327e76a..c551c81307 100644 --- a/venus-shared/api/chain/v1/eth.go +++ b/venus-shared/api/chain/v1/eth.go @@ -55,7 +55,7 @@ type IETH interface { EthFeeHistory(ctx context.Context, p jsonrpc.RawParams) (types.EthFeeHistory, error) //perm:read EthMaxPriorityFeePerGas(ctx context.Context) (types.EthBigInt, error) //perm:read - EthEstimateGas(ctx context.Context, tx types.EthCall) (types.EthUint64, error) //perm:read + EthEstimateGas(ctx context.Context, p jsonrpc.RawParams) (types.EthUint64, error) //perm:read EthCall(ctx context.Context, tx types.EthCall, blkParam types.EthBlockNumberOrHash) (types.EthBytes, error) //perm:read EthSendRawTransaction(ctx context.Context, rawTx types.EthBytes) (types.EthHash, error) //perm:read @@ -64,8 +64,24 @@ type IETH interface { Web3ClientVersion(ctx context.Context) (string, error) //perm:read // TraceAPI related methods + + // Returns an OpenEthereum-compatible trace of the given block (implementing `trace_block`), + // translating Filecoin semantics into Ethereum semantics and tracing both EVM and FVM calls. + // + // Features: + // + // - FVM actor create events, calls, etc. show up as if they were EVM smart contract events. + // - Native FVM call inputs are ABI-encoded (Solidity ABI) as if they were calls to a + // `handle_filecoin_method(uint64 method, uint64 codec, bytes params)` function + // (where `codec` is the IPLD codec of `params`). + // - Native FVM call outputs (return values) are ABI-encoded as `(uint32 exit_code, uint64 + // codec, bytes output)` where `codec` is the IPLD codec of `output`. + // + // Limitations (for now): // - // Returns traces created at given block + // 1. Block rewards are not included in the trace. + // 2. SELFDESTRUCT operations are not included in the trace. + // 3. EVM smart contract "create" events always specify `0xfe` as the "code" for newly created EVM smart contracts. EthTraceBlock(ctx context.Context, blkNum string) ([]*types.EthTraceBlock, error) //perm:read // Replays all transactions in a block returning the requested traces for each transaction EthTraceReplayBlockTransactions(ctx context.Context, blkNum string, traceTypes []string) ([]*types.EthTraceReplayBlockTransaction, error) //perm:read diff --git a/venus-shared/api/chain/v1/fullnode.go b/venus-shared/api/chain/v1/fullnode.go index 8afc3effb4..9a363b9f88 100644 --- a/venus-shared/api/chain/v1/fullnode.go +++ b/venus-shared/api/chain/v1/fullnode.go @@ -12,4 +12,5 @@ type FullNode interface { IWallet ICommon FullETH + IActorEvent } diff --git a/venus-shared/api/chain/v1/method.md b/venus-shared/api/chain/v1/method.md index 143f53a90e..06dc2d1a00 100644 --- a/venus-shared/api/chain/v1/method.md +++ b/venus-shared/api/chain/v1/method.md @@ -11,6 +11,9 @@ curl http://:/rpc/v1 -X POST -H "Content-Type: application/json" -H " * [Actor](#actor) * [ListActor](#listactor) * [StateGetActor](#stategetactor) +* [ActorEvent](#actorevent) + * [GetActorEvents](#getactorevents) + * [SubscribeActorEvents](#subscribeactorevents) * [BlockStore](#blockstore) * [ChainDeleteObj](#chaindeleteobj) * [ChainHasObj](#chainhasobj) @@ -146,8 +149,11 @@ curl http://:/rpc/v1 -X POST -H "Content-Type: application/json" -H " * [StateDealProviderCollateralBounds](#statedealprovidercollateralbounds) * [StateDecodeParams](#statedecodeparams) * [StateEncodeParams](#stateencodeparams) + * [StateGetAllAllocations](#stategetallallocations) + * [StateGetAllClaims](#stategetallclaims) * [StateGetAllocation](#stategetallocation) * [StateGetAllocationForPendingDeal](#stategetallocationforpendingdeal) + * [StateGetAllocationIdForPendingDeal](#stategetallocationidforpendingdeal) * [StateGetAllocations](#stategetallocations) * [StateGetClaim](#stategetclaim) * [StateGetClaims](#stategetclaims) @@ -322,6 +328,133 @@ Response: } ``` +## ActorEvent + +### GetActorEvents +Actor events + + +Perms: read + +Inputs: +```json +[ + { + "addresses": [ + "f01234" + ], + "fields": { + "abc": [ + { + "codec": 81, + "value": "ZGRhdGE=" + } + ] + }, + "fromHeight": 1010, + "toHeight": 1020 + } +] +``` + +Response: +```json +[ + { + "entries": [ + { + "Flags": 7, + "Key": "string value", + "Codec": 42, + "Value": "Ynl0ZSBhcnJheQ==" + } + ], + "emitter": "f01234", + "reverted": true, + "height": 10101, + "tipsetKey": [ + { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + { + "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" + } + ], + "msgCid": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + } + } +] +``` + +### SubscribeActorEvents +SubscribeActorEvents returns a long-lived stream of all user-programmed and built-in actor +events that match the given filter. +Events that match the given filter are written to the stream in real-time as they are emitted +from the FVM. +The response stream is closed when the client disconnects, when a ToHeight is specified and is +reached, or if there is an error while writing an event to the stream. +This API also allows clients to read all historical events matching the given filter before any +real-time events are written to the response stream if the filter specifies an earlier +FromHeight. +Results available from this API may be limited by the MaxFilterResults and MaxFilterHeightRange +configuration options and also the amount of historical data available in the node. + +Note: this API is only available via websocket connections. +This is an EXPERIMENTAL API and may be subject to change. + + +Perms: read + +Inputs: +```json +[ + { + "addresses": [ + "f01234" + ], + "fields": { + "abc": [ + { + "codec": 81, + "value": "ZGRhdGE=" + } + ] + }, + "fromHeight": 1010, + "toHeight": 1020 + } +] +``` + +Response: +```json +{ + "entries": [ + { + "Flags": 7, + "Key": "string value", + "Codec": 42, + "Value": "Ynl0ZSBhcnJheQ==" + } + ], + "emitter": "f01234", + "reverted": true, + "height": 10101, + "tipsetKey": [ + { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + { + "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" + } + ], + "msgCid": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + } +} +``` + ## BlockStore ### ChainDeleteObj @@ -1264,7 +1397,7 @@ Perms: read Inputs: ```json [ - 21 + 22 ] ``` @@ -1279,7 +1412,7 @@ Perms: read Inputs: ```json [ - 21 + 22 ] ``` @@ -1374,16 +1507,27 @@ Response: "Params": "Ynl0ZSBhcnJheQ==", "ParamsCodec": 42, "GasLimit": 42, - "ReadOnly": true, - "CodeCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } + "ReadOnly": true }, "MsgRct": { "ExitCode": 0, "Return": "Ynl0ZSBhcnJheQ==", "ReturnCodec": 42 }, + "InvokedActor": { + "Id": 1000, + "State": { + "Code": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Head": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Nonce": 42, + "Balance": "0", + "Address": "f01234" + } + }, "GasCharges": [ { "Name": "string value", @@ -1403,16 +1547,27 @@ Response: "Params": "Ynl0ZSBhcnJheQ==", "ParamsCodec": 42, "GasLimit": 42, - "ReadOnly": true, - "CodeCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } + "ReadOnly": true }, "MsgRct": { "ExitCode": 0, "Return": "Ynl0ZSBhcnJheQ==", "ReturnCodec": 42 }, + "InvokedActor": { + "Id": 1000, + "State": { + "Code": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Head": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Nonce": 42, + "Balance": "0", + "Address": "f01234" + } + }, "GasCharges": [ { "Name": "string value", @@ -1555,16 +1710,27 @@ Response: "Params": "Ynl0ZSBhcnJheQ==", "ParamsCodec": 42, "GasLimit": 42, - "ReadOnly": true, - "CodeCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } + "ReadOnly": true }, "MsgRct": { "ExitCode": 0, "Return": "Ynl0ZSBhcnJheQ==", "ReturnCodec": 42 }, + "InvokedActor": { + "Id": 1000, + "State": { + "Code": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Head": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Nonce": 42, + "Balance": "0", + "Address": "f01234" + } + }, "GasCharges": [ { "Name": "string value", @@ -1584,16 +1750,27 @@ Response: "Params": "Ynl0ZSBhcnJheQ==", "ParamsCodec": 42, "GasLimit": 42, - "ReadOnly": true, - "CodeCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } + "ReadOnly": true }, "MsgRct": { "ExitCode": 0, "Return": "Ynl0ZSBhcnJheQ==", "ReturnCodec": 42 }, + "InvokedActor": { + "Id": 1000, + "State": { + "Code": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Head": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Nonce": 42, + "Balance": "0", + "Address": "f01234" + } + }, "GasCharges": [ { "Name": "string value", @@ -1680,7 +1857,9 @@ Response: "UpgradeHyggeHeight": 10101, "UpgradeLightningHeight": 10101, "UpgradeThunderHeight": 10101, - "UpgradeWatermelonHeight": 10101 + "UpgradeWatermelonHeight": 10101, + "UpgradeDragonHeight": 10101, + "UpgradePhoenixHeight": 10101 }, "Eip155ChainID": 123 } @@ -1808,7 +1987,7 @@ Inputs: ] ``` -Response: `21` +Response: `22` ### StateReplay @@ -1882,16 +2061,27 @@ Response: "Params": "Ynl0ZSBhcnJheQ==", "ParamsCodec": 42, "GasLimit": 42, - "ReadOnly": true, - "CodeCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } + "ReadOnly": true }, "MsgRct": { "ExitCode": 0, "Return": "Ynl0ZSBhcnJheQ==", "ReturnCodec": 42 }, + "InvokedActor": { + "Id": 1000, + "State": { + "Code": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Head": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Nonce": 42, + "Balance": "0", + "Address": "f01234" + } + }, "GasCharges": [ { "Name": "string value", @@ -1911,16 +2101,27 @@ Response: "Params": "Ynl0ZSBhcnJheQ==", "ParamsCodec": 42, "GasLimit": 42, - "ReadOnly": true, - "CodeCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } + "ReadOnly": true }, "MsgRct": { "ExitCode": 0, "Return": "Ynl0ZSBhcnJheQ==", "ReturnCodec": 42 }, + "InvokedActor": { + "Id": 1000, + "State": { + "Code": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Head": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Nonce": 42, + "Balance": "0", + "Address": "f01234" + } + }, "GasCharges": [ { "Name": "string value", @@ -2278,14 +2479,7 @@ Perms: read Inputs: ```json [ - { - "from": "0x5cbeecf99d3fdb3f25e309cc264f240bb0664031", - "to": "0x5cbeecf99d3fdb3f25e309cc264f240bb0664031", - "gas": "0x5", - "gasPrice": "0x0", - "value": "0x0", - "data": "0x07" - } + "Bw==" ] ``` @@ -2850,8 +3044,6 @@ Response: `false` ### EthTraceBlock TraceAPI related methods -Returns traces created at given block - Perms: read @@ -2866,23 +3058,14 @@ Response: ```json [ { - "action": { - "callType": "string value", - "from": "0x0707070707070707070707070707070707070707", - "to": "0x0707070707070707070707070707070707070707", - "gas": "0x5", - "input": "0x07", - "value": "0x0" - }, - "result": { - "gasUsed": "0x5", - "output": "0x07" - }, + "type": "string value", + "error": "string value", "subtraces": 123, "traceAddress": [ 123 ], - "Type": "string value", + "action": {}, + "result": {}, "blockHash": "0x0707070707070707070707070707070707070707070707070707070707070707", "blockNumber": 9, "transactionHash": "0x0707070707070707070707070707070707070707070707070707070707070707", @@ -2915,23 +3098,14 @@ Response: "stateDiff": "string value", "trace": [ { - "action": { - "callType": "string value", - "from": "0x0707070707070707070707070707070707070707", - "to": "0x0707070707070707070707070707070707070707", - "gas": "0x5", - "input": "0x07", - "value": "0x0" - }, - "result": { - "gasUsed": "0x5", - "output": "0x07" - }, + "type": "string value", + "error": "string value", "subtraces": 123, "traceAddress": [ 123 ], - "Type": "string value" + "action": {}, + "result": {} } ], "transactionHash": "0x0707070707070707070707070707070707070707070707070707070707070707", @@ -4348,6 +4522,50 @@ Inputs: Response: `"Ynl0ZSBhcnJheQ=="` +### StateGetAllAllocations +StateGetAllAllocations returns the all the allocations available in verified registry actor. + + +Perms: read + +Inputs: +```json +[ + [ + { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + { + "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" + } + ] +] +``` + +Response: `{}` + +### StateGetAllClaims +StateGetAllClaims returns the all the claims available in verified registry actor. + + +Perms: read + +Inputs: +```json +[ + [ + { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + { + "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" + } + ] +] +``` + +Response: `{}` + ### StateGetAllocation StateGetAllocation returns the allocation for a given address and allocation ID. @@ -4422,6 +4640,29 @@ Response: } ``` +### StateGetAllocationIdForPendingDeal +StateGetAllocationIdForPendingDeal is like StateGetAllocationForPendingDeal except it returns the allocation ID + + +Perms: read + +Inputs: +```json +[ + 5432, + [ + { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + { + "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" + } + ] +] +``` + +Response: `0` + ### StateGetAllocations StateGetAllocations returns the all the allocations for a given client. @@ -4705,8 +4946,7 @@ Response: "State": { "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, - "SlashEpoch": 10101, - "VerifiedClaim": 0 + "SlashEpoch": 10101 } } } @@ -4753,8 +4993,7 @@ Response: "State": { "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, - "SlashEpoch": 10101, - "VerifiedClaim": 0 + "SlashEpoch": 10101 } } ``` diff --git a/venus-shared/api/chain/v1/mock/mock_fullnode.go b/venus-shared/api/chain/v1/mock/mock_fullnode.go index 0c83a836b2..0af5ca0d13 100644 --- a/venus-shared/api/chain/v1/mock/mock_fullnode.go +++ b/venus-shared/api/chain/v1/mock/mock_fullnode.go @@ -531,7 +531,7 @@ func (mr *MockFullNodeMockRecorder) EthChainId(arg0 interface{}) *gomock.Call { } // EthEstimateGas mocks base method. -func (m *MockFullNode) EthEstimateGas(arg0 context.Context, arg1 types.EthCall) (types.EthUint64, error) { +func (m *MockFullNode) EthEstimateGas(arg0 context.Context, arg1 jsonrpc.RawParams) (types.EthUint64, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "EthEstimateGas", arg0, arg1) ret0, _ := ret[0].(types.EthUint64) @@ -1145,6 +1145,21 @@ func (mr *MockFullNodeMockRecorder) GetActor(arg0, arg1 interface{}) *gomock.Cal return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetActor", reflect.TypeOf((*MockFullNode)(nil).GetActor), arg0, arg1) } +// GetActorEvents mocks base method. +func (m *MockFullNode) GetActorEvents(arg0 context.Context, arg1 *types0.ActorEventFilter) ([]*types0.ActorEvent, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetActorEvents", arg0, arg1) + ret0, _ := ret[0].([]*types0.ActorEvent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetActorEvents indicates an expected call of GetActorEvents. +func (mr *MockFullNodeMockRecorder) GetActorEvents(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetActorEvents", reflect.TypeOf((*MockFullNode)(nil).GetActorEvents), arg0, arg1) +} + // GetEntry mocks base method. func (m *MockFullNode) GetEntry(arg0 context.Context, arg1 abi.ChainEpoch, arg2 uint64) (*types0.BeaconEntry, error) { m.ctrl.T.Helper() @@ -2420,6 +2435,36 @@ func (mr *MockFullNodeMockRecorder) StateGetActor(arg0, arg1, arg2 interface{}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetActor", reflect.TypeOf((*MockFullNode)(nil).StateGetActor), arg0, arg1, arg2) } +// StateGetAllAllocations mocks base method. +func (m *MockFullNode) StateGetAllAllocations(arg0 context.Context, arg1 types0.TipSetKey) (map[verifreg.AllocationId]verifreg.Allocation, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateGetAllAllocations", arg0, arg1) + ret0, _ := ret[0].(map[verifreg.AllocationId]verifreg.Allocation) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateGetAllAllocations indicates an expected call of StateGetAllAllocations. +func (mr *MockFullNodeMockRecorder) StateGetAllAllocations(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllAllocations", reflect.TypeOf((*MockFullNode)(nil).StateGetAllAllocations), arg0, arg1) +} + +// StateGetAllClaims mocks base method. +func (m *MockFullNode) StateGetAllClaims(arg0 context.Context, arg1 types0.TipSetKey) (map[verifreg.ClaimId]verifreg.Claim, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateGetAllClaims", arg0, arg1) + ret0, _ := ret[0].(map[verifreg.ClaimId]verifreg.Claim) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateGetAllClaims indicates an expected call of StateGetAllClaims. +func (mr *MockFullNodeMockRecorder) StateGetAllClaims(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllClaims", reflect.TypeOf((*MockFullNode)(nil).StateGetAllClaims), arg0, arg1) +} + // StateGetAllocation mocks base method. func (m *MockFullNode) StateGetAllocation(arg0 context.Context, arg1 address.Address, arg2 verifreg.AllocationId, arg3 types0.TipSetKey) (*verifreg.Allocation, error) { m.ctrl.T.Helper() @@ -2450,6 +2495,21 @@ func (mr *MockFullNodeMockRecorder) StateGetAllocationForPendingDeal(arg0, arg1, return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllocationForPendingDeal", reflect.TypeOf((*MockFullNode)(nil).StateGetAllocationForPendingDeal), arg0, arg1, arg2) } +// StateGetAllocationIdForPendingDeal mocks base method. +func (m *MockFullNode) StateGetAllocationIdForPendingDeal(arg0 context.Context, arg1 abi.DealID, arg2 types0.TipSetKey) (verifreg.AllocationId, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateGetAllocationIdForPendingDeal", arg0, arg1, arg2) + ret0, _ := ret[0].(verifreg.AllocationId) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateGetAllocationIdForPendingDeal indicates an expected call of StateGetAllocationIdForPendingDeal. +func (mr *MockFullNodeMockRecorder) StateGetAllocationIdForPendingDeal(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllocationIdForPendingDeal", reflect.TypeOf((*MockFullNode)(nil).StateGetAllocationIdForPendingDeal), arg0, arg1, arg2) +} + // StateGetAllocations mocks base method. func (m *MockFullNode) StateGetAllocations(arg0 context.Context, arg1 address.Address, arg2 types0.TipSetKey) (map[verifreg.AllocationId]verifreg.Allocation, error) { m.ctrl.T.Helper() @@ -3185,6 +3245,21 @@ func (mr *MockFullNodeMockRecorder) StateWaitMsg(arg0, arg1, arg2, arg3, arg4 in return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateWaitMsg", reflect.TypeOf((*MockFullNode)(nil).StateWaitMsg), arg0, arg1, arg2, arg3, arg4) } +// SubscribeActorEvents mocks base method. +func (m *MockFullNode) SubscribeActorEvents(arg0 context.Context, arg1 *types0.ActorEventFilter) (<-chan *types0.ActorEvent, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SubscribeActorEvents", arg0, arg1) + ret0, _ := ret[0].(<-chan *types0.ActorEvent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SubscribeActorEvents indicates an expected call of SubscribeActorEvents. +func (mr *MockFullNodeMockRecorder) SubscribeActorEvents(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeActorEvents", reflect.TypeOf((*MockFullNode)(nil).SubscribeActorEvents), arg0, arg1) +} + // SyncIncomingBlocks mocks base method. func (m *MockFullNode) SyncIncomingBlocks(arg0 context.Context) (<-chan *types0.BlockHeader, error) { m.ctrl.T.Helper() diff --git a/venus-shared/api/chain/v1/proxy_gen.go b/venus-shared/api/chain/v1/proxy_gen.go index 9ead662775..1f9b96ede5 100644 --- a/venus-shared/api/chain/v1/proxy_gen.go +++ b/venus-shared/api/chain/v1/proxy_gen.go @@ -22,6 +22,7 @@ import ( "github.com/libp2p/go-libp2p/core/protocol" lminer "github.com/filecoin-project/venus/venus-shared/actors/builtin/miner" + "github.com/filecoin-project/venus/venus-shared/actors/builtin/verifreg" "github.com/filecoin-project/venus/venus-shared/types" ) @@ -84,8 +85,11 @@ type IMinerStateStruct struct { StateDealProviderCollateralBounds func(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (types.DealCollateralBounds, error) `perm:"read"` StateDecodeParams func(ctx context.Context, toAddr address.Address, method abi.MethodNum, params []byte, tsk types.TipSetKey) (interface{}, error) `perm:"read"` StateEncodeParams func(ctx context.Context, toActCode cid.Cid, method abi.MethodNum, params json.RawMessage) ([]byte, error) `perm:"read"` + StateGetAllAllocations func(ctx context.Context, tsk types.TipSetKey) (map[types.AllocationId]types.Allocation, error) `perm:"read"` + StateGetAllClaims func(ctx context.Context, tsk types.TipSetKey) (map[types.ClaimId]types.Claim, error) `perm:"read"` StateGetAllocation func(ctx context.Context, clientAddr address.Address, allocationID types.AllocationId, tsk types.TipSetKey) (*types.Allocation, error) `perm:"read"` StateGetAllocationForPendingDeal func(ctx context.Context, dealID abi.DealID, tsk types.TipSetKey) (*types.Allocation, error) `perm:"read"` + StateGetAllocationIdForPendingDeal func(ctx context.Context, dealID abi.DealID, tsk types.TipSetKey) (verifreg.AllocationId, error) `perm:"read"` StateGetAllocations func(ctx context.Context, clientAddr address.Address, tsk types.TipSetKey) (map[types.AllocationId]types.Allocation, error) `perm:"read"` StateGetClaim func(ctx context.Context, providerAddr address.Address, claimID types.ClaimId, tsk types.TipSetKey) (*types.Claim, error) `perm:"read"` StateGetClaims func(ctx context.Context, providerAddr address.Address, tsk types.TipSetKey) (map[types.ClaimId]types.Claim, error) `perm:"read"` @@ -145,12 +149,21 @@ func (s *IMinerStateStruct) StateDecodeParams(p0 context.Context, p1 address.Add func (s *IMinerStateStruct) StateEncodeParams(p0 context.Context, p1 cid.Cid, p2 abi.MethodNum, p3 json.RawMessage) ([]byte, error) { return s.Internal.StateEncodeParams(p0, p1, p2, p3) } +func (s *IMinerStateStruct) StateGetAllAllocations(p0 context.Context, p1 types.TipSetKey) (map[types.AllocationId]types.Allocation, error) { + return s.Internal.StateGetAllAllocations(p0, p1) +} +func (s *IMinerStateStruct) StateGetAllClaims(p0 context.Context, p1 types.TipSetKey) (map[types.ClaimId]types.Claim, error) { + return s.Internal.StateGetAllClaims(p0, p1) +} func (s *IMinerStateStruct) StateGetAllocation(p0 context.Context, p1 address.Address, p2 types.AllocationId, p3 types.TipSetKey) (*types.Allocation, error) { return s.Internal.StateGetAllocation(p0, p1, p2, p3) } func (s *IMinerStateStruct) StateGetAllocationForPendingDeal(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*types.Allocation, error) { return s.Internal.StateGetAllocationForPendingDeal(p0, p1, p2) } +func (s *IMinerStateStruct) StateGetAllocationIdForPendingDeal(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (verifreg.AllocationId, error) { + return s.Internal.StateGetAllocationIdForPendingDeal(p0, p1, p2) +} func (s *IMinerStateStruct) StateGetAllocations(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (map[types.AllocationId]types.Allocation, error) { return s.Internal.StateGetAllocations(p0, p1, p2) } @@ -855,7 +868,7 @@ type IETHStruct struct { EthBlockNumber func(ctx context.Context) (types.EthUint64, error) `perm:"read"` EthCall func(ctx context.Context, tx types.EthCall, blkParam types.EthBlockNumberOrHash) (types.EthBytes, error) `perm:"read"` EthChainId func(ctx context.Context) (types.EthUint64, error) `perm:"read"` - EthEstimateGas func(ctx context.Context, tx types.EthCall) (types.EthUint64, error) `perm:"read"` + EthEstimateGas func(ctx context.Context, p jsonrpc.RawParams) (types.EthUint64, error) `perm:"read"` EthFeeHistory func(ctx context.Context, p jsonrpc.RawParams) (types.EthFeeHistory, error) `perm:"read"` EthGasPrice func(ctx context.Context) (types.EthBigInt, error) `perm:"read"` EthGetBalance func(ctx context.Context, address types.EthAddress, blkParam types.EthBlockNumberOrHash) (types.EthBigInt, error) `perm:"read"` @@ -902,7 +915,7 @@ func (s *IETHStruct) EthCall(p0 context.Context, p1 types.EthCall, p2 types.EthB func (s *IETHStruct) EthChainId(p0 context.Context) (types.EthUint64, error) { return s.Internal.EthChainId(p0) } -func (s *IETHStruct) EthEstimateGas(p0 context.Context, p1 types.EthCall) (types.EthUint64, error) { +func (s *IETHStruct) EthEstimateGas(p0 context.Context, p1 jsonrpc.RawParams) (types.EthUint64, error) { return s.Internal.EthEstimateGas(p0, p1) } func (s *IETHStruct) EthFeeHistory(p0 context.Context, p1 jsonrpc.RawParams) (types.EthFeeHistory, error) { @@ -1035,6 +1048,20 @@ type FullETHStruct struct { IETHEventStruct } +type IActorEventStruct struct { + Internal struct { + GetActorEvents func(ctx context.Context, filter *types.ActorEventFilter) ([]*types.ActorEvent, error) `perm:"read"` + SubscribeActorEvents func(ctx context.Context, filter *types.ActorEventFilter) (<-chan *types.ActorEvent, error) `perm:"read"` + } +} + +func (s *IActorEventStruct) GetActorEvents(p0 context.Context, p1 *types.ActorEventFilter) ([]*types.ActorEvent, error) { + return s.Internal.GetActorEvents(p0, p1) +} +func (s *IActorEventStruct) SubscribeActorEvents(p0 context.Context, p1 *types.ActorEventFilter) (<-chan *types.ActorEvent, error) { + return s.Internal.SubscribeActorEvents(p0, p1) +} + type FullNodeStruct struct { IBlockStoreStruct IChainStruct @@ -1047,4 +1074,5 @@ type FullNodeStruct struct { IWalletStruct ICommonStruct FullETHStruct + IActorEventStruct } diff --git a/venus-shared/api/gateway/v1/method.md b/venus-shared/api/gateway/v1/method.md index 32acd22260..6a1fc0161d 100644 --- a/venus-shared/api/gateway/v1/method.md +++ b/venus-shared/api/gateway/v1/method.md @@ -205,7 +205,7 @@ Inputs: ], "Bw==", 10101, - 21 + 22 ] ``` diff --git a/venus-shared/api/gateway/v2/method.md b/venus-shared/api/gateway/v2/method.md index fc7ae223a7..7312b2d60d 100644 --- a/venus-shared/api/gateway/v2/method.md +++ b/venus-shared/api/gateway/v2/method.md @@ -174,7 +174,7 @@ Inputs: ], "Bw==", 10101, - 21 + 22 ] ``` diff --git a/venus-shared/api/market/v0/method.md b/venus-shared/api/market/v0/method.md index 76cd317e58..2e26bf15e3 100644 --- a/venus-shared/api/market/v0/method.md +++ b/venus-shared/api/market/v0/method.md @@ -1695,8 +1695,7 @@ Response: "State": { "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, - "SlashEpoch": 10101, - "VerifiedClaim": 0 + "SlashEpoch": 10101 } } ] diff --git a/venus-shared/api/market/v1/method.md b/venus-shared/api/market/v1/method.md index 4f6e9aef24..f0134fba44 100644 --- a/venus-shared/api/market/v1/method.md +++ b/venus-shared/api/market/v1/method.md @@ -1696,8 +1696,7 @@ Response: "State": { "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, - "SlashEpoch": 10101, - "VerifiedClaim": 0 + "SlashEpoch": 10101 } } ] diff --git a/venus-shared/blockstore/cbor_gen.go b/venus-shared/blockstore/cbor_gen.go index a1048911ed..0d0e23b1fa 100644 --- a/venus-shared/blockstore/cbor_gen.go +++ b/venus-shared/blockstore/cbor_gen.go @@ -44,7 +44,7 @@ func (t *NetRPCReq) MarshalCBOR(w io.Writer) error { } // t.Cid ([]cid.Cid) (slice) - if len(t.Cid) > cbg.MaxLength { + if len(t.Cid) > 8192 { return xerrors.Errorf("Slice value in field t.Cid was too long") } @@ -60,7 +60,7 @@ func (t *NetRPCReq) MarshalCBOR(w io.Writer) error { } // t.Data ([][]uint8) (slice) - if len(t.Data) > cbg.MaxLength { + if len(t.Data) > 8192 { return xerrors.Errorf("Slice value in field t.Data was too long") } @@ -68,7 +68,7 @@ func (t *NetRPCReq) MarshalCBOR(w io.Writer) error { return err } for _, v := range t.Data { - if len(v) > cbg.ByteArrayMaxLen { + if len(v) > 2097152 { return xerrors.Errorf("Byte array in field v was too long") } @@ -76,9 +76,10 @@ func (t *NetRPCReq) MarshalCBOR(w io.Writer) error { return err } - if _, err := cw.Write(v[:]); err != nil { + if _, err := cw.Write(v); err != nil { return err } + } return nil } @@ -140,7 +141,7 @@ func (t *NetRPCReq) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Cid: array too large (%d)", extra) } @@ -171,9 +172,9 @@ func (t *NetRPCReq) UnmarshalCBOR(r io.Reader) (err error) { t.Cid[i] = c } + } } - // t.Data ([][]uint8) (slice) maj, extra, err = cr.ReadHeader() @@ -181,7 +182,7 @@ func (t *NetRPCReq) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Data: array too large (%d)", extra) } @@ -207,7 +208,7 @@ func (t *NetRPCReq) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.ByteArrayMaxLen { + if extra > 2097152 { return fmt.Errorf("t.Data[i]: byte array too large (%d)", extra) } if maj != cbg.MajByteString { @@ -218,12 +219,12 @@ func (t *NetRPCReq) UnmarshalCBOR(r io.Reader) (err error) { t.Data[i] = make([]uint8, extra) } - if _, err := io.ReadFull(cr, t.Data[i][:]); err != nil { + if _, err := io.ReadFull(cr, t.Data[i]); err != nil { return err } + } } - return nil } @@ -253,7 +254,7 @@ func (t *NetRPCResp) MarshalCBOR(w io.Writer) error { } // t.Data ([]uint8) (slice) - if len(t.Data) > cbg.ByteArrayMaxLen { + if len(t.Data) > 2097152 { return xerrors.Errorf("Byte array in field t.Data was too long") } @@ -261,9 +262,10 @@ func (t *NetRPCResp) MarshalCBOR(w io.Writer) error { return err } - if _, err := cw.Write(t.Data[:]); err != nil { + if _, err := cw.Write(t.Data); err != nil { return err } + return nil } @@ -324,7 +326,7 @@ func (t *NetRPCResp) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.ByteArrayMaxLen { + if extra > 2097152 { return fmt.Errorf("t.Data: byte array too large (%d)", extra) } if maj != cbg.MajByteString { @@ -335,9 +337,10 @@ func (t *NetRPCResp) UnmarshalCBOR(r io.Reader) (err error) { t.Data = make([]uint8, extra) } - if _, err := io.ReadFull(cr, t.Data[:]); err != nil { + if _, err := io.ReadFull(cr, t.Data); err != nil { return err } + return nil } @@ -361,7 +364,7 @@ func (t *NetRPCErr) MarshalCBOR(w io.Writer) error { } // t.Msg (string) (string) - if len(t.Msg) > cbg.MaxLength { + if len(t.Msg) > 8192 { return xerrors.Errorf("Value in field t.Msg was too long") } @@ -426,7 +429,7 @@ func (t *NetRPCErr) UnmarshalCBOR(r io.Reader) (err error) { // t.Msg (string) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } diff --git a/venus-shared/compatible-checks/actor-sources.txt b/venus-shared/compatible-checks/actor-sources.txt index 80a22a25b6..d6354ef186 100644 --- a/venus-shared/compatible-checks/actor-sources.txt +++ b/venus-shared/compatible-checks/actor-sources.txt @@ -13,6 +13,7 @@ SOURCES IN chain/actors: builtin/account/v10.go builtin/account/v11.go builtin/account/v12.go + builtin/account/v13.go builtin/account/v2.go builtin/account/v3.go builtin/account/v4.go @@ -27,6 +28,7 @@ SOURCES IN chain/actors: builtin/cron/v10.go builtin/cron/v11.go builtin/cron/v12.go + builtin/cron/v13.go builtin/cron/v2.go builtin/cron/v3.go builtin/cron/v4.go @@ -40,17 +42,20 @@ SOURCES IN chain/actors: builtin/datacap/v10.go builtin/datacap/v11.go builtin/datacap/v12.go + builtin/datacap/v13.go builtin/datacap/v9.go builtin/evm/evm.go builtin/evm/v10.go builtin/evm/v11.go builtin/evm/v12.go + builtin/evm/v13.go builtin/init/diff.go builtin/init/init.go builtin/init/v0.go builtin/init/v10.go builtin/init/v11.go builtin/init/v12.go + builtin/init/v13.go builtin/init/v2.go builtin/init/v3.go builtin/init/v4.go @@ -65,6 +70,7 @@ SOURCES IN chain/actors: builtin/market/v10.go builtin/market/v11.go builtin/market/v12.go + builtin/market/v13.go builtin/market/v2.go builtin/market/v3.go builtin/market/v4.go @@ -81,6 +87,7 @@ SOURCES IN chain/actors: builtin/miner/v10.go builtin/miner/v11.go builtin/miner/v12.go + builtin/miner/v13.go builtin/miner/v2.go builtin/miner/v3.go builtin/miner/v4.go @@ -94,6 +101,7 @@ SOURCES IN chain/actors: builtin/multisig/message10.go builtin/multisig/message11.go builtin/multisig/message12.go + builtin/multisig/message13.go builtin/multisig/message2.go builtin/multisig/message3.go builtin/multisig/message4.go @@ -107,6 +115,7 @@ SOURCES IN chain/actors: builtin/multisig/v10.go builtin/multisig/v11.go builtin/multisig/v12.go + builtin/multisig/v13.go builtin/multisig/v2.go builtin/multisig/v3.go builtin/multisig/v4.go @@ -119,6 +128,7 @@ SOURCES IN chain/actors: builtin/paych/message10.go builtin/paych/message11.go builtin/paych/message12.go + builtin/paych/message13.go builtin/paych/message2.go builtin/paych/message3.go builtin/paych/message4.go @@ -133,6 +143,7 @@ SOURCES IN chain/actors: builtin/paych/v10.go builtin/paych/v11.go builtin/paych/v12.go + builtin/paych/v13.go builtin/paych/v2.go builtin/paych/v3.go builtin/paych/v4.go @@ -147,6 +158,7 @@ SOURCES IN chain/actors: builtin/power/v10.go builtin/power/v11.go builtin/power/v12.go + builtin/power/v13.go builtin/power/v2.go builtin/power/v3.go builtin/power/v4.go @@ -161,6 +173,7 @@ SOURCES IN chain/actors: builtin/reward/v10.go builtin/reward/v11.go builtin/reward/v12.go + builtin/reward/v13.go builtin/reward/v2.go builtin/reward/v3.go builtin/reward/v4.go @@ -174,6 +187,7 @@ SOURCES IN chain/actors: builtin/system/v10.go builtin/system/v11.go builtin/system/v12.go + builtin/system/v13.go builtin/system/v2.go builtin/system/v3.go builtin/system/v4.go @@ -187,6 +201,7 @@ SOURCES IN chain/actors: builtin/verifreg/v10.go builtin/verifreg/v11.go builtin/verifreg/v12.go + builtin/verifreg/v13.go builtin/verifreg/v2.go builtin/verifreg/v3.go builtin/verifreg/v4.go diff --git a/venus-shared/compatible-checks/api-checksum.txt b/venus-shared/compatible-checks/api-checksum.txt index 09aa489ddf..1261ae0c68 100644 --- a/venus-shared/compatible-checks/api-checksum.txt +++ b/venus-shared/compatible-checks/api-checksum.txt @@ -152,6 +152,8 @@ v0api.FullNode: StateDealProviderCollateralBounds: In=4, Out=2, CheckSum=5231e44843c0b74a04371e1e7170d4b2 StateDecodeParams: In=5, Out=2, CheckSum=8c6311be4dc064a657368516c33e1307 StateGetActor: In=3, Out=2, CheckSum=5ca2405c99c6a03afc0ca0dedefd263b + StateGetAllAllocations: In=2, Out=2, CheckSum=d5fa693dc271bfb4aab231364cf8ea3b + StateGetAllClaims: In=2, Out=2, CheckSum=249fd75d6486d5113d443144b732123f StateGetAllocation: In=4, Out=2, CheckSum=306a8d2eb65b1bd436f2230bb96666b5 StateGetAllocationForPendingDeal: In=3, Out=2, CheckSum=3d2912f0c80606576bb697499140ae2f StateGetAllocations: In=3, Out=2, CheckSum=570266653b3643cf22e6b47609db7e55 @@ -290,7 +292,7 @@ api.FullNode: EthBlockNumber: In=1, Out=2, CheckSum=442f3dc12ea5a22b7b8fea633069692a EthCall: In=3, Out=2, CheckSum=4ad62b9ec4eb1da934580efa4878279a EthChainId: In=1, Out=2, CheckSum=442f3dc12ea5a22b7b8fea633069692a - EthEstimateGas: In=2, Out=2, CheckSum=f4d63e320f2fb2778b210a925516a114 + EthEstimateGas: In=2, Out=2, CheckSum=06642bd8bc4a814495e4d5db5c3d11d5 EthFeeHistory: In=2, Out=2, CheckSum=6a4806cfbd9b939d6f7fc3fbe7dc1ff7 EthGasPrice: In=1, Out=2, CheckSum=e2f5588dddfc36a9cdef0fad6f4db93e EthGetBalance: In=3, Out=2, CheckSum=80912669b93ebbd53024dbc6b4f39d94 @@ -320,6 +322,8 @@ api.FullNode: EthSendRawTransaction: In=2, Out=2, CheckSum=f63e0b205164d628bc8022b6d5a496f5 EthSubscribe: In=2, Out=2, CheckSum=f63e0b205164d628bc8022b6d5a496f5 EthSyncing: In=1, Out=2, CheckSum=2c17cf64e376c0e9d0d56053d33c0722 + EthTraceBlock: In=2, Out=2, CheckSum=87ad85d70d0a285fae530a47eee79d13 + EthTraceReplayBlockTransactions: In=3, Out=2, CheckSum=ec2c86340cf2a777bc64bab8d10e3fdb EthUninstallFilter: In=2, Out=2, CheckSum=eaa6a477ffaae115413457bbdb11e339 EthUnsubscribe: In=2, Out=2, CheckSum=eaa6a477ffaae115413457bbdb11e339 FilecoinAddressToEthAddress: In=2, Out=2, CheckSum=13a0b5ce8f82604e17803a00c4086c4c @@ -327,6 +331,7 @@ api.FullNode: GasEstimateGasLimit: In=3, Out=2, CheckSum=4d1bd57eef0ee90d4c2e89f097d0604d GasEstimateGasPremium: In=5, Out=2, CheckSum=550724ed37e2fdaa64e55147e82214b1 GasEstimateMessageGas: In=4, Out=2, CheckSum=6ff6179b579feed33897d96429504624 + GetActorEvents: In=2, Out=2, CheckSum=e0c47876fd090c7125f3610b99e0dd27 ID: In=1, Out=2, CheckSum=1635810444d2b13b381cbefece853ba7 LogAlerts: In=1, Out=2, CheckSum=c9262fa7c93e891ec80868e0b83a2222 LogList: In=1, Out=2, CheckSum=c6d763b6ec7190283b7c648e735725c0 @@ -432,8 +437,11 @@ api.FullNode: StateDecodeParams: In=5, Out=2, CheckSum=8c6311be4dc064a657368516c33e1307 StateEncodeParams: In=4, Out=2, CheckSum=3e1a5390b92b1b69f9be038cd7400e38 StateGetActor: In=3, Out=2, CheckSum=5ca2405c99c6a03afc0ca0dedefd263b + StateGetAllAllocations: In=2, Out=2, CheckSum=d5fa693dc271bfb4aab231364cf8ea3b + StateGetAllClaims: In=2, Out=2, CheckSum=249fd75d6486d5113d443144b732123f StateGetAllocation: In=4, Out=2, CheckSum=306a8d2eb65b1bd436f2230bb96666b5 StateGetAllocationForPendingDeal: In=3, Out=2, CheckSum=3d2912f0c80606576bb697499140ae2f + StateGetAllocationIdForPendingDeal: In=3, Out=2, CheckSum=7008c851d474bd08a8df23d7a7368098 StateGetAllocations: In=3, Out=2, CheckSum=570266653b3643cf22e6b47609db7e55 StateGetBeaconEntry: In=2, Out=2, CheckSum=c74f5c0f4039207ea45c11bfe3319c38 StateGetClaim: In=4, Out=2, CheckSum=79bc50cf65a4d6b102267fd020b97510 @@ -481,6 +489,7 @@ api.FullNode: StateVerifiedRegistryRootKey: In=2, Out=2, CheckSum=5ad3a497ee24e321c780a69b8d2f0936 StateVerifierStatus: In=3, Out=2, CheckSum=e33ae4cd2315832f2d6f2aa74b68c34e StateWaitMsg: In=5, Out=2, CheckSum=561c18d1417310b5cd35cfffb0b75a00 + SubscribeActorEvents: In=2, Out=2, CheckSum=af75eb1b19217696987fdf472121561c SyncCheckBad: In=2, Out=2, CheckSum=ba06470da0ca1d6cc2f9ada7f0288a6c SyncCheckpoint: In=2, Out=1, CheckSum=cdfe593ac791e823186abb77bfad49a0 SyncIncomingBlocks: In=1, Out=2, CheckSum=f6ad051ba2ce73511f74f9c08032acc3 diff --git a/venus-shared/compatible-checks/api-diff.txt b/venus-shared/compatible-checks/api-diff.txt index a92ef87b64..94f0bcc00b 100644 --- a/venus-shared/compatible-checks/api-diff.txt +++ b/venus-shared/compatible-checks/api-diff.txt @@ -38,7 +38,7 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v0.FullNode <> github.c - CreateBackup - Discover + GasBatchEstimateMessageGas - > GasEstimateMessageGas {[func(context.Context, *types.Message, *types.MessageSendSpec, types.TipSetKey) (*types.Message, error) <> func(context.Context, *types.Message, *api.MessageSendSpec, types.TipSetKey) (*types.Message, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 2; nested=nil}}}} + > GasEstimateMessageGas {[func(context.Context, *types.Message, *types.MessageSendSpec, types.TipSetKey) (*types.Message, error) <> func(context.Context, *types.Message, *api.MessageSendSpec, types.TipSetKey) (*types.Message, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported field name: #1 field, GasOverEstimation != MsgUuid; nested=nil}}}} + GetActor + GetEntry + GetFullBlock @@ -54,11 +54,11 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v0.FullNode <> github.c - MarketReleaseFunds - MarketReserveFunds - MarketWithdraw - > MpoolBatchPushMessage {[func(context.Context, []*types.Message, *types.MessageSendSpec) ([]*types.SignedMessage, error) <> func(context.Context, []*types.Message, *api.MessageSendSpec) ([]*types.SignedMessage, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 2; nested=nil}}}} + > MpoolBatchPushMessage {[func(context.Context, []*types.Message, *types.MessageSendSpec) ([]*types.SignedMessage, error) <> func(context.Context, []*types.Message, *api.MessageSendSpec) ([]*types.SignedMessage, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported field name: #1 field, GasOverEstimation != MsgUuid; nested=nil}}}} + MpoolDeleteByAdress + MpoolPublishByAddr + MpoolPublishMessage - > MpoolPushMessage {[func(context.Context, *types.Message, *types.MessageSendSpec) (*types.SignedMessage, error) <> func(context.Context, *types.Message, *api.MessageSendSpec) (*types.SignedMessage, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 2; nested=nil}}}} + > MpoolPushMessage {[func(context.Context, *types.Message, *types.MessageSendSpec) (*types.SignedMessage, error) <> func(context.Context, *types.Message, *api.MessageSendSpec) (*types.SignedMessage, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported field name: #1 field, GasOverEstimation != MsgUuid; nested=nil}}}} + MpoolSelects - MsigAddApprove - MsigAddCancel @@ -90,7 +90,8 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v0.FullNode <> github.c + SetConcurrent + SetPassword - Shutdown - > StateGetNetworkParams {[func(context.Context) (*types.NetworkParams, error) <> func(context.Context) (*api.NetworkParams, error)] base=func out type: #0 input; nested={[*types.NetworkParams <> *api.NetworkParams] base=pointed type; nested={[types.NetworkParams <> api.NetworkParams] base=struct field; nested={[types.NetworkParams <> api.NetworkParams] base=exported fields count: 7 != 6; nested=nil}}}} + - StateGetAllAllocations + - StateGetAllClaims + StateMinerSectorSize + StateMinerWorkerAddress - SyncCheckBad @@ -158,10 +159,10 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.c + Concurrent - CreateBackup - Discover - + EthTraceBlock - + EthTraceReplayBlockTransactions + > EthTraceBlock {[func(context.Context, string) ([]*types.EthTraceBlock, error) <> func(context.Context, string) ([]*ethtypes.EthTraceBlock, error)] base=func out type: #0 input; nested={[[]*types.EthTraceBlock <> []*ethtypes.EthTraceBlock] base=slice element; nested={[*types.EthTraceBlock <> *ethtypes.EthTraceBlock] base=pointed type; nested={[types.EthTraceBlock <> ethtypes.EthTraceBlock] base=struct field; nested={[types.EthTraceBlock <> ethtypes.EthTraceBlock] base=exported field type: #0 field named EthTrace; nested={[*types.EthTrace <> *ethtypes.EthTrace] base=pointed type; nested={[types.EthTrace <> ethtypes.EthTrace] base=struct field; nested={[types.EthTrace <> ethtypes.EthTrace] base=exported fields count: 8 != 6; nested=nil}}}}}}}} + > EthTraceReplayBlockTransactions {[func(context.Context, string, []string) ([]*types.EthTraceReplayBlockTransaction, error) <> func(context.Context, string, []string) ([]*ethtypes.EthTraceReplayBlockTransaction, error)] base=func out type: #0 input; nested={[[]*types.EthTraceReplayBlockTransaction <> []*ethtypes.EthTraceReplayBlockTransaction] base=slice element; nested={[*types.EthTraceReplayBlockTransaction <> *ethtypes.EthTraceReplayBlockTransaction] base=pointed type; nested={[types.EthTraceReplayBlockTransaction <> ethtypes.EthTraceReplayBlockTransaction] base=struct field; nested={[types.EthTraceReplayBlockTransaction <> ethtypes.EthTraceReplayBlockTransaction] base=exported field type: #2 field named Trace; nested={[[]*types.EthTrace <> []*ethtypes.EthTrace] base=slice element; nested={[*types.EthTrace <> *ethtypes.EthTrace] base=pointed type; nested={[types.EthTrace <> ethtypes.EthTrace] base=struct field; nested={[types.EthTrace <> ethtypes.EthTrace] base=exported fields count: 8 != 6; nested=nil}}}}}}}}} + GasBatchEstimateMessageGas - > GasEstimateMessageGas {[func(context.Context, *types.Message, *types.MessageSendSpec, types.TipSetKey) (*types.Message, error) <> func(context.Context, *types.Message, *api.MessageSendSpec, types.TipSetKey) (*types.Message, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 2; nested=nil}}}} + > GasEstimateMessageGas {[func(context.Context, *types.Message, *types.MessageSendSpec, types.TipSetKey) (*types.Message, error) <> func(context.Context, *types.Message, *api.MessageSendSpec, types.TipSetKey) (*types.Message, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported field name: #1 field, GasOverEstimation != MsgUuid; nested=nil}}}} + GetActor + GetEntry + GetFullBlock @@ -177,11 +178,11 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.c - MarketReleaseFunds - MarketReserveFunds - MarketWithdraw - > MpoolBatchPushMessage {[func(context.Context, []*types.Message, *types.MessageSendSpec) ([]*types.SignedMessage, error) <> func(context.Context, []*types.Message, *api.MessageSendSpec) ([]*types.SignedMessage, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 2; nested=nil}}}} + > MpoolBatchPushMessage {[func(context.Context, []*types.Message, *types.MessageSendSpec) ([]*types.SignedMessage, error) <> func(context.Context, []*types.Message, *api.MessageSendSpec) ([]*types.SignedMessage, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported field name: #1 field, GasOverEstimation != MsgUuid; nested=nil}}}} + MpoolDeleteByAdress + MpoolPublishByAddr + MpoolPublishMessage - > MpoolPushMessage {[func(context.Context, *types.Message, *types.MessageSendSpec) (*types.SignedMessage, error) <> func(context.Context, *types.Message, *api.MessageSendSpec) (*types.SignedMessage, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 2; nested=nil}}}} + > MpoolPushMessage {[func(context.Context, *types.Message, *types.MessageSendSpec) (*types.SignedMessage, error) <> func(context.Context, *types.Message, *api.MessageSendSpec) (*types.SignedMessage, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported field name: #1 field, GasOverEstimation != MsgUuid; nested=nil}}}} + MpoolSelects - MsigAddApprove - MsigAddCancel @@ -216,7 +217,6 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.c + SetConcurrent + SetPassword - Shutdown - > StateGetNetworkParams {[func(context.Context) (*types.NetworkParams, error) <> func(context.Context) (*api.NetworkParams, error)] base=func out type: #0 input; nested={[*types.NetworkParams <> *api.NetworkParams] base=pointed type; nested={[types.NetworkParams <> api.NetworkParams] base=struct field; nested={[types.NetworkParams <> api.NetworkParams] base=exported fields count: 7 != 6; nested=nil}}}} + StateMinerSectorSize + StateMinerWorkerAddress - SyncCheckBad diff --git a/venus-shared/compatible-checks/api-perm.txt b/venus-shared/compatible-checks/api-perm.txt index 44170fbca4..1abfaa8248 100644 --- a/venus-shared/compatible-checks/api-perm.txt +++ b/venus-shared/compatible-checks/api-perm.txt @@ -67,8 +67,6 @@ v1: github.com/filecoin-project/venus/venus-shared/api/chain/v1 <> github.com/fi - IMinerState.StateMinerSectorSize - IMinerState.StateMinerWorkerAddress - EthSubscriber.EthSubscription - - IETH.EthTraceBlock - - IETH.EthTraceReplayBlockTransactions - IMessagePool.GasBatchEstimateMessageGas - IMessagePool.MpoolDeleteByAdress - IMessagePool.MpoolPublishByAddr diff --git a/venus-shared/libp2p/exchange/cbor_gen.go b/venus-shared/libp2p/exchange/cbor_gen.go index 7181ea5365..2d7c26f7a5 100644 --- a/venus-shared/libp2p/exchange/cbor_gen.go +++ b/venus-shared/libp2p/exchange/cbor_gen.go @@ -35,7 +35,7 @@ func (t *Request) MarshalCBOR(w io.Writer) error { } // t.Head ([]cid.Cid) (slice) - if len(t.Head) > cbg.MaxLength { + if len(t.Head) > 8192 { return xerrors.Errorf("Slice value in field t.Head was too long") } @@ -95,7 +95,7 @@ func (t *Request) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Head: array too large (%d)", extra) } @@ -126,9 +126,9 @@ func (t *Request) UnmarshalCBOR(r io.Reader) (err error) { t.Head[i] = c } + } } - // t.Length (uint64) (uint64) { @@ -181,7 +181,7 @@ func (t *Response) MarshalCBOR(w io.Writer) error { } // t.ErrorMessage (string) (string) - if len(t.ErrorMessage) > cbg.MaxLength { + if len(t.ErrorMessage) > 8192 { return xerrors.Errorf("Value in field t.ErrorMessage was too long") } @@ -193,7 +193,7 @@ func (t *Response) MarshalCBOR(w io.Writer) error { } // t.Chain ([]*exchange.BSTipSet) (slice) - if len(t.Chain) > cbg.MaxLength { + if len(t.Chain) > 8192 { return xerrors.Errorf("Slice value in field t.Chain was too long") } @@ -204,6 +204,7 @@ func (t *Response) MarshalCBOR(w io.Writer) error { if err := v.MarshalCBOR(cw); err != nil { return err } + } return nil } @@ -248,7 +249,7 @@ func (t *Response) UnmarshalCBOR(r io.Reader) (err error) { // t.ErrorMessage (string) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } @@ -262,7 +263,7 @@ func (t *Response) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Chain: array too large (%d)", extra) } @@ -300,9 +301,9 @@ func (t *Response) UnmarshalCBOR(r io.Reader) (err error) { } } + } } - return nil } @@ -332,10 +333,11 @@ func (t *CompactedMessagesCBOR) MarshalCBOR(w io.Writer) error { if err := v.MarshalCBOR(cw); err != nil { return err } + } // t.BlsIncludes ([]exchange.messageIndices) (slice) - if len(t.BlsIncludes) > cbg.MaxLength { + if len(t.BlsIncludes) > 8192 { return xerrors.Errorf("Slice value in field t.BlsIncludes was too long") } @@ -346,6 +348,7 @@ func (t *CompactedMessagesCBOR) MarshalCBOR(w io.Writer) error { if err := v.MarshalCBOR(cw); err != nil { return err } + } // t.Secpk ([]*types.SignedMessage) (slice) @@ -360,10 +363,11 @@ func (t *CompactedMessagesCBOR) MarshalCBOR(w io.Writer) error { if err := v.MarshalCBOR(cw); err != nil { return err } + } // t.SecpkIncludes ([]exchange.messageIndices) (slice) - if len(t.SecpkIncludes) > cbg.MaxLength { + if len(t.SecpkIncludes) > 8192 { return xerrors.Errorf("Slice value in field t.SecpkIncludes was too long") } @@ -374,6 +378,7 @@ func (t *CompactedMessagesCBOR) MarshalCBOR(w io.Writer) error { if err := v.MarshalCBOR(cw); err != nil { return err } + } return nil } @@ -446,9 +451,9 @@ func (t *CompactedMessagesCBOR) UnmarshalCBOR(r io.Reader) (err error) { } } + } } - // t.BlsIncludes ([]exchange.messageIndices) (slice) maj, extra, err = cr.ReadHeader() @@ -456,7 +461,7 @@ func (t *CompactedMessagesCBOR) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.BlsIncludes: array too large (%d)", extra) } @@ -484,9 +489,9 @@ func (t *CompactedMessagesCBOR) UnmarshalCBOR(r io.Reader) (err error) { } } + } } - // t.Secpk ([]*types.SignedMessage) (slice) maj, extra, err = cr.ReadHeader() @@ -532,9 +537,9 @@ func (t *CompactedMessagesCBOR) UnmarshalCBOR(r io.Reader) (err error) { } } + } } - // t.SecpkIncludes ([]exchange.messageIndices) (slice) maj, extra, err = cr.ReadHeader() @@ -542,7 +547,7 @@ func (t *CompactedMessagesCBOR) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.SecpkIncludes: array too large (%d)", extra) } @@ -570,9 +575,9 @@ func (t *CompactedMessagesCBOR) UnmarshalCBOR(r io.Reader) (err error) { } } + } } - return nil } @@ -591,7 +596,7 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error { } // t.Blocks ([]*types.BlockHeader) (slice) - if len(t.Blocks) > cbg.MaxLength { + if len(t.Blocks) > 8192 { return xerrors.Errorf("Slice value in field t.Blocks was too long") } @@ -602,6 +607,7 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error { if err := v.MarshalCBOR(cw); err != nil { return err } + } // t.Messages (exchange.CompactedMessages) (struct) @@ -641,7 +647,7 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Blocks: array too large (%d)", extra) } @@ -679,9 +685,9 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) (err error) { } } + } } - // t.Messages (exchange.CompactedMessages) (struct) { diff --git a/venus-shared/libp2p/hello/cbor_gen.go b/venus-shared/libp2p/hello/cbor_gen.go index c768c33076..be2a87c78d 100644 --- a/venus-shared/libp2p/hello/cbor_gen.go +++ b/venus-shared/libp2p/hello/cbor_gen.go @@ -34,7 +34,7 @@ func (t *GreetingMessage) MarshalCBOR(w io.Writer) error { } // t.HeaviestTipSet ([]cid.Cid) (slice) - if len(t.HeaviestTipSet) > cbg.MaxLength { + if len(t.HeaviestTipSet) > 8192 { return xerrors.Errorf("Slice value in field t.HeaviestTipSet was too long") } @@ -104,7 +104,7 @@ func (t *GreetingMessage) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.HeaviestTipSet: array too large (%d)", extra) } @@ -135,16 +135,16 @@ func (t *GreetingMessage) UnmarshalCBOR(r io.Reader) (err error) { t.HeaviestTipSet[i] = c } + } } - // t.HeaviestTipSetHeight (abi.ChainEpoch) (int64) { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -222,6 +222,7 @@ func (t *LatencyMessage) MarshalCBOR(w io.Writer) error { return err } } + return nil } @@ -251,10 +252,10 @@ func (t *LatencyMessage) UnmarshalCBOR(r io.Reader) (err error) { // t.TArrival (int64) (int64) { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -276,10 +277,10 @@ func (t *LatencyMessage) UnmarshalCBOR(r io.Reader) (err error) { // t.TSent (int64) (int64) { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) diff --git a/venus-shared/types/actor_event.go b/venus-shared/types/actor_event.go new file mode 100644 index 0000000000..bf95189e19 --- /dev/null +++ b/venus-shared/types/actor_event.go @@ -0,0 +1,67 @@ +package types + +import ( + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" +) + +type ActorEventBlock struct { + // The value codec to match when filtering event values. + Codec uint64 `json:"codec"` + + // The value to want to match on associated with the corresponding "event key" + // when filtering events. + // Should be a byte array encoded with the specified codec. + // Assumes base64 encoding when converting to/from JSON strings. + Value []byte `json:"value"` +} + +type ActorEventFilter struct { + // Matches events from one of these actors, or any actor if empty. + // For now, this MUST be a Filecoin address. + Addresses []address.Address `json:"addresses,omitempty"` + + // Matches events with the specified key/values, or all events if empty. + // If the value is an empty slice, the filter will match on the key only, accepting any value. + Fields map[string][]ActorEventBlock `json:"fields,omitempty"` + + // The height of the earliest tipset to include in the query. If empty, the query starts at the + // last finalized tipset. + // NOTE: In a future upgrade, this will be strict when set and will result in an error if a filter + // cannot be fulfilled by the depth of history available in the node. Currently, the node will + // nott return an error, but will return starting from the epoch it has data for. + FromHeight *abi.ChainEpoch `json:"fromHeight,omitempty"` + + // The height of the latest tipset to include in the query. If empty, the query ends at the + // latest tipset. + ToHeight *abi.ChainEpoch `json:"toHeight,omitempty"` + + // Restricts events returned to those emitted from messages contained in this tipset. + // If `TipSetKey` is legt empty in the filter criteria, then neither `FromHeight` nor `ToHeight` are allowed. + TipSetKey *TipSetKey `json:"tipsetKey,omitempty"` +} + +type ActorEvent struct { + // Event entries in log form. + Entries []EventEntry `json:"entries"` + + // Filecoin address of the actor that emitted this event. + // NOTE: In a future upgrade, this will change to always be an ID address. Currently this will be + // either the f4 address, or ID address if an f4 is not available for this actor. + Emitter address.Address `json:"emitter"` + + // Reverted is set to true if the message that produced this event was reverted because of a network re-org + // in that case, the event should be considered as reverted as well. + Reverted bool `json:"reverted"` + + // Height of the tipset that contained the message that produced this event. + Height abi.ChainEpoch `json:"height"` + + // The tipset that contained the message that produced this event. + TipSetKey TipSetKey `json:"tipsetKey"` + + // CID of message that produced this event. + MsgCid cid.Cid `json:"msgCid"` +} diff --git a/venus-shared/types/actor_event_test.go b/venus-shared/types/actor_event_test.go new file mode 100644 index 0000000000..29e30c9c78 --- /dev/null +++ b/venus-shared/types/actor_event_test.go @@ -0,0 +1,125 @@ +package types + +import ( + "encoding/json" + pseudo "math/rand" + "testing" + + "github.com/ipfs/go-cid" + mh "github.com/multiformats/go-multihash" + "github.com/stretchr/testify/require" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + builtintypes "github.com/filecoin-project/go-state-types/builtin" +) + +func TestJSONMarshalling(t *testing.T) { + rng := pseudo.New(pseudo.NewSource(0)) + t.Run("actor event with entries", + testJsonMarshalling( + ActorEvent{ + Entries: []EventEntry{ + { + Key: "key1", + Codec: 0x51, + Value: []byte("value1"), + }, + { + Key: "key2", + Codec: 0x52, + Value: []byte("value2"), + }, + }, + Emitter: randomF4Addr(t, rng), + Reverted: false, + Height: 1001, + TipSetKey: NewTipSetKey(randomCid(t, rng)), + MsgCid: randomCid(t, rng), + }, + `{"entries":[{"Flags":0,"Key":"key1","Codec":81,"Value":"dmFsdWUx"},{"Flags":0,"Key":"key2","Codec":82,"Value":"dmFsdWUy"}],"emitter":"t410fagkp3qx2f76maqot74jaiw3tzbxe76k76zrkl3xifk67isrnbn2sll3yua","reverted":false,"height":1001,"tipsetKey":[{"/":"bafkqacx3dag26sfht3qlcdi"}],"msgCid":{"/":"bafkqacrziziykd6uuf4islq"}}`, + ), + ) + + t.Run("actor event filter", + testJsonMarshalling( + ActorEventFilter{ + Addresses: []address.Address{ + randomF4Addr(t, pseudo.New(pseudo.NewSource(0))), + randomF4Addr(t, pseudo.New(pseudo.NewSource(0))), + }, + Fields: map[string][]ActorEventBlock{ + "key1": { + { + Codec: 0x51, + Value: []byte("value1"), + }, + }, + "key2": { + { + Codec: 0x52, + Value: []byte("value2"), + }, + }, + }, + FromHeight: heightOf(0), + ToHeight: heightOf(100), + TipSetKey: randomTipSetKey(t, rng), + }, + `{"addresses":["t410fagkp3qx2f76maqot74jaiw3tzbxe76k76zrkl3xifk67isrnbn2sll3yua","t410fagkp3qx2f76maqot74jaiw3tzbxe76k76zrkl3xifk67isrnbn2sll3yua"],"fields":{"key1":[{"codec":81,"value":"dmFsdWUx"}],"key2":[{"codec":82,"value":"dmFsdWUy"}]},"fromHeight":0,"toHeight":100,"tipsetKey":[{"/":"bafkqacxcqxwocuiukv4aq5i"}]}`, + ), + ) + t.Run("actor event block", + testJsonMarshalling( + ActorEventBlock{ + Codec: 1, + Value: []byte("test"), + }, + `{"codec":1,"value":"dGVzdA=="}`, + ), + ) +} + +func testJsonMarshalling[V ActorEvent | ActorEventBlock | ActorEventFilter](subject V, expect string) func(t *testing.T) { + return func(t *testing.T) { + gotMarshalled, err := json.Marshal(subject) + require.NoError(t, err) + require.JSONEqf(t, expect, string(gotMarshalled), "serialization mismatch") + var gotUnmarshalled V + require.NoError(t, json.Unmarshal([]byte(expect), &gotUnmarshalled)) + require.Equal(t, subject, gotUnmarshalled) + } +} + +func heightOf(h int64) *abi.ChainEpoch { + hp := abi.ChainEpoch(h) + return &hp +} + +func randomTipSetKey(tb testing.TB, rng *pseudo.Rand) *TipSetKey { + tb.Helper() + tk := NewTipSetKey(randomCid(tb, rng)) + return &tk +} + +func randomF4Addr(tb testing.TB, rng *pseudo.Rand) address.Address { + tb.Helper() + addr, err := address.NewDelegatedAddress(builtintypes.EthereumAddressManagerActorID, randomBytes(32, rng)) + require.NoError(tb, err) + + return addr +} + +func randomCid(tb testing.TB, rng *pseudo.Rand) cid.Cid { + tb.Helper() + cb := cid.V1Builder{Codec: cid.Raw, MhType: mh.IDENTITY} + c, err := cb.Sum(randomBytes(10, rng)) + require.NoError(tb, err) + return c +} + +func randomBytes(n int, rng *pseudo.Rand) []byte { + buf := make([]byte, n) + rng.Read(buf) + return buf +} diff --git a/venus-shared/types/api_types.go b/venus-shared/types/api_types.go index bae93fba10..a67c2adb53 100644 --- a/venus-shared/types/api_types.go +++ b/venus-shared/types/api_types.go @@ -13,6 +13,7 @@ import ( "github.com/libp2p/go-libp2p/core/peer" "github.com/filecoin-project/venus/venus-shared/actors/builtin" + "github.com/filecoin-project/venus/venus-shared/actors/builtin/market" "github.com/filecoin-project/venus/venus-shared/actors/builtin/power" ) @@ -170,9 +171,47 @@ type Deadline struct { var MarketBalanceNil = MarketBalance{} +type MarketDealState struct { + SectorStartEpoch abi.ChainEpoch // -1 if not yet included in proven sector + LastUpdatedEpoch abi.ChainEpoch // -1 if deal state never updated + SlashEpoch abi.ChainEpoch // -1 if deal never slashed +} + +func MakeDealState(mds market.DealState) MarketDealState { + return MarketDealState{ + SectorStartEpoch: mds.SectorStartEpoch(), + LastUpdatedEpoch: mds.LastUpdatedEpoch(), + SlashEpoch: mds.SlashEpoch(), + } +} + +type mstate struct { + s MarketDealState +} + +func (m mstate) SectorStartEpoch() abi.ChainEpoch { + return m.s.SectorStartEpoch +} + +func (m mstate) LastUpdatedEpoch() abi.ChainEpoch { + return m.s.LastUpdatedEpoch +} + +func (m mstate) SlashEpoch() abi.ChainEpoch { + return m.s.SlashEpoch +} + +func (m mstate) Equals(o market.DealState) bool { + return market.DealStatesEqual(m, o) +} + +func (m MarketDealState) Iface() market.DealState { + return mstate{m} +} + type MarketDeal struct { Proposal DealProposal - State DealState + State MarketDealState } type MinerPower struct { @@ -430,6 +469,8 @@ type ForkUpgradeParams struct { UpgradeLightningHeight abi.ChainEpoch UpgradeThunderHeight abi.ChainEpoch UpgradeWatermelonHeight abi.ChainEpoch + UpgradeDragonHeight abi.ChainEpoch + UpgradePhoenixHeight abi.ChainEpoch } type NodeStatus struct { diff --git a/venus-shared/types/cbor_gen.go b/venus-shared/types/cbor_gen.go index 56f586782c..0b8e2e6a00 100644 --- a/venus-shared/types/cbor_gen.go +++ b/venus-shared/types/cbor_gen.go @@ -54,7 +54,7 @@ func (t *BlockHeader) MarshalCBOR(w io.Writer) error { } // t.BeaconEntries ([]types.BeaconEntry) (slice) - if len(t.BeaconEntries) > cbg.MaxLength { + if len(t.BeaconEntries) > 8192 { return xerrors.Errorf("Slice value in field t.BeaconEntries was too long") } @@ -65,10 +65,11 @@ func (t *BlockHeader) MarshalCBOR(w io.Writer) error { if err := v.MarshalCBOR(cw); err != nil { return err } + } // t.WinPoStProof ([]proof.PoStProof) (slice) - if len(t.WinPoStProof) > cbg.MaxLength { + if len(t.WinPoStProof) > 8192 { return xerrors.Errorf("Slice value in field t.WinPoStProof was too long") } @@ -79,10 +80,11 @@ func (t *BlockHeader) MarshalCBOR(w io.Writer) error { if err := v.MarshalCBOR(cw); err != nil { return err } + } // t.Parents ([]cid.Cid) (slice) - if len(t.Parents) > cbg.MaxLength { + if len(t.Parents) > 8192 { return xerrors.Errorf("Slice value in field t.Parents was too long") } @@ -237,7 +239,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.BeaconEntries: array too large (%d)", extra) } @@ -265,9 +267,9 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) (err error) { } } + } } - // t.WinPoStProof ([]proof.PoStProof) (slice) maj, extra, err = cr.ReadHeader() @@ -275,7 +277,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.WinPoStProof: array too large (%d)", extra) } @@ -303,9 +305,9 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) (err error) { } } + } } - // t.Parents ([]cid.Cid) (slice) maj, extra, err = cr.ReadHeader() @@ -313,7 +315,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Parents: array too large (%d)", extra) } @@ -344,9 +346,9 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) (err error) { t.Parents[i] = c } + } } - // t.ParentWeight (big.Int) (struct) { @@ -359,10 +361,10 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) (err error) { // t.Height (abi.ChainEpoch) (int64) { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -510,7 +512,7 @@ func (t *Ticket) MarshalCBOR(w io.Writer) error { } // t.VRFProof (types.VRFPi) (slice) - if len(t.VRFProof) > cbg.ByteArrayMaxLen { + if len(t.VRFProof) > 2097152 { return xerrors.Errorf("Byte array in field t.VRFProof was too long") } @@ -518,9 +520,10 @@ func (t *Ticket) MarshalCBOR(w io.Writer) error { return err } - if _, err := cw.Write(t.VRFProof[:]); err != nil { + if _, err := cw.Write(t.VRFProof); err != nil { return err } + return nil } @@ -554,7 +557,7 @@ func (t *Ticket) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.ByteArrayMaxLen { + if extra > 2097152 { return fmt.Errorf("t.VRFProof: byte array too large (%d)", extra) } if maj != cbg.MajByteString { @@ -565,9 +568,10 @@ func (t *Ticket) UnmarshalCBOR(r io.Reader) (err error) { t.VRFProof = make([]uint8, extra) } - if _, err := io.ReadFull(cr, t.VRFProof[:]); err != nil { + if _, err := io.ReadFull(cr, t.VRFProof); err != nil { return err } + return nil } @@ -597,7 +601,7 @@ func (t *ElectionProof) MarshalCBOR(w io.Writer) error { } // t.VRFProof (types.VRFPi) (slice) - if len(t.VRFProof) > cbg.ByteArrayMaxLen { + if len(t.VRFProof) > 2097152 { return xerrors.Errorf("Byte array in field t.VRFProof was too long") } @@ -605,9 +609,10 @@ func (t *ElectionProof) MarshalCBOR(w io.Writer) error { return err } - if _, err := cw.Write(t.VRFProof[:]); err != nil { + if _, err := cw.Write(t.VRFProof); err != nil { return err } + return nil } @@ -637,10 +642,10 @@ func (t *ElectionProof) UnmarshalCBOR(r io.Reader) (err error) { // t.WinCount (int64) (int64) { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -666,7 +671,7 @@ func (t *ElectionProof) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.ByteArrayMaxLen { + if extra > 2097152 { return fmt.Errorf("t.VRFProof: byte array too large (%d)", extra) } if maj != cbg.MajByteString { @@ -677,9 +682,10 @@ func (t *ElectionProof) UnmarshalCBOR(r io.Reader) (err error) { t.VRFProof = make([]uint8, extra) } - if _, err := io.ReadFull(cr, t.VRFProof[:]); err != nil { + if _, err := io.ReadFull(cr, t.VRFProof); err != nil { return err } + return nil } @@ -704,7 +710,7 @@ func (t *BeaconEntry) MarshalCBOR(w io.Writer) error { } // t.Data ([]uint8) (slice) - if len(t.Data) > cbg.ByteArrayMaxLen { + if len(t.Data) > 2097152 { return xerrors.Errorf("Byte array in field t.Data was too long") } @@ -712,9 +718,10 @@ func (t *BeaconEntry) MarshalCBOR(w io.Writer) error { return err } - if _, err := cw.Write(t.Data[:]); err != nil { + if _, err := cw.Write(t.Data); err != nil { return err } + return nil } @@ -762,7 +769,7 @@ func (t *BeaconEntry) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.ByteArrayMaxLen { + if extra > 2097152 { return fmt.Errorf("t.Data: byte array too large (%d)", extra) } if maj != cbg.MajByteString { @@ -773,9 +780,10 @@ func (t *BeaconEntry) UnmarshalCBOR(r io.Reader) (err error) { t.Data = make([]uint8, extra) } - if _, err := io.ReadFull(cr, t.Data[:]); err != nil { + if _, err := io.ReadFull(cr, t.Data); err != nil { return err } + return nil } @@ -878,7 +886,7 @@ func (t *BlockMsg) MarshalCBOR(w io.Writer) error { } // t.BlsMessages ([]cid.Cid) (slice) - if len(t.BlsMessages) > cbg.MaxLength { + if len(t.BlsMessages) > 8192 { return xerrors.Errorf("Slice value in field t.BlsMessages was too long") } @@ -894,7 +902,7 @@ func (t *BlockMsg) MarshalCBOR(w io.Writer) error { } // t.SecpkMessages ([]cid.Cid) (slice) - if len(t.SecpkMessages) > cbg.MaxLength { + if len(t.SecpkMessages) > 8192 { return xerrors.Errorf("Slice value in field t.SecpkMessages was too long") } @@ -960,7 +968,7 @@ func (t *BlockMsg) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.BlsMessages: array too large (%d)", extra) } @@ -991,9 +999,9 @@ func (t *BlockMsg) UnmarshalCBOR(r io.Reader) (err error) { t.BlsMessages[i] = c } + } } - // t.SecpkMessages ([]cid.Cid) (slice) maj, extra, err = cr.ReadHeader() @@ -1001,7 +1009,7 @@ func (t *BlockMsg) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.SecpkMessages: array too large (%d)", extra) } @@ -1032,9 +1040,9 @@ func (t *BlockMsg) UnmarshalCBOR(r io.Reader) (err error) { t.SecpkMessages[i] = c } + } } - return nil } @@ -1053,7 +1061,7 @@ func (t *ExpTipSet) MarshalCBOR(w io.Writer) error { } // t.Cids ([]cid.Cid) (slice) - if len(t.Cids) > cbg.MaxLength { + if len(t.Cids) > 8192 { return xerrors.Errorf("Slice value in field t.Cids was too long") } @@ -1069,7 +1077,7 @@ func (t *ExpTipSet) MarshalCBOR(w io.Writer) error { } // t.Blocks ([]*types.BlockHeader) (slice) - if len(t.Blocks) > cbg.MaxLength { + if len(t.Blocks) > 8192 { return xerrors.Errorf("Slice value in field t.Blocks was too long") } @@ -1080,6 +1088,7 @@ func (t *ExpTipSet) MarshalCBOR(w io.Writer) error { if err := v.MarshalCBOR(cw); err != nil { return err } + } // t.Height (abi.ChainEpoch) (int64) @@ -1092,6 +1101,7 @@ func (t *ExpTipSet) MarshalCBOR(w io.Writer) error { return err } } + return nil } @@ -1125,7 +1135,7 @@ func (t *ExpTipSet) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Cids: array too large (%d)", extra) } @@ -1156,9 +1166,9 @@ func (t *ExpTipSet) UnmarshalCBOR(r io.Reader) (err error) { t.Cids[i] = c } + } } - // t.Blocks ([]*types.BlockHeader) (slice) maj, extra, err = cr.ReadHeader() @@ -1166,7 +1176,7 @@ func (t *ExpTipSet) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Blocks: array too large (%d)", extra) } @@ -1204,16 +1214,16 @@ func (t *ExpTipSet) UnmarshalCBOR(r io.Reader) (err error) { } } + } } - // t.Height (abi.ChainEpoch) (int64) { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -1261,7 +1271,7 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error { } // t.Vouchers ([]*paych.SignedVoucher) (slice) - if len(t.Vouchers) > cbg.MaxLength { + if len(t.Vouchers) > 8192 { return xerrors.Errorf("Slice value in field t.Vouchers was too long") } @@ -1272,6 +1282,7 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error { if err := v.MarshalCBOR(cw); err != nil { return err } + } return nil } @@ -1327,7 +1338,7 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Vouchers: array too large (%d)", extra) } @@ -1365,9 +1376,9 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) (err error) { } } + } } - return nil } @@ -1392,7 +1403,7 @@ func (t *Event) MarshalCBOR(w io.Writer) error { } // t.Entries ([]types.EventEntry) (slice) - if len(t.Entries) > cbg.MaxLength { + if len(t.Entries) > 8192 { return xerrors.Errorf("Slice value in field t.Entries was too long") } @@ -1403,6 +1414,7 @@ func (t *Event) MarshalCBOR(w io.Writer) error { if err := v.MarshalCBOR(cw); err != nil { return err } + } return nil } @@ -1451,7 +1463,7 @@ func (t *Event) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Entries: array too large (%d)", extra) } @@ -1479,9 +1491,9 @@ func (t *Event) UnmarshalCBOR(r io.Reader) (err error) { } } + } } - return nil } @@ -1505,7 +1517,7 @@ func (t *EventEntry) MarshalCBOR(w io.Writer) error { } // t.Key (string) (string) - if len(t.Key) > cbg.MaxLength { + if len(t.Key) > 8192 { return xerrors.Errorf("Value in field t.Key was too long") } @@ -1523,7 +1535,7 @@ func (t *EventEntry) MarshalCBOR(w io.Writer) error { } // t.Value ([]uint8) (slice) - if len(t.Value) > cbg.ByteArrayMaxLen { + if len(t.Value) > 2097152 { return xerrors.Errorf("Byte array in field t.Value was too long") } @@ -1531,9 +1543,10 @@ func (t *EventEntry) MarshalCBOR(w io.Writer) error { return err } - if _, err := cw.Write(t.Value[:]); err != nil { + if _, err := cw.Write(t.Value); err != nil { return err } + return nil } @@ -1576,7 +1589,7 @@ func (t *EventEntry) UnmarshalCBOR(r io.Reader) (err error) { // t.Key (string) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } @@ -1604,7 +1617,7 @@ func (t *EventEntry) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.ByteArrayMaxLen { + if extra > 2097152 { return fmt.Errorf("t.Value: byte array too large (%d)", extra) } if maj != cbg.MajByteString { @@ -1615,9 +1628,10 @@ func (t *EventEntry) UnmarshalCBOR(r io.Reader) (err error) { t.Value = make([]uint8, extra) } - if _, err := io.ReadFull(cr, t.Value[:]); err != nil { + if _, err := io.ReadFull(cr, t.Value); err != nil { return err } + return nil } @@ -1636,7 +1650,7 @@ func (t *GasTrace) MarshalCBOR(w io.Writer) error { } // t.Name (string) (string) - if len(t.Name) > cbg.MaxLength { + if len(t.Name) > 8192 { return xerrors.Errorf("Value in field t.Name was too long") } @@ -1690,6 +1704,7 @@ func (t *GasTrace) MarshalCBOR(w io.Writer) error { return err } } + return nil } @@ -1719,7 +1734,7 @@ func (t *GasTrace) UnmarshalCBOR(r io.Reader) (err error) { // t.Name (string) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } @@ -1729,10 +1744,10 @@ func (t *GasTrace) UnmarshalCBOR(r io.Reader) (err error) { // t.TotalGas (int64) (int64) { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -1754,10 +1769,10 @@ func (t *GasTrace) UnmarshalCBOR(r io.Reader) (err error) { // t.ComputeGas (int64) (int64) { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -1779,10 +1794,10 @@ func (t *GasTrace) UnmarshalCBOR(r io.Reader) (err error) { // t.StorageGas (int64) (int64) { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -1804,10 +1819,10 @@ func (t *GasTrace) UnmarshalCBOR(r io.Reader) (err error) { // t.TimeTaken (time.Duration) (int64) { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -1829,7 +1844,83 @@ func (t *GasTrace) UnmarshalCBOR(r io.Reader) (err error) { return nil } -var lengthBufMessageTrace = []byte{137} +var lengthBufActorTrace = []byte{130} + +func (t *ActorTrace) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write(lengthBufActorTrace); err != nil { + return err + } + + // t.Id (abi.ActorID) (uint64) + + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Id)); err != nil { + return err + } + + // t.State (types.ActorV5) (struct) + if err := t.State.MarshalCBOR(cw); err != nil { + return err + } + return nil +} + +func (t *ActorTrace) UnmarshalCBOR(r io.Reader) (err error) { + *t = ActorTrace{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajArray { + return fmt.Errorf("cbor input should be of type array") + } + + if extra != 2 { + return fmt.Errorf("cbor input had wrong number of fields") + } + + // t.Id (abi.ActorID) (uint64) + + { + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajUnsignedInt { + return fmt.Errorf("wrong type for uint64 field") + } + t.Id = abi.ActorID(extra) + + } + // t.State (types.ActorV5) (struct) + + { + + if err := t.State.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.State: %w", err) + } + + } + return nil +} + +var lengthBufMessageTrace = []byte{136} func (t *MessageTrace) MarshalCBOR(w io.Writer) error { if t == nil { @@ -1865,7 +1956,7 @@ func (t *MessageTrace) MarshalCBOR(w io.Writer) error { } // t.Params ([]uint8) (slice) - if len(t.Params) > cbg.ByteArrayMaxLen { + if len(t.Params) > 2097152 { return xerrors.Errorf("Byte array in field t.Params was too long") } @@ -1873,7 +1964,7 @@ func (t *MessageTrace) MarshalCBOR(w io.Writer) error { return err } - if _, err := cw.Write(t.Params[:]); err != nil { + if _, err := cw.Write(t.Params); err != nil { return err } @@ -1893,13 +1984,6 @@ func (t *MessageTrace) MarshalCBOR(w io.Writer) error { if err := cbg.WriteBool(w, t.ReadOnly); err != nil { return err } - - // t.CodeCid (cid.Cid) (struct) - - if err := cbg.WriteCid(cw, t.CodeCid); err != nil { - return xerrors.Errorf("failed to write cid field t.CodeCid: %w", err) - } - return nil } @@ -1922,7 +2006,7 @@ func (t *MessageTrace) UnmarshalCBOR(r io.Reader) (err error) { return fmt.Errorf("cbor input should be of type array") } - if extra != 9 { + if extra != 8 { return fmt.Errorf("cbor input had wrong number of fields") } @@ -1974,7 +2058,7 @@ func (t *MessageTrace) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.ByteArrayMaxLen { + if extra > 2097152 { return fmt.Errorf("t.Params: byte array too large (%d)", extra) } if maj != cbg.MajByteString { @@ -1985,9 +2069,10 @@ func (t *MessageTrace) UnmarshalCBOR(r io.Reader) (err error) { t.Params = make([]uint8, extra) } - if _, err := io.ReadFull(cr, t.Params[:]); err != nil { + if _, err := io.ReadFull(cr, t.Params); err != nil { return err } + // t.ParamsCodec (uint64) (uint64) { @@ -2033,18 +2118,6 @@ func (t *MessageTrace) UnmarshalCBOR(r io.Reader) (err error) { default: return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) } - // t.CodeCid (cid.Cid) (struct) - - { - - c, err := cbg.ReadCid(cr) - if err != nil { - return xerrors.Errorf("failed to read cid field t.CodeCid: %w", err) - } - - t.CodeCid = c - - } return nil } @@ -2074,7 +2147,7 @@ func (t *ReturnTrace) MarshalCBOR(w io.Writer) error { } // t.Return ([]uint8) (slice) - if len(t.Return) > cbg.ByteArrayMaxLen { + if len(t.Return) > 2097152 { return xerrors.Errorf("Byte array in field t.Return was too long") } @@ -2082,7 +2155,7 @@ func (t *ReturnTrace) MarshalCBOR(w io.Writer) error { return err } - if _, err := cw.Write(t.Return[:]); err != nil { + if _, err := cw.Write(t.Return); err != nil { return err } @@ -2121,10 +2194,10 @@ func (t *ReturnTrace) UnmarshalCBOR(r io.Reader) (err error) { // t.ExitCode (exitcode.ExitCode) (int64) { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -2150,7 +2223,7 @@ func (t *ReturnTrace) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.ByteArrayMaxLen { + if extra > 2097152 { return fmt.Errorf("t.Return: byte array too large (%d)", extra) } if maj != cbg.MajByteString { @@ -2161,9 +2234,10 @@ func (t *ReturnTrace) UnmarshalCBOR(r io.Reader) (err error) { t.Return = make([]uint8, extra) } - if _, err := io.ReadFull(cr, t.Return[:]); err != nil { + if _, err := io.ReadFull(cr, t.Return); err != nil { return err } + // t.ReturnCodec (uint64) (uint64) { @@ -2181,7 +2255,7 @@ func (t *ReturnTrace) UnmarshalCBOR(r io.Reader) (err error) { return nil } -var lengthBufExecutionTrace = []byte{132} +var lengthBufExecutionTrace = []byte{133} func (t *ExecutionTrace) MarshalCBOR(w io.Writer) error { if t == nil { @@ -2205,6 +2279,11 @@ func (t *ExecutionTrace) MarshalCBOR(w io.Writer) error { return err } + // t.InvokedActor (types.ActorTrace) (struct) + if err := t.InvokedActor.MarshalCBOR(cw); err != nil { + return err + } + // t.GasCharges ([]*types.GasTrace) (slice) if len(t.GasCharges) > 1000000000 { return xerrors.Errorf("Slice value in field t.GasCharges was too long") @@ -2217,6 +2296,7 @@ func (t *ExecutionTrace) MarshalCBOR(w io.Writer) error { if err := v.MarshalCBOR(cw); err != nil { return err } + } // t.Subcalls ([]types.ExecutionTrace) (slice) @@ -2231,6 +2311,7 @@ func (t *ExecutionTrace) MarshalCBOR(w io.Writer) error { if err := v.MarshalCBOR(cw); err != nil { return err } + } return nil } @@ -2254,7 +2335,7 @@ func (t *ExecutionTrace) UnmarshalCBOR(r io.Reader) (err error) { return fmt.Errorf("cbor input should be of type array") } - if extra != 4 { + if extra != 5 { return fmt.Errorf("cbor input had wrong number of fields") } @@ -2275,6 +2356,25 @@ func (t *ExecutionTrace) UnmarshalCBOR(r io.Reader) (err error) { return xerrors.Errorf("unmarshaling t.MsgRct: %w", err) } + } + // t.InvokedActor (types.ActorTrace) (struct) + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.InvokedActor = new(ActorTrace) + if err := t.InvokedActor.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.InvokedActor pointer: %w", err) + } + } + } // t.GasCharges ([]*types.GasTrace) (slice) @@ -2321,9 +2421,9 @@ func (t *ExecutionTrace) UnmarshalCBOR(r io.Reader) (err error) { } } + } } - // t.Subcalls ([]types.ExecutionTrace) (slice) maj, extra, err = cr.ReadHeader() @@ -2359,8 +2459,8 @@ func (t *ExecutionTrace) UnmarshalCBOR(r io.Reader) (err error) { } } + } } - return nil } diff --git a/venus-shared/types/eth.go b/venus-shared/types/eth.go index ef6c4b78ba..db6b424630 100644 --- a/venus-shared/types/eth.go +++ b/venus-shared/types/eth.go @@ -31,6 +31,11 @@ type ( EthBlockNumberOrHash = types.EthBlockNumberOrHash EthBytes = types.EthBytes EthCall = types.EthCall + EthCallTraceAction = types.EthCallTraceAction + EthCallTraceResult = types.EthCallTraceResult + EthCreateTraceAction = types.EthCreateTraceAction + EthCreateTraceResult = types.EthCreateTraceResult + EthEstimateGasParams = types.EthEstimateGasParams EthFeeHistory = types.EthFeeHistory EthFeeHistoryParams = types.EthFeeHistoryParams EthFilterID = types.EthFilterID @@ -47,10 +52,8 @@ type ( EthSyncingResult = types.EthSyncingResult EthTopicSpec = types.EthTopicSpec EthTrace = types.EthTrace - EthTraceAction = types.EthTraceAction EthTraceBlock = types.EthTraceBlock EthTraceReplayBlockTransaction = types.EthTraceReplayBlockTransaction - EthTraceResult = types.EthTraceResult EthTxReceipt = types.EthTxReceipt EthUint64 = types.EthUint64 ) @@ -59,6 +62,7 @@ var ( CastEthAddress = types.CastEthAddress DecodeHexString = types.DecodeHexString DecodeHexStringTrimSpace = types.DecodeHexStringTrimSpace + EthAddressFromActorID = types.EthAddressFromActorID EthAddressFromFilecoinAddress = types.EthAddressFromFilecoinAddress EthAddressFromPubKey = types.EthAddressFromPubKey EthBloomSet = types.EthBloomSet diff --git a/venus-shared/types/event.go b/venus-shared/types/event.go index 106a120e21..5f6415d49e 100644 --- a/venus-shared/types/event.go +++ b/venus-shared/types/event.go @@ -28,7 +28,7 @@ type EventEntry struct { // The event value's codec Codec uint64 - // The event value + // The event value. It is encoded using the codec specified above Value []byte } diff --git a/venus-shared/types/exec.go b/venus-shared/types/exec.go index 2ff6c4d89d..9e3cdaa28a 100644 --- a/venus-shared/types/exec.go +++ b/venus-shared/types/exec.go @@ -7,7 +7,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/exitcode" - "github.com/ipfs/go-cid" ) type GasTrace struct { @@ -18,6 +17,11 @@ type GasTrace struct { TimeTaken time.Duration `json:"tt"` } +type ActorTrace struct { + Id abi.ActorID // nolint + State Actor +} + type ReturnTrace struct { ExitCode exitcode.ExitCode Return []byte @@ -25,10 +29,11 @@ type ReturnTrace struct { } type ExecutionTrace struct { - Msg MessageTrace - MsgRct ReturnTrace - GasCharges []*GasTrace `cborgen:"maxlen=1000000000"` - Subcalls []ExecutionTrace `cborgen:"maxlen=1000000000"` + Msg MessageTrace + MsgRct ReturnTrace + InvokedActor *ActorTrace `json:",omitempty"` + GasCharges []*GasTrace `cborgen:"maxlen=1000000000"` + Subcalls []ExecutionTrace `cborgen:"maxlen=1000000000"` } func (et ExecutionTrace) SumGas() GasTrace { @@ -61,5 +66,4 @@ type MessageTrace struct { ParamsCodec uint64 GasLimit uint64 ReadOnly bool - CodeCid cid.Cid } diff --git a/venus-shared/types/market/cbor_gen.go b/venus-shared/types/market/cbor_gen.go index 56c0c35ef4..82edd94293 100644 --- a/venus-shared/types/market/cbor_gen.go +++ b/venus-shared/types/market/cbor_gen.go @@ -160,7 +160,7 @@ func (t *MsgInfo) MarshalCBOR(w io.Writer) error { } // t.ChannelID (string) (string) - if len(t.ChannelID) > cbg.MaxLength { + if len(t.ChannelID) > 8192 { return xerrors.Errorf("Value in field t.ChannelID was too long") } @@ -183,7 +183,7 @@ func (t *MsgInfo) MarshalCBOR(w io.Writer) error { } // t.Err (string) (string) - if len(t.Err) > cbg.MaxLength { + if len(t.Err) > 8192 { return xerrors.Errorf("Value in field t.Err was too long") } @@ -227,7 +227,7 @@ func (t *MsgInfo) UnmarshalCBOR(r io.Reader) (err error) { // t.ChannelID (string) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } @@ -266,7 +266,7 @@ func (t *MsgInfo) UnmarshalCBOR(r io.Reader) (err error) { // t.Err (string) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } @@ -300,7 +300,7 @@ func (t *ChannelInfo) MarshalCBOR(w io.Writer) error { } // t.ChannelID (string) (string) - if len(t.ChannelID) > cbg.MaxLength { + if len(t.ChannelID) > 8192 { return xerrors.Errorf("Value in field t.ChannelID was too long") } @@ -333,7 +333,7 @@ func (t *ChannelInfo) MarshalCBOR(w io.Writer) error { } // t.Vouchers ([]*market.VoucherInfo) (slice) - if len(t.Vouchers) > cbg.MaxLength { + if len(t.Vouchers) > 8192 { return xerrors.Errorf("Slice value in field t.Vouchers was too long") } @@ -344,6 +344,7 @@ func (t *ChannelInfo) MarshalCBOR(w io.Writer) error { if err := v.MarshalCBOR(cw); err != nil { return err } + } // t.NextLane (uint64) (uint64) @@ -434,7 +435,7 @@ func (t *ChannelInfo) UnmarshalCBOR(r io.Reader) (err error) { // t.ChannelID (string) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } @@ -499,7 +500,7 @@ func (t *ChannelInfo) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Vouchers: array too large (%d)", extra) } @@ -537,9 +538,9 @@ func (t *ChannelInfo) UnmarshalCBOR(r io.Reader) (err error) { } } + } } - // t.NextLane (uint64) (uint64) { @@ -683,7 +684,7 @@ func (t *VoucherInfo) MarshalCBOR(w io.Writer) error { } // t.Proof ([]uint8) (slice) - if len(t.Proof) > cbg.ByteArrayMaxLen { + if len(t.Proof) > 2097152 { return xerrors.Errorf("Byte array in field t.Proof was too long") } @@ -691,7 +692,7 @@ func (t *VoucherInfo) MarshalCBOR(w io.Writer) error { return err } - if _, err := cw.Write(t.Proof[:]); err != nil { + if _, err := cw.Write(t.Proof); err != nil { return err } @@ -751,7 +752,7 @@ func (t *VoucherInfo) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.ByteArrayMaxLen { + if extra > 2097152 { return fmt.Errorf("t.Proof: byte array too large (%d)", extra) } if maj != cbg.MajByteString { @@ -762,9 +763,10 @@ func (t *VoucherInfo) UnmarshalCBOR(r io.Reader) (err error) { t.Proof = make([]uint8, extra) } - if _, err := io.ReadFull(cr, t.Proof[:]); err != nil { + if _, err := io.ReadFull(cr, t.Proof); err != nil { return err } + // t.Submitted (bool) (bool) maj, extra, err = cr.ReadHeader() @@ -800,7 +802,7 @@ func (t *MinerDeal) MarshalCBOR(w io.Writer) error { } // t.ID (uuid.UUID) (array) - if len(t.ID) > cbg.ByteArrayMaxLen { + if len(t.ID) > 2097152 { return xerrors.Errorf("Byte array in field t.ID was too long") } @@ -848,7 +850,7 @@ func (t *MinerDeal) MarshalCBOR(w io.Writer) error { } // t.Miner (peer.ID) (string) - if len(t.Miner) > cbg.MaxLength { + if len(t.Miner) > 8192 { return xerrors.Errorf("Value in field t.Miner was too long") } @@ -860,7 +862,7 @@ func (t *MinerDeal) MarshalCBOR(w io.Writer) error { } // t.Client (peer.ID) (string) - if len(t.Client) > cbg.MaxLength { + if len(t.Client) > 8192 { return xerrors.Errorf("Value in field t.Client was too long") } @@ -878,7 +880,7 @@ func (t *MinerDeal) MarshalCBOR(w io.Writer) error { } // t.PiecePath (filestore.Path) (string) - if len(t.PiecePath) > cbg.MaxLength { + if len(t.PiecePath) > 8192 { return xerrors.Errorf("Value in field t.PiecePath was too long") } @@ -896,7 +898,7 @@ func (t *MinerDeal) MarshalCBOR(w io.Writer) error { } // t.MetadataPath (filestore.Path) (string) - if len(t.MetadataPath) > cbg.MaxLength { + if len(t.MetadataPath) > 8192 { return xerrors.Errorf("Value in field t.MetadataPath was too long") } @@ -924,7 +926,7 @@ func (t *MinerDeal) MarshalCBOR(w io.Writer) error { } // t.Message (string) (string) - if len(t.Message) > cbg.MaxLength { + if len(t.Message) > 8192 { return xerrors.Errorf("Value in field t.Message was too long") } @@ -979,7 +981,7 @@ func (t *MinerDeal) MarshalCBOR(w io.Writer) error { } // t.PieceStatus (market.PieceStatus) (string) - if len(t.PieceStatus) > cbg.MaxLength { + if len(t.PieceStatus) > 8192 { return xerrors.Errorf("Value in field t.PieceStatus was too long") } @@ -991,7 +993,7 @@ func (t *MinerDeal) MarshalCBOR(w io.Writer) error { } // t.InboundCAR (string) (string) - if len(t.InboundCAR) > cbg.MaxLength { + if len(t.InboundCAR) > 8192 { return xerrors.Errorf("Value in field t.InboundCAR was too long") } @@ -1039,19 +1041,17 @@ func (t *MinerDeal) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.ByteArrayMaxLen { + if extra > 2097152 { return fmt.Errorf("t.ID: byte array too large (%d)", extra) } if maj != cbg.MajByteString { return fmt.Errorf("expected byte array") } - if extra != 16 { return fmt.Errorf("expected array to have 16 elements") } t.ID = [16]uint8{} - if _, err := io.ReadFull(cr, t.ID[:]); err != nil { return err } @@ -1123,7 +1123,7 @@ func (t *MinerDeal) UnmarshalCBOR(r io.Reader) (err error) { // t.Miner (peer.ID) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } @@ -1133,7 +1133,7 @@ func (t *MinerDeal) UnmarshalCBOR(r io.Reader) (err error) { // t.Client (peer.ID) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } @@ -1157,7 +1157,7 @@ func (t *MinerDeal) UnmarshalCBOR(r io.Reader) (err error) { // t.PiecePath (filestore.Path) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } @@ -1181,7 +1181,7 @@ func (t *MinerDeal) UnmarshalCBOR(r io.Reader) (err error) { // t.MetadataPath (filestore.Path) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } @@ -1191,10 +1191,10 @@ func (t *MinerDeal) UnmarshalCBOR(r io.Reader) (err error) { // t.SlashEpoch (abi.ChainEpoch) (int64) { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -1233,7 +1233,7 @@ func (t *MinerDeal) UnmarshalCBOR(r io.Reader) (err error) { // t.Message (string) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } @@ -1358,7 +1358,7 @@ func (t *MinerDeal) UnmarshalCBOR(r io.Reader) (err error) { // t.PieceStatus (market.PieceStatus) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } @@ -1368,7 +1368,7 @@ func (t *MinerDeal) UnmarshalCBOR(r io.Reader) (err error) { // t.InboundCAR (string) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } @@ -1568,7 +1568,7 @@ func (t *ProviderDealState) MarshalCBOR(w io.Writer) error { } // t.Receiver (peer.ID) (string) - if len(t.Receiver) > cbg.MaxLength { + if len(t.Receiver) > 8192 { return xerrors.Errorf("Value in field t.Receiver was too long") } @@ -1591,7 +1591,7 @@ func (t *ProviderDealState) MarshalCBOR(w io.Writer) error { } // t.Message (string) (string) - if len(t.Message) > cbg.MaxLength { + if len(t.Message) > 8192 { return xerrors.Errorf("Value in field t.Message was too long") } @@ -1714,7 +1714,7 @@ func (t *ProviderDealState) UnmarshalCBOR(r io.Reader) (err error) { // t.Receiver (peer.ID) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } @@ -1747,7 +1747,7 @@ func (t *ProviderDealState) UnmarshalCBOR(r io.Reader) (err error) { // t.Message (string) (string) { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 8192) if err != nil { return err } diff --git a/venus-shared/utils/method_map.go b/venus-shared/utils/method_map.go index 1b6673bb6e..38adf699e8 100644 --- a/venus-shared/utils/method_map.go +++ b/venus-shared/utils/method_map.go @@ -60,6 +60,7 @@ func loadMethodsMap() { actors = append(actors, actorsWithVersion{av: actorstypes.Version10, actors: builtin.MakeRegistry(actorstypes.Version10)}) actors = append(actors, actorsWithVersion{av: actorstypes.Version11, actors: builtin.MakeRegistry(actorstypes.Version11)}) actors = append(actors, actorsWithVersion{av: actorstypes.Version12, actors: builtin.MakeRegistry(actorstypes.Version12)}) + actors = append(actors, actorsWithVersion{av: actorstypes.Version13, actors: builtin.MakeRegistry(actorstypes.Version13)}) for _, awv := range actors { for _, actor := range awv.actors {