Merge pull request #6006 from filecoin-project/asr/proofs-update

Update to latest proofs
This commit is contained in:
Łukasz Magiera 2021-04-13 11:27:02 +02:00 committed by GitHub
commit 335a2df062
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 107 additions and 1 deletions

View File

@ -6,6 +6,8 @@ import (
"os"
"strconv"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/chain/actors/policy"
)
@ -91,3 +93,5 @@ const SlashablePowerDelay = 20
const InteractivePoRepConfidence = 6
const BootstrapPeerThreshold = 1
var WhitelistedBlock = cid.Undef

View File

@ -7,6 +7,7 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/chain/actors/policy"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
"github.com/ipfs/go-cid"
)
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
@ -51,3 +52,5 @@ const PropagationDelaySecs = uint64(6)
// BootstrapPeerThreshold is the minimum number peers we need to track for a sync worker to start
const BootstrapPeerThreshold = 2
var WhitelistedBlock = cid.Undef

View File

@ -7,6 +7,7 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/chain/actors/policy"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
"github.com/ipfs/go-cid"
)
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
@ -62,3 +63,5 @@ const PropagationDelaySecs = uint64(6)
// BootstrapPeerThreshold is the minimum number peers we need to track for a sync worker to start
const BootstrapPeerThreshold = 4
var WhitelistedBlock = cid.Undef

View File

@ -81,3 +81,6 @@ const PropagationDelaySecs = uint64(6)
// BootstrapPeerThreshold is the minimum number peers we need to track for a sync worker to start
const BootstrapPeerThreshold = 4
// we skip checks on message validity in this block to sidestep the zero-bls signature
var WhitelistedBlock = MustParseCid("bafy2bzaceapyg2uyzk7vueh3xccxkuwbz3nxewjyguoxvhx77malc2lzn2ybi")

View File

@ -5,6 +5,7 @@ package build
import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/ipfs/go-cid"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
)
@ -71,3 +72,5 @@ const PropagationDelaySecs = uint64(6)
// BootstrapPeerThreshold is the minimum number peers we need to track for a sync worker to start
const BootstrapPeerThreshold = 4
var WhitelistedBlock = cid.Undef

View File

@ -2,6 +2,7 @@ package build
import (
"github.com/filecoin-project/go-address"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/protocol"
@ -28,3 +29,12 @@ func MustParseAddress(addr string) address.Address {
return ret
}
func MustParseCid(c string) cid.Cid {
ret, err := cid.Decode(c)
if err != nil {
panic(err)
}
return ret
}

View File

@ -12,6 +12,7 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
"github.com/ipfs/go-cid"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
@ -105,6 +106,7 @@ var (
Devnet = true
ZeroAddress = MustParseAddress("f3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a")
WhitelistedBlock = cid.Undef
BootstrappersFile = ""
GenesisFile = ""
)

View File

@ -751,6 +751,10 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock, use
}
msgsCheck := async.Err(func() error {
if b.Cid() == build.WhitelistedBlock {
return nil
}
if err := syncer.checkBlockMessages(ctx, b, baseTs); err != nil {
return xerrors.Errorf("block had invalid messages: %w", err)
}

View File

@ -5,6 +5,10 @@ import (
"fmt"
"strconv"
ffi "github.com/filecoin-project/filecoin-ffi"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/lotus/lib/sigs"
@ -18,6 +22,76 @@ var signaturesCmd = &cli.Command{
Usage: "tools involving signatures",
Subcommands: []*cli.Command{
sigsVerifyVoteCmd,
sigsVerifyBlsMsgsCmd,
},
}
var sigsVerifyBlsMsgsCmd = &cli.Command{
Name: "verify-bls",
Description: "given a block, verifies the bls signature of the messages in the block",
Usage: "<blockCid>",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 1 {
return xerrors.Errorf("usage: <blockCid>")
}
api, closer, err := lcli.GetFullNodeAPI(cctx)
if err != nil {
return err
}
defer closer()
ctx := lcli.ReqContext(cctx)
bc, err := cid.Decode(cctx.Args().First())
if err != nil {
return err
}
b, err := api.ChainGetBlock(ctx, bc)
if err != nil {
return err
}
ms, err := api.ChainGetBlockMessages(ctx, bc)
if err != nil {
return err
}
var sigCids []cid.Cid // this is what we get for people not wanting the marshalcbor method on the cid type
var pubks [][]byte
for _, m := range ms.BlsMessages {
sigCids = append(sigCids, m.Cid())
if m.From.Protocol() != address.BLS {
return xerrors.Errorf("address must be BLS address")
}
pubks = append(pubks, m.From.Payload())
}
msgsS := make([]ffi.Message, len(sigCids))
pubksS := make([]ffi.PublicKey, len(sigCids))
for i := 0; i < len(sigCids); i++ {
msgsS[i] = sigCids[i].Bytes()
copy(pubksS[i][:], pubks[i][:ffi.PublicKeyBytes])
}
sigS := new(ffi.Signature)
copy(sigS[:], b.BLSAggregate.Data[:ffi.SignatureBytes])
if len(sigCids) == 0 {
return nil
}
valid := ffi.HashVerify(sigS, msgsS, pubksS)
if !valid {
return xerrors.New("bls aggregate signature failed to verify")
}
fmt.Println("BLS siggys valid!")
return nil
},
}

2
extern/filecoin-ffi vendored

@ -1 +1 @@
Subproject commit b6e0b35fb49ed0fedb6a6a473b222e3b8a7d7f17
Subproject commit d82899449741ce190e950a3582ebe33806f018a9