From 1cf79dab805ce2efe0a92c7ca4923910109afbe2 Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Thu, 31 Oct 2024 13:55:51 +0800 Subject: [PATCH 1/7] feat: implement F3 list participants API --- pkg/vf3/f3.go | 13 +++++++ pkg/vf3/participation_lease.go | 37 +++++++++++++------ venus-shared/api/chain/v1/f3.go | 3 ++ venus-shared/api/chain/v1/method.md | 20 ++++++++++ .../api/chain/v1/mock/mock_fullnode.go | 15 ++++++++ venus-shared/api/chain/v1/proxy_gen.go | 4 ++ venus-shared/types/api_types.go | 13 +++++++ 7 files changed, 94 insertions(+), 11 deletions(-) diff --git a/pkg/vf3/f3.go b/pkg/vf3/f3.go index baafa85b31..9645c3c3ca 100644 --- a/pkg/vf3/f3.go +++ b/pkg/vf3/f3.go @@ -225,3 +225,16 @@ func (fff *F3) IsRunning() bool { func (fff *F3) Progress() gpbft.Instant { return fff.inner.Progress() } + +func (fff *F3) ListParticipants() []types.F3Participant { + leases := fff.leaser.getValidLeases() + participants := make([]types.F3Participant, len(leases)) + for i, lease := range leases { + participants[i] = types.F3Participant{ + MinerID: lease.MinerID, + FromInstance: lease.FromInstance, + ValidityTerm: lease.ValidityTerm, + } + } + return participants +} diff --git a/pkg/vf3/participation_lease.go b/pkg/vf3/participation_lease.go index 230c5ea026..c5f5f47ba5 100644 --- a/pkg/vf3/participation_lease.go +++ b/pkg/vf3/participation_lease.go @@ -55,7 +55,7 @@ func (l *leaser) getOrRenewParticipationTicket(participant uint64, previous type // - it is valid and was issued by this node. // // Otherwise, return ErrF3ParticipationIssuerMismatch to signal to the caller the need for retry. - switch _, err := l.validate(manifest.NetworkName, currentInstance, previous); { + switch _, err := l.validateTicket(manifest.NetworkName, currentInstance, previous); { case errors.Is(err, types.ErrF3ParticipationTicketInvalid): // Invalid ticket means the miner must have got the ticket from a node with a potentially different version. // Refuse to issue a new ticket in case there is some other node with active lease for the miner. @@ -89,7 +89,7 @@ func (l *leaser) participate(ticket types.F3ParticipationTicket) (types.F3Partic if manifest == nil { return types.F3ParticipationLease{}, types.ErrF3NotReady } - newLease, err := l.validate(manifest.NetworkName, instant.ID, ticket) + newLease, err := l.validateTicket(manifest.NetworkName, instant.ID, ticket) if err != nil { return types.F3ParticipationLease{}, err } @@ -118,15 +118,10 @@ func (l *leaser) getParticipantsByInstance(network gpbft.NetworkName, instance u } var participants []uint64 for id, lease := range l.leases { - if currentNetwork != lease.Network { - // Lazily delete any lease that does not belong to network, likely acquired from - // prior manifests. + if _, err := l.validateLease(currentNetwork, instance, lease); err != nil { + // Lazily clear old leases. + log.Warnf("lost F3 participation lease for miner %d at instance %d since it is no loger valid: %v ", id, instance, err) delete(l.leases, id) - log.Warnf("lost F3 participation lease for miner %d at instance %d due to network mismatch: %s != %s", id, instance, currentNetwork, lease.Network) - } else if instance > lease.ToInstance() { - // Lazily delete the expired leases. - delete(l.leases, id) - log.Warnf("lost F3 participation lease for miner %d due to instance (%d) > lease to instance (%d)", id, instance, lease.ToInstance()) } else { participants = append(participants, id) } @@ -134,6 +129,23 @@ func (l *leaser) getParticipantsByInstance(network gpbft.NetworkName, instance u return participants } +func (l *leaser) getValidLeases() []types.F3ParticipationLease { + l.mutex.Lock() + defer l.mutex.Unlock() + currentManifest, progress := l.status() + var leases []types.F3ParticipationLease + for id, lease := range l.leases { + // Lazily clear old leases. + if validatedLease, err := l.validateLease(currentManifest.NetworkName, progress.ID, lease); err != nil { + log.Warnf("lost F3 participation lease for miner %d at instance %d while getting valid leases since it is no loger valid: %v ", id, progress.ID, err) + delete(l.leases, id) + } else { + leases = append(leases, validatedLease) + } + } + return leases +} + func (l *leaser) newParticipationTicket(nn gpbft.NetworkName, participant uint64, from uint64, instances uint64) (types.F3ParticipationTicket, error) { // Lotus node API and miners run in a trusted environment. For now we make the // ticket to simply be the CBOR encoding of the lease. In the future, where the @@ -152,13 +164,16 @@ func (l *leaser) newParticipationTicket(nn gpbft.NetworkName, participant uint64 return buf.Bytes(), nil } -func (l *leaser) validate(currentNetwork gpbft.NetworkName, currentInstance uint64, t types.F3ParticipationTicket) (types.F3ParticipationLease, error) { +func (l *leaser) validateTicket(currentNetwork gpbft.NetworkName, currentInstance uint64, t types.F3ParticipationTicket) (types.F3ParticipationLease, error) { var lease types.F3ParticipationLease reader := bytes.NewReader(t) if err := lease.UnmarshalCBOR(reader); err != nil { return types.F3ParticipationLease{}, types.ErrF3ParticipationTicketInvalid } + return l.validateLease(currentNetwork, currentInstance, lease) +} +func (l *leaser) validateLease(currentNetwork gpbft.NetworkName, currentInstance uint64, lease types.F3ParticipationLease) (types.F3ParticipationLease, error) { // Combine the errors to remove significance of the order by which they are // checked outside if this function. var err error diff --git a/venus-shared/api/chain/v1/f3.go b/venus-shared/api/chain/v1/f3.go index a3d7b3664a..e088590fbc 100644 --- a/venus-shared/api/chain/v1/f3.go +++ b/venus-shared/api/chain/v1/f3.go @@ -68,4 +68,7 @@ type IF3 interface { F3IsRunning(ctx context.Context) (bool, error) //perm:read // F3GetProgress returns the progress of the current F3 instance in terms of instance ID, round and phase. F3GetProgress(ctx context.Context) (gpbft.Instant, error) //perm:read + + // F3ListParticipants returns the list of miners that are currently participating in F3 via this node. + F3ListParticipants(ctx context.Context) ([]types.F3Participant, error) //perm:read } diff --git a/venus-shared/api/chain/v1/method.md b/venus-shared/api/chain/v1/method.md index a07d0a200d..d06dca4485 100644 --- a/venus-shared/api/chain/v1/method.md +++ b/venus-shared/api/chain/v1/method.md @@ -126,6 +126,7 @@ curl http://:/rpc/v1 -X POST -H "Content-Type: application/json" -H " * [F3GetOrRenewParticipationTicket](#f3getorrenewparticipationticket) * [F3GetProgress](#f3getprogress) * [F3IsRunning](#f3isrunning) + * [F3ListParticipants](#f3listparticipants) * [F3Participate](#f3participate) * [Market](#market) * [StateMarketParticipants](#statemarketparticipants) @@ -3803,6 +3804,25 @@ Inputs: `[]` Response: `true` +### F3ListParticipants +F3ListParticipants returns the list of miners that are currently participating in F3 via this node. + + +Perms: read + +Inputs: `[]` + +Response: +```json +[ + { + "MinerID": 42, + "FromInstance": 42, + "ValidityTerm": 42 + } +] +``` + ### F3Participate F3Participate enrolls a storage provider in the F3 consensus process using a provided participation ticket. This ticket grants a temporary lease that enables diff --git a/venus-shared/api/chain/v1/mock/mock_fullnode.go b/venus-shared/api/chain/v1/mock/mock_fullnode.go index 4c4e4c9eea..ba26845c47 100644 --- a/venus-shared/api/chain/v1/mock/mock_fullnode.go +++ b/venus-shared/api/chain/v1/mock/mock_fullnode.go @@ -1224,6 +1224,21 @@ func (mr *MockFullNodeMockRecorder) F3IsRunning(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "F3IsRunning", reflect.TypeOf((*MockFullNode)(nil).F3IsRunning), arg0) } +// F3ListParticipants mocks base method. +func (m *MockFullNode) F3ListParticipants(arg0 context.Context) ([]types0.F3Participant, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "F3ListParticipants", arg0) + ret0, _ := ret[0].([]types0.F3Participant) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// F3ListParticipants indicates an expected call of F3ListParticipants. +func (mr *MockFullNodeMockRecorder) F3ListParticipants(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "F3ListParticipants", reflect.TypeOf((*MockFullNode)(nil).F3ListParticipants), arg0) +} + // F3Participate mocks base method. func (m *MockFullNode) F3Participate(arg0 context.Context, arg1 types0.F3ParticipationTicket) (types0.F3ParticipationLease, 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 0690ff561e..59e7288dba 100644 --- a/venus-shared/api/chain/v1/proxy_gen.go +++ b/venus-shared/api/chain/v1/proxy_gen.go @@ -1099,6 +1099,7 @@ type IF3Struct struct { F3GetOrRenewParticipationTicket func(ctx context.Context, minerID address.Address, previous types.F3ParticipationTicket, instances uint64) (types.F3ParticipationTicket, error) `perm:"sign"` F3GetProgress func(ctx context.Context) (gpbft.Instant, error) `perm:"read"` F3IsRunning func(ctx context.Context) (bool, error) `perm:"read"` + F3ListParticipants func(ctx context.Context) ([]types.F3Participant, error) `perm:"read"` F3Participate func(ctx context.Context, ticket types.F3ParticipationTicket) (types.F3ParticipationLease, error) `perm:"sign"` } } @@ -1125,6 +1126,9 @@ func (s *IF3Struct) F3GetProgress(p0 context.Context) (gpbft.Instant, error) { return s.Internal.F3GetProgress(p0) } func (s *IF3Struct) F3IsRunning(p0 context.Context) (bool, error) { return s.Internal.F3IsRunning(p0) } +func (s *IF3Struct) F3ListParticipants(p0 context.Context) ([]types.F3Participant, error) { + return s.Internal.F3ListParticipants(p0) +} func (s *IF3Struct) F3Participate(p0 context.Context, p1 types.F3ParticipationTicket) (types.F3ParticipationLease, error) { return s.Internal.F3Participate(p0, p1) } diff --git a/venus-shared/types/api_types.go b/venus-shared/types/api_types.go index 4aee040bcb..b4dbe9d0db 100644 --- a/venus-shared/types/api_types.go +++ b/venus-shared/types/api_types.go @@ -528,6 +528,19 @@ func (l *F3ParticipationLease) ToInstance() uint64 { return l.FromInstance + l.ValidityTerm } +// F3Participant captures information about the miners that are currently +// participating in F3, along with the number of instances for which their lease +// is valid. +type F3Participant struct { + // MinerID is the actor ID of the miner that is + MinerID uint64 + // FromInstance specifies the instance ID from which this lease is valid. + FromInstance uint64 + // ValidityTerm specifies the number of instances for which the lease remains + // valid from the FromInstance. + ValidityTerm uint64 +} + var ( // ErrF3Disabled signals that F3 consensus process is disabled. ErrF3Disabled = errF3Disabled{} From 9effc9dd2daedcd4107004379e80f3db14643fd4 Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:13:42 +0800 Subject: [PATCH 2/7] fix(f3): poll the lease by repeatedly participating instead of checking progress --- pkg/vf3/participation_lease.go | 24 ++++++++++++---- pkg/vf3/participation_lease_test.go | 44 ++++++++++++++++++++--------- venus-devtool/api-gen/example.go | 10 +++++++ venus-shared/api/chain/v1/method.md | 6 ++-- venus-shared/types/api_types.go | 4 +-- venus-shared/types/cbor_gen.go | 7 ++--- 6 files changed, 66 insertions(+), 29 deletions(-) diff --git a/pkg/vf3/participation_lease.go b/pkg/vf3/participation_lease.go index c5f5f47ba5..8aab026572 100644 --- a/pkg/vf3/participation_lease.go +++ b/pkg/vf3/participation_lease.go @@ -19,7 +19,7 @@ type f3Status = func() (*manifest.Manifest, gpbft.Instant) type leaser struct { mutex sync.Mutex leases map[uint64]types.F3ParticipationLease - issuer peer.ID + issuer string // issuer is the base58 encoding of the node peer ID. status f3Status maxLeasableInstances uint64 // Signals that a lease was created and/or updated. @@ -29,7 +29,7 @@ type leaser struct { func newParticipationLeaser(nodeID peer.ID, status f3Status, maxLeasedInstances uint64) *leaser { return &leaser{ leases: make(map[uint64]types.F3ParticipationLease), - issuer: nodeID, + issuer: nodeID.String(), status: status, maxLeasableInstances: maxLeasedInstances, notifyParticipation: make(chan struct{}, 1), @@ -37,7 +37,9 @@ func newParticipationLeaser(nodeID peer.ID, status f3Status, maxLeasedInstances } func (l *leaser) getOrRenewParticipationTicket(participant uint64, previous types.F3ParticipationTicket, instances uint64) (types.F3ParticipationTicket, error) { - + if instances == 0 { + return nil, errors.New("not enough instances") + } if instances > l.maxLeasableInstances { return nil, types.ErrF3ParticipationTooManyInstances } @@ -96,15 +98,25 @@ func (l *leaser) participate(ticket types.F3ParticipationTicket) (types.F3Partic l.mutex.Lock() defer l.mutex.Unlock() currentLease, found := l.leases[newLease.MinerID] - if found && currentLease.Network == newLease.Network && currentLease.FromInstance > newLease.FromInstance { - // For safety, strictly require lease start instance to never decrease. - return types.F3ParticipationLease{}, types.ErrF3ParticipationTicketStartBeforeExisting + if found { + // short-circuite for reparticipation. + if currentLease == newLease { + return newLease, nil + } + if currentLease.Network == newLease.Network && currentLease.FromInstance > newLease.FromInstance { + // For safety, strictly require lease start instance to never decrease. + return types.F3ParticipationLease{}, types.ErrF3ParticipationTicketStartBeforeExisting + } + } else { + log.Infof("started participating in F3 for miner %d", newLease.MinerID) } l.leases[newLease.MinerID] = newLease select { case l.notifyParticipation <- struct{}{}: default: } + newLease.ValidityTerm = newLease.ToInstance() - instant.ID + newLease.FromInstance = instant.ID return newLease, nil } diff --git a/pkg/vf3/participation_lease_test.go b/pkg/vf3/participation_lease_test.go index 1510e6a984..444f8d316c 100644 --- a/pkg/vf3/participation_lease_test.go +++ b/pkg/vf3/participation_lease_test.go @@ -10,24 +10,21 @@ import ( "github.com/filecoin-project/go-f3/gpbft" "github.com/filecoin-project/go-f3/manifest" + tf "github.com/filecoin-project/venus/pkg/testhelpers/testflags" "github.com/filecoin-project/venus/venus-shared/types" ) func TestLeaser(t *testing.T) { - nodeID := peer.ID("peerID") + tf.UnitTest(t) + issuer := peer.ID("peerID") progress := mockProgress{currentInstance: 10} - subject := newParticipationLeaser(nodeID, progress.Progress, 5) - - t.Run("participate", func(t *testing.T) { - ticket, err := subject.getOrRenewParticipationTicket(123, nil, 5) - require.NoError(t, err) - - lease, err := subject.participate(ticket) - require.NoError(t, err) - require.Equal(t, uint64(123), lease.MinerID) - require.Equal(t, nodeID, lease.Issuer) - require.Equal(t, uint64(5), lease.ValidityTerm) // Current instance (10) + offset (5) + subject := newParticipationLeaser(issuer, progress.Progress, 5) + t.Run("participate zero", func(t *testing.T) { + ticket, err := subject.getOrRenewParticipationTicket(123, nil, 0) + require.Error(t, err) + require.Nil(t, ticket) }) + t.Run("get participants", func(t *testing.T) { progress.currentInstance = 11 ticket1, err := subject.getOrRenewParticipationTicket(123, nil, 4) @@ -46,6 +43,23 @@ func TestLeaser(t *testing.T) { require.Contains(t, participants, uint64(123)) require.Contains(t, participants, uint64(456)) + leases := subject.getValidLeases() + require.Len(t, leases, 2) + require.Contains(t, leases, types.F3ParticipationLease{ + Network: testManifest.NetworkName, + Issuer: issuer.String(), + MinerID: 123, + FromInstance: 11, + ValidityTerm: 4, + }) + require.Contains(t, leases, types.F3ParticipationLease{ + Network: testManifest.NetworkName, + Issuer: issuer.String(), + MinerID: 456, + FromInstance: 11, + ValidityTerm: 5, + }) + // After instance 16, only participant 456 should be valid. participants = subject.getParticipantsByInstance(testManifest.NetworkName, 16) require.Len(t, participants, 1) @@ -71,7 +85,7 @@ func TestLeaser(t *testing.T) { // Generate a token from the same subject but with higher term, then assert that // original subject with lower term rejects it. - subjectSpoofWithHigherMaxLease := newParticipationLeaser(nodeID, progress.Progress, 6) + subjectSpoofWithHigherMaxLease := newParticipationLeaser(issuer, progress.Progress, 6) ticket, err = subjectSpoofWithHigherMaxLease.getOrRenewParticipationTicket(123, nil, 6) require.NoError(t, err) require.NotEmpty(t, ticket) @@ -138,6 +152,7 @@ func TestLeaser(t *testing.T) { // Get or renew with valid but mismatching issuer progress.currentInstance -= 10 anotherIssuer := newParticipationLeaser("barreleye", progress.Progress, 5) + require.NoError(t, err) newTicket, err = anotherIssuer.getOrRenewParticipationTicket(123, previous, 5) require.ErrorIs(t, err, types.ErrF3ParticipationIssuerMismatch) require.Empty(t, newTicket) @@ -151,7 +166,8 @@ func TestLeaser(t *testing.T) { // Get or renew with expired but mismatching session progress.currentInstance -= 10 - subjectAtNewSession := newParticipationLeaser(nodeID, progress.Progress, 5) + subjectAtNewSession := newParticipationLeaser(issuer, progress.Progress, 5) + require.NoError(t, err) newTicket, err = subjectAtNewSession.getOrRenewParticipationTicket(123, previous, 5) require.NoError(t, err) require.NotNil(t, newTicket) diff --git a/venus-devtool/api-gen/example.go b/venus-devtool/api-gen/example.go index 7ae7b91969..543651fbb1 100644 --- a/venus-devtool/api-gen/example.go +++ b/venus-devtool/api-gen/example.go @@ -350,6 +350,16 @@ func init() { } addExample(ðTraceFilterCriteria) addExample(ethTraceFilterCriteria) + + f3Lease := types.F3ParticipationLease{ + Network: "filecoin", + Issuer: pid.String(), + MinerID: 1234, + FromInstance: 10, + ValidityTerm: 15, + } + addExample(f3Lease) + addExample(&f3Lease) } func ExampleValue(method string, t, parent reflect.Type) interface{} { diff --git a/venus-shared/api/chain/v1/method.md b/venus-shared/api/chain/v1/method.md index d06dca4485..13890b6715 100644 --- a/venus-shared/api/chain/v1/method.md +++ b/venus-shared/api/chain/v1/method.md @@ -3859,9 +3859,9 @@ Response: { "Network": "filecoin", "Issuer": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "MinerID": 42, - "FromInstance": 42, - "ValidityTerm": 42 + "MinerID": 1234, + "FromInstance": 10, + "ValidityTerm": 15 } ``` diff --git a/venus-shared/types/api_types.go b/venus-shared/types/api_types.go index b4dbe9d0db..5941584ecb 100644 --- a/venus-shared/types/api_types.go +++ b/venus-shared/types/api_types.go @@ -513,8 +513,8 @@ type F3ParticipationTicket []byte type F3ParticipationLease struct { // Network is the name of the network this lease belongs to. Network gpbft.NetworkName - // Issuer is the identity of the node that issued the lease. - Issuer peer.ID + // Issuer is the identity of the node that issued the lease, encoded as base58. + Issuer string // MinerID is the actor ID of the miner that holds the lease. MinerID uint64 // FromInstance specifies the instance ID from which this lease is valid. diff --git a/venus-shared/types/cbor_gen.go b/venus-shared/types/cbor_gen.go index 8dcf56b3a6..24fcbc621f 100644 --- a/venus-shared/types/cbor_gen.go +++ b/venus-shared/types/cbor_gen.go @@ -15,7 +15,6 @@ import ( exitcode "github.com/filecoin-project/go-state-types/exitcode" proof "github.com/filecoin-project/go-state-types/proof" cid "github.com/ipfs/go-cid" - peer "github.com/libp2p/go-libp2p/core/peer" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" time "time" @@ -2493,7 +2492,7 @@ func (t *F3ParticipationLease) MarshalCBOR(w io.Writer) error { return err } - // t.Issuer (peer.ID) (string) + // t.Issuer (string) (string) if len(t.Issuer) > 8192 { return xerrors.Errorf("Value in field t.Issuer was too long") } @@ -2559,7 +2558,7 @@ func (t *F3ParticipationLease) UnmarshalCBOR(r io.Reader) (err error) { t.Network = gpbft.NetworkName(sval) } - // t.Issuer (peer.ID) (string) + // t.Issuer (string) (string) { sval, err := cbg.ReadStringWithMax(cr, 8192) @@ -2567,7 +2566,7 @@ func (t *F3ParticipationLease) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.Issuer = peer.ID(sval) + t.Issuer = string(sval) } // t.MinerID (uint64) (uint64) From f6fbd53daee2203d34382eb3afb9afd53162f228 Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:39:49 +0800 Subject: [PATCH 3/7] chore: fix lint --- app/submodule/f3/f3_api.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/submodule/f3/f3_api.go b/app/submodule/f3/f3_api.go index f433379ae0..38f2c5daa7 100644 --- a/app/submodule/f3/f3_api.go +++ b/app/submodule/f3/f3_api.go @@ -89,3 +89,10 @@ func (f3api *f3API) F3GetProgress(context.Context) (gpbft.Instant, error) { } return f3api.f3module.F3.Progress(), nil } + +func (f3api *f3API) F3ListParticipants(ctx context.Context) ([]types.F3Participant, error) { + if f3api.f3module.F3 == nil { + return nil, types.ErrF3Disabled + } + return f3api.f3module.F3.ListParticipants(), nil +} From e81986517f121d1e6ccf78a1d1d076f0ed0d6cde Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:20:10 +0800 Subject: [PATCH 4/7] chore: set calibnet F3InitialPowerTableCID --- fixtures/networks/butterfly.go | 1 - fixtures/networks/calibration.go | 3 +-- fixtures/networks/forcenet.go | 1 - fixtures/networks/integrationtestnet.go | 1 - fixtures/networks/interopnet.go | 1 - fixtures/networks/mainnet.go | 1 - fixtures/networks/net_2k.go | 1 - pkg/config/config.go | 3 --- pkg/vf3/config.go | 2 +- 9 files changed, 2 insertions(+), 12 deletions(-) diff --git a/fixtures/networks/butterfly.go b/fixtures/networks/butterfly.go index 7b69591e1f..33495955ce 100644 --- a/fixtures/networks/butterfly.go +++ b/fixtures/networks/butterfly.go @@ -75,7 +75,6 @@ func ButterflySnapNet() *NetworkConf { F3Enabled: true, F3BootstrapEpoch: 1000, ManifestServerID: "12D3KooWJr9jy4ngtJNR7JC1xgLFra3DjEtyxskRYWvBK9TC3Yn6", - F3Consensus: true, F3InitialPowerTableCID: cid.Undef, }, } diff --git a/fixtures/networks/calibration.go b/fixtures/networks/calibration.go index e50cb5e380..988c80afbd 100644 --- a/fixtures/networks/calibration.go +++ b/fixtures/networks/calibration.go @@ -80,8 +80,7 @@ func Calibration() *NetworkConf { AllowableClockDriftSecs: 1, Eip155ChainID: 314159, ActorDebugging: false, - F3Consensus: true, - F3InitialPowerTableCID: cid.Undef, + F3InitialPowerTableCID: cid.MustParse("bafy2bzaceab236vmmb3n4q4tkvua2n4dphcbzzxerxuey3mot4g3cov5j3r2c"), }, } diff --git a/fixtures/networks/forcenet.go b/fixtures/networks/forcenet.go index 1516aa3d4d..0330cc1550 100644 --- a/fixtures/networks/forcenet.go +++ b/fixtures/networks/forcenet.go @@ -77,7 +77,6 @@ func ForceNet() *NetworkConf { F3Enabled: true, F3BootstrapEpoch: 1000, ManifestServerID: "12D3KooWHcNBkqXEBrsjoveQvj6zDF3vK5S9tAfqyYaQF1LGSJwG", - F3Consensus: true, F3InitialPowerTableCID: cid.Undef, }, } diff --git a/fixtures/networks/integrationtestnet.go b/fixtures/networks/integrationtestnet.go index 42fa6f124a..c794540425 100644 --- a/fixtures/networks/integrationtestnet.go +++ b/fixtures/networks/integrationtestnet.go @@ -68,7 +68,6 @@ func IntegrationNet() *NetworkConf { F3Enabled: false, F3BootstrapEpoch: -1, ManifestServerID: "12D3KooWHcNBkqXEBrsjoveQvj6zDF3vK5S9tAfqyYaQF1LGSJwG", - F3Consensus: true, F3InitialPowerTableCID: cid.Undef, }, } diff --git a/fixtures/networks/interopnet.go b/fixtures/networks/interopnet.go index ee5fcbca4d..f1fc6efab4 100644 --- a/fixtures/networks/interopnet.go +++ b/fixtures/networks/interopnet.go @@ -76,7 +76,6 @@ func InteropNet() *NetworkConf { F3Enabled: true, F3BootstrapEpoch: 1000, ManifestServerID: "12D3KooWQJ2rdVnG4okDUB6yHQhAjNutGNemcM7XzqC9Eo4z9Jce", - F3Consensus: true, F3InitialPowerTableCID: cid.Undef, }, } diff --git a/fixtures/networks/mainnet.go b/fixtures/networks/mainnet.go index f8b5c95473..81f90de36a 100644 --- a/fixtures/networks/mainnet.go +++ b/fixtures/networks/mainnet.go @@ -80,7 +80,6 @@ func Mainnet() *NetworkConf { F3Enabled: true, F3BootstrapEpoch: -1, ManifestServerID: "12D3KooWENMwUF9YxvQxar7uBWJtZkA6amvK4xWmKXfSiHUo2Qq7", - F3Consensus: false, F3InitialPowerTableCID: cid.Undef, }, } diff --git a/fixtures/networks/net_2k.go b/fixtures/networks/net_2k.go index fd1846a7b5..11573296ea 100644 --- a/fixtures/networks/net_2k.go +++ b/fixtures/networks/net_2k.go @@ -71,7 +71,6 @@ func Net2k() *NetworkConf { F3Enabled: true, F3BootstrapEpoch: 1000, ManifestServerID: "12D3KooWHcNBkqXEBrsjoveQvj6zDF3vK5S9tAfqyYaQF1LGSJwG", - F3Consensus: true, F3InitialPowerTableCID: cid.Undef, }, } diff --git a/pkg/config/config.go b/pkg/config/config.go index 9d3a97a665..b27830c925 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -311,9 +311,6 @@ type NetworkParamsConfig struct { F3Enabled bool `json:"f3Enabled"` F3BootstrapEpoch abi.ChainEpoch `json:"f3BootstrapEpoch"` ManifestServerID string `json:"manifestServerID"` - // F3Consensus set whether F3 should checkpoint tipsets finalized by F3. This - // flag has no effect if F3 is not enabled. - F3Consensus bool `json:"f3Consensus"` // The initial F3 power table CID. F3InitialPowerTableCID cid.Cid `json:"f3InitialPowerTableCID"` } diff --git a/pkg/vf3/config.go b/pkg/vf3/config.go index d1d61f250e..84bae8fbd0 100644 --- a/pkg/vf3/config.go +++ b/pkg/vf3/config.go @@ -55,7 +55,7 @@ func NewManifest( Finality: int64(finality), DelayMultiplier: manifest.DefaultEcConfig.DelayMultiplier, BaseDecisionBackoffTable: manifest.DefaultEcConfig.BaseDecisionBackoffTable, - HeadLookback: 0, + HeadLookback: 4, Finalize: true, }, CertificateExchange: manifest.CxConfig{ From 2a24ca1104bdc08122d0e32f35a0fb25263db719 Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Fri, 1 Nov 2024 10:02:11 +0800 Subject: [PATCH 5/7] feat(chain): rework checkpoint logic to better handle finality --- app/submodule/syncer/syncer_api.go | 1 - pkg/chain/store.go | 74 ++++++++++++++++++++---------- 2 files changed, 51 insertions(+), 24 deletions(-) diff --git a/app/submodule/syncer/syncer_api.go b/app/submodule/syncer/syncer_api.go index 0d66627b94..0c6d6f6883 100644 --- a/app/submodule/syncer/syncer_api.go +++ b/app/submodule/syncer/syncer_api.go @@ -216,6 +216,5 @@ func (sa *syncerAPI) SyncIncomingBlocks(ctx context.Context) (<-chan *types.Bloc } func (sa *syncerAPI) SyncCheckpoint(ctx context.Context, tsk types.TipSetKey) error { - log.Warnf("Marking tipset %s as checkpoint", tsk) return sa.syncer.SyncProvider.SyncCheckpoint(ctx, tsk) } diff --git a/pkg/chain/store.go b/pkg/chain/store.go index 514c325437..55620b1f4d 100644 --- a/pkg/chain/store.go +++ b/pkg/chain/store.go @@ -321,6 +321,10 @@ func (store *Store) GetTipSet(ctx context.Context, key types.TipSetKey) (*types. return store.GetHead(), nil } + return store.getTipSet(ctx, key) +} + +func (store *Store) getTipSet(ctx context.Context, key types.TipSetKey) (*types.TipSet, error) { if val, has := store.tsCache.Get(key); has { return val, nil } @@ -1099,9 +1103,7 @@ func (store *Store) Import(ctx context.Context, r io.Reader) (*types.TipSet, *ty // SetCheckpoint will set a checkpoint past which the chainstore will not allow forks. If the new // checkpoint is not an ancestor of the current head, head will be set to the new checkpoint. // -// NOTE: Checkpoints cannot be set beyond ForkLengthThreshold epochs in the past, but can be set -// arbitrarily far into the future. -// NOTE: The new checkpoint must already be synced. +// NOTE: Checkpoints cannot revert more than policy.Finality epochs. func (store *Store) SetCheckpoint(ctx context.Context, ts *types.TipSet) error { log.Infof("SetCheckPoint at %d: %v", ts.Height(), ts.Key()) buf := new(bytes.Buffer) @@ -1113,26 +1115,57 @@ func (store *Store) SetCheckpoint(ctx context.Context, ts *types.TipSet) error { store.mu.RLock() defer store.mu.RUnlock() - // Otherwise, this operation could get _very_ expensive. - if store.head.Height()-ts.Height() > policy.ChainFinality { - return fmt.Errorf("cannot set a checkpoint before the fork threshold") + finality := store.head.Height() - policy.ChainFinality + targetChain, currentChain := ts, store.head + + // First attempt to skip backwards to a common height using the chain index. + if targetChain.Height() > currentChain.Height() { + targetChain, err = store.GetTipSetByHeight(ctx, targetChain, currentChain.Height(), true) + } else if targetChain.Height() < currentChain.Height() { + currentChain, err = store.GetTipSetByHeight(ctx, currentChain, targetChain.Height(), true) + } + if err != nil { + return fmt.Errorf("checkpoint failed: error when finding the fork point: %w", err) } - if !ts.Equals(store.head) { - anc, err := store.IsAncestorOf(ctx, ts, store.head) - if err != nil { - return fmt.Errorf("cannot determine whether checkpoint tipset is in main-chain: %w", err) + // Then walk backwards until either we find a common block (the fork height) or we reach + // finality. If the tipsets are _equal_ on the first pass through this loop, it means one + // chain is a prefix of the other chain because we've only walked back on one chain so far. + // In that case, we _don't_ check finality because we're not forking. + for !currentChain.Equals(targetChain) && currentChain.Height() > finality { + if currentChain.Height() >= targetChain.Height() { + currentChain, err = store.getTipSet(ctx, currentChain.Parents()) + if err != nil { + return fmt.Errorf("checkpoint failed: error when walking the current chain: %w", err) + } } - if !anc { - if err := store.setHead(ctx, ts); err != nil { - return fmt.Errorf("failed to switch chains when setting checkpoint: %w", err) + if targetChain.Height() > currentChain.Height() { + targetChain, err = store.getTipSet(ctx, targetChain.Parents()) + if err != nil { + return fmt.Errorf("checkpoint failed: error when walking the target chain: %w", err) } } } + // If we haven't found a common tipset by this point, we can't switch chains. + if !currentChain.Equals(targetChain) { + return fmt.Errorf("checkpoint failed: failed to find the fork point from %s (head) to %s (target) within finality", + store.head.Key(), + ts.Key(), + ) + } + + // If the target tipset isn't an ancestor of our current chain, we need to switch chains. + if !currentChain.Equals(ts) { + if err := store.setHead(ctx, ts); err != nil { + return fmt.Errorf("failed to switch chains when setting checkpoint: %w", err) + } + } + + // Finally, set the checkpoint. if err := store.ds.Put(ctx, CheckPoint, buf.Bytes()); err != nil { - return err + return fmt.Errorf("checkpoint failed: failed to record checkpoint in the datastore: %w", err) } store.checkPoint = ts.Key() @@ -1145,17 +1178,12 @@ func (store *Store) IsAncestorOf(ctx context.Context, a, b *types.TipSet) (bool, return false, nil } - cur := b - for !a.Equals(cur) && cur.Height() > a.Height() { - next, err := store.GetTipSet(ctx, cur.Parents()) - if err != nil { - return false, err - } - - cur = next + target, err := store.GetTipSetByHeight(ctx, b, a.Height(), false) + if err != nil { + return false, err } - return cur.Equals(a), nil + return target.Equals(a), nil } // GetCheckPoint get the check point from store or disk. From f7cff68c5698bc20d8fd0d3f3950924023e954aa Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Fri, 1 Nov 2024 10:44:23 +0800 Subject: [PATCH 6/7] chore: fix lint --- pkg/chainsync/syncer/syncer_integration_test.go | 1 + venus-shared/compatible-checks/api-diff.txt | 2 ++ venus-shared/compatible-checks/api-perm.txt | 1 + 3 files changed, 4 insertions(+) diff --git a/pkg/chainsync/syncer/syncer_integration_test.go b/pkg/chainsync/syncer/syncer_integration_test.go index 85e02b4280..c32a4c7bfb 100644 --- a/pkg/chainsync/syncer/syncer_integration_test.go +++ b/pkg/chainsync/syncer/syncer_integration_test.go @@ -91,6 +91,7 @@ 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(), chainselector.Weight) + require.NoError(t, newStore.SetHead(ctx, genesis)) require.NoError(t, newStore.SetCheckpoint(ctx, genesis)) require.NoError(t, newStore.Load(ctx)) _, err = syncer.NewSyncer(stmgr, diff --git a/venus-shared/compatible-checks/api-diff.txt b/venus-shared/compatible-checks/api-diff.txt index c9803f0ff0..a7a3c14816 100644 --- a/venus-shared/compatible-checks/api-diff.txt +++ b/venus-shared/compatible-checks/api-diff.txt @@ -106,6 +106,8 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.c - Discover - EthSendRawTransactionUntrusted > 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 name: #4 field, VMTrace != VmTrace; nested=nil}}}}} + + F3ListParticipants + > F3Participate {[func(context.Context, types.F3ParticipationTicket) (types.F3ParticipationLease, error) <> func(context.Context, api.F3ParticipationTicket) (api.F3ParticipationLease, error)] base=func out type: #0 input; nested={[types.F3ParticipationLease <> api.F3ParticipationLease] base=struct field; nested={[types.F3ParticipationLease <> api.F3ParticipationLease] base=exported field type: #1 field named Issuer; nested={[string <> peer.ID] base=codec marshaler implementations for codec JSON: false != true; nested=nil}}}} > FilecoinAddressToEthAddress {[func(context.Context, address.Address) (types.EthAddress, error) <> func(context.Context, jsonrpc.RawParams) (ethtypes.EthAddress, error)] base=func in type: #1 input; nested={[address.Address <> jsonrpc.RawParams] base=type kinds: struct != slice; 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 field name: #1 field, GasOverEstimation != MsgUuid; nested=nil}}}} diff --git a/venus-shared/compatible-checks/api-perm.txt b/venus-shared/compatible-checks/api-perm.txt index 9c3dc6ae5b..9aaf5afb78 100644 --- a/venus-shared/compatible-checks/api-perm.txt +++ b/venus-shared/compatible-checks/api-perm.txt @@ -68,6 +68,7 @@ v1: github.com/filecoin-project/venus/venus-shared/api/chain/v1 <> github.com/fi - IMinerState.StateMinerSectorSize - IMinerState.StateMinerWorkerAddress - EthSubscriber.EthSubscription + - IF3.F3ListParticipants - IMessagePool.GasBatchEstimateMessageGas - IMessagePool.MpoolDeleteByAdress - IMessagePool.MpoolPublishByAddr From 70c210a1832729f836c16e1fd50880f7fa59ef57 Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Mon, 4 Nov 2024 10:08:40 +0800 Subject: [PATCH 7/7] chore: make compatible-all --- app/submodule/eth/dummy.go | 4 ++-- app/submodule/eth/eth_api.go | 18 ++++-------------- venus-devtool/go.mod | 4 ++-- venus-devtool/go.sum | 8 ++++---- venus-shared/api/chain/v1/eth.go | 2 +- .../api/chain/v1/mock/mock_fullnode.go | 4 ++-- venus-shared/api/chain/v1/proxy_gen.go | 4 ++-- .../compatible-checks/api-checksum.txt | 3 ++- venus-shared/compatible-checks/api-diff.txt | 2 -- venus-shared/compatible-checks/api-perm.txt | 1 - venus-shared/types/api_types.go | 14 +++++++------- 11 files changed, 26 insertions(+), 38 deletions(-) diff --git a/app/submodule/eth/dummy.go b/app/submodule/eth/dummy.go index a9b537c550..81a626ed0a 100644 --- a/app/submodule/eth/dummy.go +++ b/app/submodule/eth/dummy.go @@ -53,8 +53,8 @@ func (e *ethAPIDummy) EthGetBlockByHash(ctx context.Context, blkHash types.EthHa return types.EthBlock{}, ErrModuleDisabled } -func (e *ethAPIDummy) EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (*types.EthBlock, error) { - return nil, ErrModuleDisabled +func (e *ethAPIDummy) EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (types.EthBlock, error) { + return types.EthBlock{}, ErrModuleDisabled } func (e *ethAPIDummy) EthGetTransactionByHash(ctx context.Context, txHash *types.EthHash) (*types.EthTx, error) { diff --git a/app/submodule/eth/eth_api.go b/app/submodule/eth/eth_api.go index 4fbe107fb3..d5d89ff144 100644 --- a/app/submodule/eth/eth_api.go +++ b/app/submodule/eth/eth_api.go @@ -273,23 +273,13 @@ func (a *ethAPI) parseBlkParam(ctx context.Context, blkParam string, strict bool } } -func (a *ethAPI) EthGetBlockByNumber(ctx context.Context, blkParam string, fullTxInfo bool) (*types.EthBlock, error) { - // Get the tipset for the specified block parameter - ts, err := a.parseBlkParam(ctx, blkParam, true) +func (a *ethAPI) EthGetBlockByNumber(ctx context.Context, blkParam string, fullTxInfo bool) (types.EthBlock, error) { + ts, err := getTipsetByBlockNumber(ctx, a.em.chainModule.ChainReader, blkParam, true) if err != nil { - if err == ErrNullRound { - // Return nil for null rounds - return nil, nil - } - return nil, fmt.Errorf("failed to get tipset: %w", err) - } - // Create an Ethereum block from the Filecoin tipset - block, err := newEthBlockFromFilecoinTipSet(ctx, ts, fullTxInfo, a.em.chainModule.MessageStore, a.em.chainModule.Stmgr) - if err != nil { - return nil, fmt.Errorf("failed to create Ethereum block: %w", err) + return types.EthBlock{}, err } - return &block, nil + return newEthBlockFromFilecoinTipSet(ctx, ts, fullTxInfo, a.em.chainModule.MessageStore, a.em.chainModule.Stmgr) } func (a *ethAPI) EthGetTransactionByHash(ctx context.Context, txHash *types.EthHash) (*types.EthTx, error) { diff --git a/venus-devtool/go.mod b/venus-devtool/go.mod index ce5240254a..d716734a0a 100644 --- a/venus-devtool/go.mod +++ b/venus-devtool/go.mod @@ -8,11 +8,11 @@ require ( github.com/filecoin-project/go-address v1.2.0 github.com/filecoin-project/go-bitfield v0.2.4 github.com/filecoin-project/go-data-transfer/v2 v2.0.0-rc7 - github.com/filecoin-project/go-f3 v0.7.0 + github.com/filecoin-project/go-f3 v0.7.1 github.com/filecoin-project/go-fil-markets v1.28.3 github.com/filecoin-project/go-jsonrpc v0.6.0 github.com/filecoin-project/go-state-types v0.15.0-rc1 - github.com/filecoin-project/lotus v1.30.0-rc2 + github.com/filecoin-project/lotus v1.30.0-rc3 github.com/filecoin-project/venus v0.0.0-00010101000000-000000000000 github.com/google/uuid v1.6.0 github.com/ipfs/go-block-format v0.2.0 diff --git a/venus-devtool/go.sum b/venus-devtool/go.sum index b82a5ef687..7950fdd4cc 100644 --- a/venus-devtool/go.sum +++ b/venus-devtool/go.sum @@ -250,8 +250,8 @@ github.com/filecoin-project/go-data-transfer/v2 v2.0.0-rc7 h1:v+zJS5B6pA3ptWZS4t github.com/filecoin-project/go-data-transfer/v2 v2.0.0-rc7/go.mod h1:V3Y4KbttaCwyg1gwkP7iai8CbQx4mZUGjd3h9GZWLKE= github.com/filecoin-project/go-ds-versioning v0.1.2 h1:to4pTadv3IeV1wvgbCbN6Vqd+fu+7tveXgv/rCEZy6w= github.com/filecoin-project/go-ds-versioning v0.1.2/go.mod h1:C9/l9PnB1+mwPa26BBVpCjG/XQCB0yj/q5CK2J8X1I4= -github.com/filecoin-project/go-f3 v0.7.0 h1:JNo39SAELT5hEn+rmQZbSJQBJfmGJtp70RfyWJrIayY= -github.com/filecoin-project/go-f3 v0.7.0/go.mod h1:QoxuoK4aktNZD1R/unlhNbhV6TnlNTAbA/QODCnAjak= +github.com/filecoin-project/go-f3 v0.7.1 h1:3xCxKgVtlQVTZooeUWIL1isk5MK/BGcdrhZlR0ZbIIU= +github.com/filecoin-project/go-f3 v0.7.1/go.mod h1:QoxuoK4aktNZD1R/unlhNbhV6TnlNTAbA/QODCnAjak= github.com/filecoin-project/go-fil-commcid v0.2.0 h1:B+5UX8XGgdg/XsdUpST4pEBviKkFOw+Fvl2bLhSKGpI= github.com/filecoin-project/go-fil-commcid v0.2.0/go.mod h1:8yigf3JDIil+/WpqR5zoKyP0jBPCOGtEqq/K1CcMy9Q= github.com/filecoin-project/go-fil-commp-hashhash v0.2.0 h1:HYIUugzjq78YvV3vC6rL95+SfC/aSTVSnZSZiDV5pCk= @@ -284,8 +284,8 @@ github.com/filecoin-project/go-statemachine v1.0.3/go.mod h1:jZdXXiHa61n4NmgWFG4 github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI= github.com/filecoin-project/go-statestore v0.2.0 h1:cRRO0aPLrxKQCZ2UOQbzFGn4WDNdofHZoGPjfNaAo5Q= github.com/filecoin-project/go-statestore v0.2.0/go.mod h1:8sjBYbS35HwPzct7iT4lIXjLlYyPor80aU7t7a/Kspo= -github.com/filecoin-project/lotus v1.30.0-rc2 h1:LLzMnb6dqxN5QHj4IAvDpFPYp8InXY8fvcTGr4uhpnw= -github.com/filecoin-project/lotus v1.30.0-rc2/go.mod h1:gXQFTK6OpJIjg2yWnYsf0awszREDffb/X+LPCDmZkwI= +github.com/filecoin-project/lotus v1.30.0-rc3 h1:pRMWd2TMWJbpWfj4jF4lbrnb7LD8+dcUonR0C0bLRw0= +github.com/filecoin-project/lotus v1.30.0-rc3/go.mod h1:A48LDh6u4h60SpcUQHgzKS66qA35hJNHut6uDvTO6ew= 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= diff --git a/venus-shared/api/chain/v1/eth.go b/venus-shared/api/chain/v1/eth.go index 4ffd177113..a5c0693a3e 100644 --- a/venus-shared/api/chain/v1/eth.go +++ b/venus-shared/api/chain/v1/eth.go @@ -32,7 +32,7 @@ type IETH interface { EthGetBlockTransactionCountByHash(ctx context.Context, blkHash types.EthHash) (types.EthUint64, error) //perm:read EthGetBlockByHash(ctx context.Context, blkHash types.EthHash, fullTxInfo bool) (types.EthBlock, error) //perm:read - EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (*types.EthBlock, error) //perm:read + EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (types.EthBlock, error) //perm:read EthGetTransactionByHash(ctx context.Context, txHash *types.EthHash) (*types.EthTx, error) //perm:read EthGetTransactionByHashLimited(ctx context.Context, txHash *types.EthHash, limit abi.ChainEpoch) (*types.EthTx, error) //perm:read EthGetTransactionHashByCid(ctx context.Context, cid cid.Cid) (*types.EthHash, error) //perm:read diff --git a/venus-shared/api/chain/v1/mock/mock_fullnode.go b/venus-shared/api/chain/v1/mock/mock_fullnode.go index ba26845c47..32cdd84e26 100644 --- a/venus-shared/api/chain/v1/mock/mock_fullnode.go +++ b/venus-shared/api/chain/v1/mock/mock_fullnode.go @@ -610,10 +610,10 @@ func (mr *MockFullNodeMockRecorder) EthGetBlockByHash(arg0, arg1, arg2 interface } // EthGetBlockByNumber mocks base method. -func (m *MockFullNode) EthGetBlockByNumber(arg0 context.Context, arg1 string, arg2 bool) (*types.EthBlock, error) { +func (m *MockFullNode) EthGetBlockByNumber(arg0 context.Context, arg1 string, arg2 bool) (types.EthBlock, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "EthGetBlockByNumber", arg0, arg1, arg2) - ret0, _ := ret[0].(*types.EthBlock) + ret0, _ := ret[0].(types.EthBlock) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/venus-shared/api/chain/v1/proxy_gen.go b/venus-shared/api/chain/v1/proxy_gen.go index 59e7288dba..a8787434df 100644 --- a/venus-shared/api/chain/v1/proxy_gen.go +++ b/venus-shared/api/chain/v1/proxy_gen.go @@ -884,7 +884,7 @@ type IETHStruct struct { 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"` EthGetBlockByHash func(ctx context.Context, blkHash types.EthHash, fullTxInfo bool) (types.EthBlock, error) `perm:"read"` - EthGetBlockByNumber func(ctx context.Context, blkNum string, fullTxInfo bool) (*types.EthBlock, error) `perm:"read"` + EthGetBlockByNumber func(ctx context.Context, blkNum string, fullTxInfo bool) (types.EthBlock, error) `perm:"read"` EthGetBlockReceipts func(ctx context.Context, blkParam types.EthBlockNumberOrHash) ([]*types.EthTxReceipt, error) `perm:"read"` EthGetBlockReceiptsLimited func(ctx context.Context, blkParam types.EthBlockNumberOrHash, limit abi.ChainEpoch) ([]*types.EthTxReceipt, error) `perm:"read"` EthGetBlockTransactionCountByHash func(ctx context.Context, blkHash types.EthHash) (types.EthUint64, error) `perm:"read"` @@ -945,7 +945,7 @@ func (s *IETHStruct) EthGetBalance(p0 context.Context, p1 types.EthAddress, p2 t func (s *IETHStruct) EthGetBlockByHash(p0 context.Context, p1 types.EthHash, p2 bool) (types.EthBlock, error) { return s.Internal.EthGetBlockByHash(p0, p1, p2) } -func (s *IETHStruct) EthGetBlockByNumber(p0 context.Context, p1 string, p2 bool) (*types.EthBlock, error) { +func (s *IETHStruct) EthGetBlockByNumber(p0 context.Context, p1 string, p2 bool) (types.EthBlock, error) { return s.Internal.EthGetBlockByNumber(p0, p1, p2) } func (s *IETHStruct) EthGetBlockReceipts(p0 context.Context, p1 types.EthBlockNumberOrHash) ([]*types.EthTxReceipt, error) { diff --git a/venus-shared/compatible-checks/api-checksum.txt b/venus-shared/compatible-checks/api-checksum.txt index 9e5f1e77ac..b95f352a00 100644 --- a/venus-shared/compatible-checks/api-checksum.txt +++ b/venus-shared/compatible-checks/api-checksum.txt @@ -242,7 +242,7 @@ api.FullNode: EthGasPrice: In=1, Out=2, CheckSum=e2f5588dddfc36a9cdef0fad6f4db93e EthGetBalance: In=3, Out=2, CheckSum=80912669b93ebbd53024dbc6b4f39d94 EthGetBlockByHash: In=3, Out=2, CheckSum=606bca6c962d8e2d4e0b8bb14e8fa0a9 - EthGetBlockByNumber: In=3, Out=2, CheckSum=06d77a6c80b11ea456c9207a10459abe + EthGetBlockByNumber: In=3, Out=2, CheckSum=9d82b96bb03c2de85dc7a31e7d4c45d2 EthGetBlockReceipts: In=2, Out=2, CheckSum=e2817ae4c1a093339a0fd251150de95a EthGetBlockReceiptsLimited: In=3, Out=2, CheckSum=f5992631f35a54511e4a494b84e66b33 EthGetBlockTransactionCountByHash: In=2, Out=2, CheckSum=aea75f99eaccb878b97512a29568c204 @@ -284,6 +284,7 @@ api.FullNode: F3GetOrRenewParticipationTicket: In=4, Out=2, CheckSum=f025742e52bb59e839db5182af1a829a F3GetProgress: In=1, Out=2, CheckSum=47af12f74b39fcca4877ebed425b6558 F3IsRunning: In=1, Out=2, CheckSum=de305c848673f2b095e6cfdecdaf85c3 + F3ListParticipants: In=1, Out=2, CheckSum=9811f07369b67dc95919328bed3b6a62 F3Participate: In=2, Out=2, CheckSum=a09f021cb508b413dddcfae6eb535db4 FilecoinAddressToEthAddress: In=2, Out=2, CheckSum=59affa319c910c555ee5f1d194049f53 GasEstimateFeeCap: In=4, Out=2, CheckSum=0fcac02de1d21c9ac6e10696a6499eba diff --git a/venus-shared/compatible-checks/api-diff.txt b/venus-shared/compatible-checks/api-diff.txt index a7a3c14816..c9803f0ff0 100644 --- a/venus-shared/compatible-checks/api-diff.txt +++ b/venus-shared/compatible-checks/api-diff.txt @@ -106,8 +106,6 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.c - Discover - EthSendRawTransactionUntrusted > 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 name: #4 field, VMTrace != VmTrace; nested=nil}}}}} - + F3ListParticipants - > F3Participate {[func(context.Context, types.F3ParticipationTicket) (types.F3ParticipationLease, error) <> func(context.Context, api.F3ParticipationTicket) (api.F3ParticipationLease, error)] base=func out type: #0 input; nested={[types.F3ParticipationLease <> api.F3ParticipationLease] base=struct field; nested={[types.F3ParticipationLease <> api.F3ParticipationLease] base=exported field type: #1 field named Issuer; nested={[string <> peer.ID] base=codec marshaler implementations for codec JSON: false != true; nested=nil}}}} > FilecoinAddressToEthAddress {[func(context.Context, address.Address) (types.EthAddress, error) <> func(context.Context, jsonrpc.RawParams) (ethtypes.EthAddress, error)] base=func in type: #1 input; nested={[address.Address <> jsonrpc.RawParams] base=type kinds: struct != slice; 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 field name: #1 field, GasOverEstimation != MsgUuid; nested=nil}}}} diff --git a/venus-shared/compatible-checks/api-perm.txt b/venus-shared/compatible-checks/api-perm.txt index 9aaf5afb78..9c3dc6ae5b 100644 --- a/venus-shared/compatible-checks/api-perm.txt +++ b/venus-shared/compatible-checks/api-perm.txt @@ -68,7 +68,6 @@ v1: github.com/filecoin-project/venus/venus-shared/api/chain/v1 <> github.com/fi - IMinerState.StateMinerSectorSize - IMinerState.StateMinerWorkerAddress - EthSubscriber.EthSubscription - - IF3.F3ListParticipants - IMessagePool.GasBatchEstimateMessageGas - IMessagePool.MpoolDeleteByAdress - IMessagePool.MpoolPublishByAddr diff --git a/venus-shared/types/api_types.go b/venus-shared/types/api_types.go index 5941584ecb..36c6e0087a 100644 --- a/venus-shared/types/api_types.go +++ b/venus-shared/types/api_types.go @@ -543,22 +543,22 @@ type F3Participant struct { var ( // ErrF3Disabled signals that F3 consensus process is disabled. - ErrF3Disabled = errF3Disabled{} + ErrF3Disabled = &errF3Disabled{} // ErrF3ParticipationTicketInvalid signals that F3ParticipationTicket cannot be decoded. - ErrF3ParticipationTicketInvalid = errF3ParticipationTicketInvalid{} + ErrF3ParticipationTicketInvalid = &errF3ParticipationTicketInvalid{} // ErrF3ParticipationTicketExpired signals that the current GPBFT instance as surpassed the expiry of the ticket. - ErrF3ParticipationTicketExpired = errF3ParticipationTicketExpired{} + ErrF3ParticipationTicketExpired = &errF3ParticipationTicketExpired{} // ErrF3ParticipationIssuerMismatch signals that the ticket is not issued by the current node. - ErrF3ParticipationIssuerMismatch = errF3ParticipationIssuerMismatch{} + ErrF3ParticipationIssuerMismatch = &errF3ParticipationIssuerMismatch{} // ErrF3ParticipationTooManyInstances signals that participation ticket cannot be // issued because it asks for too many instances. - ErrF3ParticipationTooManyInstances = errF3ParticipationTooManyInstances{} + ErrF3ParticipationTooManyInstances = &errF3ParticipationTooManyInstances{} // ErrF3ParticipationTicketStartBeforeExisting signals that participation ticket // is before the start instance of an existing lease held by the miner. - ErrF3ParticipationTicketStartBeforeExisting = errF3ParticipationTicketStartBeforeExisting{} + ErrF3ParticipationTicketStartBeforeExisting = &errF3ParticipationTicketStartBeforeExisting{} // ErrF3NotReady signals that the F3 instance isn't ready for participation yet. The caller // should back off and try again later. - ErrF3NotReady = errF3NotReady{} + ErrF3NotReady = &errF3NotReady{} _ error = (*ErrOutOfGas)(nil) // _ error = (*ErrActorNotFound)(nil)