don't require signatures for self deals
This commit is contained in:
parent
f0f8d83980
commit
6c9289df0a
@ -122,15 +122,21 @@ func (sdp *StorageDealProposal) Cid() (cid.Cid, error) {
|
|||||||
return nd.Cid(), nil
|
return nd.Cid(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sdp *StorageDealProposal) Verify() error {
|
func (sdp *StorageDealProposal) Verify(worker address.Address) error {
|
||||||
unsigned := *sdp
|
if sdp.Client != worker || worker == address.Undef {
|
||||||
unsigned.ProposerSignature = nil
|
unsigned := *sdp
|
||||||
var buf bytes.Buffer
|
unsigned.ProposerSignature = nil
|
||||||
if err := unsigned.MarshalCBOR(&buf); err != nil {
|
var buf bytes.Buffer
|
||||||
return err
|
if err := unsigned.MarshalCBOR(&buf); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := sdp.ProposerSignature.Verify(sdp.Client, buf.Bytes()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sdp.ProposerSignature.Verify(sdp.Client, buf.Bytes())
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type OnChainDeal struct {
|
type OnChainDeal struct {
|
||||||
@ -396,7 +402,7 @@ func (st *StorageMarketState) validateDeal(vmctx types.VMContext, deal StorageDe
|
|||||||
return aerrors.New(2, "Deals must be submitted by the miner worker")
|
return aerrors.New(2, "Deals must be submitted by the miner worker")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := deal.Verify(); err != nil {
|
if err := deal.Verify(providerWorker); err != nil {
|
||||||
return aerrors.Absorb(err, 3, "verifying proposer signature")
|
return aerrors.Absorb(err, 3, "verifying proposer signature")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-data-transfer"
|
datatransfer "github.com/filecoin-project/go-data-transfer"
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
"github.com/ipld/go-ipld-prime"
|
"github.com/ipld/go-ipld-prime"
|
||||||
@ -56,7 +56,11 @@ func (p *Provider) readProposal(s inet.Stream) (proposal Proposal, err error) {
|
|||||||
return proposal, err
|
return proposal, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := proposal.DealProposal.Verify(); err != nil {
|
if proposal.DealProposal.ProposerSignature == nil {
|
||||||
|
return proposal, xerrors.Errorf("incoming deal proposal has no signature")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := proposal.DealProposal.Verify(address.Undef); err != nil {
|
||||||
return proposal, xerrors.Errorf("verifying StorageDealProposal: %w", err)
|
return proposal, xerrors.Errorf("verifying StorageDealProposal: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
@ -39,11 +38,7 @@ func (m *Miner) pledgeSector(ctx context.Context, sectorID uint64, existingPiece
|
|||||||
Duration: math.MaxUint64 / 2, // /2 because overflows
|
Duration: math.MaxUint64 / 2, // /2 because overflows
|
||||||
StoragePricePerEpoch: types.NewInt(0),
|
StoragePricePerEpoch: types.NewInt(0),
|
||||||
StorageCollateral: types.NewInt(0),
|
StorageCollateral: types.NewInt(0),
|
||||||
ProposerSignature: nil,
|
ProposerSignature: nil, // nil because self dealing
|
||||||
}
|
|
||||||
|
|
||||||
if err := api.SignWith(ctx, m.api.WalletSign, m.worker, &sdp); err != nil {
|
|
||||||
return nil, xerrors.Errorf("signing storage deal failed: ", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deals[i] = sdp
|
deals[i] = sdp
|
||||||
|
Loading…
Reference in New Issue
Block a user