Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] FIP0013 integration for Actors v5 #5769

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/api_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ type StorageMiner interface {
// SectorTerminatePending returns a list of pending sector terminations to be sent in the next batch message
SectorTerminatePending(ctx context.Context) ([]abi.SectorID, error) //perm:admin
SectorMarkForUpgrade(ctx context.Context, id abi.SectorNumber) error //perm:admin
SectorCommitFlush(ctx context.Context) (*cid.Cid, error) //perm:admin
SectorCommitPending(ctx context.Context) ([]abi.SectorID, error) //perm:admin

// WorkerConnect tells the node to connect to workers RPC
WorkerConnect(context.Context, string) error //perm:admin retry:true
Expand Down
12 changes: 12 additions & 0 deletions api/apistruct/struct.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified build/openrpc/full.json.gz
Binary file not shown.
Binary file modified build/openrpc/miner.json.gz
Binary file not shown.
Binary file modified build/openrpc/worker.json.gz
Binary file not shown.
4 changes: 4 additions & 0 deletions build/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ import rice "github.com/GeertJohan/go.rice"
func ParametersJSON() []byte {
return rice.MustFindBox("proof-params").MustBytes("parameters.json")
}

func SrsJSON() []byte {
return rice.MustFindBox("proof-params").MustBytes("srs-inner-product.json")
}
7 changes: 7 additions & 0 deletions build/proof-params/srs-inner-product.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"v28-fil-inner-product-v1.srs": {
"cid": "Qmdq44DjcQnFfU3PJcdX7J49GCqcUYszr1TxMbHtAkvQ3g",
"digest": "ae20310138f5ba81451d723f858e3797",
"sector_size": 0
}
}
24 changes: 16 additions & 8 deletions chain/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"go.opencensus.io/trace"
"golang.org/x/xerrors"

proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof"
proof3 "github.com/filecoin-project/specs-actors/v3/actors/runtime/proof"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/blockstore"
Expand All @@ -50,7 +50,7 @@ const msgsPerBlock = 20
//nolint:deadcode,varcheck
var log = logging.Logger("gen")

