ceremonyclient/node/consensus/master/master_clock_consensus_engine.go

507 lines
12 KiB
Go
Raw Normal View History

2023-09-03 23:47:09 +00:00
package master
import (
v1.4.18-patch-1 (#216) * experiment: verify in channel (#215) * Change volume mapping so .config folder is created inside node folder and not on root (#214) * Update main.go to fix Q logo (#213) Q logo is not appearing correctly on the terminal while running node. Added a new line character after "Signature check passed" to fix it * switched get node info response to use masterClock frame for maxFrame field (#212) * fix: keys file remains null (#217) * Revert "Change volume mapping so .config folder is created inside node folder…" (#218) This reverts commit 27f50a92c6f5e340fd4106da828c6e8cdc12116b. * Docker split take 2 (#219) * split runtime docker files into a docker subfolder * split DOCKER-README.md * updated docker instructions * add restore command * add image update related tasks * add command to test if P2P port is visible * Remove bootstrap peer (#189) * Change bootstrap servers to DHT-only peers (#187) * support voucher file-based claims (#183) * Change bootstrap servers to DHT-only peers Changing my bootstrap servers to DHT-only peers with somewhat lower specs. One of the new ones is in the US and the other one is in Switzerland. Both use reliable providers and have 10Gbps network interfaces. --------- Co-authored-by: Cassandra Heart <7929478+CassOnMars@users.noreply.github.com> * Don't run self-test in DHT-only mode (#186) * support voucher file-based claims (#183) * Don't run self-test in DHT-only mode The node tries to create a self-test when ran with the `-dht-only` flag, but it doesn't load the KZG ceremony data in DHT-only mode which leads to a crash. Don't run self-test when the `-dht-only` flag is set. I tested by starting a node locally with and without existing self-test and with the `-dht-only` flag. --------- Co-authored-by: Cassandra Heart <7929478+CassOnMars@users.noreply.github.com> * Embed json files in binary (#182) * Embed ceremony.json in binary * Embed retroactive_peers.json in binary * Signers build and verification tasks (#181) * add signers specific Taskfile * add verify tasks * move signer task under signer folder * create docker image specific for signers * map current user into docker image and container * ignore node-tmp-* * add verify:build:internal * prevent tasks with docker commands from being run inside a container * rename *:internal to *:container * add README.md * add pem files to git * Updating Q Guide link (#173) * Update README.md Updated link to Quilibrium guide to new website * Update README.md --------- Co-authored-by: littleblackcloud <163544315+littleblackcloud@users.noreply.github.com> Co-authored-by: Agost Biro <5764438+agostbiro@users.noreply.github.com> Co-authored-by: Cassandra Heart <7929478+CassOnMars@users.noreply.github.com> Co-authored-by: Demipoet <161999657+demipoet@users.noreply.github.com> * Signer related fixes (#220) * add pems 16 and 17 * remove .bin extension from generated binaries * no more json files to copy to docker image * feat: recalibrate self-test on the fly (#221) * fix: switch RPC for peer and node info (#222) * replace binaries with patch build * add digests * Signatory #13 added * Signatory #4 added (#223) * Signatory #14 added * Signatory #17 added * Signatory #12 added * Signatory #3 added * Signatory #2 added * Signatory #16 added * Signatory #1 added * Signatory #8 added * remove binaries, release ready --------- Co-authored-by: AvAcalho <158583728+AvAcalho@users.noreply.github.com> Co-authored-by: Ravish Ahmad <ravishahmad16@gmail.com> Co-authored-by: luk <luk@luktech.dev> Co-authored-by: Marius Scurtescu <marius.scurtescu@gmail.com> Co-authored-by: littleblackcloud <163544315+littleblackcloud@users.noreply.github.com> Co-authored-by: Agost Biro <5764438+agostbiro@users.noreply.github.com> Co-authored-by: Demipoet <161999657+demipoet@users.noreply.github.com> Co-authored-by: 0xOzgur <29779769+0xOzgur@users.noreply.github.com>
2024-05-27 05:10:15 +00:00
gcrypto "crypto"
2023-09-03 23:47:09 +00:00
"encoding/hex"
2024-03-04 03:20:24 +00:00
"math/big"
2023-09-03 23:47:09 +00:00
"sync"
"time"
v1.4.18-patch-1 (#216) * experiment: verify in channel (#215) * Change volume mapping so .config folder is created inside node folder and not on root (#214) * Update main.go to fix Q logo (#213) Q logo is not appearing correctly on the terminal while running node. Added a new line character after "Signature check passed" to fix it * switched get node info response to use masterClock frame for maxFrame field (#212) * fix: keys file remains null (#217) * Revert "Change volume mapping so .config folder is created inside node folder…" (#218) This reverts commit 27f50a92c6f5e340fd4106da828c6e8cdc12116b. * Docker split take 2 (#219) * split runtime docker files into a docker subfolder * split DOCKER-README.md * updated docker instructions * add restore command * add image update related tasks * add command to test if P2P port is visible * Remove bootstrap peer (#189) * Change bootstrap servers to DHT-only peers (#187) * support voucher file-based claims (#183) * Change bootstrap servers to DHT-only peers Changing my bootstrap servers to DHT-only peers with somewhat lower specs. One of the new ones is in the US and the other one is in Switzerland. Both use reliable providers and have 10Gbps network interfaces. --------- Co-authored-by: Cassandra Heart <7929478+CassOnMars@users.noreply.github.com> * Don't run self-test in DHT-only mode (#186) * support voucher file-based claims (#183) * Don't run self-test in DHT-only mode The node tries to create a self-test when ran with the `-dht-only` flag, but it doesn't load the KZG ceremony data in DHT-only mode which leads to a crash. Don't run self-test when the `-dht-only` flag is set. I tested by starting a node locally with and without existing self-test and with the `-dht-only` flag. --------- Co-authored-by: Cassandra Heart <7929478+CassOnMars@users.noreply.github.com> * Embed json files in binary (#182) * Embed ceremony.json in binary * Embed retroactive_peers.json in binary * Signers build and verification tasks (#181) * add signers specific Taskfile * add verify tasks * move signer task under signer folder * create docker image specific for signers * map current user into docker image and container * ignore node-tmp-* * add verify:build:internal * prevent tasks with docker commands from being run inside a container * rename *:internal to *:container * add README.md * add pem files to git * Updating Q Guide link (#173) * Update README.md Updated link to Quilibrium guide to new website * Update README.md --------- Co-authored-by: littleblackcloud <163544315+littleblackcloud@users.noreply.github.com> Co-authored-by: Agost Biro <5764438+agostbiro@users.noreply.github.com> Co-authored-by: Cassandra Heart <7929478+CassOnMars@users.noreply.github.com> Co-authored-by: Demipoet <161999657+demipoet@users.noreply.github.com> * Signer related fixes (#220) * add pems 16 and 17 * remove .bin extension from generated binaries * no more json files to copy to docker image * feat: recalibrate self-test on the fly (#221) * fix: switch RPC for peer and node info (#222) * replace binaries with patch build * add digests * Signatory #13 added * Signatory #4 added (#223) * Signatory #14 added * Signatory #17 added * Signatory #12 added * Signatory #3 added * Signatory #2 added * Signatory #16 added * Signatory #1 added * Signatory #8 added * remove binaries, release ready --------- Co-authored-by: AvAcalho <158583728+AvAcalho@users.noreply.github.com> Co-authored-by: Ravish Ahmad <ravishahmad16@gmail.com> Co-authored-by: luk <luk@luktech.dev> Co-authored-by: Marius Scurtescu <marius.scurtescu@gmail.com> Co-authored-by: littleblackcloud <163544315+littleblackcloud@users.noreply.github.com> Co-authored-by: Agost Biro <5764438+agostbiro@users.noreply.github.com> Co-authored-by: Demipoet <161999657+demipoet@users.noreply.github.com> Co-authored-by: 0xOzgur <29779769+0xOzgur@users.noreply.github.com>
2024-05-27 05:10:15 +00:00
"github.com/iden3/go-iden3-crypto/poseidon"
"github.com/libp2p/go-libp2p/core/peer"
2023-09-03 23:47:09 +00:00
"github.com/pkg/errors"
"go.uber.org/zap"
"source.quilibrium.com/quilibrium/monorepo/node/config"
"source.quilibrium.com/quilibrium/monorepo/node/consensus"
2024-02-13 07:04:56 +00:00
qtime "source.quilibrium.com/quilibrium/monorepo/node/consensus/time"
"source.quilibrium.com/quilibrium/monorepo/node/crypto"
2023-09-03 23:47:09 +00:00
"source.quilibrium.com/quilibrium/monorepo/node/execution"
"source.quilibrium.com/quilibrium/monorepo/node/keys"
"source.quilibrium.com/quilibrium/monorepo/node/p2p"
"source.quilibrium.com/quilibrium/monorepo/node/protobufs"
2023-09-09 23:45:47 +00:00
"source.quilibrium.com/quilibrium/monorepo/node/store"
2023-09-03 23:47:09 +00:00
)
type SyncStatusType int
const (
SyncStatusNotSyncing = iota
SyncStatusAwaitingResponse
SyncStatusSynchronizing
)
type MasterClockConsensusEngine struct {
2024-03-01 07:12:31 +00:00
*protobufs.UnimplementedValidationServiceServer
2023-09-03 23:47:09 +00:00
difficulty uint32
logger *zap.Logger
state consensus.EngineState
pubSub p2p.PubSub
keyManager keys.KeyManager
2024-06-08 11:32:45 +00:00
dataProver crypto.InclusionProver
2024-02-13 07:04:56 +00:00
frameProver crypto.FrameProver
2023-09-03 23:47:09 +00:00
lastFrameReceivedAt time.Time
frameChan chan *protobufs.ClockFrame
executionEngines map[string]execution.ExecutionEngine
filter []byte
input []byte
syncingStatus SyncStatusType
syncingTarget []byte
engineMx sync.Mutex
seenFramesMx sync.Mutex
historicFramesMx sync.Mutex
seenFrames []*protobufs.ClockFrame
historicFrames []*protobufs.ClockFrame
clockStore store.ClockStore
masterTimeReel *qtime.MasterTimeReel
2024-03-21 07:14:45 +00:00
peerInfoManager p2p.PeerInfoManager
report *protobufs.SelfTestReport
frameValidationCh chan *protobufs.ClockFrame
beacon peer.ID
currentReceivingSyncPeers int
currentReceivingSyncPeersMx sync.Mutex
collectedProverSlots []*protobufs.InclusionAggregateProof
collectedProverSlotsMx sync.Mutex
engineConfig *config.EngineConfig
2023-09-03 23:47:09 +00:00
}
var _ consensus.ConsensusEngine = (*MasterClockConsensusEngine)(nil)
var MASTER_CLOCK_RATE = uint32(10000000)
2023-09-03 23:47:09 +00:00
func NewMasterClockConsensusEngine(
engineConfig *config.EngineConfig,
logger *zap.Logger,
2023-09-09 23:45:47 +00:00
clockStore store.ClockStore,
2023-09-03 23:47:09 +00:00
keyManager keys.KeyManager,
pubSub p2p.PubSub,
2024-06-08 11:32:45 +00:00
dataProver crypto.InclusionProver,
2024-02-13 07:04:56 +00:00
frameProver crypto.FrameProver,
masterTimeReel *qtime.MasterTimeReel,
2024-03-21 07:14:45 +00:00
peerInfoManager p2p.PeerInfoManager,
2024-03-01 07:12:31 +00:00
report *protobufs.SelfTestReport,
2023-09-03 23:47:09 +00:00
) *MasterClockConsensusEngine {
if logger == nil {
panic(errors.New("logger is nil"))
}
if engineConfig == nil {
panic(errors.New("engine config is nil"))
}
if keyManager == nil {
panic(errors.New("key manager is nil"))
}
if pubSub == nil {
panic(errors.New("pubsub is nil"))
}
2024-06-08 11:32:45 +00:00
if dataProver == nil {
panic(errors.New("data prover is nil"))
}
2024-02-13 07:04:56 +00:00
if frameProver == nil {
panic(errors.New("frame prover is nil"))
}
if masterTimeReel == nil {
panic(errors.New("master time reel is nil"))
}
2023-09-03 23:47:09 +00:00
seed, err := hex.DecodeString(engineConfig.GenesisSeed)
if err != nil {
panic(errors.New("genesis seed is nil"))
}
e := &MasterClockConsensusEngine{
difficulty: MASTER_CLOCK_RATE,
logger: logger,
state: consensus.EngineStateStopped,
keyManager: keyManager,
pubSub: pubSub,
executionEngines: map[string]execution.ExecutionEngine{},
frameChan: make(chan *protobufs.ClockFrame),
input: seed,
lastFrameReceivedAt: time.Time{},
syncingStatus: SyncStatusNotSyncing,
clockStore: clockStore,
dataProver: dataProver,
frameProver: frameProver,
masterTimeReel: masterTimeReel,
peerInfoManager: peerInfoManager,
report: report,
frameValidationCh: make(chan *protobufs.ClockFrame),
collectedProverSlots: []*protobufs.InclusionAggregateProof{},
engineConfig: engineConfig,
2024-01-03 07:31:42 +00:00
}
2024-03-21 07:14:45 +00:00
e.addPeerManifestReport(e.pubSub.GetPeerID(), report)
2024-03-01 07:12:31 +00:00
if e.filter, err = hex.DecodeString(
"0000000000000000000000000000000000000000000000000000000000000000",
); err != nil {
2023-09-03 23:47:09 +00:00
panic(errors.Wrap(err, "could not parse filter value"))
}
v1.4.18-patch-1 (#216) * experiment: verify in channel (#215) * Change volume mapping so .config folder is created inside node folder and not on root (#214) * Update main.go to fix Q logo (#213) Q logo is not appearing correctly on the terminal while running node. Added a new line character after "Signature check passed" to fix it * switched get node info response to use masterClock frame for maxFrame field (#212) * fix: keys file remains null (#217) * Revert "Change volume mapping so .config folder is created inside node folder…" (#218) This reverts commit 27f50a92c6f5e340fd4106da828c6e8cdc12116b. * Docker split take 2 (#219) * split runtime docker files into a docker subfolder * split DOCKER-README.md * updated docker instructions * add restore command * add image update related tasks * add command to test if P2P port is visible * Remove bootstrap peer (#189) * Change bootstrap servers to DHT-only peers (#187) * support voucher file-based claims (#183) * Change bootstrap servers to DHT-only peers Changing my bootstrap servers to DHT-only peers with somewhat lower specs. One of the new ones is in the US and the other one is in Switzerland. Both use reliable providers and have 10Gbps network interfaces. --------- Co-authored-by: Cassandra Heart <7929478+CassOnMars@users.noreply.github.com> * Don't run self-test in DHT-only mode (#186) * support voucher file-based claims (#183) * Don't run self-test in DHT-only mode The node tries to create a self-test when ran with the `-dht-only` flag, but it doesn't load the KZG ceremony data in DHT-only mode which leads to a crash. Don't run self-test when the `-dht-only` flag is set. I tested by starting a node locally with and without existing self-test and with the `-dht-only` flag. --------- Co-authored-by: Cassandra Heart <7929478+CassOnMars@users.noreply.github.com> * Embed json files in binary (#182) * Embed ceremony.json in binary * Embed retroactive_peers.json in binary * Signers build and verification tasks (#181) * add signers specific Taskfile * add verify tasks * move signer task under signer folder * create docker image specific for signers * map current user into docker image and container * ignore node-tmp-* * add verify:build:internal * prevent tasks with docker commands from being run inside a container * rename *:internal to *:container * add README.md * add pem files to git * Updating Q Guide link (#173) * Update README.md Updated link to Quilibrium guide to new website * Update README.md --------- Co-authored-by: littleblackcloud <163544315+littleblackcloud@users.noreply.github.com> Co-authored-by: Agost Biro <5764438+agostbiro@users.noreply.github.com> Co-authored-by: Cassandra Heart <7929478+CassOnMars@users.noreply.github.com> Co-authored-by: Demipoet <161999657+demipoet@users.noreply.github.com> * Signer related fixes (#220) * add pems 16 and 17 * remove .bin extension from generated binaries * no more json files to copy to docker image * feat: recalibrate self-test on the fly (#221) * fix: switch RPC for peer and node info (#222) * replace binaries with patch build * add digests * Signatory #13 added * Signatory #4 added (#223) * Signatory #14 added * Signatory #17 added * Signatory #12 added * Signatory #3 added * Signatory #2 added * Signatory #16 added * Signatory #1 added * Signatory #8 added * remove binaries, release ready --------- Co-authored-by: AvAcalho <158583728+AvAcalho@users.noreply.github.com> Co-authored-by: Ravish Ahmad <ravishahmad16@gmail.com> Co-authored-by: luk <luk@luktech.dev> Co-authored-by: Marius Scurtescu <marius.scurtescu@gmail.com> Co-authored-by: littleblackcloud <163544315+littleblackcloud@users.noreply.github.com> Co-authored-by: Agost Biro <5764438+agostbiro@users.noreply.github.com> Co-authored-by: Demipoet <161999657+demipoet@users.noreply.github.com> Co-authored-by: 0xOzgur <29779769+0xOzgur@users.noreply.github.com>
2024-05-27 05:10:15 +00:00
e.getProvingKey(engineConfig)
if err := e.createCommunicationKeys(); err != nil {
panic(err)
}
2023-09-03 23:47:09 +00:00
logger.Info("constructing consensus engine")
return e
}
func (e *MasterClockConsensusEngine) Start() <-chan error {
2024-01-03 07:31:42 +00:00
e.logger.Info("starting master consensus engine")
2023-09-03 23:47:09 +00:00
e.state = consensus.EngineStateStarting
errChan := make(chan error)
2024-03-21 07:14:45 +00:00
e.peerInfoManager.Start()
2023-09-03 23:47:09 +00:00
e.state = consensus.EngineStateLoading
e.logger.Info("syncing last seen state")
var genesis *config.SignedGenesisUnlock
var err error
for {
genesis, err := config.DownloadAndVerifyGenesis()
if err != nil {
time.Sleep(10 * time.Minute)
continue
}
e.engineConfig.GenesisSeed = genesis.GenesisSeedHex
break
}
err = e.masterTimeReel.Start()
if err != nil {
panic(err)
}
e.beacon, err = peer.IDFromBytes(genesis.Beacon)
2024-02-13 07:04:56 +00:00
if err != nil {
panic(err)
}
2023-09-09 23:45:47 +00:00
2024-02-13 07:04:56 +00:00
frame, err := e.masterTimeReel.Head()
if err != nil {
2023-09-09 23:45:47 +00:00
panic(err)
}
2024-02-13 07:04:56 +00:00
e.buildHistoricFrameCache(frame)
2023-09-03 23:47:09 +00:00
go func() {
for {
select {
case newFrame := <-e.frameValidationCh:
head, err := e.masterTimeReel.Head()
if err != nil {
panic(err)
}
if head.FrameNumber > newFrame.FrameNumber ||
newFrame.FrameNumber-head.FrameNumber > 128 {
e.logger.Debug(
"frame out of range, ignoring",
zap.Uint64("number", newFrame.FrameNumber),
)
continue
}
if err := e.frameProver.VerifyMasterClockFrame(newFrame); err != nil {
e.logger.Error("could not verify clock frame", zap.Error(err))
continue
}
e.masterTimeReel.Insert(newFrame, false)
}
}
}()
2023-09-03 23:47:09 +00:00
e.logger.Info("subscribing to pubsub messages")
e.pubSub.Subscribe(e.filter, e.handleMessage)
2023-09-03 23:47:09 +00:00
e.state = consensus.EngineStateCollecting
2023-09-10 23:29:17 +00:00
go func() {
for {
e.logger.Info(
"peers in store",
zap.Int("peer_store_count", e.pubSub.GetPeerstoreCount()),
zap.Int("network_peer_count", e.pubSub.GetNetworkPeersCount()),
)
time.Sleep(10 * time.Second)
}
}()
2023-09-03 23:47:09 +00:00
go func() {
for e.state < consensus.EngineStateStopping {
frame, err := e.masterTimeReel.Head()
if err != nil {
panic(err)
}
2024-02-13 07:04:56 +00:00
if frame, err = e.prove(frame); err != nil {
e.logger.Error("could not prove", zap.Error(err))
continue
}
if err = e.publishProof(frame); err != nil {
e.logger.Error("could not publish", zap.Error(err))
2023-09-03 23:47:09 +00:00
}
}
}()
go func() {
errChan <- nil
}()
return errChan
}
func (e *MasterClockConsensusEngine) Stop(force bool) <-chan error {
e.logger.Info("stopping consensus engine")
e.state = consensus.EngineStateStopping
errChan := make(chan error)
wg := sync.WaitGroup{}
wg.Add(len(e.executionEngines))
for name := range e.executionEngines {
name := name
go func(name string) {
2024-02-13 07:04:56 +00:00
frame, err := e.masterTimeReel.Head()
if err != nil {
errChan <- err
return
}
err = <-e.UnregisterExecutor(name, frame.FrameNumber, force)
2023-09-03 23:47:09 +00:00
if err != nil {
errChan <- err
}
wg.Done()
}(name)
}
e.logger.Info("waiting for execution engines to stop")
wg.Wait()
e.logger.Info("execution engines stopped")
2024-02-13 07:04:56 +00:00
e.masterTimeReel.Stop()
2024-03-21 07:14:45 +00:00
e.peerInfoManager.Stop()
2023-09-03 23:47:09 +00:00
e.state = consensus.EngineStateStopped
go func() {
errChan <- nil
}()
return errChan
}
2024-03-04 03:20:24 +00:00
func (
e *MasterClockConsensusEngine,
) GetPeerManifests() *protobufs.PeerManifestsResponse {
response := &protobufs.PeerManifestsResponse{
PeerManifests: []*protobufs.PeerManifest{},
}
2024-03-21 07:14:45 +00:00
peerMap := e.peerInfoManager.GetPeerMap()
for peerId, peerManifest := range peerMap {
2024-03-04 03:20:24 +00:00
peerId := peerId
peerManifest := peerManifest
manifest := &protobufs.PeerManifest{
PeerId: []byte(peerId),
Cores: peerManifest.Cores,
Memory: new(big.Int).SetBytes(peerManifest.Memory).Bytes(),
Storage: new(big.Int).SetBytes(peerManifest.Storage).Bytes(),
MasterHeadFrame: peerManifest.MasterHeadFrame,
LastSeen: peerManifest.LastSeen,
2024-03-04 03:20:24 +00:00
}
for _, capability := range peerManifest.Capabilities {
metadata := make([]byte, len(capability.AdditionalMetadata))
copy(metadata[:], capability.AdditionalMetadata[:])
manifest.Capabilities = append(
manifest.Capabilities,
&protobufs.Capability{
ProtocolIdentifier: capability.ProtocolIdentifier,
AdditionalMetadata: metadata,
},
)
}
response.PeerManifests = append(
response.PeerManifests,
manifest,
)
}
return response
}
2023-09-03 23:47:09 +00:00
func (e *MasterClockConsensusEngine) GetDifficulty() uint32 {
return e.difficulty
}
2024-01-03 07:31:42 +00:00
func (e *MasterClockConsensusEngine) GetFrame() *protobufs.ClockFrame {
2024-02-13 07:04:56 +00:00
frame, err := e.masterTimeReel.Head()
if err != nil {
panic(err)
}
return frame
2023-09-03 23:47:09 +00:00
}
func (e *MasterClockConsensusEngine) GetState() consensus.EngineState {
return e.state
}
2024-01-03 07:31:42 +00:00
func (
e *MasterClockConsensusEngine,
) GetFrameChannel() <-chan *protobufs.ClockFrame {
2023-09-03 23:47:09 +00:00
return e.frameChan
}
2024-01-03 07:31:42 +00:00
func (e *MasterClockConsensusEngine) buildHistoricFrameCache(
latestFrame *protobufs.ClockFrame,
) {
e.historicFrames = []*protobufs.ClockFrame{}
if latestFrame.FrameNumber != 0 {
min := uint64(0)
if latestFrame.FrameNumber-255 > min && latestFrame.FrameNumber > 255 {
min = latestFrame.FrameNumber - 255
}
iter, err := e.clockStore.RangeMasterClockFrames(
e.filter,
min,
latestFrame.FrameNumber-1,
)
if err != nil {
panic(err)
}
for iter.First(); iter.Valid(); iter.Next() {
frame, err := iter.Value()
if err != nil {
panic(err)
}
e.historicFrames = append(e.historicFrames, frame)
}
if err = iter.Close(); err != nil {
panic(err)
}
}
e.historicFrames = append(e.historicFrames, latestFrame)
}
2024-03-21 07:14:45 +00:00
func (e *MasterClockConsensusEngine) addPeerManifestReport(
peerId []byte,
report *protobufs.SelfTestReport,
) {
manifest := &p2p.PeerManifest{
PeerId: peerId,
Cores: report.Cores,
Memory: report.Memory,
Storage: report.Storage,
Capabilities: []p2p.Capability{},
MasterHeadFrame: report.MasterHeadFrame,
LastSeen: time.Now().UnixMilli(),
2024-03-21 07:14:45 +00:00
}
for _, capability := range manifest.Capabilities {
metadata := make([]byte, len(capability.AdditionalMetadata))
copy(metadata[:], capability.AdditionalMetadata[:])
manifest.Capabilities = append(
manifest.Capabilities,
p2p.Capability{
ProtocolIdentifier: capability.ProtocolIdentifier,
AdditionalMetadata: metadata,
},
)
}
e.peerInfoManager.AddPeerInfo(manifest)
}
v1.4.18-patch-1 (#216) * experiment: verify in channel (#215) * Change volume mapping so .config folder is created inside node folder and not on root (#214) * Update main.go to fix Q logo (#213) Q logo is not appearing correctly on the terminal while running node. Added a new line character after "Signature check passed" to fix it * switched get node info response to use masterClock frame for maxFrame field (#212) * fix: keys file remains null (#217) * Revert "Change volume mapping so .config folder is created inside node folder…" (#218) This reverts commit 27f50a92c6f5e340fd4106da828c6e8cdc12116b. * Docker split take 2 (#219) * split runtime docker files into a docker subfolder * split DOCKER-README.md * updated docker instructions * add restore command * add image update related tasks * add command to test if P2P port is visible * Remove bootstrap peer (#189) * Change bootstrap servers to DHT-only peers (#187) * support voucher file-based claims (#183) * Change bootstrap servers to DHT-only peers Changing my bootstrap servers to DHT-only peers with somewhat lower specs. One of the new ones is in the US and the other one is in Switzerland. Both use reliable providers and have 10Gbps network interfaces. --------- Co-authored-by: Cassandra Heart <7929478+CassOnMars@users.noreply.github.com> * Don't run self-test in DHT-only mode (#186) * support voucher file-based claims (#183) * Don't run self-test in DHT-only mode The node tries to create a self-test when ran with the `-dht-only` flag, but it doesn't load the KZG ceremony data in DHT-only mode which leads to a crash. Don't run self-test when the `-dht-only` flag is set. I tested by starting a node locally with and without existing self-test and with the `-dht-only` flag. --------- Co-authored-by: Cassandra Heart <7929478+CassOnMars@users.noreply.github.com> * Embed json files in binary (#182) * Embed ceremony.json in binary * Embed retroactive_peers.json in binary * Signers build and verification tasks (#181) * add signers specific Taskfile * add verify tasks * move signer task under signer folder * create docker image specific for signers * map current user into docker image and container * ignore node-tmp-* * add verify:build:internal * prevent tasks with docker commands from being run inside a container * rename *:internal to *:container * add README.md * add pem files to git * Updating Q Guide link (#173) * Update README.md Updated link to Quilibrium guide to new website * Update README.md --------- Co-authored-by: littleblackcloud <163544315+littleblackcloud@users.noreply.github.com> Co-authored-by: Agost Biro <5764438+agostbiro@users.noreply.github.com> Co-authored-by: Cassandra Heart <7929478+CassOnMars@users.noreply.github.com> Co-authored-by: Demipoet <161999657+demipoet@users.noreply.github.com> * Signer related fixes (#220) * add pems 16 and 17 * remove .bin extension from generated binaries * no more json files to copy to docker image * feat: recalibrate self-test on the fly (#221) * fix: switch RPC for peer and node info (#222) * replace binaries with patch build * add digests * Signatory #13 added * Signatory #4 added (#223) * Signatory #14 added * Signatory #17 added * Signatory #12 added * Signatory #3 added * Signatory #2 added * Signatory #16 added * Signatory #1 added * Signatory #8 added * remove binaries, release ready --------- Co-authored-by: AvAcalho <158583728+AvAcalho@users.noreply.github.com> Co-authored-by: Ravish Ahmad <ravishahmad16@gmail.com> Co-authored-by: luk <luk@luktech.dev> Co-authored-by: Marius Scurtescu <marius.scurtescu@gmail.com> Co-authored-by: littleblackcloud <163544315+littleblackcloud@users.noreply.github.com> Co-authored-by: Agost Biro <5764438+agostbiro@users.noreply.github.com> Co-authored-by: Demipoet <161999657+demipoet@users.noreply.github.com> Co-authored-by: 0xOzgur <29779769+0xOzgur@users.noreply.github.com>
2024-05-27 05:10:15 +00:00
func (e *MasterClockConsensusEngine) getProvingKey(
engineConfig *config.EngineConfig,
) (gcrypto.Signer, keys.KeyType, []byte, []byte) {
provingKey, err := e.keyManager.GetSigningKey(engineConfig.ProvingKeyId)
if errors.Is(err, keys.KeyNotFoundErr) {
e.logger.Info("could not get proving key, generating")
provingKey, err = e.keyManager.CreateSigningKey(
engineConfig.ProvingKeyId,
keys.KeyTypeEd448,
)
}
if err != nil {
e.logger.Error("could not get proving key", zap.Error(err))
panic(err)
}
rawKey, err := e.keyManager.GetRawKey(engineConfig.ProvingKeyId)
if err != nil {
e.logger.Error("could not get proving key type", zap.Error(err))
panic(err)
}
provingKeyType := rawKey.Type
h, err := poseidon.HashBytes(rawKey.PublicKey)
if err != nil {
e.logger.Error("could not hash proving key", zap.Error(err))
panic(err)
}
provingKeyAddress := h.Bytes()
provingKeyAddress = append(
make([]byte, 32-len(provingKeyAddress)),
provingKeyAddress...,
)
return provingKey, provingKeyType, rawKey.PublicKey, provingKeyAddress
}
func (e *MasterClockConsensusEngine) createCommunicationKeys() error {
_, err := e.keyManager.GetAgreementKey("q-ratchet-idk")
if err != nil {
if errors.Is(err, keys.KeyNotFoundErr) {
_, err = e.keyManager.CreateAgreementKey(
"q-ratchet-idk",
keys.KeyTypeX448,
)
if err != nil {
return errors.Wrap(err, "create communication keys")
}
} else {
return errors.Wrap(err, "create communication keys")
}
}
_, err = e.keyManager.GetAgreementKey("q-ratchet-spk")
if err != nil {
if errors.Is(err, keys.KeyNotFoundErr) {
_, err = e.keyManager.CreateAgreementKey(
"q-ratchet-spk",
keys.KeyTypeX448,
)
if err != nil {
return errors.Wrap(err, "create communication keys")
}
} else {
return errors.Wrap(err, "create communication keys")
}
}
return nil
}