diff --git a/.circleci/config.yml b/.circleci/config.yml index 5fcb83145..960e47e33 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,12 +7,12 @@ executors: golang: docker: # Must match GO_VERSION_MIN in project root - - image: cimg/go:1.19.7 + - image: cimg/go:1.19.12 resource_class: medium+ golang-2xl: docker: # Must match GO_VERSION_MIN in project root - - image: cimg/go:1.19.7 + - image: cimg/go:1.19.12 resource_class: 2xlarge ubuntu: docker: @@ -545,12 +545,6 @@ workflows: - build suite: itest-batch_deal target: "./itests/batch_deal_test.go" - - test: - name: test-itest-ccupgrade - requires: - - build - suite: itest-ccupgrade - target: "./itests/ccupgrade_test.go" - test: name: test-itest-cli requires: @@ -876,12 +870,6 @@ workflows: - build suite: itest-remove_verifreg_datacap target: "./itests/remove_verifreg_datacap_test.go" - - test: - name: test-itest-sdr_upgrade - requires: - - build - suite: itest-sdr_upgrade - target: "./itests/sdr_upgrade_test.go" - test: name: test-itest-sealing_resources requires: @@ -906,12 +894,6 @@ workflows: - build suite: itest-sector_import_simple target: "./itests/sector_import_simple_test.go" - - test: - name: test-itest-sector_make_cc_avail - requires: - - build - suite: itest-sector_make_cc_avail - target: "./itests/sector_make_cc_avail_test.go" - test: name: test-itest-sector_miner_collateral requires: @@ -930,18 +912,6 @@ workflows: - build suite: itest-sector_pledge target: "./itests/sector_pledge_test.go" - - test: - name: test-itest-sector_prefer_no_upgrade - requires: - - build - suite: itest-sector_prefer_no_upgrade - target: "./itests/sector_prefer_no_upgrade_test.go" - - test: - name: test-itest-sector_revert_available - requires: - - build - suite: itest-sector_revert_available - target: "./itests/sector_revert_available_test.go" - test: name: test-itest-sector_terminate requires: @@ -966,12 +936,6 @@ workflows: - build suite: itest-splitstore target: "./itests/splitstore_test.go" - - test: - name: test-itest-tape - requires: - - build - suite: itest-tape - target: "./itests/tape_test.go" - test: name: test-itest-verifreg requires: diff --git a/.circleci/template.yml b/.circleci/template.yml index cd8aeb663..33f62ee3a 100644 --- a/.circleci/template.yml +++ b/.circleci/template.yml @@ -7,12 +7,12 @@ executors: golang: docker: # Must match GO_VERSION_MIN in project root - - image: cimg/go:1.19.7 + - image: cimg/go:1.19.12 resource_class: medium+ golang-2xl: docker: # Must match GO_VERSION_MIN in project root - - image: cimg/go:1.19.7 + - image: cimg/go:1.19.12 resource_class: 2xlarge ubuntu: docker: diff --git a/.golangci.yml b/.golangci.yml index fe663ef7b..a4cca9bab 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -12,7 +12,6 @@ linters: - unconvert - staticcheck - varcheck - - structcheck - deadcode - scopelint diff --git a/CHANGELOG.md b/CHANGELOG.md index 956e5b0d2..5045d8773 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,23 +2,27 @@ # UNRELEASED -# v1.23.3-rc2 / 2023-07-11 +# v1.23.3 / 2023-08-01 -This is the second release candidate for the upcoming feature release v1.23.3 of Lotus. This feature release includes numerous improvements and enhancements for node operators, ETH RPC-providers and storage providers. +This feature release of Lotus includes numerous improvements and enhancements for node operators, ETH RPC-providers and storage providers. + +This feature release requires a **minimum Go version of v1.19.12 or higher to successfully build Lotus**. Go version 1.20 is also supported, but 1.21 is NOT. ## Highlights +- [Lotus now includes a Slasher tool](https://github.com/filecoin-project/lotus/pull/10928) to monitor the network for Consensus Faults, and report them as appropriate + - The Slasher investigates all incoming blocks, and assesses whether they trigger any of the three Consensus Faults defined in the Filecoin protocol + - If any faults are detected, the Slasher sends a `ReportConsensusFault` message to the faulty miner + - For more information on the Slasher, including how to run it, please find the documentation [here](https://lotus.filecoin.io/lotus/manage/slasher-and-disputer/) - The Ethereum-like RPC exposed by Lotus is now compatible with EIP-1898: https://github.com/filecoin-project/lotus/pull/10815 - The lotus-miner PieceReader now supports parallel reads: https://github.com/filecoin-project/lotus/pull/10913 - Added new environment variable `LOTUS_EXEC_TRACE_CACHE_SIZE` to configure execution trace cache size ([filecoin-project/lotus#10585](https://github.com/filecoin-project/lotus/pull/10585)) - - If unset, we default to caching 16 most recent execution traces. Storage Providers may want to set this to 0, while exchanges may want to crank it up. + - If unset, we default to caching 16 most recent execution traces. Storage Providers may want to set this to 0, while exchanges may want to crank it up. ## New features - - Implement a tooling for slasher ([filecoin-project/lotus#10928](https://github.com/filecoin-project/lotus/pull/10928)) - feat: miner cli: sectors list upgrade-bounds tool ([filecoin-project/lotus#10923](https://github.com/filecoin-project/lotus/pull/10923)) - Add new RPC stress testing tool (lotus-bench rpc) with rich reporting ([filecoin-project/lotus#10761](https://github.com/filecoin-project/lotus/pull/10761)) - feat: alert: Add FVM_CONCURRENCY alert ([filecoin-project/lotus#10933](https://github.com/filecoin-project/lotus/pull/10933)) - - feat: tracer: upgrade elastic search transport for pubsub traces ([filecoin-project/lotus#10405](https://github.com/filecoin-project/lotus/pull/10405)) - feat: Add eth_syncing RPC method ([filecoin-project/lotus#10719](https://github.com/filecoin-project/lotus/pull/10719)) - feat: sealing: flag to run data_cid untied from addpiece ([filecoin-project/lotus#10797](https://github.com/filecoin-project/lotus/pull/10797)) - feat: Lotus Gateway: add MpoolPending, ChainGetBlock and MinerGetBaseInfo ([filecoin-project/lotus#10929](https://github.com/filecoin-project/lotus/pull/10929)) diff --git a/Dockerfile b/Dockerfile index dfdfedce3..99625eea1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ ##################################### -FROM golang:1.19.7-buster AS lotus-builder +FROM golang:1.19.12-bullseye AS lotus-builder MAINTAINER Lotus Development Team RUN apt-get update && apt-get install -y ca-certificates build-essential clang ocl-icd-opencl-dev ocl-icd-libopencl1 jq libhwloc-dev @@ -58,7 +58,7 @@ COPY --from=lotus-builder /lib/*/libgcc_s.so.1 /lib/ COPY --from=lotus-builder /lib/*/libutil.so.1 /lib/ COPY --from=lotus-builder /usr/lib/*/libltdl.so.7 /lib/ COPY --from=lotus-builder /usr/lib/*/libnuma.so.1 /lib/ -COPY --from=lotus-builder /usr/lib/*/libhwloc.so.5 /lib/ +COPY --from=lotus-builder /usr/lib/*/libhwloc.so.* /lib/ COPY --from=lotus-builder /usr/lib/*/libOpenCL.so.1 /lib/ RUN useradd -r -u 532 -U fc \ diff --git a/GO_VERSION_MIN b/GO_VERSION_MIN index 98adfe8e1..e54f3135a 100644 --- a/GO_VERSION_MIN +++ b/GO_VERSION_MIN @@ -1 +1 @@ -1.19.7 +1.19.12 diff --git a/README.md b/README.md index b67cb952f..f6ac75932 100644 --- a/README.md +++ b/README.md @@ -71,10 +71,10 @@ For other distributions you can find the required dependencies [here.](https://l #### Go -To build Lotus, you need a working installation of [Go 1.19.7 or higher](https://golang.org/dl/): +To build Lotus, you need a working installation of [Go 1.19.12 or higher](https://golang.org/dl/): ```bash -wget -c https://golang.org/dl/go1.19.7.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local +wget -c https://golang.org/dl/go1.19.12.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local ``` **TIP:** diff --git a/api/api_full.go b/api/api_full.go index 591799b48..e5f88936a 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -21,7 +21,6 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/go-state-types/builtin/v9/market" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" @@ -29,7 +28,7 @@ import ( apitypes "github.com/filecoin-project/lotus/api/types" "github.com/filecoin-project/lotus/chain/actors/builtin" - lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/builtin/power" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types/ethtypes" @@ -499,9 +498,9 @@ type FullNode interface { // expiration epoch StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) //perm:read // StateSectorExpiration returns epoch at which given sector will expire - StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*lminer.SectorExpiration, error) //perm:read + StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorExpiration, error) //perm:read // StateSectorPartition finds deadline/partition with the specified sector - StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*lminer.SectorLocation, error) //perm:read + StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error) //perm:read // StateSearchMsg looks back up to limit epochs in the chain for a message, and returns its receipt and the tipset where it was executed // // NOTE: If a replacing message is found on chain, this method will return @@ -641,6 +640,11 @@ type FullNode interface { // StateGetRandomnessFromBeacon is used to sample the beacon for randomness. StateGetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error) //perm:read + // StateGetRandomnessDigestFromTickets. is used to sample the chain for randomness. + StateGetRandomnessDigestFromTickets(ctx context.Context, randEpoch abi.ChainEpoch, tsk types.TipSetKey) (abi.Randomness, error) //perm:read + // StateGetRandomnessDigestFromBeacon is used to sample the beacon for randomness. + StateGetRandomnessDigestFromBeacon(ctx context.Context, randEpoch abi.ChainEpoch, tsk types.TipSetKey) (abi.Randomness, error) //perm:read + // StateGetBeaconEntry returns the beacon entry for the given filecoin epoch. If // the entry has not yet been produced, the call will block until the entry // becomes available diff --git a/api/api_gateway.go b/api/api_gateway.go index f6740e1e0..3f7bc21cc 100644 --- a/api/api_gateway.go +++ b/api/api_gateway.go @@ -9,10 +9,10 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-jsonrpc" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/dline" apitypes "github.com/filecoin-project/lotus/api/types" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types/ethtypes" "github.com/filecoin-project/lotus/node/modules/dtypes" diff --git a/api/api_storage.go b/api/api_storage.go index a9e632998..d5b3d5c1d 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -19,10 +19,10 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/builtin/v9/market" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" abinetwork "github.com/filecoin-project/go-state-types/network" builtinactors "github.com/filecoin-project/lotus/chain/actors/builtin" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/storage/pipeline/sealiface" "github.com/filecoin-project/lotus/storage/sealer/fsutil" @@ -461,10 +461,15 @@ type SectorOffset struct { // DealInfo is a tuple of deal identity and its schedule type PieceDealInfo struct { + // "Old" builtin-market deal info PublishCid *cid.Cid DealID abi.DealID DealProposal *market.DealProposal + + // Common deal info DealSchedule DealSchedule + + // Best-effort deal asks KeepUnsealed bool } diff --git a/api/mocks/mock_full.go b/api/mocks/mock_full.go index a1e9c1230..d2f2e528e 100644 --- a/api/mocks/mock_full.go +++ b/api/mocks/mock_full.go @@ -3263,6 +3263,36 @@ func (mr *MockFullNodeMockRecorder) StateGetNetworkParams(arg0 interface{}) *gom return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetNetworkParams", reflect.TypeOf((*MockFullNode)(nil).StateGetNetworkParams), arg0) } +// StateGetRandomnessDigestFromBeacon mocks base method. +func (m *MockFullNode) StateGetRandomnessDigestFromBeacon(arg0 context.Context, arg1 abi.ChainEpoch, arg2 types.TipSetKey) (abi.Randomness, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateGetRandomnessDigestFromBeacon", arg0, arg1, arg2) + ret0, _ := ret[0].(abi.Randomness) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateGetRandomnessDigestFromBeacon indicates an expected call of StateGetRandomnessDigestFromBeacon. +func (mr *MockFullNodeMockRecorder) StateGetRandomnessDigestFromBeacon(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetRandomnessDigestFromBeacon", reflect.TypeOf((*MockFullNode)(nil).StateGetRandomnessDigestFromBeacon), arg0, arg1, arg2) +} + +// StateGetRandomnessDigestFromTickets mocks base method. +func (m *MockFullNode) StateGetRandomnessDigestFromTickets(arg0 context.Context, arg1 abi.ChainEpoch, arg2 types.TipSetKey) (abi.Randomness, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateGetRandomnessDigestFromTickets", arg0, arg1, arg2) + ret0, _ := ret[0].(abi.Randomness) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateGetRandomnessDigestFromTickets indicates an expected call of StateGetRandomnessDigestFromTickets. +func (mr *MockFullNodeMockRecorder) StateGetRandomnessDigestFromTickets(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetRandomnessDigestFromTickets", reflect.TypeOf((*MockFullNode)(nil).StateGetRandomnessDigestFromTickets), arg0, arg1, arg2) +} + // StateGetRandomnessFromBeacon mocks base method. func (m *MockFullNode) StateGetRandomnessFromBeacon(arg0 context.Context, arg1 crypto.DomainSeparationTag, arg2 abi.ChainEpoch, arg3 []byte, arg4 types.TipSetKey) (abi.Randomness, error) { m.ctrl.T.Helper() diff --git a/api/proxy_gen.go b/api/proxy_gen.go index ce4ec3d1e..79bf0a738 100644 --- a/api/proxy_gen.go +++ b/api/proxy_gen.go @@ -26,7 +26,6 @@ import ( "github.com/filecoin-project/go-jsonrpc/auth" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/builtin/v8/paych" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" @@ -35,7 +34,7 @@ import ( apitypes "github.com/filecoin-project/lotus/api/types" builtinactors "github.com/filecoin-project/lotus/chain/actors/builtin" - lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types/ethtypes" "github.com/filecoin-project/lotus/journal/alerting" @@ -494,6 +493,10 @@ type FullNodeMethods struct { StateGetNetworkParams func(p0 context.Context) (*NetworkParams, error) `perm:"read"` + StateGetRandomnessDigestFromBeacon func(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) (abi.Randomness, error) `perm:"read"` + + StateGetRandomnessDigestFromTickets func(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) (abi.Randomness, error) `perm:"read"` + StateGetRandomnessFromBeacon func(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) `perm:"read"` StateGetRandomnessFromTickets func(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) `perm:"read"` @@ -556,11 +559,11 @@ type FullNodeMethods struct { StateSearchMsg func(p0 context.Context, p1 types.TipSetKey, p2 cid.Cid, p3 abi.ChainEpoch, p4 bool) (*MsgLookup, error) `perm:"read"` - StateSectorExpiration func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) `perm:"read"` + StateSectorExpiration func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) `perm:"read"` StateSectorGetInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorOnChainInfo, error) `perm:"read"` - StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) `perm:"read"` + StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) `perm:"read"` StateSectorPreCommitInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorPreCommitOnChainInfo, error) `perm:"read"` @@ -3422,6 +3425,28 @@ func (s *FullNodeStub) StateGetNetworkParams(p0 context.Context) (*NetworkParams return nil, ErrNotSupported } +func (s *FullNodeStruct) StateGetRandomnessDigestFromBeacon(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) (abi.Randomness, error) { + if s.Internal.StateGetRandomnessDigestFromBeacon == nil { + return *new(abi.Randomness), ErrNotSupported + } + return s.Internal.StateGetRandomnessDigestFromBeacon(p0, p1, p2) +} + +func (s *FullNodeStub) StateGetRandomnessDigestFromBeacon(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) (abi.Randomness, error) { + return *new(abi.Randomness), ErrNotSupported +} + +func (s *FullNodeStruct) StateGetRandomnessDigestFromTickets(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) (abi.Randomness, error) { + if s.Internal.StateGetRandomnessDigestFromTickets == nil { + return *new(abi.Randomness), ErrNotSupported + } + return s.Internal.StateGetRandomnessDigestFromTickets(p0, p1, p2) +} + +func (s *FullNodeStub) StateGetRandomnessDigestFromTickets(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) (abi.Randomness, error) { + return *new(abi.Randomness), ErrNotSupported +} + func (s *FullNodeStruct) StateGetRandomnessFromBeacon(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) { if s.Internal.StateGetRandomnessFromBeacon == nil { return *new(abi.Randomness), ErrNotSupported @@ -3763,14 +3788,14 @@ func (s *FullNodeStub) StateSearchMsg(p0 context.Context, p1 types.TipSetKey, p2 return nil, ErrNotSupported } -func (s *FullNodeStruct) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) { +func (s *FullNodeStruct) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) { if s.Internal.StateSectorExpiration == nil { return nil, ErrNotSupported } return s.Internal.StateSectorExpiration(p0, p1, p2, p3) } -func (s *FullNodeStub) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) { +func (s *FullNodeStub) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) { return nil, ErrNotSupported } @@ -3785,14 +3810,14 @@ func (s *FullNodeStub) StateSectorGetInfo(p0 context.Context, p1 address.Address return nil, ErrNotSupported } -func (s *FullNodeStruct) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) { +func (s *FullNodeStruct) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) { if s.Internal.StateSectorPartition == nil { return nil, ErrNotSupported } return s.Internal.StateSectorPartition(p0, p1, p2, p3) } -func (s *FullNodeStub) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) { +func (s *FullNodeStub) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) { return nil, ErrNotSupported } diff --git a/api/types.go b/api/types.go index e6ffaead2..6e98a4de4 100644 --- a/api/types.go +++ b/api/types.go @@ -19,8 +19,8 @@ import ( datatransfer "github.com/filecoin-project/go-data-transfer/v2" "github.com/filecoin-project/go-fil-markets/retrievalmarket" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/modules/dtypes" ) diff --git a/api/v0api/full.go b/api/v0api/full.go index 322f72449..d92d5a95c 100644 --- a/api/v0api/full.go +++ b/api/v0api/full.go @@ -15,7 +15,6 @@ import ( "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/builtin/v8/paych" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" @@ -23,7 +22,7 @@ import ( "github.com/filecoin-project/lotus/api" apitypes "github.com/filecoin-project/lotus/api/types" - lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" marketevents "github.com/filecoin-project/lotus/markets/loggers" "github.com/filecoin-project/lotus/node/modules/dtypes" @@ -450,9 +449,9 @@ type FullNode interface { // expiration epoch StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) //perm:read // StateSectorExpiration returns epoch at which given sector will expire - StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*lminer.SectorExpiration, error) //perm:read + StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorExpiration, error) //perm:read // StateSectorPartition finds deadline/partition with the specified sector - StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*lminer.SectorLocation, error) //perm:read + StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error) //perm:read // StateSearchMsg searches for a message in the chain, and returns its receipt and the tipset where it was executed // // NOTE: If a replacing message is found on chain, this method will return diff --git a/api/v0api/gateway.go b/api/v0api/gateway.go index 9f6c54fa9..60885a1b7 100644 --- a/api/v0api/gateway.go +++ b/api/v0api/gateway.go @@ -8,11 +8,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/dline" abinetwork "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/modules/dtypes" ) diff --git a/api/v0api/proxy_gen.go b/api/v0api/proxy_gen.go index 29f6f6773..f2f3973c1 100644 --- a/api/v0api/proxy_gen.go +++ b/api/v0api/proxy_gen.go @@ -17,7 +17,6 @@ import ( "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/builtin/v8/paych" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" @@ -25,7 +24,7 @@ import ( "github.com/filecoin-project/lotus/api" apitypes "github.com/filecoin-project/lotus/api/types" - lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" marketevents "github.com/filecoin-project/lotus/markets/loggers" "github.com/filecoin-project/lotus/node/modules/dtypes" @@ -355,11 +354,11 @@ type FullNodeMethods struct { StateSearchMsgLimited func(p0 context.Context, p1 cid.Cid, p2 abi.ChainEpoch) (*api.MsgLookup, error) `perm:"read"` - StateSectorExpiration func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) `perm:"read"` + StateSectorExpiration func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) `perm:"read"` StateSectorGetInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorOnChainInfo, error) `perm:"read"` - StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) `perm:"read"` + StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) `perm:"read"` StateSectorPreCommitInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"` @@ -2235,14 +2234,14 @@ func (s *FullNodeStub) StateSearchMsgLimited(p0 context.Context, p1 cid.Cid, p2 return nil, ErrNotSupported } -func (s *FullNodeStruct) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) { +func (s *FullNodeStruct) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) { if s.Internal.StateSectorExpiration == nil { return nil, ErrNotSupported } return s.Internal.StateSectorExpiration(p0, p1, p2, p3) } -func (s *FullNodeStub) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) { +func (s *FullNodeStub) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) { return nil, ErrNotSupported } @@ -2257,14 +2256,14 @@ func (s *FullNodeStub) StateSectorGetInfo(p0 context.Context, p1 address.Address return nil, ErrNotSupported } -func (s *FullNodeStruct) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) { +func (s *FullNodeStruct) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) { if s.Internal.StateSectorPartition == nil { return nil, ErrNotSupported } return s.Internal.StateSectorPartition(p0, p1, p2, p3) } -func (s *FullNodeStub) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) { +func (s *FullNodeStub) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) { return nil, ErrNotSupported } diff --git a/api/v0api/v1_wrapper.go b/api/v0api/v1_wrapper.go index f58b0420f..265674e71 100644 --- a/api/v0api/v1_wrapper.go +++ b/api/v0api/v1_wrapper.go @@ -12,11 +12,11 @@ import ( "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api/v1api" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" marketevents "github.com/filecoin-project/lotus/markets/loggers" ) diff --git a/build/builtin_actors_gen.go b/build/builtin_actors_gen.go index 5bc65dd81..fdd4c34f8 100644 --- a/build/builtin_actors_gen.go +++ b/build/builtin_actors_gen.go @@ -94,6 +94,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": MustParseCid("bafk2bzacedtuh7cht3fud7fb4avl4g2zbz57lc4ohiaufpaex6dkmdokn5rgo"), "verifiedregistry": MustParseCid("bafk2bzaceb37hxeuoo5rgf6ansrdl2ykm5v5zp6kireubn4orcopr67jbxv6k"), }, +}, { + Network: "butterflynet", + Version: 12, + BundleGitTag: "v11.0.0", + ManifestCid: MustParseCid("bafy2bzaceaiy4dsxxus5xp5n5i4tjzkb7sc54mjz7qnk2efhgmsrobjesxnza"), + Actors: map[string]cid.Cid{ + "account": MustParseCid("bafk2bzacecfdqb7p3jakhaa3cqnzpt7hxmhghrbxvafsylqno3febx55fnidw"), + "cron": MustParseCid("bafk2bzaceavmqu2qihgbe3xdaotgypuzvdpiifnm7ll6rolks2u4lac6voosk"), + "datacap": MustParseCid("bafk2bzacealtvh65rzb34fmyzw4m2np2htnio4w3pn4alzqovwxkdbf23dvpo"), + "eam": MustParseCid("bafk2bzacedko6hcjmwpuwgma5pb4gr2wgyvregk3nqqjxit7dv4es6vh5cjoc"), + "ethaccount": MustParseCid("bafk2bzacedhcei2xnr34poxr4xziypm2obqlibke4cs2cjfnr3sz6nf6h7fyy"), + "evm": MustParseCid("bafk2bzacebn5lwxboiikhz67ajwa34v2lc4qevnhpwdnipbmrnutkvrrqkb46"), + "init": MustParseCid("bafk2bzacea6vw4esh5tg7mprv5jkbx5xcyilcy4vvf64lss32mjyuvv2mh5ng"), + "multisig": MustParseCid("bafk2bzacedq2afnwcfipay5twv5mgzjoio5bbjvyo4yqchdwqcr7wrareyx54"), + "paymentchannel": MustParseCid("bafk2bzacebbsvr7i7mqmaadyjibe5wxnv7bwvvec2wlgknuwda6ep45amnd5w"), + "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": MustParseCid("bafk2bzaceafuh6idvaqqkj353vs4qdl42tcmvnymewu5zf4rq2nruxdyunses"), + "storagemarket": MustParseCid("bafk2bzaceb7bx4honi3byjllpdk6fea32dpu3vqvil3okodybdk5m3erlnwjw"), + "storageminer": MustParseCid("bafk2bzacebxjhofdr3sb2uhy2ky2vcijh4nhmwkh5xijtbgk6dzkknji2kn7a"), + "storagepower": MustParseCid("bafk2bzaceabskmmkas6njbowols7t4ib3bipa5abpomk3jtgfwojtzd7mjzfm"), + "system": MustParseCid("bafk2bzacedtuh7cht3fud7fb4avl4g2zbz57lc4ohiaufpaex6dkmdokn5rgo"), + "verifiedregistry": MustParseCid("bafk2bzaceb37hxeuoo5rgf6ansrdl2ykm5v5zp6kireubn4orcopr67jbxv6k"), + }, }, { Network: "butterflynet", Version: 12, @@ -203,25 +226,25 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet }, { Network: "calibrationnet", Version: 12, - BundleGitTag: "v12-test", - ManifestCid: MustParseCid("bafy2bzaceaipkdiplb5geo2plfrpaxisen46lqbzn4lt7ffmsdwdps4zb6424"), + BundleGitTag: "v11.0.0", + ManifestCid: MustParseCid("bafy2bzacec5fl7crmxyw234qsmijvffhssgqwuphyaejulbryhel2pxxrxgey"), Actors: map[string]cid.Cid{ - "account": MustParseCid("bafk2bzacedgtgdr2oj2jwdp6kapxvqvuec5s5awvbcjre3npygezasdl5yb52"), - "cron": MustParseCid("bafk2bzacea4k2cgqv2aefs2rz3xd2ky25wlqoo6r3fdytlmhsf4emzqpvid2s"), - "datacap": MustParseCid("bafk2bzaceab4367hss5dd4a2q5oodmtpml5nnrnybtmf52wgxfb4cw7voxu62"), - "eam": MustParseCid("bafk2bzaceac3qbafk2ucohhurwqmoolanf33tiwtyicukiecboj3zshbd7ao2"), - "ethaccount": MustParseCid("bafk2bzacedy2lbg6qrr5z3vzyuz3qeaids7t4pvdu7ohk34e7a56xtijmhj4u"), - "evm": MustParseCid("bafk2bzacebqx3jxucwtjo5j7b5mupuybrzamq2gzd5t6lohwxzga7vuc6zhag"), - "init": MustParseCid("bafk2bzacebvqeg7ka4ogomupjnikaziqf37huz4jgvoctqwiobffdad3e2d3y"), - "multisig": MustParseCid("bafk2bzacechwpp2kvsjvrj4ry5ploj2ejkfo2zvzq4umxy7tberjaregp6kdo"), - "paymentchannel": MustParseCid("bafk2bzacedfhhvzjzhrpokf2jt7es4jq25ryagzf4qy3txyffvje23vih75i4"), + "account": MustParseCid("bafk2bzacecrjovyiuh4jryepy4pxddzqjyrg2hfinxzbv37bpzlci54r5mkr6"), + "cron": MustParseCid("bafk2bzacedy76woxmtalmsuaji4kog6wmq4h2kcgcyv5wpxbdz7f2ls2tjjmw"), + "datacap": MustParseCid("bafk2bzacec2inqddxpfm3rufwqr752d2ok3ve4cxfhmloyosy6rj2krtkpwus"), + "eam": MustParseCid("bafk2bzacea6sxno66egkqz5rqjq4e22obkeblxl7e3funjifljuinmrc2ztzg"), + "ethaccount": MustParseCid("bafk2bzacecdsvs7xm3ncm66lsjqh65uzhr3rmu3dlux7qzdgpg737r4kslhxm"), + "evm": MustParseCid("bafk2bzaceaz3b66m2znt27clmbp2zi5jsobw6g2x6fiezynyijgtkehgqhq3a"), + "init": MustParseCid("bafk2bzacecdrw7uedx456hnowtyyhm63mkekdlkh3vmlhvqlya6pn6pokiq5y"), + "multisig": MustParseCid("bafk2bzaceaxyxvmng5cel5huzy5nezscm34s7wuzn2fhndexurs3xjtp7xg5i"), + "paymentchannel": MustParseCid("bafk2bzacedrmyc4c6u6ipdo7hwaagx3urr47r4pw6lwv257wqbj6roumwfvky"), "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), - "reward": MustParseCid("bafk2bzaceby3y6qhaunjqmwrvegqh7ouj4ua7advg6eyzxcj43spaypeomjgg"), - "storagemarket": MustParseCid("bafk2bzacedgdck3s5asnn5di5ijg22gpqnxj7bynekbycvydwqgemqwzzmere"), - "storageminer": MustParseCid("bafk2bzacebwecbrksabe5w25iop6ysgwk57etueo67vnwsyny3nkzbnk6xshq"), - "storagepower": MustParseCid("bafk2bzacedam2fr6yyo5qhief6mxkxz7b53xgflntwgch6ujbc3wp35h4g4sa"), - "system": MustParseCid("bafk2bzacecfs5d6ktybdq6jeqiomte6tewufptk72qc6gstn6hb3gzkyedn3a"), - "verifiedregistry": MustParseCid("bafk2bzaceamkpusx5yglkb5oghqeihugs6zyouzxz6jjmk5s4qs4bovnpldgg"), + "reward": MustParseCid("bafk2bzacecq3bhrkatwash5zhy2275ksaj3criqb6rox5e3hsyvz7mrl2jh3o"), + "storagemarket": MustParseCid("bafk2bzacedswrpkbh7jmttskllbblym7oj2ynxp7bxtj2fpbxsx55mraog6sc"), + "storageminer": MustParseCid("bafk2bzacecki6ckm7gf4uje3fxvw6x5f77ukaqctvcsfha6oaecvl67veh3sg"), + "storagepower": MustParseCid("bafk2bzacecjcvxwibkgpufeah33gfd2jzlqjx5rn2pguvvch2squon23u6kne"), + "system": MustParseCid("bafk2bzaceavvlgqbcwhy3c24aa24z23wcbzggmb66gj7x5if7o3fbvddaocc4"), + "verifiedregistry": MustParseCid("bafk2bzacedmxdtnpy2mc63b6bi2h4vp4dfc6hxjckqnwaxyijgkpmangygcmk"), }, }, { Network: "caterpillarnet", @@ -315,6 +338,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": MustParseCid("bafk2bzacebxfzeom3d7ahcz2n2nlwp7ncv767bdbbrisugks4l6v7lcu2tmyg"), "verifiedregistry": MustParseCid("bafk2bzacedaws3or3twy45ltcxucgvqijsje4x675ph6vup2w35smlfneamno"), }, +}, { + Network: "caterpillarnet", + Version: 12, + BundleGitTag: "v11.0.0", + ManifestCid: MustParseCid("bafy2bzacebexc2jgzwr5ngn6jdnkwdqwwmcapajuypdgvopoe6bnvp4yxm4o2"), + Actors: map[string]cid.Cid{ + "account": MustParseCid("bafk2bzaceanjiq5m3feytue5m7hhxfkob2ofg2greoct5tr77reuhrjglo66g"), + "cron": MustParseCid("bafk2bzaceavgd5qj6n744tukhdrvxejygzs3jnlizmcvjsdnxkgiimrd5jrys"), + "datacap": MustParseCid("bafk2bzacedmdywxwrzop2gmf4ys5stydlmvbe35j3nyr2efmf273briksuvse"), + "eam": MustParseCid("bafk2bzacec7qo7s72li7tqysllstlrxxm2dhfqv2w32pytel2e775cki4ozqm"), + "ethaccount": MustParseCid("bafk2bzaceaygtkliu26ubb7ivljrvaeesp5sbjlis5okzl35ishxioa2tlx4w"), + "evm": MustParseCid("bafk2bzacebo7iqzy2ophz4f3civzwlltec7q5fut7kmtfckr6vy33r6ic5eqe"), + "init": MustParseCid("bafk2bzaceb7uzzlsquqwrqhb2vpbvk3jgr4wp5i3smu2splnag2v5sppdehns"), + "multisig": MustParseCid("bafk2bzacebwibfqrytobl4pjtny244zkmfoomazbap3r5gddjryckx5js4csi"), + "paymentchannel": MustParseCid("bafk2bzacecuaa5esuxpouigxoamyl5gire2qqqhvyhewsig2x2j73f6ksh7go"), + "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": MustParseCid("bafk2bzaced4xxqhv63njf2ibvsqshlwikafctxev7aho5lgsfxyt2javjwvtw"), + "storagemarket": MustParseCid("bafk2bzacedwtx3xokqmbgkgkoqkdt6lam4ymdjb3eznlbtec5wcrtx74l2bpc"), + "storageminer": MustParseCid("bafk2bzacebbbe4sdo3xxkez7x7lkl6j46w34vx7eg7xswmdzhp7moa44p3wjg"), + "storagepower": MustParseCid("bafk2bzacedfgz6n24tjsor4pcayomim2f5f3a3fgyatmjgwxxeejna7okndda"), + "system": MustParseCid("bafk2bzacebxfzeom3d7ahcz2n2nlwp7ncv767bdbbrisugks4l6v7lcu2tmyg"), + "verifiedregistry": MustParseCid("bafk2bzacedaws3or3twy45ltcxucgvqijsje4x675ph6vup2w35smlfneamno"), + }, }, { Network: "caterpillarnet", Version: 12, @@ -421,6 +467,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": MustParseCid("bafk2bzacedpyoncjbl4oxkjm5e77ngvpy2xfajjc4myfsv2vltvzxioattlu2"), "verifiedregistry": MustParseCid("bafk2bzacebdqi5tr5pjnem5nylg2zbqcugvi7oxi35bhnrfudx4y4ufhlit2k"), }, +}, { + Network: "devnet", + Version: 12, + BundleGitTag: "v11.0.0", + ManifestCid: MustParseCid("bafy2bzaceay35go4xbjb45km6o46e5bib3bi46panhovcbedrynzwmm3drr4i"), + Actors: map[string]cid.Cid{ + "account": MustParseCid("bafk2bzacecf2pprkbdlpm4e2xz3ufunxtgrgyh2ie3stuqiyhibsvdze7kvri"), + "cron": MustParseCid("bafk2bzaceasr5d2skowvzv5mzsyak6waqrgc46ewj6rzbapkfi5woom6n6bwa"), + "datacap": MustParseCid("bafk2bzaceaqd77gptubupda7rp7daxkxbkzwc253dxhiyoezxvj2tljmkgpny"), + "eam": MustParseCid("bafk2bzacedve6p4ye6zxydjbfs4ode5r2equ7rqzpyltujsq2lu6wyxnijfx4"), + "ethaccount": MustParseCid("bafk2bzacea25xfsxwew3h2crer6jlb4c5vwu2gtch2jh73ocuxjhupenyrugy"), + "evm": MustParseCid("bafk2bzacece5hivtkmi757lyfahgti7xuqgofodb2u65pxgf6oizfwiiwlcsi"), + "init": MustParseCid("bafk2bzacecxnr5y7qifzdqqiwfbjxv2yr7lbkcyu3e2mf5zjdncteupxdlquu"), + "multisig": MustParseCid("bafk2bzaceayap4k4u3lbysaeeixct5fvhmafy3fa5eagvdpk3i4a7ubfdpobe"), + "paymentchannel": MustParseCid("bafk2bzaceafgrz5wepbein35gie7rnsu7zttxvgllgdneuefmmy4j5izydtza"), + "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": MustParseCid("bafk2bzacedwbtfqlx47fdkxjrb5mwiatheci44x3zkpx33smybc2cme23ymuo"), + "storagemarket": MustParseCid("bafk2bzaceaj74fmooaf3gj3ebwon64ky7hhdh7kytdr3agclqfrqzmpzykh7g"), + "storageminer": MustParseCid("bafk2bzacedb7bokkzzs7hnbhivp74pgcpermuy7j6b3ncodylksukkxtnn7ze"), + "storagepower": MustParseCid("bafk2bzacedilnkegizkxz3nuutib4d4wwlk4bkla22loepia2h53yf4hysmq6"), + "system": MustParseCid("bafk2bzacedpyoncjbl4oxkjm5e77ngvpy2xfajjc4myfsv2vltvzxioattlu2"), + "verifiedregistry": MustParseCid("bafk2bzacebdqi5tr5pjnem5nylg2zbqcugvi7oxi35bhnrfudx4y4ufhlit2k"), + }, }, { Network: "devnet", Version: 12, @@ -550,6 +619,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": MustParseCid("bafk2bzaced7npe5mt5nh72jxr2igi2sofoa7gedt4w6kueeke7i3xxugqpjfm"), "verifiedregistry": MustParseCid("bafk2bzacedej3dnr62g2je2abmyjg3xqv4otvh6e26du5fcrhvw7zgcaaez3a"), }, +}, { + Network: "mainnet", + Version: 12, + BundleGitTag: "v11.0.0", + ManifestCid: MustParseCid("bafy2bzacecnhaiwcrpyjvzl4uv4q3jzoif26okl3m66q3cijp3dfwlcxwztwo"), + Actors: map[string]cid.Cid{ + "account": MustParseCid("bafk2bzacealnlr7st6lkwoh6wxpf2hnrlex5sknaopgmkr2tuhg7vmbfy45so"), + "cron": MustParseCid("bafk2bzacebpewdvvgt6tk2o2u4rcovdgym67tadiis5usemlbejg7k3kt567o"), + "datacap": MustParseCid("bafk2bzacebslykoyrb2hm7aacjngqgd5n2wmeii2goadrs5zaya3pvdf6pdnq"), + "eam": MustParseCid("bafk2bzaceaelwt4yfsfvsu3pa3miwalsvy3cfkcjvmt4sqoeopsppnrmj2mf2"), + "ethaccount": MustParseCid("bafk2bzaceclkmc4yidxc6lgcjpfypbde2eddnevcveo4j5kmh4ek6inqysz2k"), + "evm": MustParseCid("bafk2bzacediwh6etwzwmb5pivtclpdplewdjzphouwqpppce6opisjv2fjqfe"), + "init": MustParseCid("bafk2bzaceckwf3w6n2nw6eh77ktmsxqgsvshonvgnyk5q5syyngtetxvasfxg"), + "multisig": MustParseCid("bafk2bzaceafajceqwg5ybiz7xw6rxammuirkgtuv625gzaehsqfprm4bazjmk"), + "paymentchannel": MustParseCid("bafk2bzaceb4e6cnsnviegmqvsmoxzncruvhra54piq7bwiqfqevle6oob2gvo"), + "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": MustParseCid("bafk2bzacebwjw2vxkobs7r2kwjdqqb42h2kucyuk6flbnyzw4odg5s4mogamo"), + "storagemarket": MustParseCid("bafk2bzaceazu2j2zu4p24tr22btnqzkhzjvyjltlvsagaj6w3syevikeb5d7m"), + "storageminer": MustParseCid("bafk2bzacec24okjqrp7c7rj3hbrs5ez5apvwah2ruka6haesgfngf37mhk6us"), + "storagepower": MustParseCid("bafk2bzaceaxgloxuzg35vu7l7tohdgaq2frsfp4ejmuo7tkoxjp5zqrze6sf4"), + "system": MustParseCid("bafk2bzaced7npe5mt5nh72jxr2igi2sofoa7gedt4w6kueeke7i3xxugqpjfm"), + "verifiedregistry": MustParseCid("bafk2bzacedej3dnr62g2je2abmyjg3xqv4otvh6e26du5fcrhvw7zgcaaez3a"), + }, }, { Network: "mainnet", Version: 12, @@ -656,6 +748,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": MustParseCid("bafk2bzaceaatvscbnkv36ixhtt2zel4er5oskxevgumh5gegqkv7uzah36f24"), "verifiedregistry": MustParseCid("bafk2bzacebp2r56wxadvfzpfbmqwfi3dlnwpmoc5u4tau2hfftbkuafkhye64"), }, +}, { + Network: "testing", + Version: 12, + BundleGitTag: "v11.0.0", + ManifestCid: MustParseCid("bafy2bzacea2vxre32tg3xhpejrktiuzx4d3pcoe7yyazgscfibmegmchr6n42"), + Actors: map[string]cid.Cid{ + "account": MustParseCid("bafk2bzaceccerssb3tgel6ukdghlwvs7dxsolj4fpkgn7dh7owzwapqb6ejpw"), + "cron": MustParseCid("bafk2bzacebtfl6fczxnitrqqjhyefskf3asyn3gzuvqcddieoqfsaddk5fd4q"), + "datacap": MustParseCid("bafk2bzacediikc55y6uzmnhucf4mik6rqpjulwvgp5gdibogxjhgbvusmzff2"), + "eam": MustParseCid("bafk2bzaceazqi5ezossp6kvqogaaba6hxlfarqgniktmb7iy5qonha3eflz6m"), + "ethaccount": MustParseCid("bafk2bzaceb77ospgfqqmf67v23wkyeg7lr2mu53ybaacu3bslx7s7nhttdueo"), + "evm": MustParseCid("bafk2bzacedvgt7mv22hux4vrnklylq7qmw43kfrqwam6wdsfzkdnaewr33qbu"), + "init": MustParseCid("bafk2bzacealzb3nk2oypway5ubz3hs5py5ok5tuw545454vg4d3mwbslef4js"), + "multisig": MustParseCid("bafk2bzacec45ppn4hrwizmopp2v2atkxw35tb6yem6uqhqilrv7aiaknnnxmu"), + "paymentchannel": MustParseCid("bafk2bzaceajbr3t6cngzh3katqteflbcrtwtdgbthnlfemon5tg6rytf2uonw"), + "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": MustParseCid("bafk2bzacea7ycf53kbq4robcuh3ziy7qwwhaqamc5krn3lugypgpxhlewdaiq"), + "storagemarket": MustParseCid("bafk2bzacedskmbcpaeb6bezs32szh52jrukvihobluadauayroo5gzrt32tkm"), + "storageminer": MustParseCid("bafk2bzaced3yg5lctmswnbkxyd6cleg3llyux7fu2vbddyd2ho36fpym423mq"), + "storagepower": MustParseCid("bafk2bzacebvpdf372fzxgixztbz2r7ayxyvx7jmdxwlfuqt2cq7tnqgie3klw"), + "system": MustParseCid("bafk2bzaceaatvscbnkv36ixhtt2zel4er5oskxevgumh5gegqkv7uzah36f24"), + "verifiedregistry": MustParseCid("bafk2bzacebp2r56wxadvfzpfbmqwfi3dlnwpmoc5u4tau2hfftbkuafkhye64"), + }, }, { Network: "testing", Version: 12, @@ -762,6 +877,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": MustParseCid("bafk2bzaceaatvscbnkv36ixhtt2zel4er5oskxevgumh5gegqkv7uzah36f24"), "verifiedregistry": MustParseCid("bafk2bzacebp2r56wxadvfzpfbmqwfi3dlnwpmoc5u4tau2hfftbkuafkhye64"), }, +}, { + Network: "testing-fake-proofs", + Version: 12, + BundleGitTag: "v11.0.0", + ManifestCid: MustParseCid("bafy2bzacecojemqglhzzhjnhgtrcbsgkyv67ziytvtbhwlr4ym4oxqofv7zui"), + Actors: map[string]cid.Cid{ + "account": MustParseCid("bafk2bzaceccerssb3tgel6ukdghlwvs7dxsolj4fpkgn7dh7owzwapqb6ejpw"), + "cron": MustParseCid("bafk2bzacebtfl6fczxnitrqqjhyefskf3asyn3gzuvqcddieoqfsaddk5fd4q"), + "datacap": MustParseCid("bafk2bzacediikc55y6uzmnhucf4mik6rqpjulwvgp5gdibogxjhgbvusmzff2"), + "eam": MustParseCid("bafk2bzaceazqi5ezossp6kvqogaaba6hxlfarqgniktmb7iy5qonha3eflz6m"), + "ethaccount": MustParseCid("bafk2bzaceb77ospgfqqmf67v23wkyeg7lr2mu53ybaacu3bslx7s7nhttdueo"), + "evm": MustParseCid("bafk2bzacedvgt7mv22hux4vrnklylq7qmw43kfrqwam6wdsfzkdnaewr33qbu"), + "init": MustParseCid("bafk2bzacealzb3nk2oypway5ubz3hs5py5ok5tuw545454vg4d3mwbslef4js"), + "multisig": MustParseCid("bafk2bzacec45ppn4hrwizmopp2v2atkxw35tb6yem6uqhqilrv7aiaknnnxmu"), + "paymentchannel": MustParseCid("bafk2bzaceajbr3t6cngzh3katqteflbcrtwtdgbthnlfemon5tg6rytf2uonw"), + "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": MustParseCid("bafk2bzacea7ycf53kbq4robcuh3ziy7qwwhaqamc5krn3lugypgpxhlewdaiq"), + "storagemarket": MustParseCid("bafk2bzacedskmbcpaeb6bezs32szh52jrukvihobluadauayroo5gzrt32tkm"), + "storageminer": MustParseCid("bafk2bzacebqeztpa5exztccqjwqhan5droiy7ga6zekm6f2gzxoe655vneczm"), + "storagepower": MustParseCid("bafk2bzaceb2tlyuwxncdxsh3hc4fwcjnpxaijkiv54ustwdjbrqabxdsc27km"), + "system": MustParseCid("bafk2bzaceaatvscbnkv36ixhtt2zel4er5oskxevgumh5gegqkv7uzah36f24"), + "verifiedregistry": MustParseCid("bafk2bzacebp2r56wxadvfzpfbmqwfi3dlnwpmoc5u4tau2hfftbkuafkhye64"), + }, }, { Network: "testing-fake-proofs", Version: 12, diff --git a/build/openrpc/worker.json.gz b/build/openrpc/worker.json.gz index 4c403bec4..33d55e513 100644 Binary files a/build/openrpc/worker.json.gz and b/build/openrpc/worker.json.gz differ diff --git a/build/params_butterfly.go b/build/params_butterfly.go index ee06cf86a..8875482ff 100644 --- a/build/params_butterfly.go +++ b/build/params_butterfly.go @@ -58,6 +58,9 @@ const UpgradeThunderHeight = -23 // 2023-08-07 const UpgradeWatermelonHeight = 900 +// ?????????? +const UpgradeWatermelonHeight = 999999999999999 + var SupportedProofTypes = []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg512MiBV1, abi.RegisteredSealProof_StackedDrg32GiBV1, diff --git a/build/version.go b/build/version.go index bbfd39ea2..ab97f7a89 100644 --- a/build/version.go +++ b/build/version.go @@ -37,7 +37,7 @@ func BuildTypeString() string { } // BuildVersion is the local build version -const BuildVersion = "1.23.3-rc2" +const BuildVersion = "1.23.3" func UserVersion() string { if os.Getenv("LOTUS_VERSION_IGNORE_COMMIT") == "1" { diff --git a/chain/actors/builtin/market/state.go.template b/chain/actors/builtin/market/state.go.template index bbaa5c775..1eab9d743 100644 --- a/chain/actors/builtin/market/state.go.template +++ b/chain/actors/builtin/market/state.go.template @@ -19,7 +19,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" - verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" + verifregtypes "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" "github.com/filecoin-project/go-state-types/manifest" {{if (le .v 7)}} diff --git a/chain/actors/builtin/market/v0.go b/chain/actors/builtin/market/v0.go index c0a628b47..ca6970dfa 100644 --- a/chain/actors/builtin/market/v0.go +++ b/chain/actors/builtin/market/v0.go @@ -11,13 +11,13 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/manifest" market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + verifregtypes "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" "github.com/filecoin-project/lotus/chain/types" ) diff --git a/chain/actors/builtin/market/v10.go b/chain/actors/builtin/market/v10.go index aaa0ee0f1..878f0d465 100644 --- a/chain/actors/builtin/market/v10.go +++ b/chain/actors/builtin/market/v10.go @@ -17,11 +17,11 @@ import ( market10 "github.com/filecoin-project/go-state-types/builtin/v10/market" adt10 "github.com/filecoin-project/go-state-types/builtin/v10/util/adt" markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market" - verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + verifregtypes "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" "github.com/filecoin-project/lotus/chain/types" ) diff --git a/chain/actors/builtin/market/v11.go b/chain/actors/builtin/market/v11.go index a816e3409..a64272209 100644 --- a/chain/actors/builtin/market/v11.go +++ b/chain/actors/builtin/market/v11.go @@ -17,11 +17,11 @@ import ( market11 "github.com/filecoin-project/go-state-types/builtin/v11/market" adt11 "github.com/filecoin-project/go-state-types/builtin/v11/util/adt" markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market" - verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + verifregtypes "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" "github.com/filecoin-project/lotus/chain/types" ) diff --git a/chain/actors/builtin/market/v12.go b/chain/actors/builtin/market/v12.go index 3532fc4f4..56e651a9b 100644 --- a/chain/actors/builtin/market/v12.go +++ b/chain/actors/builtin/market/v12.go @@ -17,11 +17,11 @@ import ( market12 "github.com/filecoin-project/go-state-types/builtin/v12/market" adt12 "github.com/filecoin-project/go-state-types/builtin/v12/util/adt" markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market" - verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + verifregtypes "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" "github.com/filecoin-project/lotus/chain/types" ) diff --git a/chain/actors/builtin/market/v2.go b/chain/actors/builtin/market/v2.go index 89ffdde8f..ba84e3b03 100644 --- a/chain/actors/builtin/market/v2.go +++ b/chain/actors/builtin/market/v2.go @@ -11,13 +11,13 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/manifest" market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + verifregtypes "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" "github.com/filecoin-project/lotus/chain/types" ) diff --git a/chain/actors/builtin/market/v3.go b/chain/actors/builtin/market/v3.go index f4d073ed8..f6a0891e7 100644 --- a/chain/actors/builtin/market/v3.go +++ b/chain/actors/builtin/market/v3.go @@ -11,13 +11,13 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/manifest" market3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/market" adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + verifregtypes "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" "github.com/filecoin-project/lotus/chain/types" ) diff --git a/chain/actors/builtin/market/v4.go b/chain/actors/builtin/market/v4.go index 422a30cbb..629e833b6 100644 --- a/chain/actors/builtin/market/v4.go +++ b/chain/actors/builtin/market/v4.go @@ -11,13 +11,13 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/manifest" market4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/market" adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + verifregtypes "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" "github.com/filecoin-project/lotus/chain/types" ) diff --git a/chain/actors/builtin/market/v5.go b/chain/actors/builtin/market/v5.go index b30decb03..892588979 100644 --- a/chain/actors/builtin/market/v5.go +++ b/chain/actors/builtin/market/v5.go @@ -11,13 +11,13 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/manifest" market5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/market" adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + verifregtypes "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" "github.com/filecoin-project/lotus/chain/types" ) diff --git a/chain/actors/builtin/market/v6.go b/chain/actors/builtin/market/v6.go index 377b278ae..b57d49f91 100644 --- a/chain/actors/builtin/market/v6.go +++ b/chain/actors/builtin/market/v6.go @@ -13,13 +13,13 @@ import ( rlepluslazy "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/manifest" market6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/market" adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + verifregtypes "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" "github.com/filecoin-project/lotus/chain/types" ) diff --git a/chain/actors/builtin/market/v7.go b/chain/actors/builtin/market/v7.go index cd4607cbe..56a1db328 100644 --- a/chain/actors/builtin/market/v7.go +++ b/chain/actors/builtin/market/v7.go @@ -13,13 +13,13 @@ import ( rlepluslazy "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/manifest" market7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/market" adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + verifregtypes "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" "github.com/filecoin-project/lotus/chain/types" ) diff --git a/chain/actors/builtin/market/v8.go b/chain/actors/builtin/market/v8.go index 5cce06d3a..9c68ee1fd 100644 --- a/chain/actors/builtin/market/v8.go +++ b/chain/actors/builtin/market/v8.go @@ -16,11 +16,11 @@ import ( market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market" - verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + verifregtypes "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" "github.com/filecoin-project/lotus/chain/types" ) diff --git a/chain/actors/builtin/market/v9.go b/chain/actors/builtin/market/v9.go index 095c20850..d692c15cc 100644 --- a/chain/actors/builtin/market/v9.go +++ b/chain/actors/builtin/market/v9.go @@ -17,11 +17,11 @@ import ( market9 "github.com/filecoin-project/go-state-types/builtin/v9/market" markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market" adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" - verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + verifregtypes "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" "github.com/filecoin-project/lotus/chain/types" ) diff --git a/chain/actors/builtin/miner/actor.go.template b/chain/actors/builtin/miner/actor.go.template index 2be589797..b4ad3a4b5 100644 --- a/chain/actors/builtin/miner/actor.go.template +++ b/chain/actors/builtin/miner/actor.go.template @@ -230,8 +230,37 @@ type PendingBeneficiaryChange = minertypes.PendingBeneficiaryChange type WorkerKeyChange = minertypes.WorkerKeyChange type SectorPreCommitOnChainInfo = minertypes.SectorPreCommitOnChainInfo type SectorPreCommitInfo = minertypes.SectorPreCommitInfo +type SubmitWindowedPoStParams = minertypes.SubmitWindowedPoStParams +type PoStPartition = minertypes.PoStPartition +type RecoveryDeclaration = minertypes.RecoveryDeclaration +type FaultDeclaration = minertypes.FaultDeclaration +type DeclareFaultsRecoveredParams = minertypes.DeclareFaultsRecoveredParams +type DeclareFaultsParams = minertypes.DeclareFaultsParams +type ProveCommitAggregateParams = minertypes.ProveCommitAggregateParams +type ProveCommitSectorParams = minertypes.ProveCommitSectorParams +type ProveReplicaUpdatesParams = minertypes.ProveReplicaUpdatesParams +type ReplicaUpdate = minertypes.ReplicaUpdate +type PreCommitSectorBatchParams = minertypes.PreCommitSectorBatchParams +type PreCommitSectorBatchParams2 = minertypes.PreCommitSectorBatchParams2 +type ExtendSectorExpiration2Params = minertypes.ExtendSectorExpiration2Params +type SectorClaim = minertypes.SectorClaim +type ExpirationExtension2 = minertypes.ExpirationExtension2 +type CompactPartitionsParams = minertypes.CompactPartitionsParams +type WithdrawBalanceParams = minertypes.WithdrawBalanceParams + +var QAPowerMax = minertypes.QAPowerMax + type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo +var WPoStProvingPeriod = func() abi.ChainEpoch { return minertypes.WPoStProvingPeriod } +var WPoStChallengeWindow = func() abi.ChainEpoch { return minertypes.WPoStChallengeWindow } + +const WPoStPeriodDeadlines = minertypes.WPoStPeriodDeadlines +const WPoStChallengeLookback = minertypes.WPoStChallengeLookback +const FaultDeclarationCutoff = minertypes.FaultDeclarationCutoff +const MinAggregatedSectors = minertypes.MinAggregatedSectors +const MinSectorExpiration = minertypes.MinSectorExpiration + type SectorExpiration struct { OnTime abi.ChainEpoch diff --git a/chain/actors/builtin/miner/miner.go b/chain/actors/builtin/miner/miner.go index 514857b03..1637cdade 100644 --- a/chain/actors/builtin/miner/miner.go +++ b/chain/actors/builtin/miner/miner.go @@ -290,8 +290,37 @@ type PendingBeneficiaryChange = minertypes.PendingBeneficiaryChange type WorkerKeyChange = minertypes.WorkerKeyChange type SectorPreCommitOnChainInfo = minertypes.SectorPreCommitOnChainInfo type SectorPreCommitInfo = minertypes.SectorPreCommitInfo +type SubmitWindowedPoStParams = minertypes.SubmitWindowedPoStParams +type PoStPartition = minertypes.PoStPartition +type RecoveryDeclaration = minertypes.RecoveryDeclaration +type FaultDeclaration = minertypes.FaultDeclaration +type DeclareFaultsRecoveredParams = minertypes.DeclareFaultsRecoveredParams +type DeclareFaultsParams = minertypes.DeclareFaultsParams +type ProveCommitAggregateParams = minertypes.ProveCommitAggregateParams +type ProveCommitSectorParams = minertypes.ProveCommitSectorParams +type ProveReplicaUpdatesParams = minertypes.ProveReplicaUpdatesParams +type ReplicaUpdate = minertypes.ReplicaUpdate +type PreCommitSectorBatchParams = minertypes.PreCommitSectorBatchParams +type PreCommitSectorBatchParams2 = minertypes.PreCommitSectorBatchParams2 +type ExtendSectorExpiration2Params = minertypes.ExtendSectorExpiration2Params +type SectorClaim = minertypes.SectorClaim +type ExpirationExtension2 = minertypes.ExpirationExtension2 +type CompactPartitionsParams = minertypes.CompactPartitionsParams +type WithdrawBalanceParams = minertypes.WithdrawBalanceParams + +var QAPowerMax = minertypes.QAPowerMax + type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo +var WPoStProvingPeriod = func() abi.ChainEpoch { return minertypes.WPoStProvingPeriod } +var WPoStChallengeWindow = func() abi.ChainEpoch { return minertypes.WPoStChallengeWindow } + +const WPoStPeriodDeadlines = minertypes.WPoStPeriodDeadlines +const WPoStChallengeLookback = minertypes.WPoStChallengeLookback +const FaultDeclarationCutoff = minertypes.FaultDeclarationCutoff +const MinAggregatedSectors = minertypes.MinAggregatedSectors +const MinSectorExpiration = minertypes.MinSectorExpiration + type SectorExpiration struct { OnTime abi.ChainEpoch diff --git a/chain/actors/builtin/verifreg/actor.go.template b/chain/actors/builtin/verifreg/actor.go.template index 9b779a68d..991c6717b 100644 --- a/chain/actors/builtin/verifreg/actor.go.template +++ b/chain/actors/builtin/verifreg/actor.go.template @@ -97,4 +97,6 @@ func AllCodes() []cid.Cid { type Allocation = verifregtypes.Allocation type AllocationId = verifregtypes.AllocationId type Claim = verifregtypes.Claim -type ClaimId = verifregtypes.ClaimId \ No newline at end of file +type ClaimId = verifregtypes.ClaimId + +const NoAllocationID = verifregtypes.NoAllocationID diff --git a/chain/actors/builtin/verifreg/verifreg.go b/chain/actors/builtin/verifreg/verifreg.go index e79a790c7..de906f521 100644 --- a/chain/actors/builtin/verifreg/verifreg.go +++ b/chain/actors/builtin/verifreg/verifreg.go @@ -168,3 +168,5 @@ type Allocation = verifregtypes.Allocation type AllocationId = verifregtypes.AllocationId type Claim = verifregtypes.Claim type ClaimId = verifregtypes.ClaimId + +const NoAllocationID = verifregtypes.NoAllocationID diff --git a/chain/consensus/compute_state.go b/chain/consensus/compute_state.go index 793a21ccd..1edeb60b7 100644 --- a/chain/consensus/compute_state.go +++ b/chain/consensus/compute_state.go @@ -81,7 +81,7 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context, pstate cid.Cid, bms []FilecoinBlockMessages, epoch abi.ChainEpoch, - r vm.Rand, + r rand.Rand, em stmgr.ExecMonitor, vmTracing bool, baseFee abi.TokenAmount, @@ -136,6 +136,10 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context, return xerrors.Errorf("running cron: %w", err) } + if !ret.ExitCode.IsSuccess() { + return xerrors.Errorf("cron failed with exit code %d: %w", ret.ExitCode, ret.ActorErr) + } + cronGas += ret.GasUsed if em != nil { diff --git a/chain/consensus/filcns/filecoin.go b/chain/consensus/filcns/filecoin.go index 509eb8a5e..b5ec13a60 100644 --- a/chain/consensus/filcns/filecoin.go +++ b/chain/consensus/filcns/filecoin.go @@ -80,6 +80,11 @@ var RewardFunc = func(ctx context.Context, vmi vm.Interface, em stmgr.ExecMonito if actErr != nil { return xerrors.Errorf("failed to apply reward message: %w", actErr) } + + if !ret.ExitCode.IsSuccess() { + return xerrors.Errorf("reward actor failed with exit code %d: %w", ret.ExitCode, ret.ActorErr) + } + if em != nil { if err := em.MessageApplied(ctx, ts, rwMsg.Cid(), rwMsg, ret, true); err != nil { return xerrors.Errorf("callback failed on reward message: %w", err) @@ -196,7 +201,7 @@ func (filec *FilecoinEC) ValidateBlock(ctx context.Context, b *types.FullBlock) return xerrors.Errorf("failed to marshal miner address to cbor: %w", err) } - vrfBase, err := rand.DrawRandomness(rBeacon.Data, crypto.DomainSeparationTag_ElectionProofProduction, h.Height, buf.Bytes()) + vrfBase, err := rand.DrawRandomnessFromBase(rBeacon.Data, crypto.DomainSeparationTag_ElectionProofProduction, h.Height, buf.Bytes()) if err != nil { return xerrors.Errorf("could not draw randomness: %w", err) } @@ -262,7 +267,7 @@ func (filec *FilecoinEC) ValidateBlock(ctx context.Context, b *types.FullBlock) beaconBase = h.BeaconEntries[len(h.BeaconEntries)-1] } - vrfBase, err := rand.DrawRandomness(beaconBase.Data, crypto.DomainSeparationTag_TicketProduction, h.Height-build.TicketRandomnessLookback, buf.Bytes()) + vrfBase, err := rand.DrawRandomnessFromBase(beaconBase.Data, crypto.DomainSeparationTag_TicketProduction, h.Height-build.TicketRandomnessLookback, buf.Bytes()) if err != nil { return xerrors.Errorf("failed to compute vrf base for ticket: %w", err) } @@ -340,7 +345,7 @@ func (filec *FilecoinEC) VerifyWinningPoStProof(ctx context.Context, nv network. rbase = h.BeaconEntries[len(h.BeaconEntries)-1] } - rand, err := rand.DrawRandomness(rbase.Data, crypto.DomainSeparationTag_WinningPoStChallengeSeed, h.Height, buf.Bytes()) + rand, err := rand.DrawRandomnessFromBase(rbase.Data, crypto.DomainSeparationTag_WinningPoStChallengeSeed, h.Height, buf.Bytes()) if err != nil { return xerrors.Errorf("failed to get randomness for verifying winning post proof: %w", err) } diff --git a/chain/gen/gen.go b/chain/gen/gen.go index 2e5f5e7f7..087f0e00c 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -376,7 +376,7 @@ func (cg *ChainGen) nextBlockProof(ctx context.Context, pts *types.TipSet, m add buf.Write(pts.MinTicket().VRFProof) } - ticketRand, err := rand.DrawRandomness(rbase.Data, crypto.DomainSeparationTag_TicketProduction, round-build.TicketRandomnessLookback, buf.Bytes()) + ticketRand, err := rand.DrawRandomnessFromBase(rbase.Data, crypto.DomainSeparationTag_TicketProduction, round-build.TicketRandomnessLookback, buf.Bytes()) if err != nil { return nil, nil, nil, err } @@ -636,7 +636,7 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, round abi.ChainEpoch, return nil, xerrors.Errorf("failed to cbor marshal address: %w", err) } - electionRand, err := rand.DrawRandomness(brand.Data, crypto.DomainSeparationTag_ElectionProofProduction, round, buf.Bytes()) + electionRand, err := rand.DrawRandomnessFromBase(brand.Data, crypto.DomainSeparationTag_ElectionProofProduction, round, buf.Bytes()) if err != nil { return nil, xerrors.Errorf("failed to draw randomness: %w", err) } diff --git a/chain/gen/genesis/miners.go b/chain/gen/genesis/miners.go index 448fb4282..7905fd253 100644 --- a/chain/gen/genesis/miners.go +++ b/chain/gen/genesis/miners.go @@ -43,6 +43,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/builtin/reward" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/consensus" + lrand "github.com/filecoin-project/lotus/chain/rand" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" @@ -590,19 +591,21 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal return c, nil } +var _ lrand.Rand = new(fakeRand) + // TODO: copied from actors test harness, deduplicate or remove from here type fakeRand struct{} -func (fr *fakeRand) GetChainRandomness(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) ([]byte, error) { +func (fr *fakeRand) GetChainRandomness(ctx context.Context, randEpoch abi.ChainEpoch) ([32]byte, error) { out := make([]byte, 32) _, _ = rand.New(rand.NewSource(int64(randEpoch * 1000))).Read(out) //nolint - return out, nil + return *(*[32]byte)(out), nil } -func (fr *fakeRand) GetBeaconRandomness(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) ([]byte, error) { +func (fr *fakeRand) GetBeaconRandomness(ctx context.Context, randEpoch abi.ChainEpoch) ([32]byte, error) { out := make([]byte, 32) _, _ = rand.New(rand.NewSource(int64(randEpoch))).Read(out) //nolint - return out, nil + return *(*[32]byte)(out), nil } func currentTotalPower(ctx context.Context, vm vm.Interface, maddr address.Address) (*power0.CurrentTotalPowerReturn, error) { diff --git a/chain/gen/slashfilter/slashfilter.go b/chain/gen/slashfilter/slashfilter.go index 0e6b00cfb..71b5dad9a 100644 --- a/chain/gen/slashfilter/slashfilter.go +++ b/chain/gen/slashfilter/slashfilter.go @@ -26,20 +26,30 @@ func New(dstore ds.Batching) *SlashFilter { } } -func (f *SlashFilter) MinedBlock(ctx context.Context, bh *types.BlockHeader, parentEpoch abi.ChainEpoch) (cid.Cid, error) { +func (f *SlashFilter) MinedBlock(ctx context.Context, bh *types.BlockHeader, parentEpoch abi.ChainEpoch) (cid.Cid, bool, error) { epochKey := ds.NewKey(fmt.Sprintf("/%s/%d", bh.Miner, bh.Height)) { // double-fork mining (2 blocks at one epoch) - if witness, err := checkFault(ctx, f.byEpoch, epochKey, bh, "double-fork mining faults"); err != nil { - return witness, xerrors.Errorf("check double-fork mining faults: %w", err) + doubleForkWitness, doubleForkFault, err := checkFault(ctx, f.byEpoch, epochKey, bh, "double-fork mining faults") + if err != nil { + return cid.Undef, false, xerrors.Errorf("check double-fork mining faults: %w", err) + } + + if doubleForkFault { + return doubleForkWitness, doubleForkFault, nil } } parentsKey := ds.NewKey(fmt.Sprintf("/%s/%x", bh.Miner, types.NewTipSetKey(bh.Parents...).Bytes())) { // time-offset mining faults (2 blocks with the same parents) - if witness, err := checkFault(ctx, f.byParents, parentsKey, bh, "time-offset mining faults"); err != nil { - return witness, xerrors.Errorf("check time-offset mining faults: %w", err) + timeOffsetWitness, timeOffsetFault, err := checkFault(ctx, f.byParents, parentsKey, bh, "time-offset mining faults") + if err != nil { + return cid.Undef, false, xerrors.Errorf("check time-offset mining faults: %w", err) + } + + if timeOffsetFault { + return timeOffsetWitness, timeOffsetFault, nil } } @@ -50,19 +60,19 @@ func (f *SlashFilter) MinedBlock(ctx context.Context, bh *types.BlockHeader, par parentEpochKey := ds.NewKey(fmt.Sprintf("/%s/%d", bh.Miner, parentEpoch)) have, err := f.byEpoch.Has(ctx, parentEpochKey) if err != nil { - return cid.Undef, err + return cid.Undef, false, xerrors.Errorf("failed to read from db: %w", err) } if have { // If we had, make sure it's in our parent tipset cidb, err := f.byEpoch.Get(ctx, parentEpochKey) if err != nil { - return cid.Undef, xerrors.Errorf("getting other block cid: %w", err) + return cid.Undef, false, xerrors.Errorf("getting other block cid: %w", err) } _, parent, err := cid.CidFromBytes(cidb) if err != nil { - return cid.Undef, err + return cid.Undef, false, xerrors.Errorf("failed to read cid from bytes: %w", err) } var found bool @@ -73,45 +83,45 @@ func (f *SlashFilter) MinedBlock(ctx context.Context, bh *types.BlockHeader, par } if !found { - return parent, xerrors.Errorf("produced block would trigger 'parent-grinding fault' consensus fault; miner: %s; bh: %s, expected parent: %s", bh.Miner, bh.Cid(), parent) + return parent, true, nil } } } if err := f.byParents.Put(ctx, parentsKey, bh.Cid().Bytes()); err != nil { - return cid.Undef, xerrors.Errorf("putting byEpoch entry: %w", err) + return cid.Undef, false, xerrors.Errorf("putting byEpoch entry: %w", err) } if err := f.byEpoch.Put(ctx, epochKey, bh.Cid().Bytes()); err != nil { - return cid.Undef, xerrors.Errorf("putting byEpoch entry: %w", err) + return cid.Undef, false, xerrors.Errorf("putting byEpoch entry: %w", err) } - return cid.Undef, nil + return cid.Undef, false, nil } -func checkFault(ctx context.Context, t ds.Datastore, key ds.Key, bh *types.BlockHeader, faultType string) (cid.Cid, error) { +func checkFault(ctx context.Context, t ds.Datastore, key ds.Key, bh *types.BlockHeader, faultType string) (cid.Cid, bool, error) { fault, err := t.Has(ctx, key) if err != nil { - return cid.Undef, xerrors.Errorf("failed to read from datastore: %w", err) + return cid.Undef, false, xerrors.Errorf("failed to read from datastore: %w", err) } if fault { cidb, err := t.Get(ctx, key) if err != nil { - return cid.Undef, xerrors.Errorf("getting other block cid: %w", err) + return cid.Undef, false, xerrors.Errorf("getting other block cid: %w", err) } _, other, err := cid.CidFromBytes(cidb) if err != nil { - return cid.Undef, err + return cid.Undef, false, xerrors.Errorf("failed to read cid of other block: %w", err) } if other == bh.Cid() { - return cid.Undef, nil + return cid.Undef, false, nil } - return other, xerrors.Errorf("produced block would trigger '%s' consensus fault; miner: %s; bh: %s, other: %s", faultType, bh.Miner, bh.Cid(), other) + return other, true, nil } - return cid.Undef, nil + return cid.Undef, false, nil } diff --git a/chain/gen/slashfilter/slashsvc/slashservice.go b/chain/gen/slashfilter/slashsvc/slashservice.go new file mode 100644 index 000000000..7a6622880 --- /dev/null +++ b/chain/gen/slashfilter/slashsvc/slashservice.go @@ -0,0 +1,179 @@ +package slashsvc + +import ( + "context" + "time" + + "github.com/ipfs/go-cid" + levelds "github.com/ipfs/go-ds-leveldb" + logging "github.com/ipfs/go-log/v2" + ldbopts "github.com/syndtr/goleveldb/leveldb/opt" + "golang.org/x/xerrors" + + "github.com/filecoin-project/go-address" + cborutil "github.com/filecoin-project/go-cbor-util" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/specs-actors/actors/builtin/miner" + + lapi "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/gen/slashfilter" + "github.com/filecoin-project/lotus/chain/types" +) + +var log = logging.Logger("slashsvc") + +type ConsensusSlasherApi interface { + ChainHead(context.Context) (*types.TipSet, error) + ChainGetBlock(context.Context, cid.Cid) (*types.BlockHeader, error) + MpoolPushMessage(ctx context.Context, msg *types.Message, spec *lapi.MessageSendSpec) (*types.SignedMessage, error) + SyncIncomingBlocks(context.Context) (<-chan *types.BlockHeader, error) + WalletDefaultAddress(context.Context) (address.Address, error) +} + +func SlashConsensus(ctx context.Context, a ConsensusSlasherApi, p string, from string) error { + var fromAddr address.Address + + ds, err := levelds.NewDatastore(p, &levelds.Options{ + Compression: ldbopts.NoCompression, + NoSync: false, + Strict: ldbopts.StrictAll, + ReadOnly: false, + }) + if err != nil { + return xerrors.Errorf("open leveldb: %w", err) + } + sf := slashfilter.New(ds) + if from == "" { + defaddr, err := a.WalletDefaultAddress(ctx) + if err != nil { + return err + } + fromAddr = defaddr + } else { + addr, err := address.NewFromString(from) + if err != nil { + return err + } + + fromAddr = addr + } + + blocks, err := a.SyncIncomingBlocks(ctx) + if err != nil { + return xerrors.Errorf("sync incoming blocks failed: %w", err) + } + + log.Infow("consensus fault reporter", "from", fromAddr) + go func() { + for block := range blocks { + otherBlock, extraBlock, fault, err := slashFilterMinedBlock(ctx, sf, a, block) + if err != nil { + log.Errorf("slash detector errored: %s", err) + continue + } + if fault { + log.Errorf(" SLASH FILTER DETECTED FAULT DUE TO BLOCKS %s and %s", otherBlock.Cid(), block.Cid()) + bh1, err := cborutil.Dump(otherBlock) + if err != nil { + log.Errorf("could not dump otherblock:%s, err:%s", otherBlock.Cid(), err) + continue + } + + bh2, err := cborutil.Dump(block) + if err != nil { + log.Errorf("could not dump block:%s, err:%s", block.Cid(), err) + continue + } + + params := miner.ReportConsensusFaultParams{ + BlockHeader1: bh1, + BlockHeader2: bh2, + } + if extraBlock != nil { + be, err := cborutil.Dump(extraBlock) + if err != nil { + log.Errorf("could not dump block:%s, err:%s", block.Cid(), err) + continue + } + params.BlockHeaderExtra = be + } + + enc, err := actors.SerializeParams(¶ms) + if err != nil { + log.Errorf("could not serialize declare faults parameters: %s", err) + continue + } + for { + head, err := a.ChainHead(ctx) + if err != nil || head.Height() > block.Height { + break + } + time.Sleep(time.Second * 10) + } + message, err := a.MpoolPushMessage(ctx, &types.Message{ + To: block.Miner, + From: fromAddr, + Value: types.NewInt(0), + Method: builtin.MethodsMiner.ReportConsensusFault, + Params: enc, + }, nil) + if err != nil { + log.Errorf("ReportConsensusFault to messagepool error:%s", err) + continue + } + log.Infof("ReportConsensusFault message CID:%s", message.Cid()) + + } + } + }() + + return nil +} + +func slashFilterMinedBlock(ctx context.Context, sf *slashfilter.SlashFilter, a ConsensusSlasherApi, blockB *types.BlockHeader) (*types.BlockHeader, *types.BlockHeader, bool, error) { + blockC, err := a.ChainGetBlock(ctx, blockB.Parents[0]) + if err != nil { + return nil, nil, false, xerrors.Errorf("chain get block error:%s", err) + } + + blockACid, fault, err := sf.MinedBlock(ctx, blockB, blockC.Height) + if err != nil { + return nil, nil, false, xerrors.Errorf("slash filter check block error:%s", err) + } + + if !fault { + return nil, nil, false, nil + } + + blockA, err := a.ChainGetBlock(ctx, blockACid) + if err != nil { + return nil, nil, false, xerrors.Errorf("failed to get blockA: %w", err) + } + + // (a) double-fork mining (2 blocks at one epoch) + if blockA.Height == blockB.Height { + return blockA, nil, true, nil + } + + // (b) time-offset mining faults (2 blocks with the same parents) + if types.CidArrsEqual(blockB.Parents, blockA.Parents) { + return blockA, nil, true, nil + } + + // (c) parent-grinding fault + // Here extra is the "witness", a third block that shows the connection between A and B as + // A's sibling and B's parent. + // Specifically, since A is of lower height, it must be that B was mined omitting A from its tipset + // + // B + // | + // [A, C] + if types.CidArrsEqual(blockA.Parents, blockC.Parents) && blockA.Height == blockC.Height && + types.CidArrsContains(blockB.Parents, blockC.Cid()) && !types.CidArrsContains(blockB.Parents, blockA.Cid()) { + return blockA, blockC, true, nil + } + + log.Error("unexpectedly reached end of slashFilterMinedBlock despite fault being reported!") + return nil, nil, false, nil +} diff --git a/chain/rand/rand.go b/chain/rand/rand.go index c35280ab5..40f9f593a 100644 --- a/chain/rand/rand.go +++ b/chain/rand/rand.go @@ -17,18 +17,20 @@ import ( "github.com/filecoin-project/lotus/chain/beacon" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/chain/vm" ) var log = logging.Logger("rand") -func DrawRandomness(rbase []byte, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) { +func DrawRandomnessFromBase(rbase []byte, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) { + return DrawRandomnessFromDigest(blake2b.Sum256(rbase), pers, round, entropy) +} + +func DrawRandomnessFromDigest(digest [32]byte, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) { h := blake2b.New256() if err := binary.Write(h, binary.BigEndian, int64(pers)); err != nil { return nil, xerrors.Errorf("deriving randomness: %w", err) } - VRFDigest := blake2b.Sum256(rbase) - _, err := h.Write(VRFDigest[:]) + _, err := h.Write(digest[:]) if err != nil { return nil, xerrors.Errorf("hashing VRFDigest: %w", err) } @@ -70,18 +72,18 @@ func (sr *stateRand) GetBeaconRandomnessTipset(ctx context.Context, round abi.Ch return randTs, nil } -func (sr *stateRand) getChainRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte, lookback bool) ([]byte, error) { +func (sr *stateRand) getChainRandomness(ctx context.Context, round abi.ChainEpoch, lookback bool) ([32]byte, error) { _, span := trace.StartSpan(ctx, "store.GetChainRandomness") defer span.End() span.AddAttributes(trace.Int64Attribute("round", int64(round))) ts, err := sr.cs.LoadTipSet(ctx, types.NewTipSetKey(sr.blks...)) if err != nil { - return nil, err + return [32]byte{}, err } if round > ts.Height() { - return nil, xerrors.Errorf("cannot draw randomness from the future") + return [32]byte{}, xerrors.Errorf("cannot draw randomness from the future") } searchHeight := round @@ -91,14 +93,10 @@ func (sr *stateRand) getChainRandomness(ctx context.Context, pers crypto.DomainS randTs, err := sr.cs.GetTipsetByHeight(ctx, searchHeight, ts, lookback) if err != nil { - return nil, err + return [32]byte{}, err } - mtb := randTs.MinTicketBlock() - - // if at (or just past -- for null epochs) appropriate epoch - // or at genesis (works for negative epochs) - return DrawRandomness(mtb.Ticket.VRFProof, pers, round, entropy) + return blake2b.Sum256(randTs.MinTicketBlock().Ticket.VRFProof), nil } type NetworkVersionGetter func(context.Context, abi.ChainEpoch) network.Version @@ -110,7 +108,12 @@ type stateRand struct { networkVersionGetter NetworkVersionGetter } -func NewStateRand(cs *store.ChainStore, blks []cid.Cid, b beacon.Schedule, networkVersionGetter NetworkVersionGetter) vm.Rand { +type Rand interface { + GetChainRandomness(ctx context.Context, round abi.ChainEpoch) ([32]byte, error) + GetBeaconRandomness(ctx context.Context, round abi.ChainEpoch) ([32]byte, error) +} + +func NewStateRand(cs *store.ChainStore, blks []cid.Cid, b beacon.Schedule, networkVersionGetter NetworkVersionGetter) Rand { return &stateRand{ cs: cs, blks: blks, @@ -120,76 +123,102 @@ func NewStateRand(cs *store.ChainStore, blks []cid.Cid, b beacon.Schedule, netwo } // network v0-12 -func (sr *stateRand) getBeaconRandomnessV1(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) { +func (sr *stateRand) getBeaconRandomnessV1(ctx context.Context, round abi.ChainEpoch) ([32]byte, error) { randTs, err := sr.GetBeaconRandomnessTipset(ctx, round, true) if err != nil { - return nil, err + return [32]byte{}, err } be, err := sr.cs.GetLatestBeaconEntry(ctx, randTs) if err != nil { - return nil, err + return [32]byte{}, err } - // if at (or just past -- for null epochs) appropriate epoch - // or at genesis (works for negative epochs) - return DrawRandomness(be.Data, pers, round, entropy) + return blake2b.Sum256(be.Data), nil } // network v13 -func (sr *stateRand) getBeaconRandomnessV2(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) { +func (sr *stateRand) getBeaconRandomnessV2(ctx context.Context, round abi.ChainEpoch) ([32]byte, error) { randTs, err := sr.GetBeaconRandomnessTipset(ctx, round, false) if err != nil { - return nil, err + return [32]byte{}, err } be, err := sr.cs.GetLatestBeaconEntry(ctx, randTs) if err != nil { - return nil, err + return [32]byte{}, err } - // if at (or just past -- for null epochs) appropriate epoch - // or at genesis (works for negative epochs) - return DrawRandomness(be.Data, pers, round, entropy) + return blake2b.Sum256(be.Data), nil } // network v14 and on -func (sr *stateRand) getBeaconRandomnessV3(ctx context.Context, pers crypto.DomainSeparationTag, filecoinEpoch abi.ChainEpoch, entropy []byte) ([]byte, error) { +func (sr *stateRand) getBeaconRandomnessV3(ctx context.Context, filecoinEpoch abi.ChainEpoch) ([32]byte, error) { if filecoinEpoch < 0 { - return sr.getBeaconRandomnessV2(ctx, pers, filecoinEpoch, entropy) + return sr.getBeaconRandomnessV2(ctx, filecoinEpoch) } be, err := sr.extractBeaconEntryForEpoch(ctx, filecoinEpoch) if err != nil { log.Errorf("failed to get beacon entry as expected: %s", err) - return nil, err + return [32]byte{}, err } - return DrawRandomness(be.Data, pers, filecoinEpoch, entropy) + return blake2b.Sum256(be.Data), nil } -func (sr *stateRand) GetChainRandomness(ctx context.Context, pers crypto.DomainSeparationTag, filecoinEpoch abi.ChainEpoch, entropy []byte) ([]byte, error) { +func (sr *stateRand) GetChainRandomness(ctx context.Context, filecoinEpoch abi.ChainEpoch) ([32]byte, error) { nv := sr.networkVersionGetter(ctx, filecoinEpoch) if nv >= network.Version13 { - return sr.getChainRandomness(ctx, pers, filecoinEpoch, entropy, false) + return sr.getChainRandomness(ctx, filecoinEpoch, false) } - return sr.getChainRandomness(ctx, pers, filecoinEpoch, entropy, true) + return sr.getChainRandomness(ctx, filecoinEpoch, true) } -func (sr *stateRand) GetBeaconRandomness(ctx context.Context, pers crypto.DomainSeparationTag, filecoinEpoch abi.ChainEpoch, entropy []byte) ([]byte, error) { +func (sr *stateRand) GetBeaconRandomness(ctx context.Context, filecoinEpoch abi.ChainEpoch) ([32]byte, error) { nv := sr.networkVersionGetter(ctx, filecoinEpoch) if nv >= network.Version14 { - return sr.getBeaconRandomnessV3(ctx, pers, filecoinEpoch, entropy) + return sr.getBeaconRandomnessV3(ctx, filecoinEpoch) } else if nv == network.Version13 { - return sr.getBeaconRandomnessV2(ctx, pers, filecoinEpoch, entropy) + return sr.getBeaconRandomnessV2(ctx, filecoinEpoch) } else { - return sr.getBeaconRandomnessV1(ctx, pers, filecoinEpoch, entropy) + return sr.getBeaconRandomnessV1(ctx, filecoinEpoch) } } +func (sr *stateRand) DrawChainRandomness(ctx context.Context, pers crypto.DomainSeparationTag, filecoinEpoch abi.ChainEpoch, entropy []byte) ([]byte, error) { + digest, err := sr.GetChainRandomness(ctx, filecoinEpoch) + + if err != nil { + return nil, xerrors.Errorf("failed to get chain randomness: %w", err) + } + + ret, err := DrawRandomnessFromDigest(digest, pers, filecoinEpoch, entropy) + if err != nil { + return nil, xerrors.Errorf("failed to draw chain randomness: %w", err) + } + + return ret, nil +} + +func (sr *stateRand) DrawBeaconRandomness(ctx context.Context, pers crypto.DomainSeparationTag, filecoinEpoch abi.ChainEpoch, entropy []byte) ([]byte, error) { + digest, err := sr.GetBeaconRandomness(ctx, filecoinEpoch) + + if err != nil { + return nil, xerrors.Errorf("failed to get beacon randomness: %w", err) + } + + ret, err := DrawRandomnessFromDigest(digest, pers, filecoinEpoch, entropy) + if err != nil { + return nil, xerrors.Errorf("failed to draw beacon randomness: %w", err) + } + + return ret, nil +} + func (sr *stateRand) extractBeaconEntryForEpoch(ctx context.Context, filecoinEpoch abi.ChainEpoch) (*types.BeaconEntry, error) { randTs, err := sr.GetBeaconRandomnessTipset(ctx, filecoinEpoch, false) if err != nil { diff --git a/chain/rand/rand_test.go b/chain/rand/rand_test.go index acd928854..e2e722165 100644 --- a/chain/rand/rand_test.go +++ b/chain/rand/rand_test.go @@ -69,7 +69,7 @@ func TestNullRandomnessV1(t *testing.T) { } //stm: @BLOCKCHAIN_RAND_DRAW_RANDOMNESS_01 - rand2, err := rand.DrawRandomness(resp.Entry.Data, pers, randEpoch, entropy) + rand2, err := rand.DrawRandomnessFromBase(resp.Entry.Data, pers, randEpoch, entropy) if err != nil { t.Fatal(err) } @@ -148,8 +148,8 @@ func TestNullRandomnessV2(t *testing.T) { } //stm: @BLOCKCHAIN_RAND_DRAW_RANDOMNESS_01, @BLOCKCHAIN_RAND_EXTRACT_BEACON_ENTRY_FOR_EPOCH_01, @BLOCKCHAIN_RAND_GET_BEACON_RANDOMNESS_TIPSET_03 - // note that the randEpoch passed to DrawRandomness is still randEpoch (not the latest ts height) - rand2, err := rand.DrawRandomness(resp.Entry.Data, pers, randEpoch, entropy) + // note that the randEpoch passed to DrawRandomnessFromBase is still randEpoch (not the latest ts height) + rand2, err := rand.DrawRandomnessFromBase(resp.Entry.Data, pers, randEpoch, entropy) if err != nil { t.Fatal(err) } @@ -232,7 +232,7 @@ func TestNullRandomnessV3(t *testing.T) { } //stm: @BLOCKCHAIN_RAND_DRAW_RANDOMNESS_01 - rand2, err := rand.DrawRandomness(resp.Entry.Data, pers, randEpoch, entropy) + rand2, err := rand.DrawRandomnessFromBase(resp.Entry.Data, pers, randEpoch, entropy) if err != nil { t.Fatal(err) } diff --git a/chain/stmgr/actors.go b/chain/stmgr/actors.go index 4de39c7f1..56744fa74 100644 --- a/chain/stmgr/actors.go +++ b/chain/stmgr/actors.go @@ -355,7 +355,7 @@ func MinerGetBaseInfo(ctx context.Context, sm *StateManager, bcs beacon.Schedule return nil, xerrors.Errorf("failed to marshal miner address: %w", err) } - prand, err := rand.DrawRandomness(rbase.Data, crypto.DomainSeparationTag_WinningPoStChallengeSeed, round, buf.Bytes()) + prand, err := rand.DrawRandomnessFromBase(rbase.Data, crypto.DomainSeparationTag_WinningPoStChallengeSeed, round, buf.Bytes()) if err != nil { return nil, xerrors.Errorf("failed to get randomness for winning post: %w", err) } diff --git a/chain/stmgr/forks.go b/chain/stmgr/forks.go index 1f9977d96..9d59b5428 100644 --- a/chain/stmgr/forks.go +++ b/chain/stmgr/forks.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "encoding/binary" + "errors" "os" "sort" "strings" @@ -11,6 +12,7 @@ import ( "time" "github.com/ipfs/go-cid" + "github.com/ipfs/go-datastore" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" @@ -177,11 +179,15 @@ func (sm *StateManager) HandleStateForks(ctx context.Context, root cid.Cid, heig u := sm.stateMigrations[height] if u != nil && u.upgrade != nil { migCid, ok, err := u.migrationResultCache.Get(ctx, root) - if err == nil && ok { - log.Infow("CACHED migration", "height", height, "from", root, "to", migCid) - return migCid, nil - } else if err != nil { + if err == nil { + if ok { + log.Infow("CACHED migration", "height", height, "from", root, "to", migCid) + return migCid, nil + } + } else if !errors.Is(err, datastore.ErrNotFound) { log.Errorw("failed to lookup previous migration result", "err", err) + } else { + log.Debug("no cached migration found, migrating from scratch") } startTime := time.Now() diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index 12b991e57..85c82c6f1 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -509,7 +509,17 @@ func (sm *StateManager) GetRandomnessFromBeacon(ctx context.Context, personaliza r := rand.NewStateRand(sm.ChainStore(), pts.Cids(), sm.beacon, sm.GetNetworkVersion) - return r.GetBeaconRandomness(ctx, personalization, randEpoch, entropy) + digest, err := r.GetBeaconRandomness(ctx, randEpoch) + if err != nil { + return nil, xerrors.Errorf("getting beacon randomness: %w", err) + } + + ret, err := rand.DrawRandomnessFromDigest(digest, personalization, randEpoch, entropy) + if err != nil { + return nil, xerrors.Errorf("drawing beacon randomness: %w", err) + } + + return ret, nil } @@ -521,5 +531,38 @@ func (sm *StateManager) GetRandomnessFromTickets(ctx context.Context, personaliz r := rand.NewStateRand(sm.ChainStore(), pts.Cids(), sm.beacon, sm.GetNetworkVersion) - return r.GetChainRandomness(ctx, personalization, randEpoch, entropy) + digest, err := r.GetChainRandomness(ctx, randEpoch) + if err != nil { + return nil, xerrors.Errorf("getting chain randomness: %w", err) + } + + ret, err := rand.DrawRandomnessFromDigest(digest, personalization, randEpoch, entropy) + if err != nil { + return nil, xerrors.Errorf("drawing chain randomness: %w", err) + } + + return ret, nil +} + +func (sm *StateManager) GetRandomnessDigestFromBeacon(ctx context.Context, randEpoch abi.ChainEpoch, tsk types.TipSetKey) ([32]byte, error) { + pts, err := sm.ChainStore().GetTipSetFromKey(ctx, tsk) + if err != nil { + return [32]byte{}, xerrors.Errorf("loading tipset %s: %w", tsk, err) + } + + r := rand.NewStateRand(sm.ChainStore(), pts.Cids(), sm.beacon, sm.GetNetworkVersion) + + return r.GetBeaconRandomness(ctx, randEpoch) + +} + +func (sm *StateManager) GetRandomnessDigestFromTickets(ctx context.Context, randEpoch abi.ChainEpoch, tsk types.TipSetKey) ([32]byte, error) { + pts, err := sm.ChainStore().LoadTipSet(ctx, tsk) + if err != nil { + return [32]byte{}, xerrors.Errorf("loading tipset key: %w", err) + } + + r := rand.NewStateRand(sm.ChainStore(), pts.Cids(), sm.beacon, sm.GetNetworkVersion) + + return r.GetChainRandomness(ctx, randEpoch) } diff --git a/chain/vm/fvm.go b/chain/vm/fvm.go index 7c79972c7..901374a4f 100644 --- a/chain/vm/fvm.go +++ b/chain/vm/fvm.go @@ -33,6 +33,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/aerrors" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" + "github.com/filecoin-project/lotus/chain/rand" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/lib/sigs" @@ -43,7 +44,7 @@ var _ Interface = (*FVM)(nil) var _ ffi_cgo.Externs = (*FvmExtern)(nil) type FvmExtern struct { - Rand + rand.Rand blockstore.Blockstore epoch abi.ChainEpoch lbState LookbackStateGetter @@ -520,10 +521,6 @@ func (vm *FVM) ApplyImplicitMessage(ctx context.Context, cmsg *types.Message) (* } } - if ret.ExitCode != 0 { - return applyRet, fmt.Errorf("implicit message failed with exit code: %d and error: %w", ret.ExitCode, applyRet.ActorErr) - } - return applyRet, nil } diff --git a/chain/vm/runtime.go b/chain/vm/runtime.go index a5b108238..355fcea2b 100644 --- a/chain/vm/runtime.go +++ b/chain/vm/runtime.go @@ -33,6 +33,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/aerrors" "github.com/filecoin-project/lotus/chain/actors/builtin" + "github.com/filecoin-project/lotus/chain/rand" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/types" ) @@ -229,21 +230,35 @@ func (rt *Runtime) GetActorCodeCID(addr address.Address) (ret cid.Cid, ok bool) } func (rt *Runtime) GetRandomnessFromTickets(personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) abi.Randomness { - res, err := rt.vm.rand.GetChainRandomness(rt.ctx, personalization, randEpoch, entropy) + digest, err := rt.vm.rand.GetChainRandomness(rt.ctx, randEpoch) if err != nil { panic(aerrors.Fatalf("could not get ticket randomness: %s", err)) } - return res + + ret, err := rand.DrawRandomnessFromDigest(digest, personalization, randEpoch, entropy) + + if err != nil { + panic(aerrors.Fatalf("could not draw ticket randomness: %s", err)) + } + + return ret } func (rt *Runtime) GetRandomnessFromBeacon(personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) abi.Randomness { - res, err := rt.vm.rand.GetBeaconRandomness(rt.ctx, personalization, randEpoch, entropy) + digest, err := rt.vm.rand.GetBeaconRandomness(rt.ctx, randEpoch) if err != nil { - panic(aerrors.Fatalf("could not get beacon randomness: %s", err)) + panic(aerrors.Fatalf("could not get ticket randomness: %s", err)) } - return res + + ret, err := rand.DrawRandomnessFromDigest(digest, personalization, randEpoch, entropy) + + if err != nil { + panic(aerrors.Fatalf("could not draw ticket randomness: %s", err)) + } + + return ret } func (rt *Runtime) NewActorAddress() address.Address { diff --git a/chain/vm/vm.go b/chain/vm/vm.go index 58afc14bc..8f4c89e92 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -21,7 +21,6 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" builtin_types "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/network" @@ -32,6 +31,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/builtin/account" "github.com/filecoin-project/lotus/chain/actors/builtin/reward" + "github.com/filecoin-project/lotus/chain/rand" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/metrics" @@ -224,7 +224,7 @@ type LegacyVM struct { buf *blockstore.BufferedBlockstore blockHeight abi.ChainEpoch areg *ActorRegistry - rand Rand + rand rand.Rand circSupplyCalc CircSupplyCalculator networkVersion network.Version baseFee abi.TokenAmount @@ -238,7 +238,7 @@ type VMOpts struct { StateBase cid.Cid Epoch abi.ChainEpoch Timestamp uint64 - Rand Rand + Rand rand.Rand Bstore blockstore.Blockstore Actors *ActorRegistry Syscalls SyscallBuilder @@ -287,11 +287,6 @@ func NewLegacyVM(ctx context.Context, opts *VMOpts) (*LegacyVM, error) { }, nil } -type Rand interface { - GetChainRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) - GetBeaconRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) -} - type ApplyRet struct { types.MessageReceipt ActorErr aerrors.ActorError diff --git a/cmd/lotus-miner/precommits-info.go b/cmd/lotus-miner/precommits-info.go index 0ce757537..3f9e8c927 100644 --- a/cmd/lotus-miner/precommits-info.go +++ b/cmd/lotus-miner/precommits-info.go @@ -7,7 +7,6 @@ import ( cbor "github.com/ipfs/go-ipld-cbor" "github.com/urfave/cli/v2" - minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/specs-actors/v7/actors/util/adt" "github.com/filecoin-project/lotus/blockstore" @@ -39,8 +38,8 @@ var sectorPreCommitsCmd = &cli.Command{ if err != nil { return err } - preCommitSector := make([]minertypes.SectorPreCommitOnChainInfo, 0) - err = mst.ForEachPrecommittedSector(func(info minertypes.SectorPreCommitOnChainInfo) error { + preCommitSector := make([]miner.SectorPreCommitOnChainInfo, 0) + err = mst.ForEachPrecommittedSector(func(info miner.SectorPreCommitOnChainInfo) error { preCommitSector = append(preCommitSector, info) return err }) diff --git a/cmd/lotus-miner/sectors.go b/cmd/lotus-miner/sectors.go index 4c00aeb81..f7bec3ccb 100644 --- a/cmd/lotus-miner/sectors.go +++ b/cmd/lotus-miner/sectors.go @@ -24,14 +24,13 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" - lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/types" @@ -193,14 +192,14 @@ var sectorsStatusCmd = &cli.Command{ } tbs := blockstore.NewTieredBstore(blockstore.NewAPIBlockstore(fullApi), blockstore.NewMemory()) - mas, err := lminer.Load(adt.WrapStore(ctx, cbor.NewCborStore(tbs)), mact) + mas, err := miner.Load(adt.WrapStore(ctx, cbor.NewCborStore(tbs)), mact) if err != nil { return err } errFound := errors.New("found") - if err := mas.ForEachDeadline(func(dlIdx uint64, dl lminer.Deadline) error { - return dl.ForEachPartition(func(partIdx uint64, part lminer.Partition) error { + if err := mas.ForEachDeadline(func(dlIdx uint64, dl miner.Deadline) error { + return dl.ForEachPartition(func(partIdx uint64, part miner.Partition) error { pas, err := part.AllSectors() if err != nil { return err @@ -1075,22 +1074,22 @@ var sectorsExtendCmd = &cli.Command{ tbs := blockstore.NewTieredBstore(blockstore.NewAPIBlockstore(fullApi), blockstore.NewMemory()) adtStore := adt.WrapStore(ctx, cbor.NewCborStore(tbs)) - mas, err := lminer.Load(adtStore, mact) + mas, err := miner.Load(adtStore, mact) if err != nil { return err } - activeSectorsLocation := make(map[abi.SectorNumber]*lminer.SectorLocation, len(activeSet)) + activeSectorsLocation := make(map[abi.SectorNumber]*miner.SectorLocation, len(activeSet)) - if err := mas.ForEachDeadline(func(dlIdx uint64, dl lminer.Deadline) error { - return dl.ForEachPartition(func(partIdx uint64, part lminer.Partition) error { + if err := mas.ForEachDeadline(func(dlIdx uint64, dl miner.Deadline) error { + return dl.ForEachPartition(func(partIdx uint64, part miner.Partition) error { pas, err := part.ActiveSectors() if err != nil { return err } return pas.ForEach(func(i uint64) error { - activeSectorsLocation[abi.SectorNumber(i)] = &lminer.SectorLocation{ + activeSectorsLocation[abi.SectorNumber(i)] = &miner.SectorLocation{ Deadline: dlIdx, Partition: partIdx, } @@ -1177,7 +1176,7 @@ var sectorsExtendCmd = &cli.Command{ return diff <= abi.ChainEpoch(cctx.Int64("tolerance")) } - extensions := map[lminer.SectorLocation]map[abi.ChainEpoch][]abi.SectorNumber{} + extensions := map[miner.SectorLocation]map[abi.ChainEpoch][]abi.SectorNumber{} for _, si := range sis { extension := abi.ChainEpoch(cctx.Int64("extension")) newExp := si.Expiration + extension @@ -1741,7 +1740,7 @@ var sectorsCapacityCollateralCmd = &cli.Command{ return err } - spt, err := lminer.PreferredSealProofTypeFromWindowPoStType(nv, mi.WindowPoStProofType, false) + spt, err := miner.PreferredSealProofTypeFromWindowPoStType(nv, mi.WindowPoStProofType) if err != nil { return err } @@ -1910,7 +1909,7 @@ var sectorsExpiredCmd = &cli.Command{ } tbs := blockstore.NewTieredBstore(blockstore.NewAPIBlockstore(fullApi), blockstore.NewMemory()) - mas, err := lminer.Load(adt.WrapStore(ctx, cbor.NewCborStore(tbs)), mact) + mas, err := miner.Load(adt.WrapStore(ctx, cbor.NewCborStore(tbs)), mact) if err != nil { return err } @@ -1926,8 +1925,8 @@ var sectorsExpiredCmd = &cli.Command{ return xerrors.Errorf("intersecting bitfields: %w", err) } - if err := mas.ForEachDeadline(func(dlIdx uint64, dl lminer.Deadline) error { - return dl.ForEachPartition(func(partIdx uint64, part lminer.Partition) error { + if err := mas.ForEachDeadline(func(dlIdx uint64, dl miner.Deadline) error { + return dl.ForEachPartition(func(partIdx uint64, part miner.Partition) error { live, err := part.LiveSectors() if err != nil { return err diff --git a/cmd/lotus/daemon.go b/cmd/lotus/daemon.go index 106446c0a..fbb9dfd9a 100644 --- a/cmd/lotus/daemon.go +++ b/cmd/lotus/daemon.go @@ -16,12 +16,9 @@ import ( "strings" "github.com/DataDog/zstd" - "github.com/ipfs/go-cid" - levelds "github.com/ipfs/go-ds-leveldb" metricsprom "github.com/ipfs/go-metrics-prometheus" "github.com/mitchellh/go-homedir" "github.com/multiformats/go-multiaddr" - ldbopts "github.com/syndtr/goleveldb/leveldb/opt" "github.com/urfave/cli/v2" "go.opencensus.io/plugin/runmetrics" "go.opencensus.io/stats" @@ -30,19 +27,13 @@ import ( "golang.org/x/xerrors" "gopkg.in/cheggaaa/pb.v1" - "github.com/filecoin-project/go-address" - cborutil "github.com/filecoin-project/go-cbor-util" "github.com/filecoin-project/go-jsonrpc" "github.com/filecoin-project/go-paramfetch" - "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/specs-actors/actors/builtin/miner" lapi "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/consensus" "github.com/filecoin-project/lotus/chain/consensus/filcns" - "github.com/filecoin-project/lotus/chain/gen/slashfilter" "github.com/filecoin-project/lotus/chain/index" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" @@ -169,19 +160,6 @@ var DaemonCmd = &cli.Command{ Name: "restore-config", Usage: "config file to use when restoring from backup", }, - &cli.BoolFlag{ - Name: "slash-consensus", - Usage: "Report consensus fault", - Value: false, - }, - &cli.StringFlag{ - Name: "slasher-sender", - Usage: "optionally specify the account to report consensus from", - }, - &cli.StringFlag{ - Name: "slashdb-dir", - Value: "slash watch db dir path", - }, }, Action: func(cctx *cli.Context) error { isLite := cctx.Bool("lite") @@ -402,14 +380,7 @@ var DaemonCmd = &cli.Command{ if err != nil { return fmt.Errorf("failed to start json-rpc endpoint: %s", err) } - if cctx.IsSet("slash-consensus") && cctx.IsSet("slashdb-dir") { - go func() { - err := slashConsensus(api, cctx.String("slashdb-dir"), cctx.String("slasher-sender")) - if err != nil { - panic("slashConsensus error") - } - }() - } + // Monitor for shutdown. finishCh := node.MonitorShutdown(shutdownChan, node.ShutdownHandler{Component: "rpc server", StopFunc: rpcStopper}, @@ -603,122 +574,3 @@ func ImportChain(ctx context.Context, r repo.Repo, fname string, snapshot bool) return nil } - -func slashConsensus(a lapi.FullNode, p string, from string) error { - ctx := context.Background() - var fromAddr address.Address - - ds, err := levelds.NewDatastore(p, &levelds.Options{ - Compression: ldbopts.NoCompression, - NoSync: false, - Strict: ldbopts.StrictAll, - ReadOnly: false, - }) - if err != nil { - return xerrors.Errorf("open leveldb: %w", err) - } - sf := slashfilter.New(ds) - if from == "" { - defaddr, err := a.WalletDefaultAddress(ctx) - if err != nil { - return err - } - fromAddr = defaddr - } else { - addr, err := address.NewFromString(from) - if err != nil { - return err - } - - fromAddr = addr - } - - blocks, err := a.SyncIncomingBlocks(ctx) - if err != nil { - return xerrors.Errorf("sync incoming blocks failed: %w", err) - } - for block := range blocks { - log.Infof("deal with block: %d, %v, %s", block.Height, block.Miner, block.Cid()) - if otherBlock, extraBlock, err := slashFilterMinedBlock(ctx, sf, a, block); err != nil { - if otherBlock == nil { - continue - } - log.Errorf(" SLASH FILTER ERROR: %s", err) - bh1, err := cborutil.Dump(otherBlock) - if err != nil { - log.Errorf("could not dump otherblock:%s, err:%s", otherBlock.Cid(), err) - continue - } - - bh2, err := cborutil.Dump(block) - if err != nil { - log.Errorf("could not dump block:%s, err:%s", block.Cid(), err) - continue - } - - params := miner.ReportConsensusFaultParams{ - BlockHeader1: bh1, - BlockHeader2: bh2, - } - if extraBlock != nil { - be, err := cborutil.Dump(extraBlock) - if err != nil { - log.Errorf("could not dump block:%s, err:%s", block.Cid(), err) - continue - } - params.BlockHeaderExtra = be - } - - enc, err := actors.SerializeParams(¶ms) - if err != nil { - log.Errorf("could not serialize declare faults parameters: %s", err) - continue - } - message, err := a.MpoolPushMessage(ctx, &types.Message{ - To: block.Miner, - From: fromAddr, - Value: types.NewInt(0), - Method: builtin.MethodsMiner.ReportConsensusFault, - Params: enc, - }, nil) - if err != nil { - log.Errorf("ReportConsensusFault to messagepool error:%w", err) - continue - } - log.Infof("ReportConsensusFault message CID:%s", message.Cid()) - - } - } - return err -} - -func slashFilterMinedBlock(ctx context.Context, sf *slashfilter.SlashFilter, a lapi.FullNode, blockB *types.BlockHeader) (*types.BlockHeader, *types.BlockHeader, error) { - blockC, err := a.ChainGetBlock(ctx, blockB.Parents[0]) - if err != nil { - return nil, nil, xerrors.Errorf("chain get block error:%s", err) - } - otherCid, err := sf.MinedBlock(ctx, blockB, blockC.Height) - if err != nil { - return nil, nil, xerrors.Errorf("slash filter check block error:%s", err) - } - if otherCid != cid.Undef { - otherHeader, err := a.ChainGetBlock(ctx, otherCid) - return otherHeader, nil, xerrors.Errorf("chain get other block error:%s", err) - } - blockA, err := a.ChainGetBlock(ctx, otherCid) - - // (c) parent-grinding fault - // Here extra is the "witness", a third block that shows the connection between A and B as - // A's sibling and B's parent. - // Specifically, since A is of lower height, it must be that B was mined omitting A from its tipset - // - // B - // | - // [A, C] - if types.CidArrsEqual(blockA.Parents, blockC.Parents) && blockA.Height == blockC.Height && - types.CidArrsContains(blockB.Parents, blockC.Cid()) && !types.CidArrsContains(blockB.Parents, blockA.Cid()) { - return blockA, blockC, xerrors.Errorf("chain get other block error:%s", err) - } - - return nil, nil, nil -} diff --git a/cmd/tvx/extract_message.go b/cmd/tvx/extract_message.go index 8ff8a2b79..95711414b 100644 --- a/cmd/tvx/extract_message.go +++ b/cmd/tvx/extract_message.go @@ -15,7 +15,8 @@ import ( "github.com/filecoin-project/test-vectors/schema" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/api/v0api" + lapi "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/api/v1api" "github.com/filecoin-project/lotus/chain/actors/builtin" init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" "github.com/filecoin-project/lotus/chain/actors/builtin/reward" @@ -207,7 +208,7 @@ func doExtractMessage(opts extractOpts) error { // TODO sometimes this returns a nil receipt and no error ¯\_(ツ)_/¯ // ex: https://filfox.info/en/message/bafy2bzacebpxw3yiaxzy2bako62akig46x3imji7fewszen6fryiz6nymu2b2 // This code is lenient and skips receipt comparison in case of a nil receipt. - rec, err := FullAPI.StateGetReceipt(ctx, mcid, execTs.Key()) + rec, err := FullAPI.StateSearchMsg(ctx, execTs.Key(), mcid, api.LookbackNoLimit, false) if err != nil { return fmt.Errorf("failed to find receipt on chain: %w", err) } @@ -217,9 +218,9 @@ func doExtractMessage(opts extractOpts) error { var receipt *schema.Receipt if rec != nil { receipt = &schema.Receipt{ - ExitCode: int64(rec.ExitCode), - ReturnValue: rec.Return, - GasUsed: rec.GasUsed, + ExitCode: int64(rec.Receipt.ExitCode), + ReturnValue: rec.Receipt.Return, + GasUsed: rec.Receipt.GasUsed, } reporter := new(conformance.LogReporter) @@ -326,7 +327,7 @@ func doExtractMessage(opts extractOpts) error { // resolveFromChain queries the chain for the provided message, using the block CID to // speed up the query, if provided -func resolveFromChain(ctx context.Context, api v0api.FullNode, mcid cid.Cid, block string) (msg *types.Message, execTs *types.TipSet, incTs *types.TipSet, err error) { +func resolveFromChain(ctx context.Context, api lapi.FullNode, mcid cid.Cid, block string) (msg *types.Message, execTs *types.TipSet, incTs *types.TipSet, err error) { // Extract the full message. msg, err = api.ChainGetMessage(ctx, mcid) if err != nil { @@ -339,7 +340,7 @@ func resolveFromChain(ctx context.Context, api v0api.FullNode, mcid cid.Cid, blo log.Printf("locating message in blockchain") // Locate the message. - msgInfo, err := api.StateSearchMsg(ctx, mcid) + msgInfo, err := api.StateSearchMsg(ctx, types.EmptyTSK, mcid, lapi.LookbackNoLimit, false) if err != nil { return nil, nil, nil, fmt.Errorf("failed to locate message: %w", err) } @@ -384,7 +385,7 @@ func resolveFromChain(ctx context.Context, api v0api.FullNode, mcid cid.Cid, blo // as the previous tipset. In the context of vector generation, the target // tipset is the one where a message was executed, and the previous tipset is // the one where the message was included. -func fetchThisAndPrevTipset(ctx context.Context, api v0api.FullNode, target types.TipSetKey) (targetTs *types.TipSet, prevTs *types.TipSet, err error) { +func fetchThisAndPrevTipset(ctx context.Context, api v1api.FullNode, target types.TipSetKey) (targetTs *types.TipSet, prevTs *types.TipSet, err error) { // get the tipset on which this message was "executed" on. // https://github.com/filecoin-project/lotus/issues/2847 targetTs, err = api.ChainGetTipSet(ctx, target) diff --git a/cmd/tvx/main.go b/cmd/tvx/main.go index b1541e4e1..5021dd64b 100644 --- a/cmd/tvx/main.go +++ b/cmd/tvx/main.go @@ -10,13 +10,13 @@ import ( "github.com/filecoin-project/go-jsonrpc" - "github.com/filecoin-project/lotus/api/v0api" + "github.com/filecoin-project/lotus/api/v1api" lcli "github.com/filecoin-project/lotus/cli" ) // FullAPI is a JSON-RPC client targeting a full node. It's initialized in a // cli.BeforeFunc. -var FullAPI v0api.FullNode +var FullAPI v1api.FullNode // Closer is the closer for the JSON-RPC client, which must be called on // cli.AfterFunc. @@ -102,7 +102,7 @@ func initialize(c *cli.Context) error { // Make the API client. var err error - if FullAPI, Closer, err = lcli.GetFullNodeAPI(c); err != nil { + if FullAPI, Closer, err = lcli.GetFullNodeAPIV1(c); err != nil { err = fmt.Errorf("failed to locate Lotus node; err: %w", err) } return err diff --git a/cmd/tvx/state.go b/cmd/tvx/state.go index 120eddd6b..9674bf17e 100644 --- a/cmd/tvx/state.go +++ b/cmd/tvx/state.go @@ -14,7 +14,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/lotus/api/v0api" + "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/api/v1api" init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/types" @@ -24,13 +25,13 @@ import ( // StateSurgeon is an object used to fetch and manipulate state. type StateSurgeon struct { ctx context.Context - api v0api.FullNode + api v1api.FullNode stores *Stores } // NewSurgeon returns a state surgeon, an object used to fetch and manipulate // state. -func NewSurgeon(ctx context.Context, api v0api.FullNode, stores *Stores) *StateSurgeon { +func NewSurgeon(ctx context.Context, api v1api.FullNode, stores *Stores) *StateSurgeon { return &StateSurgeon{ ctx: ctx, api: api, @@ -86,9 +87,9 @@ func (sg *StateSurgeon) GetMaskedStateTree(previousRoot cid.Cid, retain []addres // GetAccessedActors identifies the actors that were accessed during the // execution of a message. -func (sg *StateSurgeon) GetAccessedActors(ctx context.Context, a v0api.FullNode, mid cid.Cid) ([]address.Address, error) { +func (sg *StateSurgeon) GetAccessedActors(ctx context.Context, a v1api.FullNode, mid cid.Cid) ([]address.Address, error) { log.Printf("calculating accessed actors during execution of message: %s", mid) - msgInfo, err := a.StateSearchMsg(ctx, mid) + msgInfo, err := a.StateSearchMsg(ctx, types.EmptyTSK, mid, api.LookbackNoLimit, false) if err != nil { return nil, err } diff --git a/cmd/tvx/stores.go b/cmd/tvx/stores.go index d4431a145..0ced44817 100644 --- a/cmd/tvx/stores.go +++ b/cmd/tvx/stores.go @@ -18,7 +18,7 @@ import ( format "github.com/ipfs/go-ipld-format" "golang.org/x/xerrors" - "github.com/filecoin-project/lotus/api/v0api" + "github.com/filecoin-project/lotus/api/v1api" "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -39,7 +39,7 @@ type Stores struct { // NewProxyingStores is a set of Stores backed by a proxying Blockstore that // proxies Get requests for unknown CIDs to a Filecoin node, via the // ChainReadObj RPC. -func NewProxyingStores(ctx context.Context, api v0api.FullNode) *Stores { +func NewProxyingStores(ctx context.Context, api v1api.FullNode) *Stores { ds := dssync.MutexWrap(ds.NewMapDatastore()) bs := &proxyingBlockstore{ ctx: ctx, @@ -84,7 +84,7 @@ type TracingBlockstore interface { // a Filecoin node via JSON-RPC. type proxyingBlockstore struct { ctx context.Context - api v0api.FullNode + api v1api.FullNode lk sync.Mutex tracing bool diff --git a/conformance/driver.go b/conformance/driver.go index eb5973f72..3c62ca7b9 100644 --- a/conformance/driver.go +++ b/conformance/driver.go @@ -23,6 +23,7 @@ import ( "github.com/filecoin-project/lotus/chain/consensus" "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/index" + "github.com/filecoin-project/lotus/chain/rand" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" @@ -89,9 +90,9 @@ type ExecuteTipsetParams struct { ParentEpoch abi.ChainEpoch Tipset *schema.Tipset ExecEpoch abi.ChainEpoch - // Rand is an optional vm.Rand implementation to use. If nil, the driver - // will use a vm.Rand that returns a fixed value for all calls. - Rand vm.Rand + // Rand is an optional rand.Rand implementation to use. If nil, the driver + // will use a rand.Rand that returns a fixed value for all calls. + Rand rand.Rand // BaseFee if not nil or zero, will override the basefee of the tipset. BaseFee abi.TokenAmount } @@ -200,9 +201,9 @@ type ExecuteMessageParams struct { BaseFee abi.TokenAmount NetworkVersion network.Version - // Rand is an optional vm.Rand implementation to use. If nil, the driver - // will use a vm.Rand that returns a fixed value for all calls. - Rand vm.Rand + // Rand is an optional rand.Rand implementation to use. If nil, the driver + // will use a rand.Rand that returns a fixed value for all calls. + Rand rand.Rand // Lookback is the LookbackStateGetter; returns the state tree at a given epoch. Lookback vm.LookbackStateGetter diff --git a/conformance/rand_fixed.go b/conformance/rand_fixed.go index d356b53d0..f35f05cd4 100644 --- a/conformance/rand_fixed.go +++ b/conformance/rand_fixed.go @@ -4,25 +4,24 @@ import ( "context" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/crypto" - "github.com/filecoin-project/lotus/chain/vm" + "github.com/filecoin-project/lotus/chain/rand" ) type fixedRand struct{} -var _ vm.Rand = (*fixedRand)(nil) +var _ rand.Rand = (*fixedRand)(nil) // NewFixedRand creates a test vm.Rand that always returns fixed bytes value // of utf-8 string 'i_am_random_____i_am_random_____'. -func NewFixedRand() vm.Rand { +func NewFixedRand() rand.Rand { return &fixedRand{} } -func (r *fixedRand) GetChainRandomness(_ context.Context, _ crypto.DomainSeparationTag, _ abi.ChainEpoch, _ []byte) ([]byte, error) { - return []byte("i_am_random_____i_am_random_____"), nil // 32 bytes. +func (r *fixedRand) GetChainRandomness(_ context.Context, _ abi.ChainEpoch) ([32]byte, error) { + return *(*[32]byte)([]byte("i_am_random_____i_am_random_____")), nil } -func (r *fixedRand) GetBeaconRandomness(_ context.Context, _ crypto.DomainSeparationTag, _ abi.ChainEpoch, _ []byte) ([]byte, error) { - return []byte("i_am_random_____i_am_random_____"), nil // 32 bytes. +func (r *fixedRand) GetBeaconRandomness(_ context.Context, _ abi.ChainEpoch) ([32]byte, error) { + return *(*[32]byte)([]byte("i_am_random_____i_am_random_____")), nil // 32 bytes. } diff --git a/conformance/rand_record.go b/conformance/rand_record.go index 277c984a7..4dc30b28e 100644 --- a/conformance/rand_record.go +++ b/conformance/rand_record.go @@ -6,17 +6,16 @@ import ( "sync" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/test-vectors/schema" - "github.com/filecoin-project/lotus/api/v0api" + "github.com/filecoin-project/lotus/api/v1api" + "github.com/filecoin-project/lotus/chain/rand" "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/chain/vm" ) type RecordingRand struct { reporter Reporter - api v0api.FullNode + api v1api.FullNode // once guards the loading of the head tipset. // can be removed when https://github.com/filecoin-project/lotus/issues/4223 @@ -27,12 +26,12 @@ type RecordingRand struct { recorded schema.Randomness } -var _ vm.Rand = (*RecordingRand)(nil) +var _ rand.Rand = (*RecordingRand)(nil) // NewRecordingRand returns a vm.Rand implementation that proxies calls to a // full Lotus node via JSON-RPC, and records matching rules and responses so // they can later be embedded in test vectors. -func NewRecordingRand(reporter Reporter, api v0api.FullNode) *RecordingRand { +func NewRecordingRand(reporter Reporter, api v1api.FullNode) *RecordingRand { return &RecordingRand{reporter: reporter, api: api} } @@ -44,22 +43,20 @@ func (r *RecordingRand) loadHead() { r.head = head.Key() } -func (r *RecordingRand) GetChainRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) { +func (r *RecordingRand) GetChainRandomness(ctx context.Context, round abi.ChainEpoch) ([32]byte, error) { r.once.Do(r.loadHead) - // FullNode's v0 ChainGetRandomnessFromTickets handles whether we should be looking forward or back - ret, err := r.api.ChainGetRandomnessFromTickets(ctx, r.head, pers, round, entropy) + // FullNode's v1 ChainGetRandomnessFromTickets handles whether we should be looking forward or back + ret, err := r.api.StateGetRandomnessDigestFromTickets(ctx, round, r.head) if err != nil { - return ret, err + return [32]byte{}, err } - r.reporter.Logf("fetched and recorded chain randomness for: dst=%d, epoch=%d, entropy=%x, result=%x", pers, round, entropy, ret) + r.reporter.Logf("fetched and recorded chain randomness for: epoch=%d, result=%x", round, ret) match := schema.RandomnessMatch{ On: schema.RandomnessRule{ - Kind: schema.RandomnessChain, - DomainSeparationTag: int64(pers), - Epoch: int64(round), - Entropy: entropy, + Kind: schema.RandomnessChain, + Epoch: int64(round), }, Return: []byte(ret), } @@ -67,24 +64,22 @@ func (r *RecordingRand) GetChainRandomness(ctx context.Context, pers crypto.Doma r.recorded = append(r.recorded, match) r.lk.Unlock() - return ret, err + return *(*[32]byte)(ret), err } -func (r *RecordingRand) GetBeaconRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) { +func (r *RecordingRand) GetBeaconRandomness(ctx context.Context, round abi.ChainEpoch) ([32]byte, error) { r.once.Do(r.loadHead) - ret, err := r.api.StateGetRandomnessFromBeacon(ctx, pers, round, entropy, r.head) + ret, err := r.api.StateGetRandomnessDigestFromBeacon(ctx, round, r.head) if err != nil { - return ret, err + return [32]byte{}, err } - r.reporter.Logf("fetched and recorded beacon randomness for: dst=%d, epoch=%d, entropy=%x, result=%x", pers, round, entropy, ret) + r.reporter.Logf("fetched and recorded beacon randomness for: epoch=%d, result=%x", round, ret) match := schema.RandomnessMatch{ On: schema.RandomnessRule{ - Kind: schema.RandomnessBeacon, - DomainSeparationTag: int64(pers), - Epoch: int64(round), - Entropy: entropy, + Kind: schema.RandomnessBeacon, + Epoch: int64(round), }, Return: []byte(ret), } @@ -92,7 +87,7 @@ func (r *RecordingRand) GetBeaconRandomness(ctx context.Context, pers crypto.Dom r.recorded = append(r.recorded, match) r.lk.Unlock() - return ret, err + return *(*[32]byte)(ret), err } func (r *RecordingRand) Recorded() schema.Randomness { diff --git a/conformance/rand_replay.go b/conformance/rand_replay.go index ef19e41bb..6d78d813b 100644 --- a/conformance/rand_replay.go +++ b/conformance/rand_replay.go @@ -1,23 +1,21 @@ package conformance import ( - "bytes" "context" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/test-vectors/schema" - "github.com/filecoin-project/lotus/chain/vm" + "github.com/filecoin-project/lotus/chain/rand" ) type ReplayingRand struct { reporter Reporter recorded schema.Randomness - fallback vm.Rand + fallback rand.Rand } -var _ vm.Rand = (*ReplayingRand)(nil) +var _ rand.Rand = (*ReplayingRand)(nil) // NewReplayingRand replays recorded randomness when requested, falling back to // fixed randomness if the value cannot be found; hence this is a safe @@ -30,50 +28,44 @@ func NewReplayingRand(reporter Reporter, recorded schema.Randomness) *ReplayingR } } -func (r *ReplayingRand) match(requested schema.RandomnessRule) ([]byte, bool) { +func (r *ReplayingRand) match(requested schema.RandomnessRule) ([32]byte, bool) { for _, other := range r.recorded { if other.On.Kind == requested.Kind && - other.On.Epoch == requested.Epoch && - other.On.DomainSeparationTag == requested.DomainSeparationTag && - bytes.Equal(other.On.Entropy, requested.Entropy) { - return other.Return, true + other.On.Epoch == requested.Epoch { + return *(*[32]byte)(other.Return), true } } - return nil, false + return [32]byte{}, false } -func (r *ReplayingRand) GetChainRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) { +func (r *ReplayingRand) GetChainRandomness(ctx context.Context, round abi.ChainEpoch) ([32]byte, error) { rule := schema.RandomnessRule{ - Kind: schema.RandomnessChain, - DomainSeparationTag: int64(pers), - Epoch: int64(round), - Entropy: entropy, + Kind: schema.RandomnessChain, + Epoch: int64(round), } if ret, ok := r.match(rule); ok { - r.reporter.Logf("returning saved chain randomness: dst=%d, epoch=%d, entropy=%x, result=%x", pers, round, entropy, ret) + r.reporter.Logf("returning saved chain randomness: epoch=%d, result=%x", round, ret) return ret, nil } - r.reporter.Logf("returning fallback chain randomness: dst=%d, epoch=%d, entropy=%x", pers, round, entropy) + r.reporter.Logf("returning fallback chain randomness: epoch=%d", round) - return r.fallback.GetChainRandomness(ctx, pers, round, entropy) + return r.fallback.GetChainRandomness(ctx, round) } -func (r *ReplayingRand) GetBeaconRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) { +func (r *ReplayingRand) GetBeaconRandomness(ctx context.Context, round abi.ChainEpoch) ([32]byte, error) { rule := schema.RandomnessRule{ - Kind: schema.RandomnessBeacon, - DomainSeparationTag: int64(pers), - Epoch: int64(round), - Entropy: entropy, + Kind: schema.RandomnessBeacon, + Epoch: int64(round), } if ret, ok := r.match(rule); ok { - r.reporter.Logf("returning saved beacon randomness: dst=%d, epoch=%d, entropy=%x, result=%x", pers, round, entropy, ret) + r.reporter.Logf("returning saved beacon randomness: epoch=%d, result=%x", round, ret) return ret, nil } - r.reporter.Logf("returning fallback beacon randomness: dst=%d, epoch=%d, entropy=%x", pers, round, entropy) + r.reporter.Logf("returning fallback beacon randomness: epoch=%d, ", round) - return r.fallback.GetBeaconRandomness(ctx, pers, round, entropy) + return r.fallback.GetBeaconRandomness(ctx, round) } diff --git a/documentation/en/api-v1-unstable-methods.md b/documentation/en/api-v1-unstable-methods.md index f29f4cbda..5ebfacddd 100644 --- a/documentation/en/api-v1-unstable-methods.md +++ b/documentation/en/api-v1-unstable-methods.md @@ -235,6 +235,8 @@ * [StateGetClaim](#StateGetClaim) * [StateGetClaims](#StateGetClaims) * [StateGetNetworkParams](#StateGetNetworkParams) + * [StateGetRandomnessDigestFromBeacon](#StateGetRandomnessDigestFromBeacon) + * [StateGetRandomnessDigestFromTickets](#StateGetRandomnessDigestFromTickets) * [StateGetRandomnessFromBeacon](#StateGetRandomnessFromBeacon) * [StateGetRandomnessFromTickets](#StateGetRandomnessFromTickets) * [StateListActors](#StateListActors) @@ -6963,6 +6965,52 @@ Response: } ``` +### StateGetRandomnessDigestFromBeacon +StateGetRandomnessDigestFromBeacon is used to sample the beacon for randomness. + + +Perms: read + +Inputs: +```json +[ + 10101, + [ + { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + { + "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" + } + ] +] +``` + +Response: `"Bw=="` + +### StateGetRandomnessDigestFromTickets +StateGetRandomnessDigestFromTickets. is used to sample the chain for randomness. + + +Perms: read + +Inputs: +```json +[ + 10101, + [ + { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + { + "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" + } + ] +] +``` + +Response: `"Bw=="` + ### StateGetRandomnessFromBeacon StateGetRandomnessFromBeacon is used to sample the beacon for randomness. diff --git a/documentation/en/cli-lotus-miner.md b/documentation/en/cli-lotus-miner.md index 13e64bbce..1c3ea0c84 100644 --- a/documentation/en/cli-lotus-miner.md +++ b/documentation/en/cli-lotus-miner.md @@ -7,7 +7,7 @@ USAGE: lotus-miner [global options] command [command options] [arguments...] VERSION: - 1.23.3-rc2 + 1.23.3 COMMANDS: init Initialize a lotus miner repo diff --git a/documentation/en/cli-lotus-worker.md b/documentation/en/cli-lotus-worker.md index 9bf3cb5d2..cb5ba125a 100644 --- a/documentation/en/cli-lotus-worker.md +++ b/documentation/en/cli-lotus-worker.md @@ -7,7 +7,7 @@ USAGE: lotus-worker [global options] command [command options] [arguments...] VERSION: - 1.23.3-rc2 + 1.23.3 COMMANDS: run Start lotus worker diff --git a/documentation/en/cli-lotus.md b/documentation/en/cli-lotus.md index 57df5b9c6..0a28cb420 100644 --- a/documentation/en/cli-lotus.md +++ b/documentation/en/cli-lotus.md @@ -7,7 +7,7 @@ USAGE: lotus [global options] command [command options] [arguments...] VERSION: - 1.23.3-rc2 + 1.23.3 COMMANDS: daemon Start a lotus daemon process @@ -74,9 +74,6 @@ OPTIONS: --api-max-req-size value maximum API request size accepted by the JSON RPC server (default: 0) --restore value restore from backup file --restore-config value config file to use when restoring from backup - --slash-consensus Report consensus fault (default: false) - --slasher-sender value optionally specify the account to report consensus from - --slashdb-dir value (default: "slash watch db dir path") --help, -h show help ``` diff --git a/documentation/en/default-lotus-config.toml b/documentation/en/default-lotus-config.toml index 8e99869a5..c37e40f74 100644 --- a/documentation/en/default-lotus-config.toml +++ b/documentation/en/default-lotus-config.toml @@ -399,3 +399,32 @@ #EnableMsgIndex = false +[FaultReporter] + # EnableConsensusFaultReporter controls whether the node will monitor and + # report consensus faults. When enabled, the node will watch for malicious + # behaviors like double-mining and parent grinding, and submit reports to the + # network. This can earn reporter rewards, but is not guaranteed. Nodes should + # enable fault reporting with care, as it may increase resource usage, and may + # generate gas fees without earning rewards. + # + # type: bool + # env var: LOTUS_FAULTREPORTER_ENABLECONSENSUSFAULTREPORTER + #EnableConsensusFaultReporter = false + + # ConsensusFaultReporterDataDir is the path where fault reporter state will be + # persisted. This directory should have adequate space and permissions for the + # node process. + # + # type: string + # env var: LOTUS_FAULTREPORTER_CONSENSUSFAULTREPORTERDATADIR + #ConsensusFaultReporterDataDir = "" + + # ConsensusFaultReporterAddress is the wallet address used for submitting + # ReportConsensusFault messages. It will pay for gas fees, and receive any + # rewards. This address should have adequate funds to cover gas fees. + # + # type: string + # env var: LOTUS_FAULTREPORTER_CONSENSUSFAULTREPORTERADDRESS + #ConsensusFaultReporterAddress = "" + + diff --git a/documentation/en/default-lotus-miner-config.toml b/documentation/en/default-lotus-miner-config.toml index 617844896..81087222f 100644 --- a/documentation/en/default-lotus-miner-config.toml +++ b/documentation/en/default-lotus-miner-config.toml @@ -581,12 +581,6 @@ # env var: LOTUS_SEALING_DISABLECOLLATERALFALLBACK #DisableCollateralFallback = false - # enable / disable precommit batching (takes effect after nv13) - # - # type: bool - # env var: LOTUS_SEALING_BATCHPRECOMMITS - #BatchPreCommits = true - # maximum precommit batch size - batches will be sent immediately above this size # # type: int @@ -636,7 +630,8 @@ #CommitBatchSlack = "1h0m0s" # network BaseFee below which to stop doing precommit batching, instead - # sending precommit messages to the chain individually + # sending precommit messages to the chain individually. When the basefee is + # below this threshold, precommit messages will get sent out immediately. # # type: types.FIL # env var: LOTUS_SEALING_BATCHPRECOMMITABOVEBASEFEE diff --git a/extern/test-vectors b/extern/test-vectors index 28b0c45ea..195bc0659 160000 --- a/extern/test-vectors +++ b/extern/test-vectors @@ -1 +1 @@ -Subproject commit 28b0c45eab4c302864af0aeaaff813625cfafe97 +Subproject commit 195bc065973ec35826621823964a5c3cbe5fa56d diff --git a/go.mod b/go.mod index 06fe97541..4eb2922ef 100644 --- a/go.mod +++ b/go.mod @@ -45,7 +45,7 @@ require ( github.com/filecoin-project/go-jsonrpc v0.3.1 github.com/filecoin-project/go-padreader v0.0.1 github.com/filecoin-project/go-paramfetch v0.0.4 - github.com/filecoin-project/go-state-types v0.12.1-0.20230804024420-40b13e0840c1 + github.com/filecoin-project/go-state-types v0.12.1 github.com/filecoin-project/go-statemachine v1.0.3 github.com/filecoin-project/go-statestore v0.2.0 github.com/filecoin-project/go-storedcounter v0.1.0 @@ -59,7 +59,7 @@ require ( github.com/filecoin-project/specs-actors/v6 v6.0.2 github.com/filecoin-project/specs-actors/v7 v7.0.1 github.com/filecoin-project/specs-actors/v8 v8.0.1 - github.com/filecoin-project/test-vectors/schema v0.0.5 + github.com/filecoin-project/test-vectors/schema v0.0.6-0.20230822140104-bed37e1ca04f github.com/gbrlsnchs/jwt/v3 v3.0.1 github.com/gdamore/tcell/v2 v2.2.0 github.com/go-openapi/spec v0.19.11 @@ -105,7 +105,7 @@ require ( github.com/kelseyhightower/envconfig v1.4.0 github.com/koalacxr/quantile v0.0.1 github.com/libp2p/go-buffer-pool v0.1.0 - github.com/libp2p/go-libp2p v0.27.6 + github.com/libp2p/go-libp2p v0.27.9 github.com/libp2p/go-libp2p-consensus v0.0.1 github.com/libp2p/go-libp2p-gorpc v0.5.0 github.com/libp2p/go-libp2p-kad-dht v0.24.0 @@ -294,9 +294,9 @@ require ( github.com/prometheus/procfs v0.9.0 // indirect github.com/prometheus/statsd_exporter v0.22.7 // indirect github.com/quic-go/qpack v0.4.0 // indirect - github.com/quic-go/qtls-go1-19 v0.3.2 // indirect - github.com/quic-go/qtls-go1-20 v0.2.2 // indirect - github.com/quic-go/quic-go v0.33.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.1 // indirect github.com/quic-go/webtransport-go v0.5.3 // indirect github.com/rivo/uniseg v0.1.0 // indirect github.com/rs/cors v1.7.0 // indirect diff --git a/go.sum b/go.sum index 2c22edbd1..90c84dcd4 100644 --- a/go.sum +++ b/go.sum @@ -337,9 +337,9 @@ github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc/go github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= 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.1-0.20230804024420-40b13e0840c1 h1:FBuJ7aJ6uKT67eedEpaTWTz6lDRukAuhg9fEgCzzl1w= -github.com/filecoin-project/go-state-types v0.12.1-0.20230804024420-40b13e0840c1/go.mod h1:KOBGyvCalT8uHBS7KSKOVbjsilD90bBZHgLAqrzz6gU= +github.com/filecoin-project/go-state-types v0.11.1/go.mod h1:SyNPwTsU7I22gL2r0OAPcImvLoTVfgRwdK/Y5rR1zz8= +github.com/filecoin-project/go-state-types v0.12.1 h1:/1ip/jXIP4QzWd3hlaQ7RGp1DHKKYG3+NOhd/r08UJY= +github.com/filecoin-project/go-state-types v0.12.1/go.mod h1:KOBGyvCalT8uHBS7KSKOVbjsilD90bBZHgLAqrzz6gU= 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= @@ -370,8 +370,8 @@ github.com/filecoin-project/specs-actors/v7 v7.0.1 h1:w72xCxijK7xs1qzmJiw+WYJaVt github.com/filecoin-project/specs-actors/v7 v7.0.1/go.mod h1:tPLEYXoXhcpyLh69Ccq91SOuLXsPWjHiY27CzawjUEk= github.com/filecoin-project/specs-actors/v8 v8.0.1 h1:4u0tIRJeT5G7F05lwLRIsDnsrN+bJ5Ixj6h49Q7uE2Y= github.com/filecoin-project/specs-actors/v8 v8.0.1/go.mod h1:UYIPg65iPWoFw5NEftREdJwv9b/5yaLKdCgTvNI/2FA= -github.com/filecoin-project/test-vectors/schema v0.0.5 h1:w3zHQhzM4pYxJDl21avXjOKBLF8egrvwUwjpT8TquDg= -github.com/filecoin-project/test-vectors/schema v0.0.5/go.mod h1:iQ9QXLpYWL3m7warwvK1JC/pTri8mnfEmKygNDqqY6E= +github.com/filecoin-project/test-vectors/schema v0.0.6-0.20230822140104-bed37e1ca04f h1:Ho3kK/WetJ7wco2VhR/pOZ9HD/WWL1BDEzYRTFQK8dw= +github.com/filecoin-project/test-vectors/schema v0.0.6-0.20230822140104-bed37e1ca04f/go.mod h1:iQ9QXLpYWL3m7warwvK1JC/pTri8mnfEmKygNDqqY6E= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/flynn/noise v1.0.0 h1:DlTHqmzmvcEiKj+4RYo/imoswx/4r6iBlCMfVtrMXpQ= github.com/flynn/noise v1.0.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag= @@ -985,8 +985,8 @@ github.com/libp2p/go-libp2p v0.7.0/go.mod h1:hZJf8txWeCduQRDC/WSqBGMxaTHCOYHt2xS github.com/libp2p/go-libp2p v0.7.4/go.mod h1:oXsBlTLF1q7pxr+9w6lqzS1ILpyHsaBPniVO7zIHGMw= github.com/libp2p/go-libp2p v0.8.1/go.mod h1:QRNH9pwdbEBpx5DTJYg+qxcVaDMAz3Ee/qDKwXujH5o= github.com/libp2p/go-libp2p v0.14.3/go.mod h1:d12V4PdKbpL0T1/gsUNN8DfgMuRPDX8bS2QxCZlwRH0= -github.com/libp2p/go-libp2p v0.27.6 h1:KmGU5kskCaaerm53heqzfGOlrW2z8icZ+fnyqgrZs38= -github.com/libp2p/go-libp2p v0.27.6/go.mod h1:oMfQGTb9CHnrOuSM6yMmyK2lXz3qIhnkn2+oK3B1Y2g= +github.com/libp2p/go-libp2p v0.27.9 h1:n5p5bQD469v7I/1qncaHDq0BeSx4iT2fHF3NyNuKOmY= +github.com/libp2p/go-libp2p v0.27.9/go.mod h1:Tdx7ZuJl9NE78PkB4FjPVbf6kaQNOh2ppU/OVvVB6Wc= 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= @@ -1472,12 +1472,12 @@ github.com/puzpuzpuz/xsync/v2 v2.4.0 h1:5sXAMHrtx1bg9nbRZTOn8T4MkWe5V+o8yKRH02Ez github.com/puzpuzpuz/xsync/v2 v2.4.0/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.2 h1:tFxjCFcTQzK+oMxG6Zcvp4Dq8dx4yD3dDiIiyc86Z5U= -github.com/quic-go/qtls-go1-19 v0.3.2/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= -github.com/quic-go/qtls-go1-20 v0.2.2 h1:WLOPx6OY/hxtTxKV1Zrq20FtXtDEkeY00CGQm8GEa3E= -github.com/quic-go/qtls-go1-20 v0.2.2/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/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.1 h1:EVsG7O/7FVZI8Za71GzpHDoWpBTKdjDv1/x0KFcckho= +github.com/quic-go/quic-go v0.33.1/go.mod h1:YMuhaAV9/jIu0XclDXwZPAsP/2Kgr5yMYhe9oxhhOFA= 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= diff --git a/itests/batch_deal_test.go b/itests/batch_deal_test.go index 68b276a0c..21db9f08d 100644 --- a/itests/batch_deal_test.go +++ b/itests/batch_deal_test.go @@ -61,7 +61,6 @@ func TestBatchDealInput(t *testing.T) { sc.MaxSealingSectorsForDeals = 3 sc.AlwaysKeepUnsealedCopy = true sc.WaitDealsDelay = time.Hour - sc.BatchPreCommits = false sc.AggregateCommits = false return sc, nil diff --git a/itests/ccupgrade_test.go b/itests/ccupgrade_test.go deleted file mode 100644 index 030e115f8..000000000 --- a/itests/ccupgrade_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// stm: #integration -package itests - -import ( - "context" - "fmt" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/network" - - "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/itests/kit" -) - -func TestCCUpgrade(t *testing.T) { - //stm: @CHAIN_SYNCER_LOAD_GENESIS_001, @CHAIN_SYNCER_FETCH_TIPSET_001, - //stm: @CHAIN_SYNCER_START_001, @CHAIN_SYNCER_SYNC_001, @BLOCKCHAIN_BEACON_VALIDATE_BLOCK_VALUES_01 - //stm: @CHAIN_SYNCER_COLLECT_CHAIN_001, @CHAIN_SYNCER_COLLECT_HEADERS_001, @CHAIN_SYNCER_VALIDATE_TIPSET_001 - //stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001 - - //stm: @CHAIN_STATE_MINER_GET_INFO_001 - //stm: @CHAIN_INCOMING_HANDLE_INCOMING_BLOCKS_001, @CHAIN_INCOMING_VALIDATE_BLOCK_PUBSUB_001, @CHAIN_INCOMING_VALIDATE_MESSAGE_PUBSUB_001 - - //stm: @MINER_SECTOR_LIST_001 - kit.QuietMiningLogs() - - n := runTestCCUpgrade(t) - - t.Run("post", func(t *testing.T) { - ctx := context.Background() - ts, err := n.ChainHead(ctx) - require.NoError(t, err) - start := ts.Height() - // wait for a full proving period - t.Log("waiting for chain") - - n.WaitTillChain(ctx, func(ts *types.TipSet) bool { - if ts.Height() > start+abi.ChainEpoch(2880) { - return true - } - return false - }) - }) -} - -func runTestCCUpgrade(t *testing.T) *kit.TestFullNode { - ctx := context.Background() - blockTime := 1 * time.Millisecond - - client, miner, ens := kit.EnsembleMinimal(t, kit.GenesisNetworkVersion(network.Version15), kit.ThroughRPC()) - ens.InterconnectAll().BeginMiningMustPost(blockTime) - - maddr, err := miner.ActorAddress(ctx) - if err != nil { - t.Fatal(err) - } - - CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner) - fmt.Printf("CCUpgrade: %d\n", CCUpgrade) - - miner.PledgeSectors(ctx, 1, 0, nil) - sl, err := miner.SectorsListNonGenesis(ctx) - require.NoError(t, err) - require.Len(t, sl, 1, "expected 1 sector") - require.Equal(t, CCUpgrade, sl[0], "unexpected sector number") - - si, err := client.StateSectorGetInfo(ctx, maddr, CCUpgrade, types.EmptyTSK) - require.NoError(t, err) - require.NotNil(t, si) - require.Less(t, 50000, int(si.Expiration)) - require.True(t, si.ReplacedSectorAge == 0) - - client.WaitForSectorActive(ctx, t, CCUpgrade, maddr) - - //stm: @SECTOR_CC_UPGRADE_001 - err = miner.SectorMarkForUpgrade(ctx, sl[0], true) - require.NoError(t, err) - - sl, err = miner.SectorsListNonGenesis(ctx) - require.NoError(t, err) - require.Len(t, sl, 1, "expected 1 sector") - - dh := kit.NewDealHarness(t, client, miner, miner) - deal, res, inPath := dh.MakeOnlineDeal(ctx, kit.MakeFullDealParams{ - Rseed: 6, - SuspendUntilCryptoeconStable: true, - }) - outPath := dh.PerformRetrieval(context.Background(), deal, res.Root, false) - kit.AssertFilesEqual(t, inPath, outPath) - - status, err := miner.SectorsStatus(ctx, CCUpgrade, true) - require.NoError(t, err) - assert.Equal(t, 1, len(status.Deals)) - - miner.WaitSectorsProving(ctx, map[abi.SectorNumber]struct{}{ - CCUpgrade: {}, - }) - - siUpdate, err := client.StateSectorGetInfo(ctx, maddr, CCUpgrade, types.EmptyTSK) - require.NoError(t, err) - require.NotNil(t, siUpdate) - require.True(t, siUpdate.SectorKeyCID != nil) - require.True(t, siUpdate.Activation > si.Activation) - - return client -} - -func TestCCUpgradeAndPoSt(t *testing.T) { - kit.QuietMiningLogs() - t.Run("upgrade and then post", func(t *testing.T) { - ctx := context.Background() - n := runTestCCUpgrade(t) - ts, err := n.ChainHead(ctx) - require.NoError(t, err) - start := ts.Height() - // wait for a full proving period - t.Log("waiting for chain") - - n.WaitTillChain(ctx, func(ts *types.TipSet) bool { - if ts.Height() > start+abi.ChainEpoch(2880) { - return true - } - return false - }) - }) -} diff --git a/itests/deadlines_test.go b/itests/deadlines_test.go index 472e66abc..fb28f4509 100644 --- a/itests/deadlines_test.go +++ b/itests/deadlines_test.go @@ -18,7 +18,6 @@ import ( "github.com/filecoin-project/go-state-types/builtin" minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/go-state-types/exitcode" - "github.com/filecoin-project/go-state-types/network" miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" "github.com/filecoin-project/lotus/api" @@ -34,28 +33,6 @@ import ( ) // TestDeadlineToggling: -// * spins up a v3 network (miner A) -// * creates an inactive miner (miner B) -// * creates another miner, pledges a sector, waits for power (miner C) -// -// * goes through v4 upgrade -// * goes through PP -// * creates minerD, minerE -// * makes sure that miner B/D are inactive, A/C still are -// * pledges sectors on miner B/D -// * precommits a sector on minerE -// * disables post on miner C -// * goes through PP 0.5PP -// * asserts that minerE is active -// * goes through rest of PP (1.5) -// * asserts that miner C loses power -// * asserts that miner B/D is active and has power -// * asserts that minerE is inactive -// * disables post on miner B -// * terminates sectors on miner D -// * goes through another PP -// * asserts that miner B loses power -// * asserts that miner D loses power, is inactive func TestDeadlineToggling(t *testing.T) { //stm: @CHAIN_SYNCER_LOAD_GENESIS_001, @CHAIN_SYNCER_FETCH_TIPSET_001, //stm: @CHAIN_SYNCER_START_001, @CHAIN_SYNCER_SYNC_001, @BLOCKCHAIN_BEACON_VALIDATE_BLOCK_VALUES_01 @@ -71,7 +48,6 @@ func TestDeadlineToggling(t *testing.T) { const sectorsC, sectorsD, sectorsB = 10, 9, 8 var ( - upgradeH abi.ChainEpoch = 4000 provingPeriod abi.ChainEpoch = 2880 blocktime = 2 * time.Millisecond ) @@ -81,14 +57,14 @@ func TestDeadlineToggling(t *testing.T) { var ( client kit.TestFullNode - minerA kit.TestMiner - minerB kit.TestMiner - minerC kit.TestMiner - minerD kit.TestMiner - minerE kit.TestMiner + minerA kit.TestMiner // A has some genesis sector, just keeps power + minerB kit.TestMiner // B pledges some sector, later fails some posts but stays alive + minerC kit.TestMiner // C pledges sectors, gains power, and later stops its PoSTs, but stays alive + minerD kit.TestMiner // D pledges sectors and later terminates them, losing all power, eventually deactivates cron + minerE kit.TestMiner // E pre-commits a sector but doesn't advance beyond that, cron should become inactive ) opts := []kit.NodeOpt{kit.WithAllSubsystems()} - ens := kit.NewEnsemble(t, kit.MockProofs(), kit.TurboUpgradeAt(upgradeH)). + ens := kit.NewEnsemble(t, kit.MockProofs()). FullNode(&client, opts...). Miner(&minerA, &client, opts...). Start(). @@ -116,6 +92,8 @@ func TestDeadlineToggling(t *testing.T) { ssz, err := minerC.ActorSectorSize(ctx, maddrC) require.NoError(t, err) + targetHeight := abi.ChainEpoch(0) + // pledge sectors on C, go through a PP, check for power { minerC.PledgeSectors(ctx, sectorsC, 0, nil) @@ -127,11 +105,13 @@ func TestDeadlineToggling(t *testing.T) { t.Log("Running one proving period (miner C)") t.Logf("End for head.Height > %d", di.PeriodStart+di.WPoStProvingPeriod*2) + targetHeight = di.PeriodStart + provingPeriod*2 + for { head, err := client.ChainHead(ctx) require.NoError(t, err) - if head.Height() > di.PeriodStart+provingPeriod*2 { + if head.Height() > targetHeight { t.Logf("Now head.Height = %d", head.Height()) break } @@ -148,18 +128,6 @@ func TestDeadlineToggling(t *testing.T) { require.Equal(t, p.MinerPower.RawBytePower, expectedPower) } - // go through upgrade + PP - for { - head, err := client.ChainHead(ctx) - require.NoError(t, err) - - if head.Height() > upgradeH+provingPeriod { - t.Logf("Now head.Height = %d", head.Height()) - break - } - build.Clock.Sleep(blocktime) - } - checkMiner := func(ma address.Address, power abi.StoragePower, active bool, tsk types.TipSetKey) { //stm: @CHAIN_STATE_MINER_POWER_001 p, err := client.StateMinerPower(ctx, ma, tsk) @@ -181,18 +149,6 @@ func TestDeadlineToggling(t *testing.T) { require.Equal(t, active, act) } - // check that just after the upgrade minerB was still active - { - uts, err := client.ChainGetTipSetByHeight(ctx, upgradeH+2, types.EmptyTSK) - require.NoError(t, err) - checkMiner(maddrB, types.NewInt(0), true, uts.Key()) - } - - //stm: @CHAIN_STATE_NETWORK_VERSION_001 - nv, err := client.StateNetworkVersion(ctx, types.EmptyTSK) - require.NoError(t, err) - require.GreaterOrEqual(t, nv, network.Version12) - ens.Miner(&minerD, &client, opts...). Miner(&minerE, &client, opts...). Start() @@ -254,12 +210,14 @@ func TestDeadlineToggling(t *testing.T) { require.Equal(t, exitcode.Ok, r.Receipt.ExitCode) } + targetHeight = targetHeight + (provingPeriod / 2) + // go through 0.5 PP for { head, err := client.ChainHead(ctx) require.NoError(t, err) - if head.Height() > upgradeH+provingPeriod+(provingPeriod/2) { + if head.Height() > targetHeight { t.Logf("Now head.Height = %d", head.Height()) break } @@ -268,12 +226,14 @@ func TestDeadlineToggling(t *testing.T) { checkMiner(maddrE, types.NewInt(0), true, types.EmptyTSK) + targetHeight = targetHeight + (provingPeriod/2)*5 + // go through rest of the PP for { head, err := client.ChainHead(ctx) require.NoError(t, err) - if head.Height() > upgradeH+(provingPeriod*3) { + if head.Height() > targetHeight { t.Logf("Now head.Height = %d", head.Height()) break } @@ -285,7 +245,12 @@ func TestDeadlineToggling(t *testing.T) { checkMiner(maddrC, types.NewInt(0), true, types.EmptyTSK) checkMiner(maddrB, types.NewInt(uint64(ssz)*sectorsB), true, types.EmptyTSK) checkMiner(maddrD, types.NewInt(uint64(ssz)*sectorsD), true, types.EmptyTSK) - checkMiner(maddrE, types.NewInt(0), false, types.EmptyTSK) + + // Note: in the older version of this test `active` would be set to false + // this is now true because the time to commit a precommit a sector has + // increased to 30 days. We could keep the original assert and increase the + // wait above to 30 days, but that makes the test take 14 minutes to run.. + checkMiner(maddrE, types.NewInt(0), true, types.EmptyTSK) // disable post on minerB minerB.StorageMiner.(*impl.StorageMinerAPI).IStorageMgr.(*mock.SectorMgr).Fail() @@ -344,12 +309,14 @@ func TestDeadlineToggling(t *testing.T) { require.True(t, p.MinerPower.RawBytePower.IsZero()) } + targetHeight = targetHeight + provingPeriod*2 + // go through another PP for { head, err := client.ChainHead(ctx) require.NoError(t, err) - if head.Height() > upgradeH+(provingPeriod*5) { + if head.Height() > targetHeight { t.Logf("Now head.Height = %d", head.Height()) break } diff --git a/itests/kit/ensemble_opts_nv.go b/itests/kit/ensemble_opts_nv.go index 027720229..d5bb1930e 100644 --- a/itests/kit/ensemble_opts_nv.go +++ b/itests/kit/ensemble_opts_nv.go @@ -23,20 +23,6 @@ func GenesisNetworkVersion(nv network.Version) EnsembleOpt { }) } -func SDRUpgradeAt(calico, persian abi.ChainEpoch) EnsembleOpt { - return UpgradeSchedule(stmgr.Upgrade{ - Network: network.Version6, - Height: -1, - }, stmgr.Upgrade{ - Network: network.Version7, - Height: calico, - Migration: filcns.UpgradeCalico, - }, stmgr.Upgrade{ - Network: network.Version8, - Height: persian, - }) -} - func LatestActorsAt(upgradeHeight abi.ChainEpoch) EnsembleOpt { /* inline-gen template return UpgradeSchedule(stmgr.Upgrade{ @@ -58,14 +44,3 @@ func LatestActorsAt(upgradeHeight abi.ChainEpoch) EnsembleOpt { }) /* inline-gen end */ } - -func TurboUpgradeAt(upgradeHeight abi.ChainEpoch) EnsembleOpt { - return UpgradeSchedule(stmgr.Upgrade{ - Network: network.Version11, - Height: -1, - }, stmgr.Upgrade{ - Network: network.Version12, - Height: upgradeHeight, - Migration: filcns.UpgradeActorsV4, - }) -} diff --git a/itests/remove_verifreg_datacap_test.go b/itests/remove_verifreg_datacap_test.go index 3fd241748..ac88574d2 100644 --- a/itests/remove_verifreg_datacap_test.go +++ b/itests/remove_verifreg_datacap_test.go @@ -275,7 +275,7 @@ func TestNoRemoveDatacapFromVerifreg(t *testing.T) { Params: params, Value: big.Zero(), }, types.EmptyTSK) - require.Error(t, err) + require.NoError(t, err) require.False(t, callResult.MsgRct.ExitCode.IsSuccess()) verifregDatacapAfter, err := clientApi.StateVerifiedClientStatus(ctx, builtin.VerifiedRegistryActorAddr, types.EmptyTSK) diff --git a/itests/sdr_upgrade_test.go b/itests/sdr_upgrade_test.go deleted file mode 100644 index d92d4edc9..000000000 --- a/itests/sdr_upgrade_test.go +++ /dev/null @@ -1,117 +0,0 @@ -// stm: #integration -package itests - -import ( - "context" - "sort" - "sync/atomic" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/network" - - "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/lotus/itests/kit" - bminer "github.com/filecoin-project/lotus/miner" -) - -func TestSDRUpgrade(t *testing.T) { - //stm: @CHAIN_SYNCER_LOAD_GENESIS_001, @CHAIN_SYNCER_FETCH_TIPSET_001, - //stm: @CHAIN_SYNCER_START_001, @CHAIN_SYNCER_SYNC_001, @BLOCKCHAIN_BEACON_VALIDATE_BLOCK_VALUES_01 - //stm: @CHAIN_SYNCER_COLLECT_CHAIN_001, @CHAIN_SYNCER_COLLECT_HEADERS_001, @CHAIN_SYNCER_VALIDATE_TIPSET_001 - //stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001 - - //stm: @CHAIN_INCOMING_HANDLE_INCOMING_BLOCKS_001, @CHAIN_INCOMING_VALIDATE_BLOCK_PUBSUB_001, @CHAIN_INCOMING_VALIDATE_MESSAGE_PUBSUB_001 - //stm: @CHAIN_STATE_NETWORK_VERSION_001 - - //stm: @MINER_SECTOR_LIST_001 - kit.QuietMiningLogs() - - // oldDelay := policy.GetPreCommitChallengeDelay() - // policy.SetPreCommitChallengeDelay(5) - // t.Cleanup(func() { - // policy.SetPreCommitChallengeDelay(oldDelay) - // }) - - blocktime := 50 * time.Millisecond - - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - client, miner, ens := kit.EnsembleMinimal(t, - kit.MockProofs(), - kit.SDRUpgradeAt(500, 1000), - ) - ens.InterconnectAll() - - build.Clock.Sleep(time.Second) - - pledge := make(chan struct{}) - mine := int64(1) - done := make(chan struct{}) - go func() { - defer close(done) - round := 0 - for atomic.LoadInt64(&mine) != 0 { - build.Clock.Sleep(blocktime) - if err := miner.MineOne(ctx, bminer.MineReq{Done: func(bool, abi.ChainEpoch, error) { - - }}); err != nil { - t.Error(err) - } - - // 3 sealing rounds: before, during after. - if round >= 3 { - continue - } - - head, err := client.ChainHead(ctx) - assert.NoError(t, err) - - // rounds happen every 100 blocks, with a 50 block offset. - if head.Height() >= abi.ChainEpoch(round*500+50) { - round++ - pledge <- struct{}{} - - ver, err := client.StateNetworkVersion(ctx, head.Key()) - assert.NoError(t, err) - switch round { - case 1: - assert.Equal(t, network.Version6, ver) - case 2: - assert.Equal(t, network.Version7, ver) - case 3: - assert.Equal(t, network.Version8, ver) - } - } - - } - }() - - // before. - miner.PledgeSectors(ctx, 9, 0, pledge) - - s, err := miner.SectorsListNonGenesis(ctx) - require.NoError(t, err) - sort.Slice(s, func(i, j int) bool { - return s[i] < s[j] - }) - - for i, id := range s { - info, err := miner.SectorsStatus(ctx, id, true) - require.NoError(t, err) - expectProof := abi.RegisteredSealProof_StackedDrg2KiBV1 - if i >= 3 { - // after - expectProof = abi.RegisteredSealProof_StackedDrg2KiBV1_1 - } - assert.Equal(t, expectProof, info.SealProof, "sector %d, id %d", i, id) - } - - atomic.StoreInt64(&mine, 0) - <-done -} diff --git a/itests/sector_make_cc_avail_test.go b/itests/sector_make_cc_avail_test.go deleted file mode 100644 index 524b3c70f..000000000 --- a/itests/sector_make_cc_avail_test.go +++ /dev/null @@ -1,78 +0,0 @@ -package itests - -import ( - "context" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/network" - - "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/itests/kit" - "github.com/filecoin-project/lotus/node/config" - sealing "github.com/filecoin-project/lotus/storage/pipeline" -) - -func TestMakeAvailable(t *testing.T) { - kit.QuietMiningLogs() - - ctx := context.Background() - blockTime := 1 * time.Millisecond - - client, miner, ens := kit.EnsembleMinimal(t, kit.GenesisNetworkVersion(network.Version15), kit.ThroughRPC(), kit.MutateSealingConfig(func(sc *config.SealingConfig) { - sc.MakeCCSectorsAvailable = true - })) - ens.InterconnectAll().BeginMiningMustPost(blockTime) - - maddr, err := miner.ActorAddress(ctx) - if err != nil { - t.Fatal(err) - } - - CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner) - - miner.PledgeSectors(ctx, 1, 0, nil) - sl, err := miner.SectorsListNonGenesis(ctx) - require.NoError(t, err) - require.Len(t, sl, 1, "expected 1 sector") - require.Equal(t, CCUpgrade, sl[0], "unexpected sector number") - { - si, err := client.StateSectorGetInfo(ctx, maddr, CCUpgrade, types.EmptyTSK) - require.NoError(t, err) - require.NotNil(t, si) - require.Less(t, 50000, int(si.Expiration)) - } - client.WaitForSectorActive(ctx, t, CCUpgrade, maddr) - - sl, err = miner.SectorsListNonGenesis(ctx) - require.NoError(t, err) - require.Len(t, sl, 1, "expected 1 sector") - - status, err := miner.SectorsStatus(ctx, CCUpgrade, true) - require.NoError(t, err) - assert.Equal(t, api.SectorState(sealing.Available), status.State) - - dh := kit.NewDealHarness(t, client, miner, miner) - deal, res, inPath := dh.MakeOnlineDeal(ctx, kit.MakeFullDealParams{ - Rseed: 6, - SuspendUntilCryptoeconStable: true, - }) - outPath := dh.PerformRetrieval(context.Background(), deal, res.Root, false) - kit.AssertFilesEqual(t, inPath, outPath) - - sl, err = miner.SectorsListNonGenesis(ctx) - require.NoError(t, err) - require.Len(t, sl, 1, "expected 1 sector") - - status, err = miner.SectorsStatus(ctx, CCUpgrade, true) - require.NoError(t, err) - assert.Equal(t, 1, len(status.Deals)) - miner.WaitSectorsProving(ctx, map[abi.SectorNumber]struct{}{ - CCUpgrade: {}, - }) -} diff --git a/itests/sector_miner_collateral_test.go b/itests/sector_miner_collateral_test.go index 8d7abacee..579b4e535 100644 --- a/itests/sector_miner_collateral_test.go +++ b/itests/sector_miner_collateral_test.go @@ -51,7 +51,6 @@ func TestMinerBalanceCollateral(t *testing.T) { sc.AlwaysKeepUnsealedCopy = true sc.WaitDealsDelay = time.Hour - sc.BatchPreCommits = batching sc.AggregateCommits = batching sc.PreCommitBatchWait = time.Hour diff --git a/itests/sector_pledge_test.go b/itests/sector_pledge_test.go index 5cef0f899..891aab3d3 100644 --- a/itests/sector_pledge_test.go +++ b/itests/sector_pledge_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/require" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/network" miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" "github.com/filecoin-project/lotus/api" diff --git a/itests/sector_prefer_no_upgrade_test.go b/itests/sector_prefer_no_upgrade_test.go deleted file mode 100644 index 96f07f9e4..000000000 --- a/itests/sector_prefer_no_upgrade_test.go +++ /dev/null @@ -1,90 +0,0 @@ -package itests - -import ( - "context" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/network" - - "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/itests/kit" - "github.com/filecoin-project/lotus/node/config" - sealing "github.com/filecoin-project/lotus/storage/pipeline" -) - -func TestPreferNoUpgrade(t *testing.T) { - kit.QuietMiningLogs() - - ctx := context.Background() - blockTime := 1 * time.Millisecond - - client, miner, ens := kit.EnsembleMinimal(t, kit.GenesisNetworkVersion(network.Version15), kit.ThroughRPC(), kit.MutateSealingConfig(func(sc *config.SealingConfig) { - sc.PreferNewSectorsForDeals = true - })) - ens.InterconnectAll().BeginMiningMustPost(blockTime) - - maddr, err := miner.ActorAddress(ctx) - if err != nil { - t.Fatal(err) - } - - CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner) - Sealed := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 1) - - { - miner.PledgeSectors(ctx, 1, 0, nil) - sl, err := miner.SectorsListNonGenesis(ctx) - require.NoError(t, err) - require.Len(t, sl, 1, "expected 1 sector") - require.Equal(t, CCUpgrade, sl[0], "unexpected sector number") - { - si, err := client.StateSectorGetInfo(ctx, maddr, CCUpgrade, types.EmptyTSK) - require.NoError(t, err) - require.NotNil(t, si) - require.Less(t, 50000, int(si.Expiration)) - } - client.WaitForSectorActive(ctx, t, CCUpgrade, maddr) - - err = miner.SectorMarkForUpgrade(ctx, sl[0], true) - require.NoError(t, err) - - sl, err = miner.SectorsListNonGenesis(ctx) - require.NoError(t, err) - require.Len(t, sl, 1, "expected 1 sector") - } - - { - dh := kit.NewDealHarness(t, client, miner, miner) - deal, res, inPath := dh.MakeOnlineDeal(ctx, kit.MakeFullDealParams{ - Rseed: 6, - SuspendUntilCryptoeconStable: true, - }) - outPath := dh.PerformRetrieval(context.Background(), deal, res.Root, false) - kit.AssertFilesEqual(t, inPath, outPath) - } - - sl, err := miner.SectorsListNonGenesis(ctx) - require.NoError(t, err) - require.Len(t, sl, 2, "expected 2 sectors") - - { - status, err := miner.SectorsStatus(ctx, CCUpgrade, true) - require.NoError(t, err) - assert.Equal(t, api.SectorState(sealing.Available), status.State) - } - - { - status, err := miner.SectorsStatus(ctx, Sealed, true) - require.NoError(t, err) - assert.Equal(t, 1, len(status.Deals)) - miner.WaitSectorsProving(ctx, map[abi.SectorNumber]struct{}{ - Sealed: {}, - }) - } -} diff --git a/itests/sector_revert_available_test.go b/itests/sector_revert_available_test.go deleted file mode 100644 index 41a46024f..000000000 --- a/itests/sector_revert_available_test.go +++ /dev/null @@ -1,85 +0,0 @@ -package itests - -import ( - "context" - "fmt" - "testing" - "time" - - "github.com/stretchr/testify/require" - - "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/network" - - "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/itests/kit" - sealing "github.com/filecoin-project/lotus/storage/pipeline" -) - -func TestAbortUpgradeAvailable(t *testing.T) { - kit.QuietMiningLogs() - - ctx := context.Background() - blockTime := 1 * time.Millisecond - - client, miner, ens := kit.EnsembleMinimal(t, kit.GenesisNetworkVersion(network.Version15), kit.ThroughRPC()) - ens.InterconnectAll().BeginMiningMustPost(blockTime) - - maddr, err := miner.ActorAddress(ctx) - if err != nil { - t.Fatal(err) - } - - CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner) - fmt.Printf("CCUpgrade: %d\n", CCUpgrade) - - miner.PledgeSectors(ctx, 1, 0, nil) - sl, err := miner.SectorsListNonGenesis(ctx) - require.NoError(t, err) - require.Len(t, sl, 1, "expected 1 sector") - require.Equal(t, CCUpgrade, sl[0], "unexpected sector number") - { - si, err := client.StateSectorGetInfo(ctx, maddr, CCUpgrade, types.EmptyTSK) - require.NoError(t, err) - require.NotNil(t, si) - require.Less(t, 50000, int(si.Expiration)) - } - client.WaitForSectorActive(ctx, t, CCUpgrade, maddr) - - err = miner.SectorMarkForUpgrade(ctx, sl[0], true) - require.NoError(t, err) - - sl, err = miner.SectorsListNonGenesis(ctx) - require.NoError(t, err) - require.Len(t, sl, 1, "expected 1 sector") - - ss, err := miner.SectorsStatus(ctx, sl[0], false) - require.NoError(t, err) - - for i := 0; i < 100; i++ { - ss, err = miner.SectorsStatus(ctx, sl[0], false) - require.NoError(t, err) - if ss.State == api.SectorState(sealing.Proving) { - time.Sleep(50 * time.Millisecond) - continue - } - - require.Equal(t, api.SectorState(sealing.Available), ss.State) - break - } - - require.NoError(t, miner.SectorAbortUpgrade(ctx, sl[0])) - - for i := 0; i < 100; i++ { - ss, err = miner.SectorsStatus(ctx, sl[0], false) - require.NoError(t, err) - if ss.State == api.SectorState(sealing.Available) { - time.Sleep(50 * time.Millisecond) - continue - } - - require.Equal(t, api.SectorState(sealing.Proving), ss.State) - break - } -} diff --git a/itests/tape_test.go b/itests/tape_test.go deleted file mode 100644 index e0db4882c..000000000 --- a/itests/tape_test.go +++ /dev/null @@ -1,71 +0,0 @@ -// stm: #integration -package itests - -import ( - "context" - "testing" - "time" - - "github.com/stretchr/testify/require" - - "github.com/filecoin-project/go-state-types/network" - - "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/lotus/itests/kit" - sealing "github.com/filecoin-project/lotus/storage/pipeline" -) - -func TestTapeFix(t *testing.T) { - //stm: @CHAIN_SYNCER_LOAD_GENESIS_001, @CHAIN_SYNCER_FETCH_TIPSET_001, - //stm: @CHAIN_SYNCER_START_001, @CHAIN_SYNCER_SYNC_001, @BLOCKCHAIN_BEACON_VALIDATE_BLOCK_VALUES_01 - //stm: @CHAIN_SYNCER_COLLECT_CHAIN_001, @CHAIN_SYNCER_COLLECT_HEADERS_001, @CHAIN_SYNCER_VALIDATE_TIPSET_001 - //stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001 - - //stm: @CHAIN_INCOMING_HANDLE_INCOMING_BLOCKS_001, @CHAIN_INCOMING_VALIDATE_BLOCK_PUBSUB_001, @CHAIN_INCOMING_VALIDATE_MESSAGE_PUBSUB_001 - kit.QuietMiningLogs() - - var blocktime = 2 * time.Millisecond - - // The "before" case is disabled, because we need the builder to mock 32 GiB sectors to accurately repro this case - // TODO: Make the mock sector size configurable and reenable this - // t.Run("before", func(t *testing.T) { testTapeFix(t, b, blocktime, false) }) - t.Run("after", func(t *testing.T) { testTapeFix(t, blocktime, true) }) -} - -func testTapeFix(t *testing.T, blocktime time.Duration, after bool) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - networkVersion := network.Version4 - if after { - networkVersion = network.Version5 - } - - _, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.GenesisNetworkVersion(networkVersion)) - ens.InterconnectAll().BeginMining(blocktime) - - sid, err := miner.PledgeSector(ctx) - require.NoError(t, err) - - t.Log("All sectors is fsm") - - // If before, we expect the precommit to fail - successState := api.SectorState(sealing.CommitFailed) - failureState := api.SectorState(sealing.Proving) - if after { - // otherwise, it should succeed. - successState, failureState = failureState, successState - } - - for { - st, err := miner.SectorsStatus(ctx, sid.Number, false) - require.NoError(t, err) - if st.State == successState { - break - } - require.NotEqual(t, failureState, st.State) - build.Clock.Sleep(100 * time.Millisecond) - t.Log("WaitSeal") - } -} diff --git a/itests/wdpost_test.go b/itests/wdpost_test.go index 08c9d4343..2a6fc866e 100644 --- a/itests/wdpost_test.go +++ b/itests/wdpost_test.go @@ -224,70 +224,6 @@ func testWindowPostUpgrade(t *testing.T, blocktime time.Duration, nSectors int, require.Equal(t, nSectors+kit.DefaultPresealsPerBootstrapMiner-2+1, int(sectors)) // -2 not recovered sectors + 1 just pledged } -func TestWindowPostBaseFeeNoBurn(t *testing.T) { - //stm: @CHAIN_SYNCER_LOAD_GENESIS_001, @CHAIN_SYNCER_FETCH_TIPSET_001, - //stm: @CHAIN_SYNCER_START_001, @CHAIN_SYNCER_SYNC_001, @BLOCKCHAIN_BEACON_VALIDATE_BLOCK_VALUES_01 - //stm: @CHAIN_SYNCER_COLLECT_CHAIN_001, @CHAIN_SYNCER_COLLECT_HEADERS_001, @CHAIN_SYNCER_VALIDATE_TIPSET_001 - //stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001 - - //stm: @CHAIN_INCOMING_HANDLE_INCOMING_BLOCKS_001, @CHAIN_INCOMING_VALIDATE_BLOCK_PUBSUB_001, @CHAIN_INCOMING_VALIDATE_MESSAGE_PUBSUB_001 - kit.Expensive(t) - - kit.QuietMiningLogs() - - var ( - blocktime = 2 * time.Millisecond - nSectors = 10 - ) - - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - och := build.UpgradeClausHeight - build.UpgradeClausHeight = 0 - t.Cleanup(func() { build.UpgradeClausHeight = och }) - - client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.GenesisNetworkVersion(network.Version9)) - ens.InterconnectAll().BeginMining(blocktime) - - maddr, err := miner.ActorAddress(ctx) - require.NoError(t, err) - - //stm: @CHAIN_STATE_MINER_INFO_001 - mi, err := client.StateMinerInfo(ctx, maddr, types.EmptyTSK) - require.NoError(t, err) - - miner.PledgeSectors(ctx, nSectors, 0, nil) - //stm: @CHAIN_STATE_GET_ACTOR_001 - wact, err := client.StateGetActor(ctx, mi.Worker, types.EmptyTSK) - require.NoError(t, err) - en := wact.Nonce - - // wait for a new message to be sent from worker address, it will be a PoSt - -waitForProof: - for { - //stm: @CHAIN_STATE_GET_ACTOR_001 - wact, err := client.StateGetActor(ctx, mi.Worker, types.EmptyTSK) - require.NoError(t, err) - if wact.Nonce > en { - break waitForProof - } - - build.Clock.Sleep(blocktime) - } - - //stm: @CHAIN_STATE_LIST_MESSAGES_001 - slm, err := client.StateListMessages(ctx, &api.MessageMatch{To: maddr}, types.EmptyTSK, 0) - require.NoError(t, err) - - //stm: @CHAIN_STATE_REPLAY_001 - pmr, err := client.StateReplay(ctx, types.EmptyTSK, slm[0]) - require.NoError(t, err) - - require.Equal(t, pmr.GasCost.BaseFeeBurn, big.Zero()) -} - func TestWindowPostBaseFeeBurn(t *testing.T) { //stm: @CHAIN_SYNCER_LOAD_GENESIS_001, @CHAIN_SYNCER_FETCH_TIPSET_001, //stm: @CHAIN_SYNCER_START_001, @CHAIN_SYNCER_SYNC_001, @BLOCKCHAIN_BEACON_VALIDATE_BLOCK_VALUES_01 @@ -345,79 +281,6 @@ waitForProof: require.NotEqual(t, pmr.GasCost.BaseFeeBurn, big.Zero()) } -// Tests that V1_1 proofs are generated and accepted in nv19, and V1 proofs are accepted -func TestWindowPostV1P1NV19(t *testing.T) { - kit.QuietMiningLogs() - - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - blocktime := 2 * time.Millisecond - - client, miner, ens := kit.EnsembleMinimal(t, kit.GenesisNetworkVersion(network.Version19)) - ens.InterconnectAll().BeginMining(blocktime) - - maddr, err := miner.ActorAddress(ctx) - require.NoError(t, err) - - mi, err := client.StateMinerInfo(ctx, maddr, types.EmptyTSK) - require.NoError(t, err) - - wact, err := client.StateGetActor(ctx, mi.Worker, types.EmptyTSK) - require.NoError(t, err) - en := wact.Nonce - - // wait for a new message to be sent from worker address, it will be a PoSt - -waitForProof: - for { - wact, err := client.StateGetActor(ctx, mi.Worker, types.EmptyTSK) - require.NoError(t, err) - if wact.Nonce > en { - break waitForProof - } - - build.Clock.Sleep(blocktime) - } - - slm, err := client.StateListMessages(ctx, &api.MessageMatch{To: maddr}, types.EmptyTSK, 0) - require.NoError(t, err) - - pmr, err := client.StateSearchMsg(ctx, types.EmptyTSK, slm[0], -1, false) - require.NoError(t, err) - - inclTs, err := client.ChainGetTipSet(ctx, pmr.TipSet) - require.NoError(t, err) - - inclTsParents, err := client.ChainGetTipSet(ctx, inclTs.Parents()) - require.NoError(t, err) - - nv, err := client.StateNetworkVersion(ctx, pmr.TipSet) - require.NoError(t, err) - require.Equal(t, network.Version19, nv) - - require.True(t, pmr.Receipt.ExitCode.IsSuccess()) - - slmsg, err := client.ChainGetMessage(ctx, slm[0]) - require.NoError(t, err) - - var params miner11.SubmitWindowedPoStParams - require.NoError(t, params.UnmarshalCBOR(bytes.NewBuffer(slmsg.Params))) - require.Equal(t, abi.RegisteredPoStProof_StackedDrgWindow2KiBV1_1, params.Proofs[0].PoStProof) - - // "Turn" this into a V1 proof -- the proof will be invalid, but won't be validated, and so the call should succeed - params.Proofs[0].PoStProof = abi.RegisteredPoStProof_StackedDrgWindow2KiBV1 - v1PostParams := new(bytes.Buffer) - require.NoError(t, params.MarshalCBOR(v1PostParams)) - - slmsg.Params = v1PostParams.Bytes() - - // Simulate call on inclTsParents's parents, so that the partition isn't already proven - call, err := client.StateCall(ctx, slmsg, inclTsParents.Parents()) - require.NoError(t, err) - require.True(t, call.MsgRct.ExitCode.IsSuccess()) -} - // Tests that V1_1 proofs are generated and accepted in nv20, and that V1 proofs are NOT func TestWindowPostV1P1NV20(t *testing.T) { kit.QuietMiningLogs() @@ -484,8 +347,9 @@ waitForProof: slmsg.Params = v1PostParams.Bytes() // Simulate call on inclTs's parents, so that the partition isn't already proven - _, err = client.StateCall(ctx, slmsg, inclTs.Parents()) - require.ErrorContains(t, err, "expected proof of type StackedDRGWindow2KiBV1P1, got StackedDRGWindow2KiBV1") + ret, err := client.StateCall(ctx, slmsg, inclTs.Parents()) + require.NoError(t, err) + require.Contains(t, ret.Error, "expected proof of type StackedDRGWindow2KiBV1P1, got StackedDRGWindow2KiBV1") for { //stm: @CHAIN_STATE_MINER_CALCULATE_DEADLINE_001 diff --git a/markets/storageadapter/ondealsectorcommitted.go b/markets/storageadapter/ondealsectorcommitted.go index a8b22c62a..54ddb73b3 100644 --- a/markets/storageadapter/ondealsectorcommitted.go +++ b/markets/storageadapter/ondealsectorcommitted.go @@ -13,6 +13,7 @@ import ( "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/builtin" + miner2 "github.com/filecoin-project/go-state-types/builtin/v11/miner" "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/go-state-types/builtin/v9/market" @@ -107,7 +108,10 @@ func (mgr *SectorCommittedManager) OnDealSectorPreCommitted(ctx context.Context, // Watch for a pre-commit message to the provider. matchEvent := func(msg *types.Message) (bool, error) { - matched := msg.To == provider && (msg.Method == builtin.MethodsMiner.PreCommitSector || msg.Method == builtin.MethodsMiner.PreCommitSectorBatch || msg.Method == builtin.MethodsMiner.ProveReplicaUpdates) + matched := msg.To == provider && (msg.Method == builtin.MethodsMiner.PreCommitSector || + msg.Method == builtin.MethodsMiner.PreCommitSectorBatch || + msg.Method == builtin.MethodsMiner.PreCommitSectorBatch2 || + msg.Method == builtin.MethodsMiner.ProveReplicaUpdates) return matched, nil } @@ -333,6 +337,21 @@ func dealSectorInPreCommitMsg(msg *types.Message, res pipeline.CurrentDealInfo) return nil, xerrors.Errorf("unmarshal pre commit: %w", err) } + for _, precommit := range params.Sectors { + // Check through the deal IDs associated with this message + for _, did := range precommit.DealIDs { + if did == res.DealID { + // Found the deal ID in this message. Callback with the sector ID. + return &precommit.SectorNumber, nil + } + } + } + case builtin.MethodsMiner.PreCommitSectorBatch2: + var params miner2.PreCommitSectorBatchParams2 + if err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)); err != nil { + return nil, xerrors.Errorf("unmarshal pre commit: %w", err) + } + for _, precommit := range params.Sectors { // Check through the deal IDs associated with this message for _, did := range precommit.DealIDs { diff --git a/miner/miner.go b/miner/miner.go index e1737009b..2d802e2cf 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -324,9 +324,16 @@ minerLoop: "block-time", btime, "time", build.Clock.Now(), "difference", build.Clock.Since(btime)) } - if _, err = m.sf.MinedBlock(ctx, b.Header, base.TipSet.Height()+base.NullRounds); err != nil { - log.Errorf(" SLASH FILTER ERROR: %s", err) - if os.Getenv("LOTUS_MINER_NO_SLASHFILTER") != "_yes_i_know_i_can_and_probably_will_lose_all_my_fil_and_power_" { + if os.Getenv("LOTUS_MINER_NO_SLASHFILTER") != "_yes_i_know_i_can_and_probably_will_lose_all_my_fil_and_power_" { + witness, fault, err := m.sf.MinedBlock(ctx, b.Header, base.TipSet.Height()+base.NullRounds) + if err != nil { + log.Errorf(" SLASH FILTER ERRORED: %s", err) + // Continue here, because it's _probably_ wiser to not submit this block + continue + } + + if fault { + log.Errorf(" SLASH FILTER DETECTED FAULT due to blocks %s and %s", b.Header.Cid(), witness) continue } } @@ -524,7 +531,7 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (minedBlock *type return nil, err } - rand, err := lrand.DrawRandomness(rbase.Data, crypto.DomainSeparationTag_WinningPoStChallengeSeed, round, buf.Bytes()) + rand, err := lrand.DrawRandomnessFromBase(rbase.Data, crypto.DomainSeparationTag_WinningPoStChallengeSeed, round, buf.Bytes()) if err != nil { err = xerrors.Errorf("failed to get randomness for winning post: %w", err) return nil, err @@ -593,7 +600,7 @@ func (m *Miner) computeTicket(ctx context.Context, brand *types.BeaconEntry, bas buf.Write(base.TipSet.MinTicket().VRFProof) } - input, err := lrand.DrawRandomness(brand.Data, crypto.DomainSeparationTag_TicketProduction, round-build.TicketRandomnessLookback, buf.Bytes()) + input, err := lrand.DrawRandomnessFromBase(brand.Data, crypto.DomainSeparationTag_TicketProduction, round-build.TicketRandomnessLookback, buf.Bytes()) if err != nil { return nil, err } diff --git a/node/builder.go b/node/builder.go index 10d366d56..f1a825be9 100644 --- a/node/builder.go +++ b/node/builder.go @@ -128,6 +128,8 @@ const ( SetupFallbackBlockstoresKey GoRPCServer + ConsensusReporterKey + SetApiEndpointKey StoreEventsKey diff --git a/node/builder_chain.go b/node/builder_chain.go index fcdb26162..267659f00 100644 --- a/node/builder_chain.go +++ b/node/builder_chain.go @@ -280,6 +280,11 @@ func ConfigFullNode(c interface{}) Option { // enable message index for full node when configured by the user, otherwise use dummy. If(cfg.Index.EnableMsgIndex, Override(new(index.MsgIndex), modules.MsgIndex)), If(!cfg.Index.EnableMsgIndex, Override(new(index.MsgIndex), modules.DummyMsgIndex)), + + // enable fault reporter when configured by the user + If(cfg.FaultReporter.EnableConsensusFaultReporter, + Override(ConsensusReporterKey, modules.RunConsensusFaultReporter(cfg.FaultReporter)), + ), ) } diff --git a/node/config/def.go b/node/config/def.go index 9a594c09e..4be902455 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -138,7 +138,6 @@ func DefaultStorageMiner() *StorageMiner { AvailableBalanceBuffer: types.FIL(big.Zero()), DisableCollateralFallback: false, - BatchPreCommits: true, MaxPreCommitBatch: miner5.PreCommitSectorBatchMaxSize, // up to 256 sectors PreCommitBatchWait: Duration(24 * time.Hour), // this should be less than 31.5 hours, which is the expiration of a precommit ticket // XXX snap deals wait deals slack if first diff --git a/node/config/doc_gen.go b/node/config/doc_gen.go index 8dc798458..1dec5b061 100644 --- a/node/config/doc_gen.go +++ b/node/config/doc_gen.go @@ -394,6 +394,35 @@ the database must already exist and be writeable. If a relative path is provided relative to the CWD (current working directory).`, }, }, + "FaultReporterConfig": []DocField{ + { + Name: "EnableConsensusFaultReporter", + Type: "bool", + + Comment: `EnableConsensusFaultReporter controls whether the node will monitor and +report consensus faults. When enabled, the node will watch for malicious +behaviors like double-mining and parent grinding, and submit reports to the +network. This can earn reporter rewards, but is not guaranteed. Nodes should +enable fault reporting with care, as it may increase resource usage, and may +generate gas fees without earning rewards.`, + }, + { + Name: "ConsensusFaultReporterDataDir", + Type: "string", + + Comment: `ConsensusFaultReporterDataDir is the path where fault reporter state will be +persisted. This directory should have adequate space and permissions for the +node process.`, + }, + { + Name: "ConsensusFaultReporterAddress", + Type: "string", + + Comment: `ConsensusFaultReporterAddress is the wallet address used for submitting +ReportConsensusFault messages. It will pay for gas fees, and receive any +rewards. This address should have adequate funds to cover gas fees.`, + }, + }, "FeeConfig": []DocField{ { Name: "DefaultMaxFee", @@ -465,6 +494,12 @@ Set to 0 to keep all mappings`, Name: "Index", Type: "IndexConfig", + Comment: ``, + }, + { + Name: "FaultReporter", + Type: "FaultReporterConfig", + Comment: ``, }, }, @@ -1169,12 +1204,6 @@ This is useful for forcing all deals to be assigned as snap deals to sectors mar Comment: `Don't send collateral with messages even if there is no available balance in the miner actor`, }, - { - Name: "BatchPreCommits", - Type: "bool", - - Comment: `enable / disable precommit batching (takes effect after nv13)`, - }, { Name: "MaxPreCommitBatch", Type: "int", @@ -1228,7 +1257,8 @@ This is useful for forcing all deals to be assigned as snap deals to sectors mar Type: "types.FIL", Comment: `network BaseFee below which to stop doing precommit batching, instead -sending precommit messages to the chain individually`, +sending precommit messages to the chain individually. When the basefee is +below this threshold, precommit messages will get sent out immediately.`, }, { Name: "AggregateAboveBaseFee", diff --git a/node/config/types.go b/node/config/types.go index f56cacc94..4a57390a3 100644 --- a/node/config/types.go +++ b/node/config/types.go @@ -22,13 +22,14 @@ type Common struct { // FullNode is a full node config type FullNode struct { Common - Client Client - Wallet Wallet - Fees FeeConfig - Chainstore Chainstore - Cluster UserRaftConfig - Fevm FevmConfig - Index IndexConfig + Client Client + Wallet Wallet + Fees FeeConfig + Chainstore Chainstore + Cluster UserRaftConfig + Fevm FevmConfig + Index IndexConfig + FaultReporter FaultReporterConfig } // // Common @@ -386,8 +387,6 @@ type SealingConfig struct { // Don't send collateral with messages even if there is no available balance in the miner actor DisableCollateralFallback bool - // enable / disable precommit batching (takes effect after nv13) - BatchPreCommits bool // maximum precommit batch size - batches will be sent immediately above this size MaxPreCommitBatch int // how long to wait before submitting a batch after crossing the minimum batch size @@ -407,7 +406,8 @@ type SealingConfig struct { CommitBatchSlack Duration // network BaseFee below which to stop doing precommit batching, instead - // sending precommit messages to the chain individually + // sending precommit messages to the chain individually. When the basefee is + // below this threshold, precommit messages will get sent out immediately. BatchPreCommitAboveBaseFee types.FIL // network BaseFee below which to stop doing commit aggregation, instead @@ -737,3 +737,23 @@ type IndexConfig struct { // EnableMsgIndex enables indexing of messages on chain. EnableMsgIndex bool } + +type FaultReporterConfig struct { + // EnableConsensusFaultReporter controls whether the node will monitor and + // report consensus faults. When enabled, the node will watch for malicious + // behaviors like double-mining and parent grinding, and submit reports to the + // network. This can earn reporter rewards, but is not guaranteed. Nodes should + // enable fault reporting with care, as it may increase resource usage, and may + // generate gas fees without earning rewards. + EnableConsensusFaultReporter bool + + // ConsensusFaultReporterDataDir is the path where fault reporter state will be + // persisted. This directory should have adequate space and permissions for the + // node process. + ConsensusFaultReporterDataDir string + + // ConsensusFaultReporterAddress is the wallet address used for submitting + // ReportConsensusFault messages. It will pay for gas fees, and receive any + // rewards. This address should have adequate funds to cover gas fees. + ConsensusFaultReporterAddress string +} diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 40bdbfdcc..357584ea0 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -19,8 +19,6 @@ import ( "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" - minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" - verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" @@ -794,7 +792,7 @@ func (a *StateAPI) StateGetAllocationForPendingDeal(ctx context.Context, dealId if err != nil { return nil, err } - if allocationId == verifregtypes.NoAllocationID { + if allocationId == verifreg.NoAllocationID { return nil, nil } @@ -1040,7 +1038,7 @@ func (a *StateAPI) StateMinerAllocated(ctx context.Context, addr address.Address return mas.GetAllocatedSectors() } -func (a *StateAPI) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*minertypes.SectorPreCommitOnChainInfo, error) { +func (a *StateAPI) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorPreCommitOnChainInfo, error) { ts, err := a.Chain.GetTipSetFromKey(ctx, tsk) if err != nil { return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err) @@ -1315,7 +1313,7 @@ func (m *StateModule) MsigGetPending(ctx context.Context, addr address.Address, var initialPledgeNum = types.NewInt(110) var initialPledgeDen = types.NewInt(100) -func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr address.Address, pci minertypes.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) { +func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) { ts, err := a.Chain.GetTipSetFromKey(ctx, tsk) if err != nil { return types.EmptyInt, xerrors.Errorf("loading tipset %s: %w", tsk, err) @@ -1347,7 +1345,7 @@ func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr sectorWeight = builtin.QAPowerForWeight(ssize, duration, w, vw) } } else { - sectorWeight = minertypes.QAPowerMax(ssize) + sectorWeight = miner.QAPowerMax(ssize) } var powerSmoothed builtin.FilterEstimate @@ -1379,7 +1377,7 @@ func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr return types.BigDiv(types.BigMul(deposit, initialPledgeNum), initialPledgeDen), nil } -func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci minertypes.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) { +func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) { // TODO: this repeats a lot of the previous function. Fix that. ts, err := a.Chain.GetTipSetFromKey(ctx, tsk) if err != nil { @@ -1752,7 +1750,34 @@ func (a *StateAPI) StateGetRandomnessFromTickets(ctx context.Context, personaliz func (a *StateAPI) StateGetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error) { return a.StateManager.GetRandomnessFromBeacon(ctx, personalization, randEpoch, entropy, tsk) +} +func (a *StateAPI) StateGetRandomnessDigestFromTickets(ctx context.Context, randEpoch abi.ChainEpoch, tsk types.TipSetKey) (abi.Randomness, error) { + ts, err := a.Chain.GetTipSetFromKey(ctx, tsk) + if err != nil { + return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err) + } + + ret, err := a.StateManager.GetRandomnessDigestFromTickets(ctx, randEpoch, ts.Key()) + if err != nil { + return nil, xerrors.Errorf("failed to get randomness digest from tickets: %w", err) + } + + return ret[:], nil +} + +func (a *StateAPI) StateGetRandomnessDigestFromBeacon(ctx context.Context, randEpoch abi.ChainEpoch, tsk types.TipSetKey) (abi.Randomness, error) { + ts, err := a.Chain.GetTipSetFromKey(ctx, tsk) + if err != nil { + return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err) + } + + ret, err := a.StateManager.GetRandomnessDigestFromBeacon(ctx, randEpoch, ts.Key()) + if err != nil { + return nil, xerrors.Errorf("failed to get randomness digest from tickets: %w", err) + } + + return ret[:], nil } func (a *StateAPI) StateGetBeaconEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) { diff --git a/node/impl/full/sync.go b/node/impl/full/sync.go index 9be43338e..223f5c29e 100644 --- a/node/impl/full/sync.go +++ b/node/impl/full/sync.go @@ -58,9 +58,16 @@ func (a *SyncAPI) SyncSubmitBlock(ctx context.Context, blk *types.BlockMsg) erro } if a.SlashFilter != nil && os.Getenv("LOTUS_NO_SLASHFILTER") != "_yes_i_know_i_can_and_probably_will_lose_all_my_fil_and_power_" { - if _, err = a.SlashFilter.MinedBlock(ctx, blk.Header, parent.Height); err != nil { - log.Errorf(" SLASH FILTER ERROR: %s", err) - return xerrors.Errorf(" SLASH FILTER ERROR: %w", err) + witness, fault, err := a.SlashFilter.MinedBlock(ctx, blk.Header, parent.Height) + if err != nil { + log.Errorf(" SLASH FILTER ERRORED: %s", err) + // Return an error here, because it's _probably_ wiser to not submit this block + return xerrors.Errorf(" SLASH FILTER ERRORED: %w", err) + } + + if fault { + log.Errorf(" SLASH FILTER DETECTED FAULT due to witness %s", witness) + return xerrors.Errorf(" SLASH FILTER DETECTED FAULT due to witness %s", witness) } } diff --git a/node/impl/storminer.go b/node/impl/storminer.go index e4fa41c78..6f460eccd 100644 --- a/node/impl/storminer.go +++ b/node/impl/storminer.go @@ -35,7 +35,6 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" builtintypes "github.com/filecoin-project/go-state-types/builtin" - minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/api" @@ -43,6 +42,7 @@ import ( "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/builtin" + lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/gen" "github.com/filecoin-project/lotus/chain/types" mktsdagstore "github.com/filecoin-project/lotus/markets/dagstore" @@ -488,7 +488,7 @@ func (sm *StorageMinerAPI) SectorReceive(ctx context.Context, meta api.RemoteSec return err } -func (sm *StorageMinerAPI) ComputeWindowPoSt(ctx context.Context, dlIdx uint64, tsk types.TipSetKey) ([]minertypes.SubmitWindowedPoStParams, error) { +func (sm *StorageMinerAPI) ComputeWindowPoSt(ctx context.Context, dlIdx uint64, tsk types.TipSetKey) ([]lminer.SubmitWindowedPoStParams, error) { var ts *types.TipSet var err error if tsk == types.EmptyTSK { @@ -1395,7 +1395,7 @@ func (sm *StorageMinerAPI) withdrawBalance(ctx context.Context, amount abi.Token amount = available } - params, err := actors.SerializeParams(&minertypes.WithdrawBalanceParams{ + params, err := actors.SerializeParams(&lminer.WithdrawBalanceParams{ AmountRequested: amount, }) if err != nil { diff --git a/node/modules/faultreport.go b/node/modules/faultreport.go new file mode 100644 index 000000000..c42602d7e --- /dev/null +++ b/node/modules/faultreport.go @@ -0,0 +1,27 @@ +package modules + +import ( + "go.uber.org/fx" + + "github.com/filecoin-project/lotus/chain/gen/slashfilter/slashsvc" + "github.com/filecoin-project/lotus/node/config" + "github.com/filecoin-project/lotus/node/impl/full" + "github.com/filecoin-project/lotus/node/modules/helpers" +) + +type consensusReporterModules struct { + fx.In + + full.WalletAPI + full.ChainAPI + full.MpoolAPI + full.SyncAPI +} + +func RunConsensusFaultReporter(config config.FaultReporterConfig) func(mctx helpers.MetricsCtx, lc fx.Lifecycle, mod consensusReporterModules) error { + return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, mod consensusReporterModules) error { + ctx := helpers.LifecycleCtx(mctx, lc) + + return slashsvc.SlashConsensus(ctx, &mod, config.ConsensusFaultReporterDataDir, config.ConsensusFaultReporterAddress) + } +} diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index 1cac7b499..12879cd64 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -1001,7 +1001,6 @@ func NewSetSealConfigFunc(r repo.LockedRepo) (dtypes.SetSealingConfigFunc, error AvailableBalanceBuffer: types.FIL(cfg.AvailableBalanceBuffer), DisableCollateralFallback: cfg.DisableCollateralFallback, - BatchPreCommits: cfg.BatchPreCommits, MaxPreCommitBatch: cfg.MaxPreCommitBatch, PreCommitBatchWait: config.Duration(cfg.PreCommitBatchWait), PreCommitBatchSlack: config.Duration(cfg.PreCommitBatchSlack), @@ -1047,7 +1046,6 @@ func ToSealingConfig(dealmakingCfg config.DealmakingConfig, sealingCfg config.Se AvailableBalanceBuffer: types.BigInt(sealingCfg.AvailableBalanceBuffer), DisableCollateralFallback: sealingCfg.DisableCollateralFallback, - BatchPreCommits: sealingCfg.BatchPreCommits, MaxPreCommitBatch: sealingCfg.MaxPreCommitBatch, PreCommitBatchWait: time.Duration(sealingCfg.PreCommitBatchWait), PreCommitBatchSlack: time.Duration(sealingCfg.PreCommitBatchSlack), diff --git a/storage/pipeline/commit_batch.go b/storage/pipeline/commit_batch.go index 9948b5432..754f31763 100644 --- a/storage/pipeline/commit_batch.go +++ b/storage/pipeline/commit_batch.go @@ -16,12 +16,12 @@ import ( actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/go-state-types/proof" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/config" diff --git a/storage/pipeline/commit_batch_test.go b/storage/pipeline/commit_batch_test.go index 15c2100cb..5ae2f171a 100644 --- a/storage/pipeline/commit_batch_test.go +++ b/storage/pipeline/commit_batch_test.go @@ -53,7 +53,6 @@ func TestCommitBatcher(t *testing.T) { WaitDealsDelay: time.Hour * 6, AlwaysKeepUnsealedCopy: true, - BatchPreCommits: true, MaxPreCommitBatch: miner5.PreCommitSectorBatchMaxSize, PreCommitBatchWait: 24 * time.Hour, PreCommitBatchSlack: 3 * time.Hour, diff --git a/storage/pipeline/fsm.go b/storage/pipeline/fsm.go index 8ae18a9fd..ac3dafa86 100644 --- a/storage/pipeline/fsm.go +++ b/storage/pipeline/fsm.go @@ -90,7 +90,7 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto on(SectorOldTicket{}, GetTicket), ), PreCommit2: planOne( - on(SectorPreCommit2{}, PreCommitting), + on(SectorPreCommit2{}, SubmitPreCommitBatch), on(SectorSealPreCommit2Failed{}, SealPreCommit2Failed), on(SectorSealPreCommit1Failed{}, SealPreCommit1Failed), ), diff --git a/storage/pipeline/fsm_test.go b/storage/pipeline/fsm_test.go index f12b66f93..4dfc8548d 100644 --- a/storage/pipeline/fsm_test.go +++ b/storage/pipeline/fsm_test.go @@ -54,10 +54,10 @@ func TestHappyPath(t *testing.T) { require.Equal(m.t, m.state.State, PreCommit2) m.planSingle(SectorPreCommit2{}) - require.Equal(m.t, m.state.State, PreCommitting) + require.Equal(m.t, m.state.State, SubmitPreCommitBatch) - m.planSingle(SectorPreCommitted{}) - require.Equal(m.t, m.state.State, PreCommitWait) + m.planSingle(SectorPreCommitBatchSent{}) + require.Equal(m.t, m.state.State, PreCommitBatchWait) m.planSingle(SectorPreCommitLanded{}) require.Equal(m.t, m.state.State, WaitSeed) @@ -77,7 +77,7 @@ func TestHappyPath(t *testing.T) { m.planSingle(SectorFinalized{}) require.Equal(m.t, m.state.State, Proving) - expected := []SectorState{Packing, GetTicket, PreCommit1, PreCommit2, PreCommitting, PreCommitWait, WaitSeed, Committing, SubmitCommit, CommitWait, FinalizeSector, Proving} + expected := []SectorState{Packing, GetTicket, PreCommit1, PreCommit2, SubmitPreCommitBatch, PreCommitBatchWait, WaitSeed, Committing, SubmitCommit, CommitWait, FinalizeSector, Proving} for i, n := range notif { if n.before.State != expected[i] { t.Fatalf("expected before state: %s, got: %s", expected[i], n.before.State) @@ -116,10 +116,10 @@ func TestHappyPathFinalizeEarly(t *testing.T) { require.Equal(m.t, m.state.State, PreCommit2) m.planSingle(SectorPreCommit2{}) - require.Equal(m.t, m.state.State, PreCommitting) + require.Equal(m.t, m.state.State, SubmitPreCommitBatch) - m.planSingle(SectorPreCommitted{}) - require.Equal(m.t, m.state.State, PreCommitWait) + m.planSingle(SectorPreCommitBatchSent{}) + require.Equal(m.t, m.state.State, PreCommitBatchWait) m.planSingle(SectorPreCommitLanded{}) require.Equal(m.t, m.state.State, WaitSeed) @@ -145,7 +145,7 @@ func TestHappyPathFinalizeEarly(t *testing.T) { m.planSingle(SectorFinalized{}) require.Equal(m.t, m.state.State, Proving) - expected := []SectorState{Packing, GetTicket, PreCommit1, PreCommit2, PreCommitting, PreCommitWait, WaitSeed, Committing, CommitFinalize, SubmitCommit, SubmitCommitAggregate, CommitAggregateWait, FinalizeSector, Proving} + expected := []SectorState{Packing, GetTicket, PreCommit1, PreCommit2, SubmitPreCommitBatch, PreCommitBatchWait, WaitSeed, Committing, CommitFinalize, SubmitCommit, SubmitCommitAggregate, CommitAggregateWait, FinalizeSector, Proving} for i, n := range notif { if n.before.State != expected[i] { t.Fatalf("expected before state: %s, got: %s", expected[i], n.before.State) @@ -220,10 +220,10 @@ func TestSeedRevert(t *testing.T) { require.Equal(m.t, m.state.State, PreCommit2) m.planSingle(SectorPreCommit2{}) - require.Equal(m.t, m.state.State, PreCommitting) + require.Equal(m.t, m.state.State, SubmitPreCommitBatch) - m.planSingle(SectorPreCommitted{}) - require.Equal(m.t, m.state.State, PreCommitWait) + m.planSingle(SectorPreCommitBatchSent{}) + require.Equal(m.t, m.state.State, PreCommitBatchWait) m.planSingle(SectorPreCommitLanded{}) require.Equal(m.t, m.state.State, WaitSeed) diff --git a/storage/pipeline/precommit_batch.go b/storage/pipeline/precommit_batch.go index 63e263662..3a86c8628 100644 --- a/storage/pipeline/precommit_batch.go +++ b/storage/pipeline/precommit_batch.go @@ -7,19 +7,18 @@ import ( "sync" "time" - "github.com/ipfs/go-cid" "golang.org/x/xerrors" "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/builtin" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/config" @@ -193,33 +192,30 @@ func (b *PreCommitBatcher) maybeStartBatch(notif bool) ([]sealiface.PreCommitBat return nil, xerrors.Errorf("getting config: %w", err) } - if notif && total < cfg.MaxPreCommitBatch { - return nil, nil - } - ts, err := b.api.ChainHead(b.mctx) if err != nil { return nil, err } - // TODO: Drop this once nv14 has come and gone + curBasefeeLow := false + if !cfg.BatchPreCommitAboveBaseFee.Equals(big.Zero()) && ts.MinTicketBlock().ParentBaseFee.LessThan(cfg.BatchPreCommitAboveBaseFee) { + curBasefeeLow = true + } + + // if this wasn't an user-forced batch, and we're not at/above the max batch size, + // and we're not above the basefee threshold, don't batch yet + if notif && total < cfg.MaxPreCommitBatch && !curBasefeeLow { + return nil, nil + } + nv, err := b.api.StateNetworkVersion(b.mctx, ts.Key()) if err != nil { return nil, xerrors.Errorf("couldn't get network version: %w", err) } - individual := false - if !cfg.BatchPreCommitAboveBaseFee.Equals(big.Zero()) && ts.MinTicketBlock().ParentBaseFee.LessThan(cfg.BatchPreCommitAboveBaseFee) && nv >= network.Version14 { - individual = true - } - - // todo support multiple batches - var res []sealiface.PreCommitBatchRes - if !individual { - res, err = b.processBatch(cfg, ts.Key(), ts.MinTicketBlock().ParentBaseFee, nv) - } else { - res, err = b.processIndividually(cfg) - } + // For precommits the only method to precommit sectors after nv21(22?) is to use the new precommit_batch2 method + // So we always batch + res, err := b.processBatch(cfg, ts.Key(), ts.MinTicketBlock().ParentBaseFee, nv) if err != nil && len(res) == 0 { return nil, err } @@ -243,91 +239,14 @@ func (b *PreCommitBatcher) maybeStartBatch(notif bool) ([]sealiface.PreCommitBat return res, nil } -func (b *PreCommitBatcher) processIndividually(cfg sealiface.Config) ([]sealiface.PreCommitBatchRes, error) { - mi, err := b.api.StateMinerInfo(b.mctx, b.maddr, types.EmptyTSK) - if err != nil { - return nil, xerrors.Errorf("couldn't get miner info: %w", err) - } - - avail := types.TotalFilecoinInt - - if cfg.CollateralFromMinerBalance && !cfg.DisableCollateralFallback { - avail, err = b.api.StateMinerAvailableBalance(b.mctx, b.maddr, types.EmptyTSK) - if err != nil { - return nil, xerrors.Errorf("getting available miner balance: %w", err) - } - - avail = big.Sub(avail, cfg.AvailableBalanceBuffer) - if avail.LessThan(big.Zero()) { - avail = big.Zero() - } - } - - var res []sealiface.PreCommitBatchRes - - for sn, info := range b.todo { - r := sealiface.PreCommitBatchRes{ - Sectors: []abi.SectorNumber{sn}, - } - - mcid, err := b.processSingle(cfg, mi, &avail, info) - if err != nil { - r.Error = err.Error() - } else { - r.Msg = &mcid - } - - res = append(res, r) - } - - return res, nil -} - -func (b *PreCommitBatcher) processSingle(cfg sealiface.Config, mi api.MinerInfo, avail *abi.TokenAmount, entry *preCommitEntry) (cid.Cid, error) { - msgParams := infoToPreCommitSectorParams(entry.pci) - enc := new(bytes.Buffer) - - if err := msgParams.MarshalCBOR(enc); err != nil { - return cid.Undef, xerrors.Errorf("marshaling precommit params: %w", err) - } - - deposit := entry.deposit - if cfg.CollateralFromMinerBalance { - c := big.Sub(deposit, *avail) - *avail = big.Sub(*avail, deposit) - deposit = c - - if deposit.LessThan(big.Zero()) { - deposit = big.Zero() - } - if (*avail).LessThan(big.Zero()) { - *avail = big.Zero() - } - } - - goodFunds := big.Add(deposit, big.Int(b.feeCfg.MaxPreCommitGasFee)) - - from, _, err := b.addrSel.AddressFor(b.mctx, b.api, mi, api.PreCommitAddr, goodFunds, deposit) - if err != nil { - return cid.Undef, xerrors.Errorf("no good address to send precommit message from: %w", err) - } - - mcid, err := sendMsg(b.mctx, b.api, from, b.maddr, builtin.MethodsMiner.PreCommitSector, deposit, big.Int(b.feeCfg.MaxPreCommitGasFee), enc.Bytes()) - if err != nil { - return cid.Undef, xerrors.Errorf("pushing message to mpool: %w", err) - } - - return mcid, nil -} - func (b *PreCommitBatcher) processPreCommitBatch(cfg sealiface.Config, bf abi.TokenAmount, entries []*preCommitEntry, nv network.Version) ([]sealiface.PreCommitBatchRes, error) { - params := miner.PreCommitSectorBatchParams{} + params := miner.PreCommitSectorBatchParams2{} deposit := big.Zero() var res sealiface.PreCommitBatchRes for _, p := range entries { res.Sectors = append(res.Sectors, p.pci.SectorNumber) - params.Sectors = append(params.Sectors, *infoToPreCommitSectorParams(p.pci)) + params.Sectors = append(params.Sectors, *p.pci) deposit = big.Add(deposit, p.deposit) } @@ -367,7 +286,7 @@ func (b *PreCommitBatcher) processPreCommitBatch(cfg sealiface.Config, bf abi.To return []sealiface.PreCommitBatchRes{res}, xerrors.Errorf("no good address found: %w", err) } - _, err = simulateMsgGas(b.mctx, b.api, from, b.maddr, builtin.MethodsMiner.PreCommitSectorBatch, needFunds, maxFee, enc.Bytes()) + _, err = simulateMsgGas(b.mctx, b.api, from, b.maddr, builtin.MethodsMiner.PreCommitSectorBatch2, needFunds, maxFee, enc.Bytes()) if err != nil && (!api.ErrorIsIn(err, []error{&api.ErrOutOfGas{}}) || len(entries) == 1) { res.Error = err.Error() @@ -385,7 +304,7 @@ func (b *PreCommitBatcher) processPreCommitBatch(cfg sealiface.Config, bf abi.To } // If state call succeeds, we can send the message for real - mcid, err := sendMsg(b.mctx, b.api, from, b.maddr, builtin.MethodsMiner.PreCommitSectorBatch, needFunds, maxFee, enc.Bytes()) + mcid, err := sendMsg(b.mctx, b.api, from, b.maddr, builtin.MethodsMiner.PreCommitSectorBatch2, needFunds, maxFee, enc.Bytes()) if err != nil { res.Error = err.Error() return []sealiface.PreCommitBatchRes{res}, xerrors.Errorf("pushing message to mpool: %w", err) diff --git a/storage/pipeline/precommit_batch_test.go b/storage/pipeline/precommit_batch_test.go index 6951faad7..1f3aaf244 100644 --- a/storage/pipeline/precommit_batch_test.go +++ b/storage/pipeline/precommit_batch_test.go @@ -56,7 +56,6 @@ func TestPrecommitBatcher(t *testing.T) { WaitDealsDelay: time.Hour * 6, AlwaysKeepUnsealedCopy: true, - BatchPreCommits: true, MaxPreCommitBatch: maxBatch, PreCommitBatchWait: 24 * time.Hour, PreCommitBatchSlack: 3 * time.Hour, @@ -114,7 +113,7 @@ func TestPrecommitBatcher(t *testing.T) { basefee = big.NewInt(10001) } - s.EXPECT().ChainHead(gomock.Any()).Return(makeBFTs(t, basefee, 1), nil) + s.EXPECT().ChainHead(gomock.Any()).Return(makeBFTs(t, basefee, 1), nil).MaxTimes(2) // once in AddPreCommit go func() { defer done.Unlock() @@ -183,28 +182,6 @@ func TestPrecommitBatcher(t *testing.T) { expectInitialCalls := func() action { return func(t *testing.T, s *mocks.MockPreCommitBatcherApi, pcb *pipeline.PreCommitBatcher) promise { s.EXPECT().ChainHead(gomock.Any()).Return(makeBFTs(t, big.NewInt(10001), 1), nil) - s.EXPECT().StateNetworkVersion(gomock.Any(), gomock.Any()).Return(network.Version14, nil) - return nil - } - } - - //stm: @CHAIN_STATE_MINER_INFO_001, @CHAIN_STATE_NETWORK_VERSION_001 - expectSendsSingle := func(expect []abi.SectorNumber) action { - return func(t *testing.T, s *mocks.MockPreCommitBatcherApi, pcb *pipeline.PreCommitBatcher) promise { - s.EXPECT().ChainHead(gomock.Any()).Return(makeBFTs(t, big.NewInt(9999), 1), nil) - s.EXPECT().StateNetworkVersion(gomock.Any(), gomock.Any()).Return(network.Version14, nil) - - s.EXPECT().StateMinerInfo(gomock.Any(), gomock.Any(), gomock.Any()).Return(api.MinerInfo{Owner: t0123, Worker: t0123}, nil) - for _, number := range expect { - numClone := number - s.EXPECT().MpoolPushMessage(gomock.Any(), funMatcher(func(i interface{}) bool { - b := i.(*types.Message) - var params miner6.PreCommitSectorParams - require.NoError(t, params.UnmarshalCBOR(bytes.NewReader(b.Params))) - require.Equal(t, numClone, params.SectorNumber) - return true - }), gomock.Any()).Return(dummySmsg, nil) - } return nil } } @@ -240,18 +217,11 @@ func TestPrecommitBatcher(t *testing.T) { }{ "addSingle": { actions: []action{ - addSector(0, false), + addSector(0, true), waitPending(1), flush([]abi.SectorNumber{0}), }, }, - "addTwo": { - actions: []action{ - addSectors(getSectors(2), false), - waitPending(2), - flush(getSectors(2)), - }, - }, "addMax": { actions: []action{ expectInitialCalls(), @@ -268,10 +238,10 @@ func TestPrecommitBatcher(t *testing.T) { addSectors(getSectors(maxBatch), true), }, }, - "addMax-belowBaseFee": { + "addOne-belowBaseFee": { actions: []action{ - expectSendsSingle(getSectors(maxBatch)), - addSectors(getSectors(maxBatch), false), + expectSend(getSectors(1), false), + addSectors(getSectors(1), false), }, }, } @@ -287,6 +257,7 @@ func TestPrecommitBatcher(t *testing.T) { // create them mocks pcapi := mocks.NewMockPreCommitBatcherApi(mockCtrl) + pcapi.EXPECT().StateNetworkVersion(gomock.Any(), gomock.Any()).Return(network.Version20, nil).AnyTimes() pcb := pipeline.NewPreCommitBatcher(ctx, t0123, pcapi, as, fc, cfg) diff --git a/storage/pipeline/sealiface/config.go b/storage/pipeline/sealiface/config.go index 65a6d4404..e41b143ec 100644 --- a/storage/pipeline/sealiface/config.go +++ b/storage/pipeline/sealiface/config.go @@ -42,7 +42,6 @@ type Config struct { AvailableBalanceBuffer abi.TokenAmount DisableCollateralFallback bool - BatchPreCommits bool MaxPreCommitBatch int PreCommitBatchWait time.Duration PreCommitBatchSlack time.Duration diff --git a/storage/pipeline/sealing.go b/storage/pipeline/sealing.go index e990a8f51..65d3fb14b 100644 --- a/storage/pipeline/sealing.go +++ b/storage/pipeline/sealing.go @@ -15,7 +15,6 @@ import ( "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" @@ -24,6 +23,7 @@ import ( "github.com/filecoin-project/go-storedcounter" "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/events" "github.com/filecoin-project/lotus/chain/types" diff --git a/storage/pipeline/sector_state.go b/storage/pipeline/sector_state.go index 84c08f43b..e1f5bfd69 100644 --- a/storage/pipeline/sector_state.go +++ b/storage/pipeline/sector_state.go @@ -82,7 +82,7 @@ const ( PreCommit1 SectorState = "PreCommit1" // do PreCommit1 PreCommit2 SectorState = "PreCommit2" // do PreCommit2 - PreCommitting SectorState = "PreCommitting" // on chain pre-commit + PreCommitting SectorState = "PreCommitting" // on chain pre-commit (deprecated) PreCommitWait SectorState = "PreCommitWait" // waiting for precommit to land on chain SubmitPreCommitBatch SectorState = "SubmitPreCommitBatch" diff --git a/storage/pipeline/states_failed.go b/storage/pipeline/states_failed.go index d952d8eda..cf9bd4d12 100644 --- a/storage/pipeline/states_failed.go +++ b/storage/pipeline/states_failed.go @@ -10,12 +10,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-commp-utils/zerocomm" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-statemachine" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/actors/builtin/market" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/storage/sealer/storiface" ) diff --git a/storage/pipeline/states_replica_update.go b/storage/pipeline/states_replica_update.go index e1b9cfc30..6717f49a6 100644 --- a/storage/pipeline/states_replica_update.go +++ b/storage/pipeline/states_replica_update.go @@ -10,12 +10,12 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-statemachine" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/types" ) diff --git a/storage/pipeline/states_sealing.go b/storage/pipeline/states_sealing.go index 0608ead07..6caa66494 100644 --- a/storage/pipeline/states_sealing.go +++ b/storage/pipeline/states_sealing.go @@ -15,7 +15,6 @@ import ( actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/network" @@ -24,6 +23,7 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/storage/pipeline/lib/nullreader" @@ -368,6 +368,10 @@ func (m *Sealing) preCommitInfo(ctx statemachine.Context, sector SectorInfo) (*m DealIDs: sector.dealIDs(), } + if sector.hasDeals() { + params.UnsealedCid = sector.CommD + } + collateral, err := m.Api.StateMinerPreCommitDepositForPower(ctx.Context(), m.maddr, *params, ts.Key()) if err != nil { return nil, big.Zero(), types.EmptyTSK, xerrors.Errorf("getting initial pledge collateral: %w", err) @@ -377,62 +381,10 @@ func (m *Sealing) preCommitInfo(ctx statemachine.Context, sector SectorInfo) (*m } func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInfo) error { - cfg, err := m.getConfig() - if err != nil { - return xerrors.Errorf("getting config: %w", err) - } - - if cfg.BatchPreCommits { - nv, err := m.Api.StateNetworkVersion(ctx.Context(), types.EmptyTSK) - if err != nil { - return xerrors.Errorf("getting network version: %w", err) - } - - if nv >= network.Version13 { - return ctx.Send(SectorPreCommitBatch{}) - } - } - - info, pcd, tsk, err := m.preCommitInfo(ctx, sector) - if err != nil { - return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("preCommitInfo: %w", err)}) - } - if info == nil { - return nil // event was sent in preCommitInfo - } - - params := infoToPreCommitSectorParams(info) - - deposit, err := collateralSendAmount(ctx.Context(), m.Api, m.maddr, cfg, pcd) - if err != nil { - return err - } - - enc := new(bytes.Buffer) - if err := params.MarshalCBOR(enc); err != nil { - return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("could not serialize pre-commit sector parameters: %w", err)}) - } - - mi, err := m.Api.StateMinerInfo(ctx.Context(), m.maddr, tsk) - if err != nil { - log.Errorf("handlePreCommitting: api error, not proceeding: %+v", err) - return nil - } - - goodFunds := big.Add(deposit, big.Int(m.feeCfg.MaxPreCommitGasFee)) - - from, _, err := m.addrSel.AddressFor(ctx.Context(), m.Api, mi, api.PreCommitAddr, goodFunds, deposit) - if err != nil { - return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("no good address to send precommit message from: %w", err)}) - } - - log.Infof("submitting precommit for sector %d (deposit: %s): ", sector.SectorNumber, deposit) - mcid, err := sendMsg(ctx.Context(), m.Api, from, m.maddr, builtin.MethodsMiner.PreCommitSector, deposit, big.Int(m.feeCfg.MaxPreCommitGasFee), enc.Bytes()) - if err != nil { - return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("pushing message to mpool: %w", err)}) - } - - return ctx.Send(SectorPreCommitted{Message: mcid, PreCommitDeposit: pcd, PreCommitInfo: *info}) + // note: this is a legacy state handler, normally new sectors won't enter this state + // but we keep this handler in order to not break existing sector state machines. + // todo: drop after nv21 + return ctx.Send(SectorPreCommitBatch{}) } func (m *Sealing) handleSubmitPreCommitBatch(ctx statemachine.Context, sector SectorInfo) error { diff --git a/storage/pipeline/utils.go b/storage/pipeline/utils.go index ce4283b6c..4b99a5bea 100644 --- a/storage/pipeline/utils.go +++ b/storage/pipeline/utils.go @@ -10,7 +10,6 @@ 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/builtin/v9/miner" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/types" @@ -127,14 +126,3 @@ func sendMsg(ctx context.Context, sa interface { return smsg.Cid(), nil } - -func infoToPreCommitSectorParams(info *miner.SectorPreCommitInfo) *miner.PreCommitSectorParams { - return &miner.PreCommitSectorParams{ - SealProof: info.SealProof, - SectorNumber: info.SectorNumber, - SealedCID: info.SealedCID, - SealRandEpoch: info.SealRandEpoch, - DealIDs: info.DealIDs, - Expiration: info.Expiration, - } -} diff --git a/storage/wdpost/wdpost_changehandler.go b/storage/wdpost/wdpost_changehandler.go index 266b8b042..5f4b0ca0c 100644 --- a/storage/wdpost/wdpost_changehandler.go +++ b/storage/wdpost/wdpost_changehandler.go @@ -6,9 +6,9 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/dline" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" ) @@ -531,12 +531,12 @@ func nextDeadline(currentDeadline *dline.Info) *dline.Info { newDeadline := currentDeadline.Index + 1 if newDeadline == miner.WPoStPeriodDeadlines { newDeadline = 0 - periodStart = periodStart + miner.WPoStProvingPeriod + periodStart = periodStart + miner.WPoStProvingPeriod() } return NewDeadlineInfo(periodStart, newDeadline, currentDeadline.CurrentEpoch) } func NewDeadlineInfo(periodStart abi.ChainEpoch, deadlineIdx uint64, currEpoch abi.ChainEpoch) *dline.Info { - return dline.NewInfo(periodStart, deadlineIdx, currEpoch, miner.WPoStPeriodDeadlines, miner.WPoStProvingPeriod, miner.WPoStChallengeWindow, miner.WPoStChallengeLookback, miner.FaultDeclarationCutoff) + return dline.NewInfo(periodStart, deadlineIdx, currEpoch, miner.WPoStPeriodDeadlines, miner.WPoStProvingPeriod(), miner.WPoStChallengeWindow(), miner.WPoStChallengeLookback, miner.FaultDeclarationCutoff) } diff --git a/storage/wdpost/wdpost_journal.go b/storage/wdpost/wdpost_journal.go index 406628f68..68cad3fcf 100644 --- a/storage/wdpost/wdpost_journal.go +++ b/storage/wdpost/wdpost_journal.go @@ -4,8 +4,9 @@ import ( "github.com/ipfs/go-cid" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/dline" + + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" ) // SchedulerState defines the possible states in which the scheduler could be, diff --git a/storage/wdpost/wdpost_run.go b/storage/wdpost/wdpost_run.go index c2a448fb0..d70d0254f 100644 --- a/storage/wdpost/wdpost_run.go +++ b/storage/wdpost/wdpost_run.go @@ -15,7 +15,6 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/network" @@ -25,6 +24,7 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/messagepool" "github.com/filecoin-project/lotus/chain/types" diff --git a/storage/wdpost/wdpost_run_faults.go b/storage/wdpost/wdpost_run_faults.go index 2474ce77b..ebdd66a69 100644 --- a/storage/wdpost/wdpost_run_faults.go +++ b/storage/wdpost/wdpost_run_faults.go @@ -14,12 +14,12 @@ import ( "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" ) diff --git a/storage/wdpost/wdpost_sched.go b/storage/wdpost/wdpost_sched.go index 29c39ad9e..8e2a8bc96 100644 --- a/storage/wdpost/wdpost_sched.go +++ b/storage/wdpost/wdpost_sched.go @@ -12,14 +12,13 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" - lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/journal" @@ -45,7 +44,7 @@ type NodeAPI interface { StateMinerPartitions(context.Context, address.Address, uint64, types.TipSetKey) ([]api.Partition, error) StateLookupID(context.Context, address.Address, types.TipSetKey) (address.Address, error) StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error) - StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*lminer.SectorLocation, error) + StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error) MpoolPushMessage(context.Context, *types.Message, *api.MessageSendSpec) (*types.SignedMessage, error)