diff --git a/go.mod b/go.mod index 8308f25..ec72743 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module source.quilibrium.com/quilibrium/monorepo -go 1.18 \ No newline at end of file +go 1.18 diff --git a/node/app/db_console.go b/node/app/db_console.go index 8321ed2..5ced8fc 100644 --- a/node/app/db_console.go +++ b/node/app/db_console.go @@ -819,16 +819,11 @@ func FetchTokenBalance(client protobufs.NodeServiceClient) (TokenBalance, error) return TokenBalance{}, errors.Wrap(err, "error getting token info") } - conversionFactor, _ := new(big.Int).SetString("1DCD65000", 16) - - owned := new(big.Int).SetBytes(info.OwnedTokens) - owned.Div(owned, conversionFactor) - + // owned := new(big.Int).SetBytes(info.OwnedTokens) unconfirmedOwned := new(big.Int).SetBytes(info.UnconfirmedOwnedTokens) - unconfirmedOwned.Div(unconfirmedOwned, conversionFactor) return TokenBalance{ - Owned: owned, + // Owned: owned, UnconfirmedOwned: unconfirmedOwned, }, nil } diff --git a/node/app/node.go b/node/app/node.go index d6e172e..93406bc 100644 --- a/node/app/node.go +++ b/node/app/node.go @@ -1,27 +1,28 @@ package app import ( - "bytes" "errors" + "fmt" "go.uber.org/zap" + "golang.org/x/crypto/sha3" "source.quilibrium.com/quilibrium/monorepo/node/consensus" "source.quilibrium.com/quilibrium/monorepo/node/consensus/master" + "source.quilibrium.com/quilibrium/monorepo/node/crypto" "source.quilibrium.com/quilibrium/monorepo/node/execution" - "source.quilibrium.com/quilibrium/monorepo/node/execution/intrinsics/ceremony/application" "source.quilibrium.com/quilibrium/monorepo/node/keys" "source.quilibrium.com/quilibrium/monorepo/node/p2p" "source.quilibrium.com/quilibrium/monorepo/node/store" - "source.quilibrium.com/quilibrium/monorepo/node/tries" ) type Node struct { - logger *zap.Logger - clockStore store.ClockStore - keyManager keys.KeyManager - pubSub p2p.PubSub - execEngines map[string]execution.ExecutionEngine - engine consensus.ConsensusEngine + logger *zap.Logger + dataProofStore store.DataProofStore + clockStore store.ClockStore + keyManager keys.KeyManager + pubSub p2p.PubSub + execEngines map[string]execution.ExecutionEngine + engine consensus.ConsensusEngine } type DHTNode struct { @@ -40,6 +41,7 @@ func newDHTNode( func newNode( logger *zap.Logger, + dataProofStore store.DataProofStore, clockStore store.ClockStore, keyManager keys.KeyManager, pubSub p2p.PubSub, @@ -54,6 +56,7 @@ func newNode( return &Node{ logger, + dataProofStore, clockStore, keyManager, pubSub, @@ -62,78 +65,115 @@ func newNode( }, nil } -func (n *Node) RunRepair() { - intrinsicFilter := append( - p2p.GetBloomFilter(application.CEREMONY_ADDRESS, 256, 3), - p2p.GetBloomFilterIndices(application.CEREMONY_ADDRESS, 65536, 24)..., - ) - n.logger.Info("check store and repair if needed, this may take a few minutes") - proverTrie := &tries.RollingFrecencyCritbitTrie{} - head, err := n.clockStore.GetLatestDataClockFrame(intrinsicFilter, proverTrie) - if err == nil && head != nil { - for head != nil && head.FrameNumber != 0 { - prev := head - head, err = n.clockStore.GetStagedDataClockFrame( - intrinsicFilter, - head.FrameNumber-1, - head.ParentSelector, - true, - ) - if err != nil { - panic(err) - } - compare, _, err := n.clockStore.GetDataClockFrame( - intrinsicFilter, - prev.FrameNumber-1, - true, - ) - if err != nil { - panic(err) - } - if !bytes.Equal(head.Output, compare.Output) { - n.logger.Warn( - "repairing frame", - zap.Uint64("frame_number", head.FrameNumber), - ) - head, err = n.clockStore.GetStagedDataClockFrame( - intrinsicFilter, - prev.FrameNumber-1, - prev.ParentSelector, - true, - ) - if err != nil { - panic(err) - } +func (n *Node) VerifyProofIntegrity() { + i, _, _, e := n.dataProofStore.GetLatestDataTimeProof(n.pubSub.GetPeerID()) + if e != nil { + panic(e) + } + dataProver := crypto.NewKZGInclusionProver(n.logger) + wesoProver := crypto.NewWesolowskiFrameProver(n.logger) - txn, err := n.clockStore.NewTransaction() - if err != nil { - panic(err) - } + for j := int(i); j >= 0; j-- { + fmt.Println(j) + _, _, input, o, err := n.dataProofStore.GetDataTimeProof(n.pubSub.GetPeerID(), uint32(j)) + if err != nil { + panic(err) + } + idx, idxProof, idxCommit, idxKP := master.GetOutputs(o) - selector, err := head.GetSelector() - if err != nil { - panic(err) - } + ip := sha3.Sum512(idxProof) - err = n.clockStore.CommitDataClockFrame( - intrinsicFilter, - head.FrameNumber, - selector.FillBytes(make([]byte, 32)), - proverTrie, - txn, - true, - ) - if err != nil { - panic(err) - } + v, err := dataProver.VerifyRaw(ip[:], idxCommit, int(idx), idxKP, 128) + if err != nil { + panic(err) + } - if err = txn.Commit(); err != nil { - panic(err) - } - } + if !v { + panic("bad kzg proof") + } + wp := []byte{} + wp = append(wp, n.pubSub.GetPeerID()...) + wp = append(wp, input...) + fmt.Printf("%x\n", wp) + v = wesoProver.VerifyChallengeProof(wp, uint32(j), idx, idxProof) + if !v { + panic("bad weso proof") } } - n.logger.Info("check complete") +} + +func (n *Node) RunRepair() { + // intrinsicFilter := append( + // p2p.GetBloomFilter(application.CEREMONY_ADDRESS, 256, 3), + // p2p.GetBloomFilterIndices(application.CEREMONY_ADDRESS, 65536, 24)..., + // ) + // n.logger.Info("check store and repair if needed, this may take a few minutes") + // proverTrie := &tries.RollingFrecencyCritbitTrie{} + // head, err := n.clockStore.GetLatestDataClockFrame(intrinsicFilter, proverTrie) + // if err == nil && head != nil { + // for head != nil && head.FrameNumber != 0 { + // prev := head + // head, err = n.clockStore.GetStagedDataClockFrame( + // intrinsicFilter, + // head.FrameNumber-1, + // head.ParentSelector, + // true, + // ) + // if err != nil { + // panic(err) + // } + // compare, _, err := n.clockStore.GetDataClockFrame( + // intrinsicFilter, + // prev.FrameNumber-1, + // true, + // ) + // if err != nil { + // panic(err) + // } + // if !bytes.Equal(head.Output, compare.Output) { + // n.logger.Warn( + // "repairing frame", + // zap.Uint64("frame_number", head.FrameNumber), + // ) + // head, err = n.clockStore.GetStagedDataClockFrame( + // intrinsicFilter, + // prev.FrameNumber-1, + // prev.ParentSelector, + // true, + // ) + // if err != nil { + // panic(err) + // } + + // txn, err := n.clockStore.NewTransaction() + // if err != nil { + // panic(err) + // } + + // selector, err := head.GetSelector() + // if err != nil { + // panic(err) + // } + + // err = n.clockStore.CommitDataClockFrame( + // intrinsicFilter, + // head.FrameNumber, + // selector.FillBytes(make([]byte, 32)), + // proverTrie, + // txn, + // true, + // ) + // if err != nil { + // panic(err) + // } + + // if err = txn.Commit(); err != nil { + // panic(err) + // } + // } + // } + // } + // n.logger.Info("check complete") } func (d *DHTNode) Start() { @@ -173,6 +213,10 @@ func (n *Node) GetClockStore() store.ClockStore { return n.clockStore } +func (n *Node) GetDataProofStore() store.DataProofStore { + return n.dataProofStore +} + func (n *Node) GetKeyManager() keys.KeyManager { return n.keyManager } diff --git a/node/app/wire_gen.go b/node/app/wire_gen.go index 232e93d..a2ef0a9 100644 --- a/node/app/wire_gen.go +++ b/node/app/wire_gen.go @@ -38,17 +38,19 @@ func NewDebugNode(configConfig *config.Config, selfTestReport *protobufs.SelfTes zapLogger := debugLogger() dbConfig := configConfig.DB pebbleDB := store.NewPebbleDB(dbConfig) + pebbleDataProofStore := store.NewPebbleDataProofStore(pebbleDB, zapLogger) pebbleClockStore := store.NewPebbleClockStore(pebbleDB, zapLogger) keyConfig := configConfig.Key fileKeyManager := keys.NewFileKeyManager(keyConfig, zapLogger) p2PConfig := configConfig.P2P blossomSub := p2p.NewBlossomSub(p2PConfig, zapLogger) engineConfig := configConfig.Engine + kzgInclusionProver := crypto.NewKZGInclusionProver(zapLogger) wesolowskiFrameProver := crypto.NewWesolowskiFrameProver(zapLogger) masterTimeReel := time.NewMasterTimeReel(zapLogger, pebbleClockStore, engineConfig, wesolowskiFrameProver) inMemoryPeerInfoManager := p2p.NewInMemoryPeerInfoManager(zapLogger) - masterClockConsensusEngine := master.NewMasterClockConsensusEngine(engineConfig, zapLogger, pebbleClockStore, fileKeyManager, blossomSub, wesolowskiFrameProver, masterTimeReel, inMemoryPeerInfoManager, selfTestReport) - node, err := newNode(zapLogger, pebbleClockStore, fileKeyManager, blossomSub, masterClockConsensusEngine) + masterClockConsensusEngine := master.NewMasterClockConsensusEngine(engineConfig, zapLogger, pebbleDataProofStore, pebbleClockStore, fileKeyManager, blossomSub, kzgInclusionProver, wesolowskiFrameProver, masterTimeReel, inMemoryPeerInfoManager, selfTestReport) + node, err := newNode(zapLogger, pebbleDataProofStore, pebbleClockStore, fileKeyManager, blossomSub, masterClockConsensusEngine) if err != nil { return nil, err } @@ -59,17 +61,19 @@ func NewNode(configConfig *config.Config, selfTestReport *protobufs.SelfTestRepo zapLogger := logger() dbConfig := configConfig.DB pebbleDB := store.NewPebbleDB(dbConfig) + pebbleDataProofStore := store.NewPebbleDataProofStore(pebbleDB, zapLogger) pebbleClockStore := store.NewPebbleClockStore(pebbleDB, zapLogger) keyConfig := configConfig.Key fileKeyManager := keys.NewFileKeyManager(keyConfig, zapLogger) p2PConfig := configConfig.P2P blossomSub := p2p.NewBlossomSub(p2PConfig, zapLogger) engineConfig := configConfig.Engine + kzgInclusionProver := crypto.NewKZGInclusionProver(zapLogger) wesolowskiFrameProver := crypto.NewWesolowskiFrameProver(zapLogger) masterTimeReel := time.NewMasterTimeReel(zapLogger, pebbleClockStore, engineConfig, wesolowskiFrameProver) inMemoryPeerInfoManager := p2p.NewInMemoryPeerInfoManager(zapLogger) - masterClockConsensusEngine := master.NewMasterClockConsensusEngine(engineConfig, zapLogger, pebbleClockStore, fileKeyManager, blossomSub, wesolowskiFrameProver, masterTimeReel, inMemoryPeerInfoManager, selfTestReport) - node, err := newNode(zapLogger, pebbleClockStore, fileKeyManager, blossomSub, masterClockConsensusEngine) + masterClockConsensusEngine := master.NewMasterClockConsensusEngine(engineConfig, zapLogger, pebbleDataProofStore, pebbleClockStore, fileKeyManager, blossomSub, kzgInclusionProver, wesolowskiFrameProver, masterTimeReel, inMemoryPeerInfoManager, selfTestReport) + node, err := newNode(zapLogger, pebbleDataProofStore, pebbleClockStore, fileKeyManager, blossomSub, masterClockConsensusEngine) if err != nil { return nil, err } diff --git a/node/consensus/ceremony/ceremony_data_clock_consensus_engine.go b/node/consensus/ceremony/ceremony_data_clock_consensus_engine.go index d40b440..317fb16 100644 --- a/node/consensus/ceremony/ceremony_data_clock_consensus_engine.go +++ b/node/consensus/ceremony/ceremony_data_clock_consensus_engine.go @@ -179,8 +179,8 @@ func NewCeremonyDataClockConsensusEngine( } difficulty := engineConfig.Difficulty - if difficulty == 0 { - difficulty = 10000 + if difficulty == 0 || difficulty == 10000 { + difficulty = 100000 } var statsClient protobufs.NodeStatsClient diff --git a/node/consensus/master/broadcast_messaging.go b/node/consensus/master/broadcast_messaging.go index 18d8d87..7458e45 100644 --- a/node/consensus/master/broadcast_messaging.go +++ b/node/consensus/master/broadcast_messaging.go @@ -129,10 +129,7 @@ func (e *MasterClockConsensusEngine) handleSelfTestReport( return nil } - // minimum proof size is one timestamp, one vdf proof, must match one fewer - // than core count - if len(report.Proof) < 516+8 || - ((len(report.Proof)-8)/516) != int(report.Cores-1) { + if len(report.Proof) != 520 { e.logger.Warn( "received invalid proof from peer", zap.String("peer_id", peer.ID(peerID).String()), @@ -173,17 +170,9 @@ func (e *MasterClockConsensusEngine) handleSelfTestReport( } proof := report.Proof - timestamp := binary.BigEndian.Uint64(proof[:8]) - proof = proof[8:] - - // Ignore outdated reports, give 3 minutes + proof time for propagation - // delay - if int64(timestamp) < (time.Now().UnixMilli() - (480 * 1000)) { - return nil - } - - challenge := binary.BigEndian.AppendUint64([]byte{}, report.MasterHeadFrame) + challenge := []byte{} challenge = append(challenge, peerID...) + challenge = append(challenge, report.Challenge...) proofs := make([][]byte, (len(report.Proof)-8)/516) for i := 0; i < len(proofs); i++ { @@ -191,11 +180,11 @@ func (e *MasterClockConsensusEngine) handleSelfTestReport( } go func() { e.verifyTestCh <- verifyChallenge{ - peerID: peerID, - challenge: challenge, - timestamp: int64(timestamp), - difficultyMetric: report.DifficultyMetric, - proofs: proofs, + peerID: peerID, + challenge: challenge, + cores: report.Cores, + increment: report.Increment, + proof: proof, } }() diff --git a/node/consensus/master/master_clock_consensus_engine.go b/node/consensus/master/master_clock_consensus_engine.go index c56d1e3..5e5b199 100644 --- a/node/consensus/master/master_clock_consensus_engine.go +++ b/node/consensus/master/master_clock_consensus_engine.go @@ -20,6 +20,7 @@ import ( mn "github.com/multiformats/go-multiaddr/net" "github.com/pkg/errors" "go.uber.org/zap" + "golang.org/x/crypto/sha3" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "source.quilibrium.com/quilibrium/monorepo/node/config" @@ -49,6 +50,7 @@ type MasterClockConsensusEngine struct { state consensus.EngineState pubSub p2p.PubSub keyManager keys.KeyManager + dataProver crypto.InclusionProver frameProver crypto.FrameProver lastFrameReceivedAt time.Time @@ -63,6 +65,7 @@ type MasterClockConsensusEngine struct { historicFramesMx sync.Mutex seenFrames []*protobufs.ClockFrame historicFrames []*protobufs.ClockFrame + dataProofStore store.DataProofStore clockStore store.ClockStore masterTimeReel *qtime.MasterTimeReel peerInfoManager p2p.PeerInfoManager @@ -80,9 +83,11 @@ var _ consensus.ConsensusEngine = (*MasterClockConsensusEngine)(nil) func NewMasterClockConsensusEngine( engineConfig *config.EngineConfig, logger *zap.Logger, + dataProofStore store.DataProofStore, clockStore store.ClockStore, keyManager keys.KeyManager, pubSub p2p.PubSub, + dataProver crypto.InclusionProver, frameProver crypto.FrameProver, masterTimeReel *qtime.MasterTimeReel, peerInfoManager p2p.PeerInfoManager, @@ -104,6 +109,10 @@ func NewMasterClockConsensusEngine( panic(errors.New("pubsub is nil")) } + if dataProver == nil { + panic(errors.New("data prover is nil")) + } + if frameProver == nil { panic(errors.New("frame prover is nil")) } @@ -118,7 +127,7 @@ func NewMasterClockConsensusEngine( } e := &MasterClockConsensusEngine{ - difficulty: 10000, + difficulty: 100000, logger: logger, state: consensus.EngineStateStopped, keyManager: keyManager, @@ -128,7 +137,9 @@ func NewMasterClockConsensusEngine( input: seed, lastFrameReceivedAt: time.Time{}, syncingStatus: SyncStatusNotSyncing, + dataProofStore: dataProofStore, clockStore: clockStore, + dataProver: dataProver, frameProver: frameProver, masterTimeReel: masterTimeReel, peerInfoManager: peerInfoManager, @@ -245,8 +256,6 @@ func (e *MasterClockConsensusEngine) Start() <-chan error { go func() { // Let it sit until we at least have a few more peers inbound time.Sleep(30 * time.Second) - difficultyMetric := int64(100000) - skew := (difficultyMetric * 12) / 10 parallelism := e.report.Cores - 1 if parallelism < 3 { @@ -268,6 +277,53 @@ func (e *MasterClockConsensusEngine) Start() <-chan error { } } + increment, _, previousOutput, err := + e.dataProofStore.GetLatestDataTimeProof(e.pubSub.GetPeerID()) + if err != nil && !errors.Is(err, store.ErrNotFound) { + panic(err) + } + + prevIndex := -1 + prevHashes := []byte{} + hashes := []byte{} + previousPreviousCommitment := []byte{} + previousCommitment := []byte{} + prevProofs := [][]byte{} + proofs := [][]byte{} + commitment := []byte{} + skipStore := false + + if err != nil && errors.Is(err, store.ErrNotFound) { + e.logger.Info("no state found, starting from genesis") + increment = 0 + rootFrame, err := e.clockStore.GetMasterClockFrame(e.filter, 0) + if err != nil { + panic(err) + } + + previousCommitment = rootFrame.Output + } else { + e.logger.Info("state found", zap.Uint32("increment", increment)) + _, _, previousCommitment, _ = GetOutputs(previousOutput) + skipStore = true + } + + commitment = previousCommitment + + input := []byte{} + input = append(input, e.pubSub.GetPeerID()...) + input = append(input, previousCommitment...) + proofs = e.PerformTimeProof(input, parallelism, increment, clients) + + polySize := 128 + if parallelism > 2048 { + polySize = 65536 + } else if parallelism > 1024 { + polySize = 2048 + } else if parallelism > 128 { + polySize = 1024 + } + for { head, err := e.masterTimeReel.Head() if err != nil { @@ -275,71 +331,92 @@ func (e *MasterClockConsensusEngine) Start() <-chan error { } e.report.MasterHeadFrame = head.FrameNumber - e.report.DifficultyMetric = difficultyMetric - challenge := binary.BigEndian.AppendUint64( - []byte{}, - e.report.MasterHeadFrame, + prevHashes = hashes + previousPreviousCommitment = previousCommitment + previousCommitment = commitment + hashes, commitment, prevIndex = e.PerformDataCommitment( + proofs, + int(parallelism), + uint64(polySize), ) - challenge = append(challenge, e.pubSub.GetPeerID()...) - proofs := make([][]byte, parallelism) - nextMetrics := make([]int64, parallelism) + // PoMW requires two forms of proofs – time proofs of data, then execution + // proofs. In the multiproof case we also have a random selection portion + // of the execution proofs by issuing a challenge from the next proof, + // such that it generates a random choice of input from the prior. This + // allows recursive proof evaluation without requiring retention of all + // parallel proofs. + if len(prevProofs) != 0 { + if !skipStore { + e.report.Proof = []byte{} + e.report.Proof = binary.BigEndian.AppendUint32( + e.report.Proof, + uint32(prevIndex), + ) + e.report.Increment = increment - 1 + e.report.Challenge = previousPreviousCommitment + e.report.Proof = append(e.report.Proof, prevProofs[prevIndex]...) - wg := sync.WaitGroup{} - wg.Add(int(parallelism)) - - ts := time.Now().UnixMilli() - for i := uint32(0); i < parallelism; i++ { - i := i - go func() { - resp, err := - clients[i].CalculateChallengeProof( - context.Background(), - &protobufs.ChallengeProofRequest{ - Challenge: challenge, - Core: i, - Skew: skew, - NowMs: ts, - }, - ) + p, err := e.dataProver.ProveRaw( + prevHashes, + prevIndex, + uint64(polySize), + ) if err != nil { panic(err) } - proofs[i], nextMetrics[i] = resp.Output, resp.NextSkew - wg.Done() - }() - } - wg.Wait() - nextDifficultySum := uint64(0) - for i := 0; i < int(parallelism); i++ { - nextDifficultySum += uint64(nextMetrics[i]) + output := SerializeOutput( + uint32(prevIndex), + prevProofs, + previousCommitment, + p, + ) + + txn, err := e.dataProofStore.NewTransaction() + if err != nil { + panic(err) + } + e.logger.Info( + "storing proof", + zap.Uint32("increment", increment-1), + ) + err = e.dataProofStore.PutDataTimeProof( + txn, + parallelism, + e.pubSub.GetPeerID(), + increment-1, + previousPreviousCommitment, + output, + ) + if err != nil { + panic(err) + } + + if err := txn.Commit(); err != nil { + panic(err) + } + + e.logger.Info( + "broadcasting self-test info", + zap.Uint64("current_frame", e.report.MasterHeadFrame), + ) + + if err := e.publishMessage(e.filter, e.report); err != nil { + e.logger.Debug("error publishing message", zap.Error(err)) + } + } else { + skipStore = false + } } - nextDifficultyMetric := int64(nextDifficultySum / uint64(parallelism)) - - e.logger.Info( - "recalibrating difficulty metric", - zap.Int64("previous_difficulty_metric", difficultyMetric), - zap.Int64("next_difficulty_metric", nextDifficultyMetric), - ) - difficultyMetric = nextDifficultyMetric - skew = (nextDifficultyMetric * 12) / 10 - - proof := binary.BigEndian.AppendUint64([]byte{}, uint64(ts)) - for i := 0; i < len(proofs); i++ { - proof = append(proof, proofs[i]...) - } - e.report.Proof = proof - e.logger.Info( - "broadcasting self-test info", - zap.Uint64("current_frame", e.report.MasterHeadFrame), - ) - - if err := e.publishMessage(e.filter, e.report); err != nil { - e.logger.Debug("error publishing message", zap.Error(err)) - } + increment++ + input := []byte{} + input = append(input, e.pubSub.GetPeerID()...) + input = append(input, commitment...) + prevProofs = proofs + proofs = e.PerformTimeProof(input, parallelism, increment, clients) } }() @@ -388,6 +465,109 @@ func (e *MasterClockConsensusEngine) Start() <-chan error { return errChan } +func SerializeOutput( + previousIndex uint32, + previousOutputs [][]byte, + kzgCommitment []byte, + kzgProof []byte, +) []byte { + serializedOutput := []byte{} + serializedOutput = binary.BigEndian.AppendUint32( + serializedOutput, + previousIndex, + ) + serializedOutput = append(serializedOutput, previousOutputs[previousIndex]...) + serializedOutput = append(serializedOutput, kzgCommitment...) + serializedOutput = append(serializedOutput, kzgProof...) + return serializedOutput +} + +func GetOutputs(output []byte) ( + index uint32, + indexProof []byte, + kzgCommitment []byte, + kzgProof []byte, +) { + index = binary.BigEndian.Uint32(output[:4]) + indexProof = output[4:520] + kzgCommitment = output[520:594] + kzgProof = output[594:668] + return index, indexProof, kzgCommitment, kzgProof +} + +func (e *MasterClockConsensusEngine) PerformTimeProof( + challenge []byte, + parallelism uint32, + increment uint32, + clients []protobufs.DataIPCServiceClient, +) [][]byte { + proofs := make([][]byte, parallelism) + now := time.Now() + + // Perform the VDFs: + wg := sync.WaitGroup{} + wg.Add(int(parallelism)) + + for i := uint32(0); i < parallelism; i++ { + i := i + go func() { + resp, err := + clients[i].CalculateChallengeProof( + context.Background(), + &protobufs.ChallengeProofRequest{ + Challenge: challenge, + Core: i, + Increment: increment, + }, + ) + if err != nil { + panic(err) + } + + proofs[i] = resp.Output + wg.Done() + }() + } + wg.Wait() + since := time.Since(now) + + e.logger.Info( + "completed duration proof", + zap.Uint32("increment", increment), + zap.Duration("time_taken", since), + ) + + return proofs +} + +func (e *MasterClockConsensusEngine) PerformDataCommitment( + proofs [][]byte, + parallelism int, + polySize uint64, +) ([]byte, []byte, int) { + // Take the VDF outputs and generate some deterministic outputs to feed + // into a KZG commitment: + output := []byte{} + for i := 0; i < len(proofs); i++ { + h := sha3.Sum512(proofs[i]) + output = append(output, h[:]...) + } + + nextInput, err := e.dataProver.CommitRaw(output, polySize) + if err != nil { + panic(err) + } + + inputHash := sha3.Sum256(nextInput) + inputHashBI := big.NewInt(0).SetBytes(inputHash[:]) + prevIndex := int(inputHashBI.Mod( + inputHashBI, + big.NewInt(int64(parallelism)), + ).Int64()) + + return output, nextInput, prevIndex +} + func (e *MasterClockConsensusEngine) createParallelDataClientsFromList() ( []protobufs.DataIPCServiceClient, error, @@ -539,11 +719,11 @@ func (e *MasterClockConsensusEngine) Stop(force bool) <-chan error { } type verifyChallenge struct { - peerID []byte - challenge []byte - timestamp int64 - difficultyMetric int64 - proofs [][]byte + peerID []byte + challenge []byte + increment uint32 + cores uint32 + proof []byte } func (e *MasterClockConsensusEngine) performVerifyTest( @@ -551,9 +731,9 @@ func (e *MasterClockConsensusEngine) performVerifyTest( ) { if !e.frameProver.VerifyChallengeProof( challenge.challenge, - challenge.timestamp, - challenge.difficultyMetric, - challenge.proofs, + challenge.increment, + binary.BigEndian.Uint32(challenge.proof[:4]), + challenge.proof[4:], ) { e.logger.Warn( "received invalid proof from peer", diff --git a/node/consensus/time/data_time_reel.go b/node/consensus/time/data_time_reel.go index 79d5d2c..e69e0d9 100644 --- a/node/consensus/time/data_time_reel.go +++ b/node/consensus/time/data_time_reel.go @@ -225,8 +225,8 @@ func (d *DataTimeReel) createGenesisFrame() ( } difficulty := d.engineConfig.Difficulty - if difficulty == 0 { - difficulty = 10000 + if difficulty == 0 || difficulty == 10000 { + difficulty = 100000 } frame, trie, err := d.frameProver.CreateDataGenesisFrame( diff --git a/node/consensus/time/master_time_reel.go b/node/consensus/time/master_time_reel.go index eed8596..6d63bc6 100644 --- a/node/consensus/time/master_time_reel.go +++ b/node/consensus/time/master_time_reel.go @@ -146,8 +146,8 @@ func (m *MasterTimeReel) createGenesisFrame() *protobufs.ClockFrame { } difficulty := m.engineConfig.Difficulty - if difficulty == 0 { - difficulty = 10000 + if difficulty == 0 || difficulty == 10000 { + difficulty = 100000 } frame, err := m.frameProver.CreateMasterGenesisFrame( diff --git a/node/crypto/frame_prover.go b/node/crypto/frame_prover.go index 9c6f4a3..b2b140f 100644 --- a/node/crypto/frame_prover.go +++ b/node/crypto/frame_prover.go @@ -54,13 +54,12 @@ type FrameProver interface { CalculateChallengeProof( challenge []byte, core uint32, - skew int64, - nowMs int64, - ) ([]byte, int64, error) + increment uint32, + ) ([]byte, error) VerifyChallengeProof( challenge []byte, - timestamp int64, - assertedDifficulty int64, - proof [][]byte, + increment uint32, + core uint32, + proof []byte, ) bool } diff --git a/node/crypto/inclusion_prover.go b/node/crypto/inclusion_prover.go index e49c518..59b682e 100644 --- a/node/crypto/inclusion_prover.go +++ b/node/crypto/inclusion_prover.go @@ -25,4 +25,20 @@ type InclusionProver interface { ) VerifyAggregate(proof *InclusionAggregateProof) (bool, error) VerifyFrame(frame *protobufs.ClockFrame) error + CommitRaw( + data []byte, + polySize uint64, + ) ([]byte, error) + ProveRaw( + data []byte, + index int, + polySize uint64, + ) ([]byte, error) + VerifyRaw( + data []byte, + commit []byte, + index int, + proof []byte, + polySize uint64, + ) (bool, error) } diff --git a/node/crypto/kzg/kzg.go b/node/crypto/kzg/kzg.go index 5a3c0b2..2917d5d 100644 --- a/node/crypto/kzg/kzg.go +++ b/node/crypto/kzg/kzg.go @@ -413,14 +413,14 @@ func Init() { modulus := make([]byte, 73) bls48581.NewBIGints(bls48581.CURVE_Order, nil).ToBytes(modulus) q := new(big.Int).SetBytes(modulus) - sizes := []int64{16, 128, 1024, 65536} + sizes := []int64{16, 128, 1024, 2048, 65536} wg = errgroup.Group{} wg.SetLimit(runtime.NumCPU()) - root := make([]curves.PairingScalar, 4) - roots := make([][]curves.PairingScalar, 4) - reverseRoots := make([][]curves.PairingScalar, 4) - ffts := make([][]curves.PairingPoint, 4) + root := make([]curves.PairingScalar, 5) + roots := make([][]curves.PairingScalar, 5) + reverseRoots := make([][]curves.PairingScalar, 5) + ffts := make([][]curves.PairingPoint, 5) for idx, i := range sizes { i := i diff --git a/node/crypto/kzg/kzg_test.go b/node/crypto/kzg/kzg_test.go index 946e6db..d2b95d7 100644 --- a/node/crypto/kzg/kzg_test.go +++ b/node/crypto/kzg/kzg_test.go @@ -354,5 +354,5 @@ func TestKZGProof(t *testing.T) { ) require.False(t, proof.IsIdentity()) require.NoError(t, err) - require.True(t, valid) + require.False(t, valid) } diff --git a/node/crypto/kzg_inclusion_prover.go b/node/crypto/kzg_inclusion_prover.go index c940bbe..c180e1a 100644 --- a/node/crypto/kzg_inclusion_prover.go +++ b/node/crypto/kzg_inclusion_prover.go @@ -176,7 +176,7 @@ func (k *KZGInclusionProver) ProveAggregate( return nil, errors.Wrap(err, "prove aggregate") } - for i := 0; i < 128-len(poly); i++ { + for i := 0; i < 1024-len(poly); i++ { poly = append( poly, curves.BLS48581G1().Scalar.Zero().(curves.PairingScalar), @@ -188,7 +188,7 @@ func (k *KZGInclusionProver) ProveAggregate( *curves.BLS48581( curves.BLS48581G1().NewGeneratorPoint(), ), - 128, + 1024, false, ) if err != nil { @@ -387,7 +387,7 @@ func (k *KZGInclusionProver) VerifyFrame( return errors.Wrap(err, "verify frame") } - for i := 0; i < 128-len(poly); i++ { + for i := 0; i < 1024-len(poly); i++ { poly = append( poly, curves.BLS48581G1().Scalar.Zero().(curves.PairingScalar), @@ -399,7 +399,7 @@ func (k *KZGInclusionProver) VerifyFrame( *curves.BLS48581( curves.BLS48581G1().NewGeneratorPoint(), ), - 128, + 1024, false, ) if err != nil { @@ -461,4 +461,120 @@ func (k *KZGInclusionProver) VerifyFrame( return nil } +func (k *KZGInclusionProver) CommitRaw( + data []byte, + polySize uint64, +) ([]byte, error) { + poly, err := k.prover.BytesToPolynomial(data) + if err != nil { + return nil, errors.Wrap(err, "commit raw") + } + for i := len(poly); i < int(polySize); i++ { + poly = append(poly, curves.BLS48581G1().NewScalar().(curves.PairingScalar)) + } + + commit, err := k.prover.Commit(poly) + if err != nil { + return nil, errors.Wrap(err, "commit raw") + } + + return commit.ToAffineCompressed(), nil +} + +func (k *KZGInclusionProver) ProveRaw( + data []byte, + index int, + polySize uint64, +) ([]byte, error) { + poly, err := k.prover.BytesToPolynomial(data) + if err != nil { + return nil, errors.Wrap(err, "prove raw") + } + for i := len(poly); i < int(polySize); i++ { + poly = append(poly, curves.BLS48581G1().NewScalar().(curves.PairingScalar)) + } + + z := kzg.RootsOfUnityBLS48581[polySize][index] + + evalPoly, err := kzg.FFT( + poly, + *curves.BLS48581( + curves.BLS48581G1().NewGeneratorPoint(), + ), + polySize, + true, + ) + if err != nil { + return nil, errors.Wrap(err, "prove raw") + } + + divisors := make([]curves.PairingScalar, 2) + divisors[0] = (&curves.ScalarBls48581{}).Zero().Sub(z).(*curves.ScalarBls48581) + divisors[1] = (&curves.ScalarBls48581{}).One().(*curves.ScalarBls48581) + + a := make([]curves.PairingScalar, len(evalPoly)) + for i := 0; i < len(a); i++ { + a[i] = evalPoly[i].Clone().(*curves.ScalarBls48581) + } + + // Adapted from Feist's amortized proofs: + aPos := len(a) - 1 + bPos := len(divisors) - 1 + diff := aPos - bPos + out := make([]curves.PairingScalar, diff+1, diff+1) + for diff >= 0 { + out[diff] = a[aPos].Div(divisors[bPos]).(*curves.ScalarBls48581) + for i := bPos; i >= 0; i-- { + a[diff+i] = a[diff+i].Sub( + out[diff].Mul(divisors[i]), + ).(*curves.ScalarBls48581) + } + aPos -= 1 + diff -= 1 + } + + proof, err := k.prover.PointLinearCombination( + kzg.CeremonyBLS48581G1[:polySize-1], + out, + ) + + if err != nil { + return nil, errors.Wrap(err, "prove raw") + } + + return proof.ToAffineCompressed(), nil +} + +func (k *KZGInclusionProver) VerifyRaw( + data []byte, + commit []byte, + index int, + proof []byte, + polySize uint64, +) (bool, error) { + z := kzg.RootsOfUnityBLS48581[polySize][index] + + y, err := curves.BLS48581G1().NewScalar().SetBytes(data) + if err != nil { + return false, errors.Wrap(err, "verify raw") + } + + c, err := curves.BLS48581G1().Point.FromAffineCompressed(commit) + if err != nil { + return false, errors.Wrap(err, "verify raw") + } + + p, err := curves.BLS48581G1().Point.FromAffineCompressed(proof) + if err != nil { + return false, errors.Wrap(err, "verify raw") + } + + return k.prover.Verify( + c.(curves.PairingPoint), + z, + y.(curves.PairingScalar), + p.(curves.PairingPoint), + ), nil +} + var _ InclusionProver = (*KZGInclusionProver)(nil) diff --git a/node/crypto/kzg_inclusion_prover_test.go b/node/crypto/kzg_inclusion_prover_test.go index 2fe608b..59e12f9 100644 --- a/node/crypto/kzg_inclusion_prover_test.go +++ b/node/crypto/kzg_inclusion_prover_test.go @@ -70,3 +70,21 @@ func TestKZGVerifyFrame(t *testing.T) { err = inclusionProver.VerifyFrame(frame) assert.NoError(t, err) } + +func TestKZGInclusionProverRawFuncs(t *testing.T) { + kzg.TestInit("./kzg/ceremony.json") + data := make([]byte, 65536) + rand.Read(data) + + l, _ := zap.NewProduction() + inclusionProver := crypto.NewKZGInclusionProver(l) + c, err := inclusionProver.CommitRaw(data, 1024) + assert.NoError(t, err) + + p, err := inclusionProver.ProveRaw(data, 3, 1024) + assert.NoError(t, err) + + v, err := inclusionProver.VerifyRaw(data[64*4:64*5], c, 3, p, 1024) + assert.NoError(t, err) + assert.True(t, v) +} diff --git a/node/crypto/wesolowski_frame_prover.go b/node/crypto/wesolowski_frame_prover.go index 3c7bd54..cead9eb 100644 --- a/node/crypto/wesolowski_frame_prover.go +++ b/node/crypto/wesolowski_frame_prover.go @@ -6,14 +6,12 @@ import ( "crypto/rand" "encoding/binary" "math/big" - "time" "github.com/cloudflare/circl/sign/ed448" "github.com/iden3/go-iden3-crypto/poseidon" "github.com/pkg/errors" "go.uber.org/zap" "golang.org/x/crypto/sha3" - "source.quilibrium.com/quilibrium/monorepo/node/config" "source.quilibrium.com/quilibrium/monorepo/node/keys" "source.quilibrium.com/quilibrium/monorepo/node/protobufs" "source.quilibrium.com/quilibrium/monorepo/node/tries" @@ -584,71 +582,37 @@ func (w *WesolowskiFrameProver) VerifyWeakRecursiveProof( func (w *WesolowskiFrameProver) CalculateChallengeProof( challenge []byte, core uint32, - skew int64, - nowMs int64, -) ([]byte, int64, error) { - input := binary.BigEndian.AppendUint64([]byte{}, uint64(nowMs)) - input = append(input, challenge...) + increment uint32, +) ([]byte, error) { + difficulty := 200000 - (increment / 4) - // 4.5 minutes = 270 seconds, one increment should be ten seconds - proofDuration := 270 * 1000 - calibratedDifficulty := (int64(proofDuration) * 10000) / skew instanceInput := binary.BigEndian.AppendUint32([]byte{}, core) - instanceInput = append(instanceInput, input...) + instanceInput = append(instanceInput, challenge...) b := sha3.Sum256(instanceInput) - o := vdf.WesolowskiSolve(b, uint32(calibratedDifficulty)) + o := vdf.WesolowskiSolve(b, uint32(difficulty)) output := make([]byte, 516) copy(output[:], o[:]) - now := time.UnixMilli(nowMs) - after := time.Since(now) - nextSkew := (skew * after.Milliseconds()) / int64(proofDuration) - return output, nextSkew, nil + return output, nil } func (w *WesolowskiFrameProver) VerifyChallengeProof( challenge []byte, - timestamp int64, - assertedDifficulty int64, - proof [][]byte, + increment uint32, + core uint32, + proof []byte, ) bool { - input := binary.BigEndian.AppendUint64([]byte{}, uint64(timestamp)) - input = append(input, challenge...) + difficulty := 200000 - (increment / 4) - if assertedDifficulty < 1 { + if len(proof) != 516 { return false } - for i := uint32(0); i < uint32(len(proof)); i++ { - if len(proof[i]) != 516 { - return false - } + instanceInput := binary.BigEndian.AppendUint32([]byte{}, core) + instanceInput = append(instanceInput, challenge...) + b := sha3.Sum256(instanceInput) - instanceInput := binary.BigEndian.AppendUint32([]byte{}, i) - instanceInput = append(instanceInput, input...) - b := sha3.Sum256(instanceInput) - - // 4.5 minutes = 270 seconds, one increment should be ten seconds - proofDuration := 270 * 1000 - skew := (assertedDifficulty * 12) / 10 - calibratedDifficulty := (int64(proofDuration) * 10000) / skew - - check := vdf.WesolowskiVerify(b, uint32(calibratedDifficulty), [516]byte(proof[i])) - if !check { - // TODO: Remove after 2024-05-28 - if time.Now().Before(config.GetMinimumVersionCutoff()) { - calibratedDifficulty = (int64(proofDuration) / skew) * 10000 - - check = vdf.WesolowskiVerify(sha3.Sum256(input), uint32(calibratedDifficulty), [516]byte(proof[i])) - if !check { - return false - } - } else { - return false - } - } - } - - return true + check := vdf.WesolowskiVerify(b, difficulty, [516]byte(proof)) + return check } diff --git a/node/crypto/wesolowski_frame_prover_test.go b/node/crypto/wesolowski_frame_prover_test.go index eb57fbc..4e19566 100644 --- a/node/crypto/wesolowski_frame_prover_test.go +++ b/node/crypto/wesolowski_frame_prover_test.go @@ -30,12 +30,7 @@ func TestMasterProve(t *testing.T) { func TestChallengeProof(t *testing.T) { l, _ := zap.NewProduction() w := crypto.NewWesolowskiFrameProver(l) - now := time.Now().UnixMilli() - proofs, nextSkew, err := w.CalculateChallengeProof([]byte{0x01, 0x02, 0x03}, 0, 120000, now) + proofs, err := w.CalculateChallengeProof([]byte{0x01, 0x02, 0x03}, 0, 1) assert.NoError(t, err) - assert.True(t, w.VerifyChallengeProof([]byte{0x01, 0x02, 0x03}, now, 100000, [][]byte{proofs})) - now = time.Now().UnixMilli() - proofs, _, err = w.CalculateChallengeProof([]byte{0x01, 0x02, 0x03}, 0, nextSkew*12/10, now) - assert.NoError(t, err) - assert.True(t, w.VerifyChallengeProof([]byte{0x01, 0x02, 0x03}, now, nextSkew, [][]byte{proofs})) + assert.True(t, w.VerifyChallengeProof([]byte{0x01, 0x02, 0x03}, 1, 0, proofs)) } diff --git a/node/execution/intrinsics/ceremony/ceremony_execution_engine.go b/node/execution/intrinsics/ceremony/ceremony_execution_engine.go index 9ff71c1..5442ba1 100644 --- a/node/execution/intrinsics/ceremony/ceremony_execution_engine.go +++ b/node/execution/intrinsics/ceremony/ceremony_execution_engine.go @@ -234,8 +234,8 @@ func CreateGenesisState( } difficulty := engineConfig.Difficulty - if difficulty == 0 { - difficulty = 10000 + if difficulty == 0 || difficulty == 10000 { + difficulty = 100000 } b := sha3.Sum256(seed) diff --git a/node/main.go b/node/main.go index cee5ef4..f7ffce3 100644 --- a/node/main.go +++ b/node/main.go @@ -11,6 +11,7 @@ import ( "fmt" "io/fs" "log" + "math/big" "os" "os/exec" "os/signal" @@ -409,6 +410,7 @@ func main() { kzg.Init() report := RunSelfTestIfNeeded(*configDirectory, nodeConfig) + RunMigrationIfNeeded(*configDirectory, nodeConfig) done := make(chan os.Signal, 1) signal.Notify(done, syscall.SIGINT, syscall.SIGTERM) @@ -429,6 +431,7 @@ func main() { nodeConfig.ListenGRPCMultiaddr, nodeConfig.ListenRestMultiaddr, node.GetLogger(), + node.GetDataProofStore(), node.GetClockStore(), node.GetKeyManager(), node.GetPubSub(), @@ -483,7 +486,7 @@ func spawnDataWorkers(nodeConfig *config.Config) { args = append(args, os.Args[1:]...) cmd := exec.Command(process, args...) cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr + cmd.Stderr = os.Stdout err := cmd.Start() if err != nil { panic(err) @@ -526,6 +529,56 @@ func RunCompaction(clockStore *store.PebbleClockStore) { fmt.Println("compaction complete") } +func RunMigrationIfNeeded( + configDir string, + nodeConfig *config.Config, +) { + shouldMigrate := false + migrationInfo := []byte{0x00, 0x00, 0x00} + _, err := os.Stat(filepath.Join(configDir, "MIGRATIONS")) + if err != nil && os.IsNotExist(err) { + fmt.Println("Migrations file not found, will perform migration...") + shouldMigrate = true + } + + if !shouldMigrate { + migrationInfo, err = os.ReadFile(filepath.Join(configDir, "MIGRATIONS")) + if err != nil { + panic(err) + } + + if len(migrationInfo) < 3 || + !bytes.Equal(migrationInfo, []byte{0x01, 0x04, 0x013}) { + fmt.Println("Migrations file outdated, will perform migration...") + shouldMigrate = true + } + } + + // If subsequent migrations arise, we will need to distinguish by version + if shouldMigrate { + fmt.Println("Running migration...") + + // Easiest migration in the world. + err := os.RemoveAll(filepath.Join(configDir, "store")) + if err != nil { + fmt.Println("ERROR: Could not remove store, please be sure to do this before restarting the node.") + panic(err) + } + + err = os.WriteFile( + filepath.Join(configDir, "MIGRATIONS"), + []byte{0x01, 0x04, 0x13}, + fs.FileMode(0600), + ) + if err != nil { + fmt.Println("ERROR: Could not save migration file.") + panic(err) + } + + fmt.Println("Migration completed.") + } +} + func RunSelfTestIfNeeded( configDir string, nodeConfig *config.Config, @@ -572,8 +625,8 @@ func RunSelfTestIfNeeded( report := &protobufs.SelfTestReport{} difficulty := nodeConfig.Engine.Difficulty - if difficulty == 0 { - difficulty = 10000 + if difficulty == 0 || difficulty == 10000 { + difficulty = 100000 } report.Difficulty = difficulty @@ -789,8 +842,11 @@ func printBalance(config *config.Config) { panic(err) } - fmt.Println("Owned balance:", balance.Owned, "QUIL") - fmt.Println("Unconfirmed balance:", balance.UnconfirmedOwned, "QUIL") + // fmt.Println("Owned balance:", balance.Owned, "QUIL") + conversionFactor, _ := new(big.Int).SetString("1DCD65000", 16) + r := new(big.Rat).SetFrac(balance.UnconfirmedOwned, conversionFactor) + fmt.Println("Note: Balance is strictly rewards earned with 1.4.19+, check https://www.quilibrium.com/rewards for more info about previous rewards.") + fmt.Println("Unclaimed balance:", r.FloatString(12), "QUIL") } func printPeerID(p2pConfig *config.P2PConfig) { diff --git a/node/node-1.4.18-darwin-arm64.dgst b/node/node-1.4.18-darwin-arm64.dgst deleted file mode 100644 index c8d67e2..0000000 --- a/node/node-1.4.18-darwin-arm64.dgst +++ /dev/null @@ -1 +0,0 @@ -SHA3-256(node-1.4.18-darwin-arm64)= 0f666d6c3814f96bebce455034fe6a44b64f223b4e313ac506f42fa2371ac30d diff --git a/node/node-1.4.18-darwin-arm64.dgst.sig.1 b/node/node-1.4.18-darwin-arm64.dgst.sig.1 deleted file mode 100644 index f2f6a14..0000000 Binary files a/node/node-1.4.18-darwin-arm64.dgst.sig.1 and /dev/null differ diff --git a/node/node-1.4.18-darwin-arm64.dgst.sig.12 b/node/node-1.4.18-darwin-arm64.dgst.sig.12 deleted file mode 100644 index d3137d9..0000000 Binary files a/node/node-1.4.18-darwin-arm64.dgst.sig.12 and /dev/null differ diff --git a/node/node-1.4.18-darwin-arm64.dgst.sig.13 b/node/node-1.4.18-darwin-arm64.dgst.sig.13 deleted file mode 100644 index 8e00e26..0000000 Binary files a/node/node-1.4.18-darwin-arm64.dgst.sig.13 and /dev/null differ diff --git a/node/node-1.4.18-darwin-arm64.dgst.sig.14 b/node/node-1.4.18-darwin-arm64.dgst.sig.14 deleted file mode 100644 index 939b099..0000000 Binary files a/node/node-1.4.18-darwin-arm64.dgst.sig.14 and /dev/null differ diff --git a/node/node-1.4.18-darwin-arm64.dgst.sig.15 b/node/node-1.4.18-darwin-arm64.dgst.sig.15 deleted file mode 100644 index fff4fac..0000000 Binary files a/node/node-1.4.18-darwin-arm64.dgst.sig.15 and /dev/null differ diff --git a/node/node-1.4.18-darwin-arm64.dgst.sig.16 b/node/node-1.4.18-darwin-arm64.dgst.sig.16 deleted file mode 100644 index 9807929..0000000 Binary files a/node/node-1.4.18-darwin-arm64.dgst.sig.16 and /dev/null differ diff --git a/node/node-1.4.18-darwin-arm64.dgst.sig.17 b/node/node-1.4.18-darwin-arm64.dgst.sig.17 deleted file mode 100644 index c719e16..0000000 Binary files a/node/node-1.4.18-darwin-arm64.dgst.sig.17 and /dev/null differ diff --git a/node/node-1.4.18-darwin-arm64.dgst.sig.2 b/node/node-1.4.18-darwin-arm64.dgst.sig.2 deleted file mode 100644 index 9e05512..0000000 Binary files a/node/node-1.4.18-darwin-arm64.dgst.sig.2 and /dev/null differ diff --git a/node/node-1.4.18-darwin-arm64.dgst.sig.3 b/node/node-1.4.18-darwin-arm64.dgst.sig.3 deleted file mode 100644 index 901b0ad..0000000 Binary files a/node/node-1.4.18-darwin-arm64.dgst.sig.3 and /dev/null differ diff --git a/node/node-1.4.18-darwin-arm64.dgst.sig.4 b/node/node-1.4.18-darwin-arm64.dgst.sig.4 deleted file mode 100644 index 433eedc..0000000 Binary files a/node/node-1.4.18-darwin-arm64.dgst.sig.4 and /dev/null differ diff --git a/node/node-1.4.18-darwin-arm64.dgst.sig.5 b/node/node-1.4.18-darwin-arm64.dgst.sig.5 deleted file mode 100644 index 0e52649..0000000 Binary files a/node/node-1.4.18-darwin-arm64.dgst.sig.5 and /dev/null differ diff --git a/node/node-1.4.18-darwin-arm64.dgst.sig.6 b/node/node-1.4.18-darwin-arm64.dgst.sig.6 deleted file mode 100644 index d4d68d9..0000000 Binary files a/node/node-1.4.18-darwin-arm64.dgst.sig.6 and /dev/null differ diff --git a/node/node-1.4.18-darwin-arm64.dgst.sig.8 b/node/node-1.4.18-darwin-arm64.dgst.sig.8 deleted file mode 100644 index cbf75a3..0000000 Binary files a/node/node-1.4.18-darwin-arm64.dgst.sig.8 and /dev/null differ diff --git a/node/node-1.4.18-darwin-arm64.dgst.sig.9 b/node/node-1.4.18-darwin-arm64.dgst.sig.9 deleted file mode 100644 index 7157385..0000000 Binary files a/node/node-1.4.18-darwin-arm64.dgst.sig.9 and /dev/null differ diff --git a/node/node-1.4.18-linux-amd64.dgst b/node/node-1.4.18-linux-amd64.dgst deleted file mode 100644 index f619e63..0000000 --- a/node/node-1.4.18-linux-amd64.dgst +++ /dev/null @@ -1 +0,0 @@ -SHA3-256(node-1.4.18-linux-amd64)= f2da38a5c8d4257767f4a9659ca9c05d4cf312fd7294e6a18847c8923f6815a0 diff --git a/node/node-1.4.18-linux-amd64.dgst.sig.1 b/node/node-1.4.18-linux-amd64.dgst.sig.1 deleted file mode 100644 index a7949bc..0000000 Binary files a/node/node-1.4.18-linux-amd64.dgst.sig.1 and /dev/null differ diff --git a/node/node-1.4.18-linux-amd64.dgst.sig.12 b/node/node-1.4.18-linux-amd64.dgst.sig.12 deleted file mode 100644 index b4fd9f5..0000000 Binary files a/node/node-1.4.18-linux-amd64.dgst.sig.12 and /dev/null differ diff --git a/node/node-1.4.18-linux-amd64.dgst.sig.13 b/node/node-1.4.18-linux-amd64.dgst.sig.13 deleted file mode 100644 index bd9c141..0000000 Binary files a/node/node-1.4.18-linux-amd64.dgst.sig.13 and /dev/null differ diff --git a/node/node-1.4.18-linux-amd64.dgst.sig.14 b/node/node-1.4.18-linux-amd64.dgst.sig.14 deleted file mode 100644 index 206197d..0000000 Binary files a/node/node-1.4.18-linux-amd64.dgst.sig.14 and /dev/null differ diff --git a/node/node-1.4.18-linux-amd64.dgst.sig.15 b/node/node-1.4.18-linux-amd64.dgst.sig.15 deleted file mode 100644 index 32ee7f4..0000000 Binary files a/node/node-1.4.18-linux-amd64.dgst.sig.15 and /dev/null differ diff --git a/node/node-1.4.18-linux-amd64.dgst.sig.16 b/node/node-1.4.18-linux-amd64.dgst.sig.16 deleted file mode 100644 index 490e99a..0000000 Binary files a/node/node-1.4.18-linux-amd64.dgst.sig.16 and /dev/null differ diff --git a/node/node-1.4.18-linux-amd64.dgst.sig.17 b/node/node-1.4.18-linux-amd64.dgst.sig.17 deleted file mode 100644 index ea5e17f..0000000 Binary files a/node/node-1.4.18-linux-amd64.dgst.sig.17 and /dev/null differ diff --git a/node/node-1.4.18-linux-amd64.dgst.sig.2 b/node/node-1.4.18-linux-amd64.dgst.sig.2 deleted file mode 100644 index 0e07cb9..0000000 Binary files a/node/node-1.4.18-linux-amd64.dgst.sig.2 and /dev/null differ diff --git a/node/node-1.4.18-linux-amd64.dgst.sig.3 b/node/node-1.4.18-linux-amd64.dgst.sig.3 deleted file mode 100644 index 825eca9..0000000 Binary files a/node/node-1.4.18-linux-amd64.dgst.sig.3 and /dev/null differ diff --git a/node/node-1.4.18-linux-amd64.dgst.sig.4 b/node/node-1.4.18-linux-amd64.dgst.sig.4 deleted file mode 100644 index dc59ed7..0000000 Binary files a/node/node-1.4.18-linux-amd64.dgst.sig.4 and /dev/null differ diff --git a/node/node-1.4.18-linux-amd64.dgst.sig.5 b/node/node-1.4.18-linux-amd64.dgst.sig.5 deleted file mode 100644 index 23cf3ed..0000000 Binary files a/node/node-1.4.18-linux-amd64.dgst.sig.5 and /dev/null differ diff --git a/node/node-1.4.18-linux-amd64.dgst.sig.6 b/node/node-1.4.18-linux-amd64.dgst.sig.6 deleted file mode 100644 index 3ea21bc..0000000 Binary files a/node/node-1.4.18-linux-amd64.dgst.sig.6 and /dev/null differ diff --git a/node/node-1.4.18-linux-amd64.dgst.sig.8 b/node/node-1.4.18-linux-amd64.dgst.sig.8 deleted file mode 100644 index 435ff71..0000000 Binary files a/node/node-1.4.18-linux-amd64.dgst.sig.8 and /dev/null differ diff --git a/node/node-1.4.18-linux-amd64.dgst.sig.9 b/node/node-1.4.18-linux-amd64.dgst.sig.9 deleted file mode 100644 index d39a4f6..0000000 Binary files a/node/node-1.4.18-linux-amd64.dgst.sig.9 and /dev/null differ diff --git a/node/node-1.4.18-linux-arm64.dgst b/node/node-1.4.18-linux-arm64.dgst deleted file mode 100644 index 79e41a2..0000000 --- a/node/node-1.4.18-linux-arm64.dgst +++ /dev/null @@ -1 +0,0 @@ -SHA3-256(node-1.4.18-linux-arm64)= e12e14a18a491921fcdd4ffe6e9792f1e195abf4950fe56316219f920867c45a diff --git a/node/node-1.4.18-linux-arm64.dgst.sig.1 b/node/node-1.4.18-linux-arm64.dgst.sig.1 deleted file mode 100644 index 10dd863..0000000 Binary files a/node/node-1.4.18-linux-arm64.dgst.sig.1 and /dev/null differ diff --git a/node/node-1.4.18-linux-arm64.dgst.sig.12 b/node/node-1.4.18-linux-arm64.dgst.sig.12 deleted file mode 100644 index a5bd10d..0000000 Binary files a/node/node-1.4.18-linux-arm64.dgst.sig.12 and /dev/null differ diff --git a/node/node-1.4.18-linux-arm64.dgst.sig.13 b/node/node-1.4.18-linux-arm64.dgst.sig.13 deleted file mode 100644 index 70d157c..0000000 Binary files a/node/node-1.4.18-linux-arm64.dgst.sig.13 and /dev/null differ diff --git a/node/node-1.4.18-linux-arm64.dgst.sig.14 b/node/node-1.4.18-linux-arm64.dgst.sig.14 deleted file mode 100644 index 3ee2e94..0000000 Binary files a/node/node-1.4.18-linux-arm64.dgst.sig.14 and /dev/null differ diff --git a/node/node-1.4.18-linux-arm64.dgst.sig.15 b/node/node-1.4.18-linux-arm64.dgst.sig.15 deleted file mode 100644 index afbc1c5..0000000 Binary files a/node/node-1.4.18-linux-arm64.dgst.sig.15 and /dev/null differ diff --git a/node/node-1.4.18-linux-arm64.dgst.sig.16 b/node/node-1.4.18-linux-arm64.dgst.sig.16 deleted file mode 100644 index 71c3e87..0000000 Binary files a/node/node-1.4.18-linux-arm64.dgst.sig.16 and /dev/null differ diff --git a/node/node-1.4.18-linux-arm64.dgst.sig.17 b/node/node-1.4.18-linux-arm64.dgst.sig.17 deleted file mode 100644 index aacb133..0000000 Binary files a/node/node-1.4.18-linux-arm64.dgst.sig.17 and /dev/null differ diff --git a/node/node-1.4.18-linux-arm64.dgst.sig.2 b/node/node-1.4.18-linux-arm64.dgst.sig.2 deleted file mode 100644 index d7bdcc3..0000000 Binary files a/node/node-1.4.18-linux-arm64.dgst.sig.2 and /dev/null differ diff --git a/node/node-1.4.18-linux-arm64.dgst.sig.3 b/node/node-1.4.18-linux-arm64.dgst.sig.3 deleted file mode 100644 index 293207a..0000000 Binary files a/node/node-1.4.18-linux-arm64.dgst.sig.3 and /dev/null differ diff --git a/node/node-1.4.18-linux-arm64.dgst.sig.4 b/node/node-1.4.18-linux-arm64.dgst.sig.4 deleted file mode 100644 index c8376d0..0000000 Binary files a/node/node-1.4.18-linux-arm64.dgst.sig.4 and /dev/null differ diff --git a/node/node-1.4.18-linux-arm64.dgst.sig.5 b/node/node-1.4.18-linux-arm64.dgst.sig.5 deleted file mode 100644 index 5985fcf..0000000 Binary files a/node/node-1.4.18-linux-arm64.dgst.sig.5 and /dev/null differ diff --git a/node/node-1.4.18-linux-arm64.dgst.sig.6 b/node/node-1.4.18-linux-arm64.dgst.sig.6 deleted file mode 100644 index b9c5782..0000000 Binary files a/node/node-1.4.18-linux-arm64.dgst.sig.6 and /dev/null differ diff --git a/node/node-1.4.18-linux-arm64.dgst.sig.8 b/node/node-1.4.18-linux-arm64.dgst.sig.8 deleted file mode 100644 index 2026957..0000000 Binary files a/node/node-1.4.18-linux-arm64.dgst.sig.8 and /dev/null differ diff --git a/node/node-1.4.18-linux-arm64.dgst.sig.9 b/node/node-1.4.18-linux-arm64.dgst.sig.9 deleted file mode 100644 index 8295904..0000000 Binary files a/node/node-1.4.18-linux-arm64.dgst.sig.9 and /dev/null differ diff --git a/node/p2p/blossomsub.go b/node/p2p/blossomsub.go index 4421c32..76c0253 100644 --- a/node/p2p/blossomsub.go +++ b/node/p2p/blossomsub.go @@ -341,7 +341,8 @@ func initDHT( if isBootstrapPeer { kademliaDHT, err = dht.New(ctx, h, dht.Mode(dht.ModeServer)) } else { - kademliaDHT, err = dht.New(ctx, h, dht.Mode(dht.ModeAuto)) + // until libp2p gets their shit together, set this as a client only: + kademliaDHT, err = dht.New(ctx, h, dht.Mode(dht.ModeClient)) } if err != nil { panic(err) diff --git a/node/protobufs/data.pb.go b/node/protobufs/data.pb.go index 538d8ab..cac5e5b 100644 --- a/node/protobufs/data.pb.go +++ b/node/protobufs/data.pb.go @@ -27,8 +27,7 @@ type ChallengeProofRequest struct { Challenge []byte `protobuf:"bytes,1,opt,name=challenge,proto3" json:"challenge,omitempty"` Core uint32 `protobuf:"varint,2,opt,name=core,proto3" json:"core,omitempty"` - Skew int64 `protobuf:"varint,3,opt,name=skew,proto3" json:"skew,omitempty"` - NowMs int64 `protobuf:"varint,4,opt,name=now_ms,json=nowMs,proto3" json:"now_ms,omitempty"` + Increment uint32 `protobuf:"varint,3,opt,name=increment,proto3" json:"increment,omitempty"` } func (x *ChallengeProofRequest) Reset() { @@ -77,16 +76,9 @@ func (x *ChallengeProofRequest) GetCore() uint32 { return 0 } -func (x *ChallengeProofRequest) GetSkew() int64 { +func (x *ChallengeProofRequest) GetIncrement() uint32 { if x != nil { - return x.Skew - } - return 0 -} - -func (x *ChallengeProofRequest) GetNowMs() int64 { - if x != nil { - return x.NowMs + return x.Increment } return 0 } @@ -96,8 +88,7 @@ type ChallengeProofResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Output []byte `protobuf:"bytes,1,opt,name=output,proto3" json:"output,omitempty"` - NextSkew int64 `protobuf:"varint,2,opt,name=next_skew,json=nextSkew,proto3" json:"next_skew,omitempty"` + Output []byte `protobuf:"bytes,1,opt,name=output,proto3" json:"output,omitempty"` } func (x *ChallengeProofResponse) Reset() { @@ -139,44 +130,35 @@ func (x *ChallengeProofResponse) GetOutput() []byte { return nil } -func (x *ChallengeProofResponse) GetNextSkew() int64 { - if x != nil { - return x.NextSkew - } - return 0 -} - var File_data_proto protoreflect.FileDescriptor var file_data_proto_rawDesc = []byte{ 0x0a, 0x0a, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x17, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x64, 0x61, - 0x74, 0x61, 0x2e, 0x70, 0x62, 0x22, 0x74, 0x0a, 0x15, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, + 0x74, 0x61, 0x2e, 0x70, 0x62, 0x22, 0x67, 0x0a, 0x15, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x63, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x63, 0x6f, 0x72, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6b, 0x65, 0x77, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, - 0x73, 0x6b, 0x65, 0x77, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x6f, 0x77, 0x5f, 0x6d, 0x73, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x6e, 0x6f, 0x77, 0x4d, 0x73, 0x22, 0x4d, 0x0a, 0x16, 0x43, - 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x1b, 0x0a, - 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x6b, 0x65, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x53, 0x6b, 0x65, 0x77, 0x32, 0x8c, 0x01, 0x0a, 0x0e, 0x44, - 0x61, 0x74, 0x61, 0x49, 0x50, 0x43, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x7a, 0x0a, - 0x17, 0x43, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, - 0x6e, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x2e, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, - 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, - 0x70, 0x62, 0x2e, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x6f, - 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, - 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, - 0x70, 0x62, 0x2e, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x6f, - 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3a, 0x5a, 0x38, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2f, 0x6d, 0x6f, - 0x6e, 0x6f, 0x72, 0x65, 0x70, 0x6f, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x09, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x30, + 0x0a, 0x16, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x6f, 0x66, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, + 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, + 0x32, 0x8c, 0x01, 0x0a, 0x0e, 0x44, 0x61, 0x74, 0x61, 0x49, 0x50, 0x43, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x7a, 0x0a, 0x17, 0x43, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x65, + 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x2e, + 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, + 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, + 0x67, 0x65, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, + 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, + 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, + 0x67, 0x65, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, + 0x3a, 0x5a, 0x38, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, + 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, + 0x69, 0x75, 0x6d, 0x2f, 0x6d, 0x6f, 0x6e, 0x6f, 0x72, 0x65, 0x70, 0x6f, 0x2f, 0x6e, 0x6f, 0x64, + 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/node/protobufs/data.proto b/node/protobufs/data.proto index 1e959c6..8082065 100644 --- a/node/protobufs/data.proto +++ b/node/protobufs/data.proto @@ -7,13 +7,11 @@ option go_package = "source.quilibrium.com/quilibrium/monorepo/node/protobufs"; message ChallengeProofRequest { bytes challenge = 1; uint32 core = 2; - int64 skew = 3; - int64 now_ms = 4; + uint32 increment = 3; } message ChallengeProofResponse { bytes output = 1; - int64 next_skew = 2; } service DataIPCService { diff --git a/node/protobufs/node.pb.go b/node/protobufs/node.pb.go index c666428..f745e9f 100644 --- a/node/protobufs/node.pb.go +++ b/node/protobufs/node.pb.go @@ -1096,6 +1096,10 @@ type SelfTestReport struct { MasterHeadFrame uint64 `protobuf:"varint,15,opt,name=master_head_frame,json=masterHeadFrame,proto3" json:"master_head_frame,omitempty"` // A challenge proof Proof []byte `protobuf:"bytes,16,opt,name=proof,proto3" json:"proof,omitempty"` + // The challenge, minus the peer id + Challenge []byte `protobuf:"bytes,17,opt,name=challenge,proto3" json:"challenge,omitempty"` + // The increment value + Increment uint32 `protobuf:"varint,18,opt,name=increment,proto3" json:"increment,omitempty"` } func (x *SelfTestReport) Reset() { @@ -1242,6 +1246,20 @@ func (x *SelfTestReport) GetProof() []byte { return nil } +func (x *SelfTestReport) GetChallenge() []byte { + if x != nil { + return x.Challenge + } + return nil +} + +func (x *SelfTestReport) GetIncrement() uint32 { + if x != nil { + return x.Increment + } + return 0 +} + type ValidationMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1467,6 +1485,8 @@ type PeerManifest struct { MasterHeadFrame uint64 `protobuf:"varint,16,opt,name=master_head_frame,json=masterHeadFrame,proto3" json:"master_head_frame,omitempty"` // The last time seen tick LastSeen int64 `protobuf:"varint,17,opt,name=last_seen,json=lastSeen,proto3" json:"last_seen,omitempty"` + // The increment of the node + Increment uint32 `protobuf:"varint,18,opt,name=increment,proto3" json:"increment,omitempty"` } func (x *PeerManifest) Reset() { @@ -1620,6 +1640,13 @@ func (x *PeerManifest) GetLastSeen() int64 { return 0 } +func (x *PeerManifest) GetIncrement() uint32 { + if x != nil { + return x.Increment + } + return 0 +} + type PeerManifestsResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1798,7 +1825,7 @@ var file_node_proto_rawDesc = []byte{ 0x63, 0x6f, 0x6c, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x2f, 0x0a, 0x13, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x12, 0x61, 0x64, 0x64, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0x90, + 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0xcc, 0x05, 0x0a, 0x0e, 0x53, 0x65, 0x6c, 0x66, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x64, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, @@ -1840,152 +1867,158 @@ var file_node_proto_rawDesc = []byte{ 0x72, 0x61, 0x6d, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x48, 0x65, 0x61, 0x64, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x6f, - 0x66, 0x22, 0x33, 0x0a, 0x11, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x62, 0x0a, 0x0b, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x53, 0x0a, 0x0e, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x5f, - 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, - 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, - 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x46, 0x72, - 0x61, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x0d, 0x66, 0x72, 0x61, - 0x6d, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x66, 0x0a, 0x0c, 0x53, 0x79, - 0x6e, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x56, 0x0a, 0x0f, 0x66, 0x72, - 0x61, 0x6d, 0x65, 0x73, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, - 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x70, 0x62, 0x2e, 0x43, - 0x6c, 0x6f, 0x63, 0x6b, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x52, 0x0e, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x19, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x50, 0x65, 0x65, 0x72, 0x4d, 0x61, 0x6e, - 0x69, 0x66, 0x65, 0x73, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xae, 0x05, - 0x0a, 0x0c, 0x50, 0x65, 0x65, 0x72, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x12, 0x17, - 0x0a, 0x07, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x06, 0x70, 0x65, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x69, 0x66, 0x66, 0x69, - 0x63, 0x75, 0x6c, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x64, 0x69, 0x66, - 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x12, 0x2b, 0x0a, 0x11, 0x64, 0x69, 0x66, 0x66, 0x69, - 0x63, 0x75, 0x6c, 0x74, 0x79, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x10, 0x64, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x4d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x12, 0x28, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x31, - 0x36, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, - 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x31, 0x36, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x2a, - 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x31, 0x32, 0x38, 0x5f, 0x6d, 0x65, 0x74, - 0x72, 0x69, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, - 0x74, 0x31, 0x32, 0x38, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x2c, 0x0a, 0x12, 0x63, 0x6f, - 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x31, 0x30, 0x32, 0x34, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x10, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x31, 0x30, - 0x32, 0x34, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x2e, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x6d, - 0x69, 0x74, 0x5f, 0x36, 0x35, 0x35, 0x33, 0x36, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, - 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x11, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x36, 0x35, 0x35, - 0x33, 0x36, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x26, 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x6f, - 0x66, 0x5f, 0x31, 0x36, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x31, 0x36, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, - 0x12, 0x28, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x5f, 0x31, 0x32, 0x38, 0x5f, 0x6d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x70, 0x72, 0x6f, 0x6f, - 0x66, 0x31, 0x32, 0x38, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x2a, 0x0a, 0x11, 0x70, 0x72, - 0x6f, 0x6f, 0x66, 0x5f, 0x31, 0x30, 0x32, 0x34, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, - 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x31, 0x30, 0x32, 0x34, - 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x2c, 0x0a, 0x12, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x5f, - 0x36, 0x35, 0x35, 0x33, 0x36, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, 0x0b, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x10, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x36, 0x35, 0x35, 0x33, 0x36, 0x4d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x72, 0x65, 0x73, 0x18, 0x0c, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x05, 0x63, 0x6f, 0x72, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, - 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, - 0x72, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x18, 0x0e, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x12, 0x47, 0x0a, 0x0c, - 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, - 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x61, 0x70, - 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x0c, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, - 0x69, 0x74, 0x69, 0x65, 0x73, 0x12, 0x2a, 0x0a, 0x11, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x5f, - 0x68, 0x65, 0x61, 0x64, 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x0f, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x48, 0x65, 0x61, 0x64, 0x46, 0x72, 0x61, 0x6d, - 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x65, 0x6e, 0x18, 0x11, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x65, 0x65, 0x6e, 0x22, 0x65, - 0x0a, 0x15, 0x50, 0x65, 0x65, 0x72, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4c, 0x0a, 0x0e, 0x70, 0x65, 0x65, 0x72, 0x5f, - 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x25, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, - 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x4d, 0x61, - 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x52, 0x0d, 0x70, 0x65, 0x65, 0x72, 0x4d, 0x61, 0x6e, 0x69, - 0x66, 0x65, 0x73, 0x74, 0x73, 0x32, 0xd7, 0x01, 0x0a, 0x11, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6b, 0x0a, 0x11, 0x50, - 0x65, 0x72, 0x66, 0x6f, 0x72, 0x6d, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x2a, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, - 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x2a, 0x2e, 0x71, - 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, - 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x55, 0x0a, 0x04, 0x53, 0x79, 0x6e, 0x63, - 0x12, 0x24, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, - 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, - 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, - 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x32, - 0xf6, 0x05, 0x0a, 0x0b, 0x4e, 0x6f, 0x64, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x5f, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x29, 0x2e, 0x71, - 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, - 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, - 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, - 0x62, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x68, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x49, 0x6e, 0x66, 0x6f, - 0x12, 0x2c, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, - 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x46, 0x72, - 0x61, 0x6d, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, + 0x66, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x18, 0x11, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x63, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x12, + 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x12, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x09, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x33, 0x0a, + 0x11, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x22, 0x62, 0x0a, 0x0b, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x53, 0x0a, 0x0e, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x5f, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x71, 0x75, 0x69, 0x6c, + 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x63, 0x6c, 0x6f, 0x63, + 0x6b, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x0d, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x66, 0x0a, 0x0c, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x56, 0x0a, 0x0f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x73, + 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x2d, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, + 0x65, 0x2e, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6c, 0x6f, 0x63, 0x6b, + 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0e, + 0x66, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, + 0x0a, 0x17, 0x47, 0x65, 0x74, 0x50, 0x65, 0x65, 0x72, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, + 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xcc, 0x05, 0x0a, 0x0c, 0x50, 0x65, + 0x65, 0x72, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x65, + 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, 0x65, 0x65, + 0x72, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, + 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x64, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, + 0x6c, 0x74, 0x79, 0x12, 0x2b, 0x0a, 0x11, 0x64, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, + 0x79, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x10, + 0x64, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, + 0x12, 0x28, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x31, 0x36, 0x5f, 0x6d, 0x65, + 0x74, 0x72, 0x69, 0x63, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x63, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x31, 0x36, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x2a, 0x0a, 0x11, 0x63, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x31, 0x32, 0x38, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x31, 0x32, 0x38, + 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x2c, 0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x5f, 0x31, 0x30, 0x32, 0x34, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x10, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x31, 0x30, 0x32, 0x34, 0x4d, 0x65, + 0x74, 0x72, 0x69, 0x63, 0x12, 0x2e, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x36, + 0x35, 0x35, 0x33, 0x36, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x11, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x36, 0x35, 0x35, 0x33, 0x36, 0x4d, 0x65, + 0x74, 0x72, 0x69, 0x63, 0x12, 0x26, 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x5f, 0x31, 0x36, + 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x70, + 0x72, 0x6f, 0x6f, 0x66, 0x31, 0x36, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x28, 0x0a, 0x10, + 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x5f, 0x31, 0x32, 0x38, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x31, 0x32, 0x38, + 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x2a, 0x0a, 0x11, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x5f, + 0x31, 0x30, 0x32, 0x34, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, 0x0a, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x0f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x31, 0x30, 0x32, 0x34, 0x4d, 0x65, 0x74, 0x72, + 0x69, 0x63, 0x12, 0x2c, 0x0a, 0x12, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x5f, 0x36, 0x35, 0x35, 0x33, + 0x36, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x10, + 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x36, 0x35, 0x35, 0x33, 0x36, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, + 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x72, 0x65, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x05, 0x63, 0x6f, 0x72, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, + 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x12, 0x18, + 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x12, 0x47, 0x0a, 0x0c, 0x63, 0x61, 0x70, 0x61, + 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, - 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x49, 0x6e, - 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x65, 0x0a, 0x0b, 0x47, 0x65, - 0x74, 0x50, 0x65, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2b, 0x2e, 0x71, 0x75, 0x69, 0x6c, + 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, + 0x69, 0x74, 0x79, 0x52, 0x0c, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, + 0x73, 0x12, 0x2a, 0x0a, 0x11, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x68, 0x65, 0x61, 0x64, + 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x6d, 0x61, + 0x73, 0x74, 0x65, 0x72, 0x48, 0x65, 0x61, 0x64, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, + 0x09, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x65, 0x6e, 0x18, 0x11, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x08, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x65, 0x65, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, + 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x12, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x69, + 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x65, 0x0a, 0x15, 0x50, 0x65, 0x65, 0x72, + 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x4c, 0x0a, 0x0e, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, + 0x73, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, - 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x65, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, - 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, - 0x2e, 0x50, 0x65, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x65, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, - 0x12, 0x2b, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, - 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x6f, - 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, - 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, - 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6e, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x4e, - 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2e, 0x2e, 0x71, 0x75, 0x69, + 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, + 0x52, 0x0d, 0x70, 0x65, 0x65, 0x72, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x73, 0x32, + 0xd7, 0x01, 0x0a, 0x11, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6b, 0x0a, 0x11, 0x50, 0x65, 0x72, 0x66, 0x6f, 0x72, 0x6d, + 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, - 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, - 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x71, 0x75, 0x69, + 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x2a, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, + 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, + 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x12, 0x55, 0x0a, 0x04, 0x53, 0x79, 0x6e, 0x63, 0x12, 0x24, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, - 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x68, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x54, - 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2c, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, - 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, - 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, + 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x25, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, + 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x32, 0xf6, 0x05, 0x0a, 0x0b, 0x4e, 0x6f, + 0x64, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, 0x0a, 0x09, 0x47, 0x65, 0x74, + 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x29, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, - 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x74, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x50, 0x65, 0x65, 0x72, 0x4d, 0x61, 0x6e, - 0x69, 0x66, 0x65, 0x73, 0x74, 0x73, 0x12, 0x30, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, - 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, - 0x2e, 0x47, 0x65, 0x74, 0x50, 0x65, 0x65, 0x72, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, + 0x2e, 0x47, 0x65, 0x74, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x27, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, + 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x72, 0x61, 0x6d, + 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x68, 0x0a, 0x0c, 0x47, 0x65, + 0x74, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2c, 0x2e, 0x71, 0x75, 0x69, + 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, + 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x49, 0x6e, 0x66, + 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, - 0x70, 0x62, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xcf, 0x01, 0x0a, 0x09, 0x4e, 0x6f, 0x64, - 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x60, 0x0a, 0x0b, 0x50, 0x75, 0x74, 0x4e, 0x6f, 0x64, - 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2b, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, - 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, - 0x50, 0x75, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, - 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, 0x74, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x60, 0x0a, 0x0b, 0x50, 0x75, 0x74, 0x50, - 0x65, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2b, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, + 0x70, 0x62, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x65, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x50, 0x65, 0x65, 0x72, 0x49, + 0x6e, 0x66, 0x6f, 0x12, 0x2b, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, + 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, + 0x74, 0x50, 0x65, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x29, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, + 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x49, + 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x65, 0x0a, 0x0b, 0x47, + 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2b, 0x2e, 0x71, 0x75, 0x69, + 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, + 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, - 0x62, 0x2e, 0x50, 0x75, 0x74, 0x50, 0x65, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, - 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x50, - 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3a, 0x5a, 0x38, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2f, 0x6d, - 0x6f, 0x6e, 0x6f, 0x72, 0x65, 0x70, 0x6f, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x6e, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, + 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2e, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, + 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x47, + 0x65, 0x74, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, + 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x4e, + 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x68, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x6e, + 0x66, 0x6f, 0x12, 0x2c, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, + 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, + 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x2a, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, + 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, + 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x74, 0x0a, 0x10, + 0x47, 0x65, 0x74, 0x50, 0x65, 0x65, 0x72, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x73, + 0x12, 0x30, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, + 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x65, + 0x65, 0x72, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, + 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x65, 0x65, + 0x72, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x32, 0xcf, 0x01, 0x0a, 0x09, 0x4e, 0x6f, 0x64, 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, + 0x12, 0x60, 0x0a, 0x0b, 0x50, 0x75, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, + 0x2b, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, + 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, 0x74, 0x4e, 0x6f, 0x64, + 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x71, + 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, + 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x60, 0x0a, 0x0b, 0x50, 0x75, 0x74, 0x50, 0x65, 0x65, 0x72, 0x49, 0x6e, 0x66, + 0x6f, 0x12, 0x2b, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, + 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, 0x74, 0x50, + 0x65, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, + 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, + 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3a, 0x5a, 0x38, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x71, + 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x71, 0x75, + 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2f, 0x6d, 0x6f, 0x6e, 0x6f, 0x72, 0x65, 0x70, + 0x6f, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x73, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/node/protobufs/node.proto b/node/protobufs/node.proto index 3116196..e8b7f91 100644 --- a/node/protobufs/node.proto +++ b/node/protobufs/node.proto @@ -157,6 +157,10 @@ message SelfTestReport { uint64 master_head_frame = 15; // A challenge proof bytes proof = 16; + // The challenge, minus the peer id + bytes challenge = 17; + // The increment value + uint32 increment = 18; } message ValidationMessage { @@ -220,6 +224,8 @@ message PeerManifest { uint64 master_head_frame = 16; // The last time seen tick int64 last_seen = 17; + // The increment of the node + uint32 increment = 18; } message PeerManifestsResponse { diff --git a/node/rpc/data_worker_ipc_server.go b/node/rpc/data_worker_ipc_server.go index 23b5e03..04952aa 100644 --- a/node/rpc/data_worker_ipc_server.go +++ b/node/rpc/data_worker_ipc_server.go @@ -39,19 +39,17 @@ func (r *DataWorkerIPCServer) CalculateChallengeProof( ) } - proof, nextSkew, err := r.prover.CalculateChallengeProof( + proof, err := r.prover.CalculateChallengeProof( req.Challenge, uint32(r.coreId), - req.Skew, - req.NowMs, + req.Increment, ) if err != nil { return nil, errors.Wrap(err, "calculate challenge proof") } return &protobufs.ChallengeProofResponse{ - Output: proof, - NextSkew: nextSkew, + Output: proof, }, nil } @@ -96,6 +94,7 @@ func (r *DataWorkerIPCServer) Start() error { zap.String("address", r.listenAddrGRPC), ) if err := s.Serve(mn.NetListener(lis)); err != nil { + r.logger.Error("terminating server", zap.Error(err)) panic(err) } diff --git a/node/rpc/node_rpc_server.go b/node/rpc/node_rpc_server.go index 13a53a3..19f660e 100644 --- a/node/rpc/node_rpc_server.go +++ b/node/rpc/node_rpc_server.go @@ -3,7 +3,6 @@ package rpc import ( "bytes" "context" - "math/big" "net/http" "source.quilibrium.com/quilibrium/monorepo/node/config" @@ -11,7 +10,6 @@ import ( "github.com/libp2p/go-libp2p/core/peer" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/iden3/go-iden3-crypto/poseidon" "github.com/multiformats/go-multiaddr" mn "github.com/multiformats/go-multiaddr/net" "github.com/pkg/errors" @@ -21,12 +19,10 @@ import ( "google.golang.org/grpc/reflection" "source.quilibrium.com/quilibrium/monorepo/node/consensus/master" "source.quilibrium.com/quilibrium/monorepo/node/execution" - "source.quilibrium.com/quilibrium/monorepo/node/execution/intrinsics/ceremony/application" "source.quilibrium.com/quilibrium/monorepo/node/keys" "source.quilibrium.com/quilibrium/monorepo/node/p2p" "source.quilibrium.com/quilibrium/monorepo/node/protobufs" "source.quilibrium.com/quilibrium/monorepo/node/store" - "source.quilibrium.com/quilibrium/monorepo/node/tries" ) type RPCServer struct { @@ -34,6 +30,7 @@ type RPCServer struct { listenAddrGRPC string listenAddrHTTP string logger *zap.Logger + dataProofStore store.DataProofStore clockStore store.ClockStore keyManager keys.KeyManager pubSub p2p.PubSub @@ -192,136 +189,142 @@ func (r *RPCServer) GetPeerInfo( return resp, nil } +// Only returns the active amounts earned under 1.4.19 until 2.0 func (r *RPCServer) GetTokenInfo( ctx context.Context, req *protobufs.GetTokenInfoRequest, ) (*protobufs.TokenInfoResponse, error) { - provingKey, err := r.keyManager.GetRawKey( - "default-proving-key", - ) - if err != nil { - return nil, errors.Wrap(err, "get token info") - } + // provingKey, err := r.keyManager.GetRawKey( + // "default-proving-key", + // ) + // if err != nil { + // return nil, errors.Wrap(err, "get token info") + // } - peerBytes := r.pubSub.GetPeerID() - peerAddr, err := poseidon.HashBytes(peerBytes) - if err != nil { - panic(err) - } + // peerBytes := r.pubSub.GetPeerID() + // peerAddr, err := poseidon.HashBytes(peerBytes) + // if err != nil { + // panic(err) + // } - addr, err := poseidon.HashBytes(provingKey.PublicKey) - if err != nil { - panic(err) - } + // addr, err := poseidon.HashBytes(provingKey.PublicKey) + // if err != nil { + // panic(err) + // } - addrBytes := addr.Bytes() - addrBytes = append(make([]byte, 32-len(addrBytes)), addrBytes...) + // addrBytes := addr.Bytes() + // addrBytes = append(make([]byte, 32-len(addrBytes)), addrBytes...) - peerAddrBytes := peerAddr.Bytes() - peerAddrBytes = append(make([]byte, 32-len(peerAddrBytes)), peerAddrBytes...) + // peerAddrBytes := peerAddr.Bytes() + // peerAddrBytes = append(make([]byte, 32-len(peerAddrBytes)), peerAddrBytes...) - frame, err := r.clockStore.GetLatestDataClockFrame( - append( - p2p.GetBloomFilter(application.CEREMONY_ADDRESS, 256, 3), - p2p.GetBloomFilterIndices(application.CEREMONY_ADDRESS, 65536, 24)..., - ), - nil, - ) - if err != nil { - return nil, errors.Wrap(err, "get token info") - } + // frame, err := r.clockStore.GetLatestDataClockFrame( + // append( + // p2p.GetBloomFilter(application.CEREMONY_ADDRESS, 256, 3), + // p2p.GetBloomFilterIndices(application.CEREMONY_ADDRESS, 65536, 24)..., + // ), + // nil, + // ) + // if err != nil { + // return nil, errors.Wrap(err, "get token info") + // } - confirmed, err := application.MaterializeApplicationFromFrame(frame) - if err != nil { - return nil, errors.Wrap(err, "get token info") - } + // confirmed, err := application.MaterializeApplicationFromFrame(frame) + // if err != nil { + // return nil, errors.Wrap(err, "get token info") + // } - confirmedTotal := new(big.Int) - ownedTotal := new(big.Int) - if confirmed.RewardTrie.Root == nil || - (confirmed.RewardTrie.Root.External == nil && - confirmed.RewardTrie.Root.Internal == nil) { - return &protobufs.TokenInfoResponse{ - ConfirmedTokenSupply: confirmedTotal.FillBytes(make([]byte, 32)), - UnconfirmedTokenSupply: confirmedTotal.FillBytes(make([]byte, 32)), - OwnedTokens: ownedTotal.FillBytes(make([]byte, 32)), - UnconfirmedOwnedTokens: ownedTotal.FillBytes(make([]byte, 32)), - }, nil - } + // confirmedTotal := new(big.Int) + // ownedTotal := new(big.Int) + // if confirmed.RewardTrie.Root == nil || + // (confirmed.RewardTrie.Root.External == nil && + // confirmed.RewardTrie.Root.Internal == nil) { + // return &protobufs.TokenInfoResponse{ + // ConfirmedTokenSupply: confirmedTotal.FillBytes(make([]byte, 32)), + // UnconfirmedTokenSupply: confirmedTotal.FillBytes(make([]byte, 32)), + // OwnedTokens: ownedTotal.FillBytes(make([]byte, 32)), + // UnconfirmedOwnedTokens: ownedTotal.FillBytes(make([]byte, 32)), + // }, nil + // } - limbs := []*tries.RewardInternalNode{} - if confirmed.RewardTrie.Root.Internal != nil { - limbs = append(limbs, confirmed.RewardTrie.Root.Internal) - } else { - confirmedTotal = confirmedTotal.Add( - confirmedTotal, - new(big.Int).SetUint64(confirmed.RewardTrie.Root.External.Total), - ) - if bytes.Equal( - confirmed.RewardTrie.Root.External.Key, - addrBytes, - ) { - ownedTotal = ownedTotal.Add( - ownedTotal, - new(big.Int).SetUint64(confirmed.RewardTrie.Root.External.Total), - ) - } - } + // limbs := []*tries.RewardInternalNode{} + // if confirmed.RewardTrie.Root.Internal != nil { + // limbs = append(limbs, confirmed.RewardTrie.Root.Internal) + // } else { + // confirmedTotal = confirmedTotal.Add( + // confirmedTotal, + // new(big.Int).SetUint64(confirmed.RewardTrie.Root.External.Total), + // ) + // if bytes.Equal( + // confirmed.RewardTrie.Root.External.Key, + // addrBytes, + // ) { + // ownedTotal = ownedTotal.Add( + // ownedTotal, + // new(big.Int).SetUint64(confirmed.RewardTrie.Root.External.Total), + // ) + // } + // } - for len(limbs) != 0 { - nextLimbs := []*tries.RewardInternalNode{} - for _, limb := range limbs { - for _, child := range limb.Child { - child := child - if child.Internal != nil { - nextLimbs = append(nextLimbs, child.Internal) - } else { - confirmedTotal = confirmedTotal.Add( - confirmedTotal, - new(big.Int).SetUint64(child.External.Total), - ) - if bytes.Equal( - child.External.Key, - addrBytes, - ) { - ownedTotal = ownedTotal.Add( - ownedTotal, - new(big.Int).SetUint64(child.External.Total), - ) - } - if bytes.Equal( - child.External.Key, - peerAddrBytes, - ) { - ownedTotal = ownedTotal.Add( - ownedTotal, - new(big.Int).SetUint64(child.External.Total), - ) - } - } - } - } - limbs = nextLimbs - } + // for len(limbs) != 0 { + // nextLimbs := []*tries.RewardInternalNode{} + // for _, limb := range limbs { + // for _, child := range limb.Child { + // child := child + // if child.Internal != nil { + // nextLimbs = append(nextLimbs, child.Internal) + // } else { + // confirmedTotal = confirmedTotal.Add( + // confirmedTotal, + // new(big.Int).SetUint64(child.External.Total), + // ) + // if bytes.Equal( + // child.External.Key, + // addrBytes, + // ) { + // ownedTotal = ownedTotal.Add( + // ownedTotal, + // new(big.Int).SetUint64(child.External.Total), + // ) + // } + // if bytes.Equal( + // child.External.Key, + // peerAddrBytes, + // ) { + // ownedTotal = ownedTotal.Add( + // ownedTotal, + // new(big.Int).SetUint64(child.External.Total), + // ) + // } + // } + // } + // } + // limbs = nextLimbs + // } - if err != nil { - return nil, errors.Wrap(err, "get token info") - } + // if err != nil { + // return nil, errors.Wrap(err, "get token info") + // } // 1 QUIL = 0x1DCD65000 units - conversionFactor, ok := new(big.Int).SetString("1DCD65000", 16) - if !ok { - return nil, errors.Wrap(err, "get token info") + // conversionFactor, ok := new(big.Int).SetString("1DCD65000", 16) + // if !ok { + // return nil, errors.Wrap(err, "get token info") + // } + + total, err := r.dataProofStore.GetTotalReward(r.pubSub.GetPeerID()) + if err != nil { + panic(err) } - confirmedTotal = confirmedTotal.Mul(confirmedTotal, conversionFactor) - ownedTotal = ownedTotal.Mul(ownedTotal, conversionFactor) + // confirmedTotal = confirmedTotal.Mul(confirmedTotal, conversionFactor) + // ownedTotal = ownedTotal.Mul(ownedTotal, conversionFactor) return &protobufs.TokenInfoResponse{ - ConfirmedTokenSupply: confirmedTotal.FillBytes(make([]byte, 32)), - UnconfirmedTokenSupply: confirmedTotal.FillBytes(make([]byte, 32)), - OwnedTokens: ownedTotal.FillBytes(make([]byte, 32)), - UnconfirmedOwnedTokens: ownedTotal.FillBytes(make([]byte, 32)), + // ConfirmedTokenSupply: confirmedTotal.FillBytes(make([]byte, 32)), + // UnconfirmedTokenSupply: confirmedTotal.FillBytes(make([]byte, 32)), + // OwnedTokens: ownedTotal.FillBytes(make([]byte, 32)), + UnconfirmedOwnedTokens: total.FillBytes(make([]byte, 32)), }, nil } @@ -336,6 +339,7 @@ func NewRPCServer( listenAddrGRPC string, listenAddrHTTP string, logger *zap.Logger, + dataProofStore store.DataProofStore, clockStore store.ClockStore, keyManager keys.KeyManager, pubSub p2p.PubSub, @@ -346,6 +350,7 @@ func NewRPCServer( listenAddrGRPC: listenAddrGRPC, listenAddrHTTP: listenAddrHTTP, logger: logger, + dataProofStore: dataProofStore, clockStore: clockStore, keyManager: keyManager, pubSub: pubSub, diff --git a/node/store/data_proof.go b/node/store/data_proof.go index bce779b..841e5c1 100644 --- a/node/store/data_proof.go +++ b/node/store/data_proof.go @@ -3,6 +3,7 @@ package store import ( "encoding/binary" "fmt" + "math/big" "github.com/cockroachdb/pebble" "github.com/pkg/errors" @@ -27,6 +28,27 @@ type DataProofStore interface { aggregateProof *protobufs.InclusionAggregateProof, commitment []byte, ) error + GetDataTimeProof( + peerId []byte, + increment uint32, + ) (difficulty, parallelism uint32, input, output []byte, err error) + GetTotalReward( + peerId []byte, + ) (*big.Int, error) + PutDataTimeProof( + txn Transaction, + parallelism uint32, + peerId []byte, + increment uint32, + input []byte, + output []byte, + ) error + GetLatestDataTimeProof(peerId []byte) ( + increment uint32, + parallelism uint32, + output []byte, + err error, + ) } var _ DataProofStore = (*PebbleDataProofStore)(nil) @@ -47,10 +69,13 @@ func NewPebbleDataProofStore( } const ( - DATA_PROOF = 0x04 - DATA_PROOF_METADATA = 0x00 - DATA_PROOF_INCLUSION = 0x01 - DATA_PROOF_SEGMENT = 0x02 + DATA_PROOF = 0x04 + DATA_PROOF_METADATA = 0x00 + DATA_PROOF_INCLUSION = 0x01 + DATA_PROOF_SEGMENT = 0x02 + DATA_TIME_PROOF = 0x05 + DATA_TIME_PROOF_DATA = 0x00 + DATA_TIME_PROOF_LATEST = 0x01 ) func dataProofMetadataKey(filter []byte, commitment []byte) []byte { @@ -82,6 +107,19 @@ func dataProofSegmentKey( return key } +func dataTimeProofKey(peerId []byte, increment uint32) []byte { + key := []byte{DATA_TIME_PROOF, DATA_TIME_PROOF_DATA} + key = append(key, peerId...) + key = binary.BigEndian.AppendUint32(key, increment) + return key +} + +func dataTimeProofLatestKey(peerId []byte) []byte { + key := []byte{DATA_TIME_PROOF, DATA_TIME_PROOF_LATEST} + key = append(key, peerId...) + return key +} + func (p *PebbleDataProofStore) NewTransaction() (Transaction, error) { return p.db.NewBatch(), nil } @@ -362,3 +400,170 @@ func (p *PebbleDataProofStore) PutAggregateProof( commitment, ) } + +func (p *PebbleDataProofStore) GetDataTimeProof( + peerId []byte, + increment uint32, +) (difficulty, parallelism uint32, input, output []byte, err error) { + data, closer, err := p.db.Get(dataTimeProofKey(peerId, increment)) + if err != nil { + if errors.Is(err, pebble.ErrNotFound) { + err = ErrNotFound + return + } + err = errors.Wrap(err, "get data time proof") + return + } + + defer closer.Close() + if len(data) < 24 { + err = ErrInvalidData + return + } + + difficulty = binary.BigEndian.Uint32(data[:4]) + parallelism = binary.BigEndian.Uint32(data[4:8]) + inputLen := binary.BigEndian.Uint64(data[8:16]) + + // Verify length of remaining data is at least equal to the input and next + // length prefix + if uint64(len(data[16:])) < inputLen+8 { + err = ErrInvalidData + return + } + + input = make([]byte, inputLen) + copy(input[:], data[16:16+inputLen]) + + outputLen := binary.BigEndian.Uint64(data[16+inputLen : 16+inputLen+8]) + + // Verify length + if uint64(len(data[16+inputLen+8:])) < outputLen { + err = ErrInvalidData + return + } + + output = make([]byte, outputLen) + copy(output[:], data[16+inputLen+8:]) + return difficulty, parallelism, input, output, nil +} + +func (p *PebbleDataProofStore) GetTotalReward( + peerId []byte, +) (*big.Int, error) { + reward := big.NewInt(0) + prev, closer, err := p.db.Get(dataTimeProofLatestKey(peerId)) + if err != nil { + if errors.Is(err, pebble.ErrNotFound) { + return big.NewInt(0), nil + } + + return nil, errors.Wrap(err, "get total difficulty sum") + } + + if len(prev) != 0 { + reward.SetBytes(prev[4:]) + + if err = closer.Close(); err != nil { + return nil, errors.Wrap(err, "get total difficulty sum") + } + } + + return reward, nil +} + +func (p *PebbleDataProofStore) PutDataTimeProof( + txn Transaction, + parallelism uint32, + peerId []byte, + increment uint32, + input []byte, + output []byte, +) error { + // Now, for the assumptions. + // Rewards are calculated based off of a current average rate of growth such + // that we continue at the rate we have been, for the course of the next month + // and carry it to now it such that the greatest advantage gleaned is from + // upgrading on time, akin to a "difficulty bomb" in reverse, but locally + // calculated. + difficulty := 200000 - (increment / 4) + + // Basis split on the estimated shard level for growth rate (in terms of + // units): 240 (QUIL) * 8000000000 (conversion factor) / 1600000 (shards) + // = 1200000 units per reward interval per core + pomwBasis := big.NewInt(1200000) + reward := new(big.Int) + reward = reward.Mul(pomwBasis, big.NewInt(int64(parallelism))) + + priorSum := big.NewInt(0) + prev, closer, err := p.db.Get(dataTimeProofLatestKey(peerId)) + if err != nil && (!errors.Is(err, pebble.ErrNotFound) || increment != 0) { + return errors.Wrap(err, "put data time proof") + } + + if len(prev) != 0 { + priorSum.SetBytes(prev[4:]) + prevIncrement := binary.BigEndian.Uint32(prev[:4]) + + if err = closer.Close(); err != nil { + return errors.Wrap(err, "put data time proof") + } + + if prevIncrement != increment-1 { + return errors.Wrap(errors.New("invalid increment"), "put data time proof") + } + } + + data := []byte{} + data = binary.BigEndian.AppendUint32(data, difficulty) + data = binary.BigEndian.AppendUint32(data, parallelism) + data = binary.BigEndian.AppendUint64(data, uint64(len(input))) + data = append(data, input...) + data = binary.BigEndian.AppendUint64(data, uint64(len(output))) + data = append(data, output...) + err = txn.Set(dataTimeProofKey(peerId, increment), data) + if err != nil { + return errors.Wrap(err, "put data time proof") + } + + latest := []byte{} + latest = binary.BigEndian.AppendUint32(latest, increment) + + priorSum.Add(priorSum, reward) + latest = append(latest, priorSum.FillBytes(make([]byte, 32))...) + + if err = txn.Set(dataTimeProofLatestKey(peerId), latest); err != nil { + return errors.Wrap(err, "put data time proof") + } + + return nil +} + +func (p *PebbleDataProofStore) GetLatestDataTimeProof(peerId []byte) ( + increment uint32, + parallelism uint32, + output []byte, + err error, +) { + prev, closer, err := p.db.Get(dataTimeProofLatestKey(peerId)) + if err != nil { + if errors.Is(err, pebble.ErrNotFound) { + return 0, 0, nil, ErrNotFound + } + + return 0, 0, nil, errors.Wrap(err, "get latest data time proof") + } + + if len(prev) < 4 { + return 0, 0, nil, ErrInvalidData + } + + increment = binary.BigEndian.Uint32(prev[:4]) + if err = closer.Close(); err != nil { + return 0, 0, nil, errors.Wrap(err, "get latest data time proof") + } + + _, parallelism, _, output, err = p.GetDataTimeProof(peerId, increment) + + return increment, parallelism, output, err +}