var ValidWpostForTesting = []proof2.PoStProof{{
var ValidWpostForTesting = []proof3.PoStProof{{
ProofBytes: []byte("valid proof"),
}}

Expand Down Expand Up @@ -459,7 +459,7 @@ func (cg *ChainGen) NextTipSetFromMinersWithMessages(base *types.TipSet, miners

func (cg *ChainGen) makeBlock(parents *types.TipSet, m address.Address, vrfticket *types.Ticket,
eticket *types.ElectionProof, bvals []types.BeaconEntry, height abi.ChainEpoch,
wpost []proof2.PoStProof, msgs []*types.SignedMessage) (*types.FullBlock, error) {
wpost []proof3.PoStProof, msgs []*types.SignedMessage) (*types.FullBlock, error) {

var ts uint64
if cg.Timestamper != nil {
Expand Down Expand Up @@ -597,7 +597,7 @@ func (mca mca) WalletSign(ctx context.Context, a address.Address, v []byte) (*cr

type WinningPoStProver interface {
GenerateCandidates(context.Context, abi.PoStRandomness, uint64) ([]uint64, error)
ComputeProof(context.Context, []proof2.SectorInfo, abi.PoStRandomness) ([]proof2.PoStProof, error)
ComputeProof(context.Context, []proof3.SectorInfo, abi.PoStRandomness) ([]proof3.PoStProof, error)
}

type wppProvider struct{}
Expand All @@ -606,7 +606,7 @@ func (wpp *wppProvider) GenerateCandidates(ctx context.Context, _ abi.PoStRandom
return []uint64{0}, nil
}

func (wpp *wppProvider) ComputeProof(context.Context, []proof2.SectorInfo, abi.PoStRandomness) ([]proof2.PoStProof, error) {
func (wpp *wppProvider) ComputeProof(context.Context, []proof3.SectorInfo, abi.PoStRandomness) ([]proof3.PoStProof, error) {
return ValidWpostForTesting, nil
}

Expand Down Expand Up @@ -673,15 +673,23 @@ type genFakeVerifier struct{}

var _ ffiwrapper.Verifier = (*genFakeVerifier)(nil)

func (m genFakeVerifier) VerifySeal(svi proof2.SealVerifyInfo) (bool, error) {
func (m genFakeVerifier) VerifySeal(svi proof3.SealVerifyInfo) (bool, error) {
return true, nil
}

func (m genFakeVerifier) VerifyWinningPoSt(ctx context.Context, info proof2.WinningPoStVerifyInfo) (bool, error) {
func (m genFakeVerifier) VerifyAggregateSeals(aggregate proof3.AggregateSealVerifyProofAndInfos) (bool, error) {
panic("not supported")
}

func (m genFakeVerifier) VerifyWindowPoSt(ctx context.Context, info proof2.WindowPoStVerifyInfo) (bool, error) {
func (m genFakeVerifier) AggregateSealProofs(proofType abi.RegisteredSealProof, proofs [][]byte) ([]byte, error) {
panic("not supported")
}

func (m genFakeVerifier) VerifyWinningPoSt(ctx context.Context, info proof3.WinningPoStVerifyInfo) (bool, error) {
panic("not supported")
}

func (m genFakeVerifier) VerifyWindowPoSt(ctx context.Context, info proof3.WindowPoStVerifyInfo) (bool, error) {
panic("not supported")
}

Expand Down
6 changes: 3 additions & 3 deletions chain/gen/genesis/miners.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
runtime2 "github.com/filecoin-project/specs-actors/v2/actors/runtime"
runtime3 "github.com/filecoin-project/specs-actors/v3/actors/runtime"

"github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/store"
Expand All @@ -46,15 +46,15 @@ func MinerAddress(genesisIndex uint64) address.Address {
}

type fakedSigSyscalls struct {
runtime2.Syscalls
runtime3.Syscalls
}

func (fss *fakedSigSyscalls) VerifySignature(signature crypto.Signature, signer address.Address, plaintext []byte) error {
return nil
}

func mkFakedSigSyscalls(base vm.SyscallBuilder) vm.SyscallBuilder {
return func(ctx context.Context, rt *vm.Runtime) runtime2.Syscalls {
return func(ctx context.Context, rt *vm.Runtime) runtime3.Syscalls {
return &fakedSigSyscalls{
base(ctx, rt),
}
Expand Down
19 changes: 15 additions & 4 deletions chain/vm/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (
addr "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/crypto"
vmr2 "github.com/filecoin-project/specs-actors/v2/actors/runtime"
proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof"
vmr3 "github.com/filecoin-project/specs-actors/v3/actors/runtime"
proof3 "github.com/filecoin-project/specs-actors/v3/actors/runtime/proof"
"github.com/ipfs/go-cid"
)

Expand Down Expand Up @@ -75,6 +76,7 @@ type Pricelist interface {
OnHashing(dataSize int) GasCharge
OnComputeUnsealedSectorCid(proofType abi.RegisteredSealProof, pieces []abi.PieceInfo) GasCharge
OnVerifySeal(info proof2.SealVerifyInfo) GasCharge
OnVerifyAggregateSeals() GasCharge
OnVerifyPost(info proof2.WindowPoStVerifyInfo) GasCharge
OnVerifyConsensusFault() GasCharge
}
Expand Down Expand Up @@ -111,6 +113,7 @@ var prices = map[abi.ChainEpoch]Pricelist{
hashingBase: 31355,
computeUnsealedSectorCidBase: 98647,
verifySealBase: 2000, // TODO gas , it VerifySeal syscall is not used
verifyAggregateSealBase: 0,
verifyPostLookup: map[abi.RegisteredPoStProof]scalingCost{
abi.RegisteredPoStProof_StackedDrgWindow512MiBV1: {
flat: 123861062,
Expand Down Expand Up @@ -158,7 +161,8 @@ var prices = map[abi.ChainEpoch]Pricelist{

hashingBase: 31355,
computeUnsealedSectorCidBase: 98647,
verifySealBase: 2000, // TODO gas , it VerifySeal syscall is not used
verifySealBase: 2000, // TODO gas , it VerifySeal syscall is not used
verifyAggregateSealBase: 400_000_000, // TODO (~40ms, I think)
verifyPostLookup: map[abi.RegisteredPoStProof]scalingCost{
abi.RegisteredPoStProof_StackedDrgWindow512MiBV1: {
flat: 117680921,
Expand Down Expand Up @@ -198,7 +202,7 @@ func PricelistByEpoch(epoch abi.ChainEpoch) Pricelist {
}

type pricedSyscalls struct {
under vmr2.Syscalls
under vmr3.Syscalls
pl Pricelist
chargeGas func(GasCharge)
}
Expand Down Expand Up @@ -257,7 +261,7 @@ func (ps pricedSyscalls) VerifyPoSt(vi proof2.WindowPoStVerifyInfo) error {
// the "parent grinding fault", in which case it must be the sibling of h1 (same parent tipset) and one of the
// blocks in the parent of h2 (i.e. h2's grandparent).
// Returns nil and an error if the headers don't prove a fault.
func (ps pricedSyscalls) VerifyConsensusFault(h1 []byte, h2 []byte, extra []byte) (*vmr2.ConsensusFault, error) {
func (ps pricedSyscalls) VerifyConsensusFault(h1 []byte, h2 []byte, extra []byte) (*vmr3.ConsensusFault, error) {
ps.chargeGas(ps.pl.OnVerifyConsensusFault())
defer ps.chargeGas(gasOnActorExec)

Expand All @@ -277,3 +281,10 @@ func (ps pricedSyscalls) BatchVerifySeals(inp map[address.Address][]proof2.SealV

return ps.under.BatchVerifySeals(inp)
}

func (ps pricedSyscalls) VerifyAggregateSeals(aggregate proof3.AggregateSealVerifyProofAndInfos) error {
ps.chargeGas(ps.pl.OnVerifyAggregateSeals())
defer ps.chargeGas(gasOnActorExec)

return ps.under.VerifyAggregateSeals(aggregate)
}
7 changes: 7 additions & 0 deletions chain/vm/gas_v0.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ type pricelistV0 struct {

computeUnsealedSectorCidBase int64
verifySealBase int64
verifyAggregateSealBase int64
verifyPostLookup map[abi.RegisteredPoStProof]scalingCost
verifyPostDiscount bool
verifyConsensusFault int64
Expand Down Expand Up @@ -185,6 +186,12 @@ func (pl *pricelistV0) OnVerifySeal(info proof2.SealVerifyInfo) GasCharge {
return newGasCharge("OnVerifySeal", pl.verifySealBase, 0)
}

// OnVerifyAggregateSeals
func (pl *pricelistV0) OnVerifyAggregateSeals() GasCharge {
// TODO: this needs more cost tunning
return newGasCharge("OnVerifyAggregateSeals", pl.verifyAggregateSealBase, 0)
}

// OnVerifyPost
func (pl *pricelistV0) OnVerifyPost(info proof2.WindowPoStVerifyInfo) GasCharge {
sectorSize := "unknown"
Expand Down
2 changes: 1 addition & 1 deletion chain/vm/invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

exported0 "github.com/filecoin-project/specs-actors/actors/builtin/exported"
exported2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/exported"
vmr "github.com/filecoin-project/specs-actors/v2/actors/runtime"
vmr "github.com/filecoin-project/specs-actors/v3/actors/runtime"
exported3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/exported"

"github.com/filecoin-project/go-state-types/abi"
Expand Down
8 changes: 4 additions & 4 deletions chain/vm/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/filecoin-project/go-state-types/network"
rtt "github.com/filecoin-project/go-state-types/rt"
rt0 "github.com/filecoin-project/specs-actors/actors/runtime"
rt2 "github.com/filecoin-project/specs-actors/v2/actors/runtime"
rt3 "github.com/filecoin-project/specs-actors/v3/actors/runtime"
"github.com/ipfs/go-cid"
ipldcbor "github.com/ipfs/go-ipld-cbor"
"go.opencensus.io/trace"
Expand Down Expand Up @@ -54,8 +54,8 @@ func (m *Message) ValueReceived() abi.TokenAmount {
var EnableGasTracing = false

type Runtime struct {
rt2.Message
rt2.Syscalls
rt3.Message
rt3.Syscalls

ctx context.Context

Expand Down Expand Up @@ -136,7 +136,7 @@ func (rt *Runtime) StorePut(x cbor.Marshaler) cid.Cid {
}

var _ rt0.Runtime = (*Runtime)(nil)
var _ rt2.Runtime = (*Runtime)(nil)
var _ rt3.Runtime = (*Runtime)(nil)

func (rt *Runtime) shimCall(f func() interface{}) (rval []byte, aerr aerrors.ActorError) {
defer func() {
Expand Down
Loading