Bake drand public key into build params

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-04-14 22:34:44 +02:00
parent 0c5e3e2533
commit 0feab0aad4
2 changed files with 22 additions and 1 deletions

View File

@ -103,3 +103,9 @@ const BlsSignatureCacheSize = 40000
// Limits
const BlockMessageLimit = 512
var DrandCoeffs = []string{
"a2a34cf9a6be2f66b5385caa520364f994ae7dbac08371ffaca575dfb3e04c8e149b32dc78f077322c613a151dc07440",
"b0c5baca062191f13099229c9a229a9946204f74fc28baa212745243553ab1f50b581b2086e24374ceb40fe34bd23ca2",
"a9c6449cf647e0a0ffaf1e01277e2821213c80310165990daf77610208abfa0ce56c7e40995e26aff3873c624362ca78",
}

View File

@ -6,6 +6,7 @@ import (
"sync"
"time"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/beacon"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/specs-actors/actors/abi"
@ -26,6 +27,16 @@ var drandServers = []string{
"drand-test1.nikkolasg.xyz:5001",
}
var drandPubKey *dkey.DistPublic
func init() {
drandPubKey = new(dkey.DistPublic)
err := drandPubKey.FromTOML(&dkey.DistPublicTOML{build.DrandCoeffs})
if err != nil {
panic(err)
}
}
type drandPeer struct {
addr string
tls bool
@ -79,7 +90,11 @@ func NewDrandBeacon(genesisTs, interval uint64) (*DrandBeacon, error) {
}
// TODO: verify these values are what we expect them to be
db.pubkey = kgroup.PublicKey
if !kgroup.PublicKey.Equal(drandPubKey) {
return nil, xerrors.Errorf("public key does not match")
}
// fmt.Printf("Drand Pubkey:\n%#v\n", kgroup.PublicKey.TOML()) // use to print public key
db.pubkey = drandPubKey
db.interval = kgroup.Period
db.drandGenTime = uint64(kgroup.GenesisTime)
db.filRoundTime = interval