From 9a099009e16ffba32db4011987076743f8476b35 Mon Sep 17 00:00:00 2001 From: Cassandra Heart Date: Mon, 21 Oct 2024 22:32:08 -0500 Subject: [PATCH] -b4 --- node/config/config.go | 2 +- node/config/version.go | 2 +- node/consensus/data/consensus_frames.go | 23 +- .../data/data_clock_consensus_engine.go | 5 +- node/consensus/data/message_handler.go | 22 +- node/consensus/data/peer_messaging.go | 409 ++++++++++++++ .../data/pre_midnight_proof_worker.go | 123 ++-- .../data}/token_handle_mint_test.go | 228 ++++++-- node/consensus/master/broadcast_messaging.go | 5 - .../master/master_clock_consensus_engine.go | 2 +- node/consensus/time/data_time_reel.go | 10 +- node/consensus/time/master_time_reel.go | 11 +- .../token/application/token_application.go | 30 +- .../application/token_handle_announce.go | 19 +- .../token/application/token_handle_merge.go | 25 +- .../token/application/token_handle_mint.go | 235 ++------ .../token/application/token_handle_split.go | 30 +- .../application/token_handle_transfer.go | 19 +- .../token/token_execution_engine.go | 96 +--- .../intrinsics/token/token_genesis.go | 4 - node/protobufs/data.pb.go | 533 ++++++++++++------ node/protobufs/data.pb.gw.go | 170 ++++++ node/protobufs/data.proto | 12 + node/protobufs/data_grpc.pb.go | 74 +++ node/store/clock.go | 18 - node/store/coin.go | 202 ++++--- 26 files changed, 1565 insertions(+), 744 deletions(-) rename node/{execution/intrinsics/token/application => consensus/data}/token_handle_mint_test.go (93%) diff --git a/node/config/config.go b/node/config/config.go index 619df91..706ea09 100644 --- a/node/config/config.go +++ b/node/config/config.go @@ -135,7 +135,7 @@ var unlock *SignedGenesisUnlock func DownloadAndVerifyGenesis(network uint) (*SignedGenesisUnlock, error) { if network != 0 { unlock = &SignedGenesisUnlock{ - GenesisSeedHex: "726573697374206d7563682c206f626579206c6974746c657c000000000000000000000001", + GenesisSeedHex: "726573697374206d7563682c206f626579206c6974746c657c000000000000000000000002", Beacon: []byte{ 0x58, 0xef, 0xd9, 0x7e, 0xdd, 0x0e, 0xb6, 0x2f, 0x51, 0xc7, 0x5d, 0x00, 0x29, 0x12, 0x45, 0x49, diff --git a/node/config/version.go b/node/config/version.go index f00972f..f561849 100644 --- a/node/config/version.go +++ b/node/config/version.go @@ -40,5 +40,5 @@ func GetPatchNumber() byte { } func GetRCNumber() byte { - return 0x03 + return 0x04 } diff --git a/node/consensus/data/consensus_frames.go b/node/consensus/data/consensus_frames.go index 969145d..ed931cd 100644 --- a/node/consensus/data/consensus_frames.go +++ b/node/consensus/data/consensus_frames.go @@ -23,6 +23,7 @@ func (e *DataClockConsensusEngine) prove( e.stagedTransactionsMx.Lock() executionOutput := &protobufs.IntrinsicExecutionOutput{} app, err := application.MaterializeApplicationFromFrame( + e.provingKey, previousFrame, e.frameProverTries, e.coinStore, @@ -263,6 +264,23 @@ func (e *DataClockConsensusEngine) sync( return latest, nil } + if response.ClockFrame == nil || + response.ClockFrame.FrameNumber != latest.FrameNumber+1 || + response.ClockFrame.Timestamp < latest.Timestamp { + e.logger.Debug("received invalid response from peer") + e.peerMapMx.Lock() + if _, ok := e.peerMap[string(peerId)]; ok { + e.uncooperativePeersMap[string(peerId)] = e.peerMap[string(peerId)] + e.uncooperativePeersMap[string(peerId)].timestamp = time.Now().UnixMilli() + delete(e.peerMap, string(peerId)) + } + e.peerMapMx.Unlock() + if err := cc.Close(); err != nil { + e.logger.Error("error while closing connection", zap.Error(err)) + } + return latest, nil + } + e.logger.Info( "received new leading frame", zap.Uint64("frame_number", response.ClockFrame.FrameNumber), @@ -286,7 +304,7 @@ func (e *DataClockConsensusEngine) sync( return nil, errors.Wrap(err, "sync") } - e.dataTimeReel.Insert(response.ClockFrame, false) + e.dataTimeReel.Insert(response.ClockFrame, true) latest = response.ClockFrame if latest.FrameNumber >= maxFrame { @@ -316,6 +334,9 @@ func (e *DataClockConsensusEngine) collect( e.logger.Info("no peers available for sync, waiting") time.Sleep(5 * time.Second) } else if maxFrame > latest.FrameNumber { + if maxFrame-latest.FrameNumber > 100 { + maxFrame = latest.FrameNumber + 100 + } latest, err = e.sync(latest, maxFrame, peerId) if err == nil { break diff --git a/node/consensus/data/data_clock_consensus_engine.go b/node/consensus/data/data_clock_consensus_engine.go index f79ea6a..ab62a5d 100644 --- a/node/consensus/data/data_clock_consensus_engine.go +++ b/node/consensus/data/data_clock_consensus_engine.go @@ -80,6 +80,8 @@ type DataClockConsensusEngine struct { lastFrameReceivedAt time.Time latestFrameReceived uint64 frameProverTries []*tries.RollingFrecencyCritbitTrie + preMidnightMintMx sync.Mutex + preMidnightMint map[string]struct{} frameProverTriesMx sync.RWMutex dependencyMap map[string]*anypb.Any pendingCommits chan *anypb.Any @@ -220,7 +222,7 @@ func NewDataClockConsensusEngine( difficulty := engineConfig.Difficulty if difficulty == 0 { - difficulty = 200000 + difficulty = 100000 } e := &DataClockConsensusEngine{ @@ -258,6 +260,7 @@ func NewDataClockConsensusEngine( peerSeniority: newFromMap(peerSeniority), messageProcessorCh: make(chan *pb.Message), engineConfig: engineConfig, + preMidnightMint: map[string]struct{}{}, } logger.Info("constructing consensus engine") diff --git a/node/consensus/data/message_handler.go b/node/consensus/data/message_handler.go index d5b930c..b82e5ff 100644 --- a/node/consensus/data/message_handler.go +++ b/node/consensus/data/message_handler.go @@ -494,10 +494,12 @@ func (e *DataClockConsensusEngine) handleTokenRequest( case *protobufs.TokenRequest_Mint: checkmint: for i := range t.Mint.Proofs { - for j := range r.Mint.Proofs { - if bytes.Equal(t.Mint.Proofs[i], r.Mint.Proofs[j]) { - found = true - break checkmint + if len(r.Mint.Proofs) < 2 { + for j := range r.Mint.Proofs { + if bytes.Equal(t.Mint.Proofs[i], r.Mint.Proofs[j]) { + found = true + break checkmint + } } } } @@ -515,3 +517,15 @@ func (e *DataClockConsensusEngine) handleTokenRequest( } return nil } + +func nearestApplicablePowerOfTwo(number uint64) uint64 { + power := uint64(128) + if number > 2048 { + power = 65536 + } else if number > 1024 { + power = 2048 + } else if number > 128 { + power = 1024 + } + return power +} diff --git a/node/consensus/data/peer_messaging.go b/node/consensus/data/peer_messaging.go index ae81c86..7dfedb3 100644 --- a/node/consensus/data/peer_messaging.go +++ b/node/consensus/data/peer_messaging.go @@ -1,13 +1,22 @@ package data import ( + "bytes" "context" + "encoding/binary" + "math/big" "time" + "github.com/iden3/go-iden3-crypto/poseidon" + pcrypto "github.com/libp2p/go-libp2p/core/crypto" + "github.com/libp2p/go-libp2p/core/peer" "github.com/mr-tron/base58" "github.com/pkg/errors" "go.uber.org/zap" + "golang.org/x/crypto/sha3" "google.golang.org/grpc" + "source.quilibrium.com/quilibrium/monorepo/node/crypto" + "source.quilibrium.com/quilibrium/monorepo/node/execution/intrinsics/token/application" "source.quilibrium.com/quilibrium/monorepo/node/p2p" "source.quilibrium.com/quilibrium/monorepo/node/protobufs" ) @@ -85,6 +94,406 @@ func (e *DataClockConsensusEngine) GetCompressedSyncFrames( return nil } +func (e *DataClockConsensusEngine) HandlePreMidnightMint( + ctx context.Context, + t *protobufs.MintCoinRequest, +) (*protobufs.PreMidnightMintResponse, error) { + addr, err := e.handleMint(t) + if err != nil { + return nil, err + } + + return &protobufs.PreMidnightMintResponse{Address: addr}, nil +} + +func (e *DataClockConsensusEngine) GetPreMidnightMintStatus( + ctx context.Context, + t *protobufs.PreMidnightMintStatusRequest, +) (*protobufs.PreMidnightMintResponse, error) { + if !e.GetFrameProverTries()[0].Contains(e.provingKeyAddress) { + return nil, errors.Wrap( + errors.New("wrong destination"), + "get pre midnight mint status", + ) + } + + if len(t.Owner) != 32 { + return nil, errors.Wrap( + errors.New("invalid data"), + "get pre midnight mint status", + ) + } + fr, pre, err := e.coinStore.GetPreCoinProofsForOwner(t.Owner) + if err != nil { + return nil, errors.Wrap( + errors.New("invalid data"), + "get pre midnight mint status", + ) + } + + if len(fr) == 0 { + return &protobufs.PreMidnightMintResponse{ + Address: make([]byte, 32), + Increment: 0, + }, nil + } else { + for i, pr := range pre { + if fr[i] == 0 { + addr, err := GetAddressOfPreCoinProof(pr) + if err != nil { + if err != nil { + return nil, errors.Wrap( + errors.New("invalid data"), + "get pre midnight mint status", + ) + } + } + + return &protobufs.PreMidnightMintResponse{ + Address: addr, + Increment: pr.Difficulty, + }, nil + } + } + } + + return &protobufs.PreMidnightMintResponse{ + Address: make([]byte, 32), + Increment: 0, + }, nil +} + +func (e *DataClockConsensusEngine) handleMint( + t *protobufs.MintCoinRequest, +) ([]byte, error) { + if !e.GetFrameProverTries()[0].Contains(e.provingKeyAddress) { + return nil, errors.Wrap(errors.New("wrong destination"), "handle mint") + } + + returnAddr := []byte{} + e.preMidnightMintMx.Lock() + if _, active := e.preMidnightMint[string( + t.Signature.PublicKey.KeyValue, + )]; active { + return nil, errors.Wrap(errors.New("busy"), "handle mint") + } + e.preMidnightMint[string( + t.Signature.PublicKey.KeyValue, + )] = struct{}{} + e.preMidnightMintMx.Unlock() + + defer func() { + e.preMidnightMintMx.Lock() + delete(e.preMidnightMint, string( + t.Signature.PublicKey.KeyValue, + )) + e.preMidnightMintMx.Unlock() + }() + + head, err := e.dataTimeReel.Head() + if err != nil { + return nil, errors.Wrap(errors.New("busy"), "handle mint") + } + + if t == nil || t.Proofs == nil { + return nil, errors.Wrap(application.ErrInvalidStateTransition, "handle mint") + } + + payload := []byte("mint") + for _, p := range t.Proofs { + payload = append(payload, p...) + } + if err := t.Signature.Verify(payload); err != nil { + return nil, errors.Wrap(application.ErrInvalidStateTransition, "handle mint") + } + pk, err := pcrypto.UnmarshalEd448PublicKey( + t.Signature.PublicKey.KeyValue, + ) + if err != nil { + return nil, errors.Wrap(application.ErrInvalidStateTransition, "handle mint") + } + + peerId, err := peer.IDFromPublicKey(pk) + if err != nil { + return nil, errors.Wrap(application.ErrInvalidStateTransition, "handle mint") + } + + altAddr, err := poseidon.HashBytes([]byte(peerId)) + if err != nil { + return nil, errors.Wrap(application.ErrInvalidStateTransition, "handle mint") + } + + if len(t.Proofs) >= 3 && + len(t.Proofs) < 104 && + bytes.Equal( + t.Proofs[0], + []byte("pre-dusk"), + ) && (!bytes.Equal(t.Proofs[1], make([]byte, 32)) || + head.FrameNumber < 60480) && e.GetFrameProverTries()[0].Contains( + e.provingKeyAddress, + ) { + deletes := []*protobufs.TokenOutput{} + if !bytes.Equal(t.Proofs[1], make([]byte, 32)) { + pre, err := e.coinStore.GetPreCoinProofByAddress(t.Proofs[1]) + if err != nil { + return nil, errors.Wrap( + application.ErrInvalidStateTransition, + "handle mint", + ) + } + if !bytes.Equal( + pre.Owner.GetImplicitAccount().Address, + altAddr.FillBytes(make([]byte, 32)), + ) { + return nil, errors.Wrap(application.ErrInvalidStateTransition, "handle mint") + } + if pre.Difficulty == 0 { + return nil, errors.Wrap(application.ErrInvalidStateTransition, "handle mint") + } + deletes = append(deletes, &protobufs.TokenOutput{ + Output: &protobufs.TokenOutput_DeletedProof{ + DeletedProof: pre, + }, + }) + } + + var previousIncrement = uint32(0xFFFFFFFF) + reward := new(big.Int) + var index uint32 + var indexProof []byte + var parallelism uint32 + var kzgCommitment []byte + var kzgProof []byte + for pi, data := range t.Proofs[2:] { + if len(data) < 28 { + return nil, errors.Wrap(application.ErrInvalidStateTransition, "handle mint") + } + + increment := binary.BigEndian.Uint32(data[:4]) + parallelism = binary.BigEndian.Uint32(data[4:8]) + inputLen := binary.BigEndian.Uint64(data[8:16]) + + if len(deletes) != 0 && pi == 0 { + if deletes[0].GetDeletedProof().Difficulty-1 != increment { + return nil, errors.Wrap( + application.ErrInvalidStateTransition, + "handle mint", + ) + } + } else if pi == 0 && bytes.Equal(t.Proofs[1], make([]byte, 32)) { + frames, _, err := e.coinStore.GetPreCoinProofsForOwner( + altAddr.FillBytes(make([]byte, 32)), + ) + if err != nil || len(frames) != 0 { + return nil, errors.Wrap( + application.ErrInvalidStateTransition, + "handle mint", + ) + } + } else if pi != 0 { + if increment != previousIncrement-1 { + return nil, errors.Wrap( + application.ErrInvalidStateTransition, + "handle mint", + ) + } + } + previousIncrement = increment + + if uint64(len(data[16:])) < inputLen+8 { + return nil, errors.Wrap(application.ErrInvalidStateTransition, "handle mint") + } + + input := make([]byte, inputLen) + copy(input[:], data[16:16+inputLen]) + + outputLen := binary.BigEndian.Uint64(data[16+inputLen : 16+inputLen+8]) + + if uint64(len(data[16+inputLen+8:])) < outputLen { + return nil, errors.Wrap(application.ErrInvalidStateTransition, "handle mint") + } + + output := make([]byte, outputLen) + copy(output[:], data[16+inputLen+8:]) + dataProver := crypto.NewKZGInclusionProver(e.logger) + wesoProver := crypto.NewWesolowskiFrameProver(e.logger) + index = binary.BigEndian.Uint32(output[:4]) + indexProof = output[4:520] + kzgCommitment = output[520:594] + kzgProof = output[594:668] + ip := sha3.Sum512(indexProof) + + v, err := dataProver.VerifyRaw( + ip[:], + kzgCommitment, + int(index), + kzgProof, + nearestApplicablePowerOfTwo(uint64(parallelism)), + ) + if err != nil { + return nil, errors.Wrap(application.ErrInvalidStateTransition, "handle mint") + } + + if !v { + return nil, errors.Wrap(application.ErrInvalidStateTransition, "handle mint") + } + + wp := []byte{} + wp = append(wp, peerId...) + wp = append(wp, input...) + v = wesoProver.VerifyPreDuskChallengeProof( + wp, + increment, + index, + indexProof, + ) + if !v { + return nil, errors.Wrap(application.ErrInvalidStateTransition, "handle mint") + } + + pomwBasis := big.NewInt(1200000) + additional := new(big.Int).Mul(pomwBasis, big.NewInt(int64(parallelism))) + reward.Add( + reward, + additional, + ) + } + + if len(deletes) != 0 { + reward.Add( + reward, + new(big.Int).SetBytes(deletes[0].GetDeletedProof().Amount), + ) + } + + if previousIncrement == uint32(0xffffffff) { + return nil, errors.Wrap(application.ErrInvalidStateTransition, "handle mint") + } + + txn, err := e.coinStore.NewTransaction() + if err != nil { + return nil, errors.Wrap(err, "handle mint") + } + if previousIncrement != 0 { + add := &protobufs.PreCoinProof{ + Amount: reward.FillBytes(make([]byte, 32)), + Index: index, + IndexProof: indexProof, + Commitment: kzgCommitment, + Proof: append(append([]byte{}, kzgProof...), indexProof...), + Parallelism: parallelism, + Difficulty: previousIncrement, + Owner: &protobufs.AccountRef{ + Account: &protobufs.AccountRef_ImplicitAccount{ + ImplicitAccount: &protobufs.ImplicitAccount{ + ImplicitType: 0, + Address: altAddr.FillBytes(make([]byte, 32)), + }, + }, + }, + } + proofAddr, err := GetAddressOfPreCoinProof(add) + if err != nil { + txn.Abort() + return nil, errors.Wrap(err, "handle mint") + } + returnAddr = proofAddr + err = e.coinStore.PutPreCoinProof( + txn, + head.FrameNumber, + proofAddr, + add, + ) + if err != nil { + txn.Abort() + return nil, errors.Wrap(err, "handle mint") + } + } else { + proof := &protobufs.PreCoinProof{ + Amount: reward.FillBytes(make([]byte, 32)), + Index: index, + IndexProof: indexProof, + Commitment: kzgCommitment, + Proof: append(append([]byte{}, kzgProof...), indexProof...), + Parallelism: parallelism, + Difficulty: previousIncrement, + Owner: &protobufs.AccountRef{ + Account: &protobufs.AccountRef_ImplicitAccount{ + ImplicitAccount: &protobufs.ImplicitAccount{ + ImplicitType: 0, + Address: altAddr.FillBytes(make([]byte, 32)), + }, + }, + }, + } + proofAddr, err := GetAddressOfPreCoinProof(proof) + if err != nil { + txn.Abort() + return nil, errors.Wrap(err, "handle mint") + } + returnAddr = proofAddr + err = e.coinStore.PutPreCoinProof( + txn, + head.FrameNumber, + proofAddr, + proof, + ) + if err != nil { + txn.Abort() + return nil, errors.Wrap(err, "handle mint") + } + + mint := []byte{} + mint = append(mint, reward.FillBytes(make([]byte, 32))...) + mint = append(mint, altAddr.FillBytes(make([]byte, 32))...) + sig := []byte("mint") + sig = append(sig, mint...) + out, err := e.pubSub.SignMessage(sig) + if err != nil { + txn.Abort() + return nil, errors.Wrap(err, "handle mint") + } + e.stagedTransactionsMx.Lock() + if e.stagedTransactions == nil { + e.stagedTransactions = &protobufs.TokenRequests{} + } + e.stagedTransactions.Requests = append(e.stagedTransactions.Requests, + &protobufs.TokenRequest{ + Request: &protobufs.TokenRequest_Mint{ + Mint: &protobufs.MintCoinRequest{ + Proofs: [][]byte{mint}, + Signature: &protobufs.Ed448Signature{ + Signature: out, + PublicKey: &protobufs.Ed448PublicKey{ + KeyValue: e.provingKeyBytes, + }, + }, + }, + }, + }) + e.stagedTransactionsMx.Unlock() + } + + if len(deletes) == 1 { + a, err := GetAddressOfPreCoinProof(deletes[0].GetDeletedProof()) + if err != nil { + txn.Abort() + return nil, errors.Wrap(err, "handle mint") + } + e.coinStore.DeletePreCoinProof( + txn, + a, + deletes[0].GetDeletedProof(), + ) + } + if err := txn.Commit(); err != nil { + txn.Abort() + return nil, errors.Wrap(err, "handle mint") + } + } + return returnAddr, nil +} + type svr struct { protobufs.UnimplementedDataServiceServer svrChan chan protobufs.DataService_GetPublicChannelServer diff --git a/node/consensus/data/pre_midnight_proof_worker.go b/node/consensus/data/pre_midnight_proof_worker.go index 308b0fe..48f3d43 100644 --- a/node/consensus/data/pre_midnight_proof_worker.go +++ b/node/consensus/data/pre_midnight_proof_worker.go @@ -1,13 +1,18 @@ package data import ( + "bytes" + "context" "encoding/binary" "time" "github.com/iden3/go-iden3-crypto/poseidon" + "github.com/libp2p/go-libp2p/core/crypto" "github.com/libp2p/go-libp2p/core/peer" "github.com/pkg/errors" "go.uber.org/zap" + "google.golang.org/grpc" + "source.quilibrium.com/quilibrium/monorepo/node/config" "source.quilibrium.com/quilibrium/monorepo/node/consensus" "source.quilibrium.com/quilibrium/monorepo/node/execution/intrinsics/token/application" "source.quilibrium.com/quilibrium/monorepo/node/protobufs" @@ -45,6 +50,18 @@ func (e *DataClockConsensusEngine) runPreMidnightProofWorker() { addr := addrBI.FillBytes(make([]byte, 32)) + genesis := config.GetGenesis() + pub, err := crypto.UnmarshalEd448PublicKey(genesis.Beacon) + if err != nil { + panic(err) + } + + peerId, err := peer.IDFromPublicKey(pub) + if err != nil { + panic(errors.Wrap(err, "error getting peer id")) + } + +outer: for { frame, err := e.dataTimeReel.Head() tries := e.GetFrameProverTries() @@ -64,39 +81,51 @@ func (e *DataClockConsensusEngine) runPreMidnightProofWorker() { continue } - frames, prfs, err := e.coinStore.GetPreCoinProofsForOwner(addr) - if err != nil && !errors.Is(err, store.ErrNotFound) { - panic(err) + cc, err := e.pubSub.GetDirectChannel([]byte(peerId), "") + if err != nil { + e.logger.Info( + "could not establish direct channel, waiting...", + zap.Error(err), + ) + time.Sleep(10 * time.Second) + continue + } + defer cc.Close() + + client := protobufs.NewDataServiceClient(cc) + + status, err := client.GetPreMidnightMintStatus( + context.Background(), + &protobufs.PreMidnightMintStatusRequest{ + Owner: addr, + }, + grpc.MaxCallRecvMsgSize(600*1024*1024), + ) + if err != nil { + e.logger.Error( + "got error response, waiting...", + zap.Error(err), + ) + time.Sleep(10 * time.Second) + continue } - resume := make([]byte, 32) - - foundPri := -1 - for pri, pr := range prfs { - if pr.IndexProof != nil { - resume, err = GetAddressOfPreCoinProof(pr) - if err != nil { - panic(err) - } - increment = pr.Difficulty - 1 - foundPri = pri - break - } - } - - if foundPri != -1 { - if frame.FrameNumber == frames[foundPri] { - e.logger.Info("waiting for a new frame to appear") - time.Sleep(10 * time.Second) - continue - } - } + resume := status.Address proofs := [][]byte{ []byte("pre-dusk"), resume, } + if status.Increment != 0 { + increment = status.Increment - 1 + } + + if status.Increment == 0 && !bytes.Equal(status.Address, make([]byte, 32)) { + e.logger.Info("already completed pre-midnight mint") + return + } + batchCount := 0 // the cast is important, it underflows without: for i := int(increment); i >= 0; i-- { @@ -121,10 +150,11 @@ func (e *DataClockConsensusEngine) runPreMidnightProofWorker() { zap.String("peer_id", peer.ID(e.pubSub.GetPeerID()).String()), zap.Int("increment", i), ) + return } batchCount++ - if batchCount == 10 || i == 0 { + if batchCount == 100 || i == 0 { e.logger.Info("publishing proof batch", zap.Int("increment", i)) payload := []byte("mint") @@ -136,36 +166,31 @@ func (e *DataClockConsensusEngine) runPreMidnightProofWorker() { panic(err) } - e.publishMessage( - e.filter, - &protobufs.TokenRequest{ - Request: &protobufs.TokenRequest_Mint{ - Mint: &protobufs.MintCoinRequest{ - Proofs: proofs, - Signature: &protobufs.Ed448Signature{ - PublicKey: &protobufs.Ed448PublicKey{ - KeyValue: e.pubSub.GetPublicKey(), - }, - Signature: sig, - }, + resp, err := client.HandlePreMidnightMint( + context.Background(), + &protobufs.MintCoinRequest{ + Proofs: proofs, + Signature: &protobufs.Ed448Signature{ + PublicKey: &protobufs.Ed448PublicKey{ + KeyValue: e.pubSub.GetPublicKey(), }, + Signature: sig, }, }, ) - time.Sleep(20 * time.Second) - - _, prfs, err := e.coinStore.GetPreCoinProofsForOwner(addr) if err != nil { - for _, pr := range prfs { - if pr.IndexProof != nil { - resume, err = GetAddressOfPreCoinProof(pr) - if err != nil { - panic(err) - } - } - } + e.logger.Error( + "got error response, waiting...", + zap.Error(err), + ) + time.Sleep(10 * time.Second) + continue outer } + + time.Sleep(10 * time.Second) + + resume = resp.Address batchCount = 0 proofs = [][]byte{ []byte("pre-dusk"), diff --git a/node/execution/intrinsics/token/application/token_handle_mint_test.go b/node/consensus/data/token_handle_mint_test.go similarity index 93% rename from node/execution/intrinsics/token/application/token_handle_mint_test.go rename to node/consensus/data/token_handle_mint_test.go index 369473c..f439103 100644 --- a/node/execution/intrinsics/token/application/token_handle_mint_test.go +++ b/node/consensus/data/token_handle_mint_test.go @@ -1,20 +1,76 @@ -package application +package data import ( + "context" + gocrypto "crypto" + "crypto/rand" "encoding/binary" "encoding/hex" "fmt" "slices" "testing" + "time" + "github.com/cloudflare/circl/sign/ed448" "github.com/iden3/go-iden3-crypto/poseidon" "github.com/libp2p/go-libp2p/core/crypto" + "github.com/libp2p/go-libp2p/core/peer" + "github.com/multiformats/go-multiaddr" "github.com/stretchr/testify/assert" "go.uber.org/zap" + "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/anypb" + "source.quilibrium.com/quilibrium/monorepo/go-libp2p-blossomsub/pb" + "source.quilibrium.com/quilibrium/monorepo/node/consensus" + qtime "source.quilibrium.com/quilibrium/monorepo/node/consensus/time" + qcrypto "source.quilibrium.com/quilibrium/monorepo/node/crypto" + "source.quilibrium.com/quilibrium/monorepo/node/execution" + "source.quilibrium.com/quilibrium/monorepo/node/execution/intrinsics/token/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 pubsub struct { + privkey ed448.PrivateKey + pubkey []byte +} + +func (pubsub) GetBitmaskPeers() map[string][]string { return nil } +func (pubsub) Publish(address []byte, data []byte) error { return nil } +func (pubsub) PublishToBitmask(bitmask []byte, data []byte) error { return nil } +func (pubsub) Subscribe(bitmask []byte, handler func(message *pb.Message) error) error { return nil } +func (pubsub) Unsubscribe(bitmask []byte, raw bool) {} +func (pubsub) GetPeerID() []byte { return nil } +func (pubsub) GetPeerstoreCount() int { return 0 } +func (pubsub) GetNetworkPeersCount() int { return 0 } +func (pubsub) GetRandomPeer(bitmask []byte) ([]byte, error) { return nil, nil } +func (pubsub) GetMultiaddrOfPeerStream(ctx context.Context, peerId []byte) <-chan multiaddr.Multiaddr { + return nil +} +func (pubsub) GetMultiaddrOfPeer(peerId []byte) string { return "" } +func (pubsub) StartDirectChannelListener( + key []byte, + purpose string, + server *grpc.Server, +) error { + return nil +} +func (pubsub) GetDirectChannel(peerId []byte, purpose string) (*grpc.ClientConn, error) { + return nil, nil +} +func (pubsub) GetNetworkInfo() *protobufs.NetworkInfoResponse { + return nil +} +func (p pubsub) SignMessage(msg []byte) ([]byte, error) { + return p.privkey.Sign(rand.Reader, msg, gocrypto.Hash(0)) +} +func (p pubsub) GetPublicKey() []byte { return p.pubkey } +func (pubsub) GetPeerScore(peerId []byte) int64 { return 0 } +func (pubsub) SetPeerScore(peerId []byte, score int64) {} + type outputs struct { difficulty uint32 parallelism uint32 @@ -24,12 +80,76 @@ type outputs struct { func TestHandlePreMidnightMint(t *testing.T) { log, _ := zap.NewDevelopment() - app := &TokenApplication{ + bpub, bprivKey, _ := ed448.GenerateKey(rand.Reader) + app := &application.TokenApplication{ + Beacon: bpub, CoinStore: store.NewPebbleCoinStore(store.NewInMemKVDB(), log), Logger: log, Difficulty: 200000, + Tries: []*tries.RollingFrecencyCritbitTrie{ + &tries.RollingFrecencyCritbitTrie{}, + }, } + clockstore := store.NewPebbleClockStore(store.NewInMemKVDB(), log) + dataproofstore := store.NewPebbleDataProofStore(store.NewInMemKVDB(), log) + keystore := store.NewPebbleKeyStore(store.NewInMemKVDB(), log) + d := &DataClockConsensusEngine{ + difficulty: 200000, + logger: log, + state: consensus.EngineStateStopped, + clockStore: clockstore, + coinStore: app.CoinStore, + dataProofStore: dataproofstore, + keyStore: keystore, + keyManager: keys.NewInMemoryKeyManager(), + pubSub: nil, + frameChan: make(chan *protobufs.ClockFrame), + executionEngines: map[string]execution.ExecutionEngine{}, + dependencyMap: make(map[string]*anypb.Any), + parentSelector: []byte{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + currentReceivingSyncPeers: 0, + lastFrameReceivedAt: time.Time{}, + frameProverTries: []*tries.RollingFrecencyCritbitTrie{}, + inclusionProver: qcrypto.NewKZGInclusionProver(log), + syncingStatus: SyncStatusNotSyncing, + peerMap: map[string]*peerInfo{}, + uncooperativePeersMap: map[string]*peerInfo{}, + minimumPeersRequired: 0, + report: nil, + frameProver: qcrypto.NewWesolowskiFrameProver(log), + masterTimeReel: nil, + dataTimeReel: &qtime.DataTimeReel{}, + peerInfoManager: nil, + peerSeniority: newFromMap(map[string]uint64{}), + messageProcessorCh: make(chan *pb.Message), + engineConfig: nil, + preMidnightMint: map[string]struct{}{}, + } + + d.dataTimeReel.SetHead(&protobufs.ClockFrame{ + FrameNumber: 0, + }) + + d.pubSub = pubsub{ + privkey: bprivKey, + pubkey: bpub, + } + d.filter = p2p.GetBloomFilter(application.TOKEN_ADDRESS, 256, 3) + d.input = nil + d.provingKey = bprivKey + d.provingKeyType = keys.KeyTypeEd448 + d.provingKeyBytes = bpub + d.frameProverTries = app.Tries + baddr, _ := poseidon.HashBytes(bpub) + d.provingKeyAddress = baddr.FillBytes(make([]byte, 32)) + + app.Tries[0].Add(baddr.FillBytes(make([]byte, 32)), 0) resume := make([]byte, 32) proofs := [][]byte{ []byte("pre-dusk"), @@ -429,7 +549,12 @@ func TestHandlePreMidnightMint(t *testing.T) { t.FailNow() } - addrBI, err := poseidon.HashBytes(pubkey) + peerId, err := peer.IDFromPublicKey(pub) + if err != nil { + t.FailNow() + } + + addrBI, err := poseidon.HashBytes([]byte(peerId)) if err != nil { t.FailNow() } @@ -438,7 +563,6 @@ func TestHandlePreMidnightMint(t *testing.T) { batchCount := 0 for i := len(outputs) - 1; i >= 0; i-- { - fmt.Println(i) parallelism, inputhex, outputhex := outputs[i].parallelism, outputs[i].input, outputs[i].output input, _ := hex.DecodeString(inputhex) output, _ := hex.DecodeString(outputhex) @@ -451,7 +575,6 @@ func TestHandlePreMidnightMint(t *testing.T) { p = append(p, output...) proofs = append(proofs, p) - fmt.Printf("%x\n", p) batchCount++ if batchCount == 10 || i == 0 { @@ -465,7 +588,7 @@ func TestHandlePreMidnightMint(t *testing.T) { panic(err) } - outputs, err := app.handleMint(0, map[string]struct{}{}, + err = d.handleMint( &protobufs.MintCoinRequest{ Proofs: proofs, Signature: &protobufs.Ed448Signature{ @@ -478,37 +601,19 @@ func TestHandlePreMidnightMint(t *testing.T) { ) assert.NoError(t, err) - txn, _ := app.CoinStore.NewTransaction() - for i, o := range outputs { - switch e := o.Output.(type) { - case *protobufs.TokenOutput_Coin: - a, err := GetAddressOfCoin(e.Coin, 1, uint64(i)) - assert.NoError(t, err) - err = app.CoinStore.PutCoin(txn, 1, a, e.Coin) - assert.NoError(t, err) - case *protobufs.TokenOutput_DeletedCoin: - c, err := app.CoinStore.GetCoinByAddress(txn, e.DeletedCoin.Address) - assert.NoError(t, err) - err = app.CoinStore.DeleteCoin(txn, e.DeletedCoin.Address, c) - assert.NoError(t, err) - case *protobufs.TokenOutput_Proof: - a, err := GetAddressOfPreCoinProof(e.Proof) - assert.NoError(t, err) - err = app.CoinStore.PutPreCoinProof(txn, 1, a, e.Proof) - resume = a - assert.NoError(t, err) - case *protobufs.TokenOutput_DeletedProof: - a, err := GetAddressOfPreCoinProof(e.DeletedProof) - assert.NoError(t, err) - c, err := app.CoinStore.GetPreCoinProofByAddress(a) - assert.NoError(t, err) - err = app.CoinStore.DeletePreCoinProof(txn, a, c) + + fmt.Printf("check %x\n", addr) + fr, prfs, err := app.CoinStore.GetPreCoinProofsForOwner(addr) + assert.Len(t, prfs, 1) + assert.Len(t, fr, 1) + for _, prf := range prfs { + if prf.IndexProof != nil { + resume, err = GetAddressOfPreCoinProof(prf) assert.NoError(t, err) } } - err = txn.Commit() assert.NoError(t, err) - assert.NotEqual(t, resume, append(make([]byte, 28), 0x27, 0xe9, 0x49, 0x00)) + assert.NotEqual(t, resume, make([]byte, 32)) batchCount = 0 proofs = [][]byte{ []byte("pre-dusk"), @@ -517,8 +622,39 @@ func TestHandlePreMidnightMint(t *testing.T) { } } + app, _, _, err = app.ApplyTransitions(1, d.stagedTransactions, false) + assert.NoError(t, err) + txn, _ := app.CoinStore.NewTransaction() + for i, o := range app.TokenOutputs.Outputs { + switch e := o.Output.(type) { + case *protobufs.TokenOutput_Coin: + a, err := GetAddressOfCoin(e.Coin, 1, uint64(i)) + assert.NoError(t, err) + err = app.CoinStore.PutCoin(txn, 1, a, e.Coin) + assert.NoError(t, err) + case *protobufs.TokenOutput_DeletedCoin: + c, err := app.CoinStore.GetCoinByAddress(txn, e.DeletedCoin.Address) + assert.NoError(t, err) + err = app.CoinStore.DeleteCoin(txn, e.DeletedCoin.Address, c) + assert.NoError(t, err) + case *protobufs.TokenOutput_Proof: + a, err := GetAddressOfPreCoinProof(e.Proof) + assert.NoError(t, err) + err = app.CoinStore.PutPreCoinProof(txn, 1, a, e.Proof) + assert.NoError(t, err) + case *protobufs.TokenOutput_DeletedProof: + a, err := GetAddressOfPreCoinProof(e.DeletedProof) + assert.NoError(t, err) + c, err := app.CoinStore.GetPreCoinProofByAddress(a) + assert.NoError(t, err) + err = app.CoinStore.DeletePreCoinProof(txn, a, c) + assert.NoError(t, err) + } + } + err = txn.Commit() + _, _, coin, err := app.CoinStore.GetCoinsForOwner(addr) - assert.Equal(t, make([]byte, 32), coin[0].Amount) + assert.Equal(t, append(make([]byte, 28), 0x27, 0xe9, 0x49, 0x00), coin[0].Amount) } func GetAddressOfCoin( @@ -527,7 +663,7 @@ func GetAddressOfCoin( seqno uint64, ) ([]byte, error) { eval := []byte{} - eval = append(eval, TOKEN_ADDRESS...) + eval = append(eval, application.TOKEN_ADDRESS...) eval = binary.BigEndian.AppendUint64(eval, frameNumber) if frameNumber != 0 { eval = binary.BigEndian.AppendUint64(eval, seqno) @@ -543,25 +679,3 @@ func GetAddressOfCoin( return addressBI.FillBytes(make([]byte, 32)), nil } - -func GetAddressOfPreCoinProof( - proof *protobufs.PreCoinProof, -) ([]byte, error) { - eval := []byte{} - eval = append(eval, TOKEN_ADDRESS...) - eval = append(eval, proof.Amount...) - eval = binary.BigEndian.AppendUint32(eval, proof.Index) - eval = append(eval, proof.IndexProof...) - eval = append(eval, proof.Commitment...) - eval = append(eval, proof.Proof...) - eval = binary.BigEndian.AppendUint32(eval, proof.Parallelism) - eval = binary.BigEndian.AppendUint32(eval, proof.Difficulty) - eval = binary.BigEndian.AppendUint32(eval, 0) - eval = append(eval, proof.Owner.GetImplicitAccount().Address...) - addressBI, err := poseidon.HashBytes(eval) - if err != nil { - return nil, err - } - - return addressBI.FillBytes(make([]byte, 32)), nil -} diff --git a/node/consensus/master/broadcast_messaging.go b/node/consensus/master/broadcast_messaging.go index 050180b..e2fe211 100644 --- a/node/consensus/master/broadcast_messaging.go +++ b/node/consensus/master/broadcast_messaging.go @@ -155,11 +155,6 @@ func (e *MasterClockConsensusEngine) publishProof( ) e.masterTimeReel.Insert(frame, false) - - err := e.publishMessage(e.filter, frame) - if err != nil { - return errors.Wrap(err, "publish proof") - } } e.state = consensus.EngineStateCollecting diff --git a/node/consensus/master/master_clock_consensus_engine.go b/node/consensus/master/master_clock_consensus_engine.go index 4eea18d..8550738 100644 --- a/node/consensus/master/master_clock_consensus_engine.go +++ b/node/consensus/master/master_clock_consensus_engine.go @@ -70,7 +70,7 @@ type MasterClockConsensusEngine struct { var _ consensus.ConsensusEngine = (*MasterClockConsensusEngine)(nil) -var MASTER_CLOCK_RATE = uint32(1000000) +var MASTER_CLOCK_RATE = uint32(100000) func NewMasterClockConsensusEngine( engineConfig *config.EngineConfig, diff --git a/node/consensus/time/data_time_reel.go b/node/consensus/time/data_time_reel.go index 6324a11..87acee7 100644 --- a/node/consensus/time/data_time_reel.go +++ b/node/consensus/time/data_time_reel.go @@ -143,6 +143,14 @@ func (d *DataTimeReel) Start() error { return nil } +func (d *DataTimeReel) SetHead(frame *protobufs.ClockFrame) { + if d.running == true { + panic("internal test function should never be called outside of tests") + } + + d.head = frame +} + func (d *DataTimeReel) Head() (*protobufs.ClockFrame, error) { return d.head, nil } @@ -177,7 +185,7 @@ func (d *DataTimeReel) Insert(frame *protobufs.ClockFrame, isSync bool) error { d.storePending(selector, parent, distance, frame) - if !isSync { + if isSync { go func() { d.frames <- &pendingFrame{ selector: selector, diff --git a/node/consensus/time/master_time_reel.go b/node/consensus/time/master_time_reel.go index f916d8c..5243d53 100644 --- a/node/consensus/time/master_time_reel.go +++ b/node/consensus/time/master_time_reel.go @@ -9,8 +9,6 @@ import ( "go.uber.org/zap" "source.quilibrium.com/quilibrium/monorepo/node/config" "source.quilibrium.com/quilibrium/monorepo/node/crypto" - "source.quilibrium.com/quilibrium/monorepo/node/execution/intrinsics/token/application" - "source.quilibrium.com/quilibrium/monorepo/node/p2p" "source.quilibrium.com/quilibrium/monorepo/node/protobufs" "source.quilibrium.com/quilibrium/monorepo/node/store" ) @@ -90,13 +88,10 @@ func (m *MasterTimeReel) Start() error { } rebuildGenesisFrame := false - if genesis != nil && genesis.Difficulty != 1000000 { + if genesis != nil && genesis.Difficulty != 100000 { m.logger.Info("rewinding time reel to genesis") err = m.clockStore.ResetMasterClockFrames(m.filter) - err = m.clockStore.ResetDataClockFrames( - p2p.GetBloomFilter(application.TOKEN_ADDRESS, 256, 3), - ) if err != nil { panic(err) } @@ -156,8 +151,8 @@ func (m *MasterTimeReel) createGenesisFrame() *protobufs.ClockFrame { } difficulty := m.engineConfig.Difficulty - if difficulty != 1000000 { - difficulty = 1000000 + if difficulty != 100000 { + difficulty = 100000 } frame, err := m.frameProver.CreateMasterGenesisFrame( diff --git a/node/execution/intrinsics/token/application/token_application.go b/node/execution/intrinsics/token/application/token_application.go index 164c017..5886de1 100644 --- a/node/execution/intrinsics/token/application/token_application.go +++ b/node/execution/intrinsics/token/application/token_application.go @@ -1,9 +1,12 @@ package application import ( + "crypto" + "github.com/pkg/errors" "go.uber.org/zap" "google.golang.org/protobuf/proto" + "source.quilibrium.com/quilibrium/monorepo/node/config" "source.quilibrium.com/quilibrium/monorepo/node/protobufs" "source.quilibrium.com/quilibrium/monorepo/node/store" "source.quilibrium.com/quilibrium/monorepo/node/tries" @@ -20,6 +23,7 @@ var TOKEN_ADDRESS = []byte{ } type TokenApplication struct { + Beacon []byte TokenOutputs *protobufs.TokenOutputs Tries []*tries.RollingFrecencyCritbitTrie CoinStore store.CoinStore @@ -67,6 +71,7 @@ func GetOutputsFromClockFrame( } func MaterializeApplicationFromFrame( + privKey crypto.Signer, frame *protobufs.ClockFrame, tries []*tries.RollingFrecencyCritbitTrie, store store.CoinStore, @@ -77,7 +82,10 @@ func MaterializeApplicationFromFrame( return nil, errors.Wrap(err, "materialize application from frame") } + genesis := config.GetGenesis() + return &TokenApplication{ + Beacon: genesis.Beacon, TokenOutputs: tokenOutputs, Tries: tries, CoinStore: store, @@ -109,7 +117,7 @@ func (a *TokenApplication) ApplyTransitions( if err != nil { if !skipFailures { return nil, nil, nil, errors.Wrap( - ErrInvalidStateTransition, + err, "apply transitions", ) } @@ -129,7 +137,7 @@ func (a *TokenApplication) ApplyTransitions( if err != nil { if !skipFailures { return nil, nil, nil, errors.Wrap( - ErrInvalidStateTransition, + err, "apply transitions", ) } @@ -149,7 +157,7 @@ func (a *TokenApplication) ApplyTransitions( if err != nil { if !skipFailures { return nil, nil, nil, errors.Wrap( - ErrInvalidStateTransition, + err, "apply transitions", ) } @@ -169,7 +177,7 @@ func (a *TokenApplication) ApplyTransitions( if err != nil { if !skipFailures { return nil, nil, nil, errors.Wrap( - ErrInvalidStateTransition, + err, "apply transitions", ) } @@ -189,7 +197,7 @@ func (a *TokenApplication) ApplyTransitions( if err != nil { if !skipFailures { return nil, nil, nil, errors.Wrap( - ErrInvalidStateTransition, + err, "apply transitions", ) } @@ -212,18 +220,6 @@ func (a *TokenApplication) ApplyTransitions( return a, finalizedTransitions, failedTransitions, nil } -func nearestApplicablePowerOfTwo(number uint64) uint64 { - power := uint64(128) - if number > 2048 { - power = 65536 - } else if number > 1024 { - power = 2048 - } else if number > 128 { - power = 1024 - } - return power -} - func (a *TokenApplication) MaterializeStateFromApplication() ( *protobufs.TokenOutputs, error, diff --git a/node/execution/intrinsics/token/application/token_handle_announce.go b/node/execution/intrinsics/token/application/token_handle_announce.go index 788b94b..e3acfa9 100644 --- a/node/execution/intrinsics/token/application/token_handle_announce.go +++ b/node/execution/intrinsics/token/application/token_handle_announce.go @@ -1,6 +1,7 @@ package application import ( + "github.com/pkg/errors" "source.quilibrium.com/quilibrium/monorepo/node/protobufs" ) @@ -16,38 +17,30 @@ func (a *TokenApplication) handleAnnounce( payload := []byte{} if t == nil || t.PublicKeySignaturesEd448 == nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle announce") } for i, p := range t.PublicKeySignaturesEd448 { if p.PublicKey == nil || p.Signature == nil || p.PublicKey.KeyValue == nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle announce") } if i == 0 { primary = p } else { payload = append(payload, p.PublicKey.KeyValue...) if err := p.Verify(primary.PublicKey.KeyValue); err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle announce") } } } if primary == nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle announce") } if err := primary.Verify(payload); err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle announce") } outputs := []*protobufs.TokenOutput{} - if t.InitialProof != nil { - o, err := a.handleMint(currentFrameNumber, lockMap, t.InitialProof) - if err != nil { - return nil, ErrInvalidStateTransition - } - outputs = append(outputs, o...) - } - return outputs, nil } diff --git a/node/execution/intrinsics/token/application/token_handle_merge.go b/node/execution/intrinsics/token/application/token_handle_merge.go index 41b9501..c4db1bd 100644 --- a/node/execution/intrinsics/token/application/token_handle_merge.go +++ b/node/execution/intrinsics/token/application/token_handle_merge.go @@ -7,6 +7,7 @@ import ( "github.com/iden3/go-iden3-crypto/poseidon" pcrypto "github.com/libp2p/go-libp2p/core/crypto" "github.com/libp2p/go-libp2p/core/peer" + "github.com/pkg/errors" "source.quilibrium.com/quilibrium/monorepo/node/protobufs" ) @@ -20,21 +21,21 @@ func (a *TokenApplication) handleMerge( newIntersection := make([]byte, 1024) payload := []byte("merge") if t == nil || t.Coins == nil || t.Signature == nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle merge") } addresses := [][]byte{} for _, c := range t.Coins { if c.Address == nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle merge") } if _, touched := lockMap[string(c.Address)]; touched { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle merge") } for _, addr := range addresses { if bytes.Equal(addr, c.Address) { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle merge") } } @@ -43,31 +44,31 @@ func (a *TokenApplication) handleMerge( } if t.Signature.PublicKey == nil || t.Signature.Signature == nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle merge") } if err := t.Signature.Verify(payload); err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle merge") } addr, err := poseidon.HashBytes(t.Signature.PublicKey.KeyValue) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle merge") } pk, err := pcrypto.UnmarshalEd448PublicKey( t.Signature.PublicKey.KeyValue, ) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle merge") } peerId, err := peer.IDFromPublicKey(pk) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle merge") } altAddr, err := poseidon.HashBytes([]byte(peerId)) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle merge") } owner := &protobufs.AccountRef{} @@ -75,7 +76,7 @@ func (a *TokenApplication) handleMerge( for _, c := range t.Coins { coin, err := a.CoinStore.GetCoinByAddress(nil, c.Address) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle merge") } if !bytes.Equal( @@ -85,7 +86,7 @@ func (a *TokenApplication) handleMerge( coin.Owner.GetImplicitAccount().Address, altAddr.FillBytes(make([]byte, 32)), ) { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle merge") } newTotal.Add(newTotal, new(big.Int).SetBytes(coin.Amount)) diff --git a/node/execution/intrinsics/token/application/token_handle_mint.go b/node/execution/intrinsics/token/application/token_handle_mint.go index 2023056..8af9ac7 100644 --- a/node/execution/intrinsics/token/application/token_handle_mint.go +++ b/node/execution/intrinsics/token/application/token_handle_mint.go @@ -8,7 +8,7 @@ import ( "github.com/iden3/go-iden3-crypto/poseidon" pcrypto "github.com/libp2p/go-libp2p/core/crypto" "github.com/libp2p/go-libp2p/core/peer" - "golang.org/x/crypto/sha3" + "github.com/pkg/errors" "source.quilibrium.com/quilibrium/monorepo/node/crypto" "source.quilibrium.com/quilibrium/monorepo/node/p2p" "source.quilibrium.com/quilibrium/monorepo/node/protobufs" @@ -20,7 +20,7 @@ func (a *TokenApplication) handleMint( t *protobufs.MintCoinRequest, ) ([]*protobufs.TokenOutput, error) { if t == nil || t.Proofs == nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle mint") } payload := []byte("mint") @@ -28,217 +28,62 @@ func (a *TokenApplication) handleMint( payload = append(payload, p...) } if err := t.Signature.Verify(payload); err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle mint") } pk, err := pcrypto.UnmarshalEd448PublicKey( t.Signature.PublicKey.KeyValue, ) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle mint") } peerId, err := peer.IDFromPublicKey(pk) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle mint") } addr, err := poseidon.HashBytes( t.Signature.PublicKey.KeyValue, ) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle mint") } altAddr, err := poseidon.HashBytes([]byte(peerId)) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle mint") } - if _, touched := lockMap[string(t.Signature.PublicKey.KeyValue)]; touched { - return nil, ErrInvalidStateTransition - } - - if len(t.Proofs) >= 3 && - len(t.Proofs) < 14 && - bytes.Equal( - t.Proofs[0], - []byte("pre-dusk"), - ) && (!bytes.Equal(t.Proofs[1], make([]byte, 32)) || - currentFrameNumber < 60480) { - deletes := []*protobufs.TokenOutput{} - outputs := []*protobufs.TokenOutput{} - if !bytes.Equal(t.Proofs[1], make([]byte, 32)) { - pre, err := a.CoinStore.GetPreCoinProofByAddress(t.Proofs[1]) - if err != nil { - return nil, ErrInvalidStateTransition - } - if !bytes.Equal( - pre.Owner.GetImplicitAccount().Address, - addr.FillBytes(make([]byte, 32)), - ) && !bytes.Equal( - pre.Owner.GetImplicitAccount().Address, - altAddr.FillBytes(make([]byte, 32)), - ) { - return nil, ErrInvalidStateTransition - } - - deletes = append(deletes, &protobufs.TokenOutput{ - Output: &protobufs.TokenOutput_DeletedProof{ - DeletedProof: pre, - }, - }) + if len(t.Proofs) == 1 && a.Tries[0].Contains( + addr.FillBytes(make([]byte, 32)), + ) && bytes.Equal(t.Signature.PublicKey.KeyValue, a.Beacon) { + if len(t.Proofs[0]) != 64 { + return nil, errors.Wrap(ErrInvalidStateTransition, "handle mint") } - var previousIncrement = uint32(0xFFFFFFFF) - reward := new(big.Int) - var index uint32 - var indexProof []byte - var parallelism uint32 - var kzgCommitment []byte - var kzgProof []byte - for pi, data := range t.Proofs[2:] { - if len(data) < 28 { - return nil, ErrInvalidStateTransition - } - - increment := binary.BigEndian.Uint32(data[:4]) - parallelism = binary.BigEndian.Uint32(data[4:8]) - inputLen := binary.BigEndian.Uint64(data[8:16]) - - if len(deletes) != 0 && pi == 0 { - if deletes[0].GetDeletedProof().Difficulty-1 != increment { - return nil, ErrInvalidStateTransition - } - } else if pi == 0 && bytes.Equal(t.Proofs[1], make([]byte, 32)) { - frames, _, err := a.CoinStore.GetPreCoinProofsForOwner( - addr.FillBytes(make([]byte, 32)), - ) - if err != nil || len(frames) != 0 { - return nil, ErrInvalidStateTransition - } - } else if pi != 0 { - if increment != previousIncrement-1 { - return nil, ErrInvalidStateTransition - } - } - previousIncrement = increment - - if uint64(len(data[16:])) < inputLen+8 { - return nil, ErrInvalidStateTransition - } - - input := make([]byte, inputLen) - copy(input[:], data[16:16+inputLen]) - - outputLen := binary.BigEndian.Uint64(data[16+inputLen : 16+inputLen+8]) - - if uint64(len(data[16+inputLen+8:])) < outputLen { - return nil, ErrInvalidStateTransition - } - - output := make([]byte, outputLen) - copy(output[:], data[16+inputLen+8:]) - dataProver := crypto.NewKZGInclusionProver(a.Logger) - wesoProver := crypto.NewWesolowskiFrameProver(a.Logger) - index = binary.BigEndian.Uint32(output[:4]) - indexProof = output[4:520] - kzgCommitment = output[520:594] - kzgProof = output[594:668] - ip := sha3.Sum512(indexProof) - - v, err := dataProver.VerifyRaw( - ip[:], - kzgCommitment, - int(index), - kzgProof, - nearestApplicablePowerOfTwo(uint64(parallelism)), - ) - if err != nil { - return nil, ErrInvalidStateTransition - } - - if !v { - return nil, ErrInvalidStateTransition - } - - wp := []byte{} - wp = append(wp, peerId...) - wp = append(wp, input...) - v = wesoProver.VerifyPreDuskChallengeProof( - wp, - increment, - index, - indexProof, - ) - if !v { - return nil, ErrInvalidStateTransition - } - - pomwBasis := big.NewInt(1200000) - additional := new(big.Int).Mul(pomwBasis, big.NewInt(int64(parallelism))) - reward.Add( - reward, - additional, - ) - } - - if len(deletes) != 0 { - reward.Add( - reward, - new(big.Int).SetBytes(deletes[0].GetDeletedProof().Amount), - ) - } - - if previousIncrement == uint32(0xffffffff) { - return nil, ErrInvalidStateTransition - } - - if previousIncrement != 0 { - add := &protobufs.PreCoinProof{ - Amount: reward.FillBytes(make([]byte, 32)), - Index: index, - IndexProof: indexProof, - Commitment: kzgCommitment, - Proof: append(append([]byte{}, kzgProof...), indexProof...), - Parallelism: parallelism, - Difficulty: previousIncrement, - Owner: &protobufs.AccountRef{ - Account: &protobufs.AccountRef_ImplicitAccount{ - ImplicitAccount: &protobufs.ImplicitAccount{ - ImplicitType: 0, - Address: addr.FillBytes(make([]byte, 32)), - }, - }, - }, - } - outputs = append(outputs, &protobufs.TokenOutput{ - Output: &protobufs.TokenOutput_Proof{ - Proof: add, - }, - }) - } else { - add := &protobufs.Coin{ - Amount: reward.FillBytes(make([]byte, 32)), - Intersection: make([]byte, 1024), - Owner: &protobufs.AccountRef{ - Account: &protobufs.AccountRef_ImplicitAccount{ - ImplicitAccount: &protobufs.ImplicitAccount{ - ImplicitType: 0, - Address: addr.FillBytes(make([]byte, 32)), - }, - }, - }, - } - outputs = append(outputs, &protobufs.TokenOutput{ + outputs := []*protobufs.TokenOutput{ + &protobufs.TokenOutput{ Output: &protobufs.TokenOutput_Coin{ - Coin: add, + Coin: &protobufs.Coin{ + Amount: t.Proofs[0][:32], + Intersection: make([]byte, 1024), + Owner: &protobufs.AccountRef{ + Account: &protobufs.AccountRef_ImplicitAccount{ + ImplicitAccount: &protobufs.ImplicitAccount{ + ImplicitType: 0, + Address: t.Proofs[0][32:], + }, + }, + }, + }, }, - }) + }, } - outputs = append(outputs, deletes...) - lockMap[string(t.Signature.PublicKey.KeyValue)] = struct{}{} return outputs, nil - } else { + } else if len(t.Proofs) != 3 && currentFrameNumber > 60480 { + if _, touched := lockMap[string(t.Signature.PublicKey.KeyValue)]; touched { + return nil, errors.Wrap(ErrInvalidStateTransition, "handle mint") + } ring := -1 addrBytes := addr.FillBytes(make([]byte, 32)) for i, t := range a.Tries { @@ -248,16 +93,16 @@ func (a *TokenApplication) handleMint( } } if ring == -1 { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle mint") } outputs := []*protobufs.TokenOutput{} for _, p := range t.Proofs { if len(p) < 516+len(peerId)+8+32 { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle mint") } if !bytes.Equal(p[516:len(peerId)], []byte(peerId)) { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle mint") } wesoProver := crypto.NewWesolowskiFrameProver(a.Logger) @@ -266,11 +111,11 @@ func (a *TokenApplication) handleMint( p[516+len(peerId) : 516+len(peerId)+8], ) if frameNumber > currentFrameNumber { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle mint") } frames, proofs, err := a.CoinStore.GetPreCoinProofsForOwner( - addr.FillBytes(make([]byte, 32)), + altAddr.FillBytes(make([]byte, 32)), ) if err == nil { none := true @@ -284,19 +129,19 @@ func (a *TokenApplication) handleMint( if !none { for _, pr := range proofs { if bytes.Equal(pr.Proof, p) { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle mint") } } } } if !wesoProver.VerifyChallengeProof(p[516:], a.Difficulty, p[:516]) { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle mint") } scale := len(p2p.GetOnesIndices(p[516+len(peerId)+8 : 32])) if scale == 0 { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle mint") } ringFactor := big.NewInt(2) @@ -346,4 +191,6 @@ func (a *TokenApplication) handleMint( lockMap[string(t.Signature.PublicKey.KeyValue)] = struct{}{} return outputs, nil } + + return nil, errors.Wrap(ErrInvalidStateTransition, "handle mint") } diff --git a/node/execution/intrinsics/token/application/token_handle_split.go b/node/execution/intrinsics/token/application/token_handle_split.go index c7bd0ff..f6b5915 100644 --- a/node/execution/intrinsics/token/application/token_handle_split.go +++ b/node/execution/intrinsics/token/application/token_handle_split.go @@ -7,6 +7,7 @@ import ( "github.com/iden3/go-iden3-crypto/poseidon" pcrypto "github.com/libp2p/go-libp2p/core/crypto" "github.com/libp2p/go-libp2p/core/peer" + "github.com/pkg/errors" "source.quilibrium.com/quilibrium/monorepo/node/protobufs" ) @@ -22,50 +23,55 @@ func (a *TokenApplication) handleSplit( t.Signature.Signature == nil || t.OfCoin == nil || t.OfCoin.Address == nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle split") } coin, err := a.CoinStore.GetCoinByAddress(nil, t.OfCoin.Address) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle split") } if _, touched := lockMap[string(t.OfCoin.Address)]; touched { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle split") } payload = append(payload, []byte("split")...) payload = append(payload, t.OfCoin.Address...) + + if len(t.Amounts) > 100 { + return nil, errors.Wrap(ErrInvalidStateTransition, "handle split") + } + for _, a := range t.Amounts { if len(a) > 32 { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle split") } payload = append(payload, a...) } if err := t.Signature.Verify(payload); err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle split") } addr, err := poseidon.HashBytes(t.Signature.PublicKey.KeyValue) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle split") } pk, err := pcrypto.UnmarshalEd448PublicKey( t.Signature.PublicKey.KeyValue, ) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle split") } peerId, err := peer.IDFromPublicKey(pk) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle split") } altAddr, err := poseidon.HashBytes([]byte(peerId)) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle split") } if !bytes.Equal( @@ -75,7 +81,7 @@ func (a *TokenApplication) handleSplit( coin.Owner.GetImplicitAccount().Address, altAddr.FillBytes(make([]byte, 32)), ) { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle split") } original := new(big.Int).SetBytes(coin.Amount) @@ -84,7 +90,7 @@ func (a *TokenApplication) handleSplit( for _, amount := range amounts { amountBI := new(big.Int).SetBytes(amount) if amountBI.Cmp(original) >= 0 { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle split") } newAmounts = append(newAmounts, amountBI) @@ -96,7 +102,7 @@ func (a *TokenApplication) handleSplit( }) } if original.Cmp(total) != 0 { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle split") } outputs := []*protobufs.TokenOutput{} diff --git a/node/execution/intrinsics/token/application/token_handle_transfer.go b/node/execution/intrinsics/token/application/token_handle_transfer.go index 1fbb29c..ea793b9 100644 --- a/node/execution/intrinsics/token/application/token_handle_transfer.go +++ b/node/execution/intrinsics/token/application/token_handle_transfer.go @@ -6,6 +6,7 @@ import ( "github.com/iden3/go-iden3-crypto/poseidon" pcrypto "github.com/libp2p/go-libp2p/core/crypto" "github.com/libp2p/go-libp2p/core/peer" + "github.com/pkg/errors" "source.quilibrium.com/quilibrium/monorepo/node/p2p" "source.quilibrium.com/quilibrium/monorepo/node/protobufs" ) @@ -17,16 +18,16 @@ func (a *TokenApplication) handleTransfer( ) ([]*protobufs.TokenOutput, error) { payload := []byte("transfer") if t == nil || t.OfCoin == nil || t.OfCoin.Address == nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle transfer") } if _, touched := lockMap[string(t.OfCoin.Address)]; touched { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle transfer") } coin, err := a.CoinStore.GetCoinByAddress(nil, t.OfCoin.Address) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle transfer") } payload = append(payload, t.OfCoin.Address...) @@ -36,29 +37,29 @@ func (a *TokenApplication) handleTransfer( ) if err := t.Signature.Verify(payload); err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle transfer") } addr, err := poseidon.HashBytes(t.Signature.PublicKey.KeyValue) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle transfer") } pk, err := pcrypto.UnmarshalEd448PublicKey( t.Signature.PublicKey.KeyValue, ) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle transfer") } peerId, err := peer.IDFromPublicKey(pk) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle transfer") } altAddr, err := poseidon.HashBytes([]byte(peerId)) if err != nil { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle transfer") } if !bytes.Equal( @@ -68,7 +69,7 @@ func (a *TokenApplication) handleTransfer( coin.Owner.GetImplicitAccount().Address, altAddr.FillBytes(make([]byte, 32)), ) { - return nil, ErrInvalidStateTransition + return nil, errors.Wrap(ErrInvalidStateTransition, "handle transfer") } newIntersection := coin.Intersection diff --git a/node/execution/intrinsics/token/token_execution_engine.go b/node/execution/intrinsics/token/token_execution_engine.go index 9ec1e4e..5e5b30d 100644 --- a/node/execution/intrinsics/token/token_execution_engine.go +++ b/node/execution/intrinsics/token/token_execution_engine.go @@ -97,7 +97,10 @@ func NewTokenExecutionEngine( } else if err != nil { panic(err) } else { - err := coinStore.Migrate(intrinsicFilter) + err := coinStore.Migrate( + intrinsicFilter, + config.GetGenesis().GenesisSeedHex, + ) if err != nil { panic(err) } @@ -138,7 +141,16 @@ func NewTokenExecutionEngine( clockStore, cfg.Engine, frameProver, - e.ProcessFrame, + func(txn store.Transaction, frame *protobufs.ClockFrame) error { + if err := e.VerifyExecution(frame); err != nil { + return err + } + if err := e.ProcessFrame(txn, frame); err != nil { + return err + } + + return nil + }, origin, inclusionProof, proverKeys, @@ -253,44 +265,6 @@ func NewTokenExecutionEngine( ) } - inc, _, _, err := dataProofStore.GetLatestDataTimeProof( - e.pubSub.GetPeerID(), - ) - _, parallelism, input, output, err := dataProofStore.GetDataTimeProof( - e.pubSub.GetPeerID(), - inc, - ) - if err == nil { - proof := []byte{} - proof = binary.BigEndian.AppendUint32(proof, inc) - proof = binary.BigEndian.AppendUint32(proof, parallelism) - proof = binary.BigEndian.AppendUint64(proof, uint64(len(input))) - proof = append(proof, input...) - proof = binary.BigEndian.AppendUint64(proof, uint64(len(output))) - proof = append(proof, output...) - announce.Announce.InitialProof = &protobufs.MintCoinRequest{} - announce.Announce.InitialProof.Proofs = [][]byte{ - []byte("pre-dusk"), - make([]byte, 32), - proof, - } - payload := []byte("mint") - for _, p := range announce.Announce.InitialProof.Proofs { - payload = append(payload, p...) - } - sig, err := e.pubSub.SignMessage(payload) - if err != nil { - panic(err) - } - - announce.Announce.InitialProof.Signature = &protobufs.Ed448Signature{ - PublicKey: &protobufs.Ed448PublicKey{ - KeyValue: e.pubSub.GetPublicKey(), - }, - Signature: sig, - } - } - req := &protobufs.TokenRequest{ Request: announce, } @@ -476,6 +450,7 @@ func (e *TokenExecutionEngine) ProcessFrame( ), ) app, err := application.MaterializeApplicationFromFrame( + e.provingKey, frame, e.clock.GetFrameProverTries(), e.coinStore, @@ -611,10 +586,6 @@ func (e *TokenExecutionEngine) publishMessage( func (e *TokenExecutionEngine) VerifyExecution( frame *protobufs.ClockFrame, ) error { - if e.clock.GetFrame().FrameNumber != frame.FrameNumber-1 { - return nil - } - if len(frame.AggregateProofs) > 0 { for _, proofs := range frame.AggregateProofs { for _, inclusion := range proofs.InclusionCommitments { @@ -624,19 +595,18 @@ func (e *TokenExecutionEngine) VerifyExecution( return errors.Wrap(err, "verify execution") } - parent, err := e.clockStore.GetStagedDataClockFrame( + parent, tries, err := e.clockStore.GetDataClockFrame( append( p2p.GetBloomFilter(application.TOKEN_ADDRESS, 256, 3), ), frame.FrameNumber-1, - frame.ParentSelector, false, ) if err != nil && !errors.Is(err, store.ErrNotFound) { return errors.Wrap(err, "verify execution") } - if parent == nil { + if parent == nil && frame.FrameNumber != 0 { return errors.Wrap( errors.New("missing parent frame"), "verify execution", @@ -644,8 +614,9 @@ func (e *TokenExecutionEngine) VerifyExecution( } a, err := application.MaterializeApplicationFromFrame( + e.provingKey, parent, - e.clock.GetFrameProverTries(), + tries, e.coinStore, e.logger, ) @@ -653,14 +624,19 @@ func (e *TokenExecutionEngine) VerifyExecution( return errors.Wrap(err, "verify execution") } - a, _, _, err = a.ApplyTransitions(frame.FrameNumber, transition, false) + a, _, _, err = a.ApplyTransitions( + frame.FrameNumber, + transition, + false, + ) if err != nil { return errors.Wrap(err, "verify execution") } a2, err := application.MaterializeApplicationFromFrame( + e.provingKey, frame, - e.clock.GetFrameProverTries(), + tries, e.coinStore, e.logger, ) @@ -670,7 +646,7 @@ func (e *TokenExecutionEngine) VerifyExecution( if len(a.TokenOutputs.Outputs) != len(a2.TokenOutputs.Outputs) { return errors.Wrap( - application.ErrInvalidStateTransition, + errors.New("mismatched outputs"), "verify execution", ) } @@ -678,23 +654,9 @@ func (e *TokenExecutionEngine) VerifyExecution( for i := range a.TokenOutputs.Outputs { o1 := a.TokenOutputs.Outputs[i] o2 := a2.TokenOutputs.Outputs[i] - b1, err := proto.Marshal(o1) - if err != nil { + if !proto.Equal(o1, o2) { return errors.Wrap( - application.ErrInvalidStateTransition, - "verify execution", - ) - } - b2, err := proto.Marshal(o2) - if err != nil { - return errors.Wrap( - application.ErrInvalidStateTransition, - "verify execution", - ) - } - if !bytes.Equal(b1, b2) { - return errors.Wrap( - application.ErrInvalidStateTransition, + errors.New("mismatched messages"), "verify execution", ) } diff --git a/node/execution/intrinsics/token/token_genesis.go b/node/execution/intrinsics/token/token_genesis.go index b927b40..83f7de0 100644 --- a/node/execution/intrinsics/token/token_genesis.go +++ b/node/execution/intrinsics/token/token_genesis.go @@ -89,10 +89,6 @@ func CreateGenesisState( [][]byte, map[string]uint64, ) { - if err := coinStore.SetMigrationVersion(); err != nil { - panic(err) - } - genesis := config.GetGenesis() if genesis == nil { panic("genesis is nil") diff --git a/node/protobufs/data.pb.go b/node/protobufs/data.pb.go index 429a2f8..eb95cdc 100644 --- a/node/protobufs/data.pb.go +++ b/node/protobufs/data.pb.go @@ -774,6 +774,108 @@ func (x *DataFrameResponse) GetProof() []byte { return nil } +type PreMidnightMintResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Increment uint32 `protobuf:"varint,2,opt,name=increment,proto3" json:"increment,omitempty"` +} + +func (x *PreMidnightMintResponse) Reset() { + *x = PreMidnightMintResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_data_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PreMidnightMintResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PreMidnightMintResponse) ProtoMessage() {} + +func (x *PreMidnightMintResponse) ProtoReflect() protoreflect.Message { + mi := &file_data_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PreMidnightMintResponse.ProtoReflect.Descriptor instead. +func (*PreMidnightMintResponse) Descriptor() ([]byte, []int) { + return file_data_proto_rawDescGZIP(), []int{11} +} + +func (x *PreMidnightMintResponse) GetAddress() []byte { + if x != nil { + return x.Address + } + return nil +} + +func (x *PreMidnightMintResponse) GetIncrement() uint32 { + if x != nil { + return x.Increment + } + return 0 +} + +type PreMidnightMintStatusRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Owner []byte `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` +} + +func (x *PreMidnightMintStatusRequest) Reset() { + *x = PreMidnightMintStatusRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_data_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PreMidnightMintStatusRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PreMidnightMintStatusRequest) ProtoMessage() {} + +func (x *PreMidnightMintStatusRequest) ProtoReflect() protoreflect.Message { + mi := &file_data_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PreMidnightMintStatusRequest.ProtoReflect.Descriptor instead. +func (*PreMidnightMintStatusRequest) Descriptor() ([]byte, []int) { + return file_data_proto_rawDescGZIP(), []int{12} +} + +func (x *PreMidnightMintStatusRequest) GetOwner() []byte { + if x != nil { + return x.Owner + } + return nil +} + type ChallengeProofRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -786,7 +888,7 @@ type ChallengeProofRequest struct { func (x *ChallengeProofRequest) Reset() { *x = ChallengeProofRequest{} if protoimpl.UnsafeEnabled { - mi := &file_data_proto_msgTypes[11] + mi := &file_data_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -799,7 +901,7 @@ func (x *ChallengeProofRequest) String() string { func (*ChallengeProofRequest) ProtoMessage() {} func (x *ChallengeProofRequest) ProtoReflect() protoreflect.Message { - mi := &file_data_proto_msgTypes[11] + mi := &file_data_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -812,7 +914,7 @@ func (x *ChallengeProofRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ChallengeProofRequest.ProtoReflect.Descriptor instead. func (*ChallengeProofRequest) Descriptor() ([]byte, []int) { - return file_data_proto_rawDescGZIP(), []int{11} + return file_data_proto_rawDescGZIP(), []int{13} } func (x *ChallengeProofRequest) GetPeerId() []byte { @@ -840,7 +942,7 @@ type ChallengeProofResponse struct { func (x *ChallengeProofResponse) Reset() { *x = ChallengeProofResponse{} if protoimpl.UnsafeEnabled { - mi := &file_data_proto_msgTypes[12] + mi := &file_data_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -853,7 +955,7 @@ func (x *ChallengeProofResponse) String() string { func (*ChallengeProofResponse) ProtoMessage() {} func (x *ChallengeProofResponse) ProtoReflect() protoreflect.Message { - mi := &file_data_proto_msgTypes[12] + mi := &file_data_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -866,7 +968,7 @@ func (x *ChallengeProofResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ChallengeProofResponse.ProtoReflect.Descriptor instead. func (*ChallengeProofResponse) Descriptor() ([]byte, []int) { - return file_data_proto_rawDescGZIP(), []int{12} + return file_data_proto_rawDescGZIP(), []int{14} } func (x *ChallengeProofResponse) GetOutput() []byte { @@ -883,167 +985,192 @@ var file_data_proto_rawDesc = []byte{ 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x62, 0x1a, 0x0d, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0b, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x0a, 0x6b, 0x65, 0x79, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x56, 0x0a, - 0x14, 0x44, 0x61, 0x74, 0x61, 0x50, 0x65, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6e, 0x6e, - 0x6f, 0x75, 0x6e, 0x63, 0x65, 0x12, 0x3e, 0x0a, 0x09, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x6c, 0x69, - 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 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, 0x44, 0x61, 0x74, 0x61, 0x50, 0x65, 0x65, 0x72, 0x52, 0x08, 0x70, 0x65, 0x65, - 0x72, 0x4c, 0x69, 0x73, 0x74, 0x22, 0xfa, 0x01, 0x0a, 0x08, 0x44, 0x61, 0x74, 0x61, 0x50, 0x65, - 0x65, 0x72, 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, 0x1c, 0x0a, 0x09, 0x6d, - 0x75, 0x6c, 0x74, 0x69, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x61, 0x64, 0x64, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x61, 0x78, - 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6d, 0x61, - 0x78, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1c, - 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x1d, 0x0a, 0x0a, - 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x0e, 0x74, - 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x64, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x08, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x44, 0x69, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x22, 0xd4, 0x02, 0x0a, 0x12, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6d, 0x70, 0x72, - 0x65, 0x73, 0x73, 0x65, 0x64, 0x53, 0x79, 0x6e, 0x63, 0x12, 0x2a, 0x0a, 0x11, 0x66, 0x72, 0x6f, - 0x6d, 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x66, 0x72, 0x6f, 0x6d, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x4e, - 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x26, 0x0a, 0x0f, 0x74, 0x6f, 0x5f, 0x66, 0x72, 0x61, 0x6d, - 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, - 0x74, 0x6f, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x5a, 0x0a, - 0x16, 0x74, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x6c, 0x6f, 0x63, 0x6b, - 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 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, 0x52, 0x14, 0x74, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6c, - 0x6f, 0x63, 0x6b, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x43, 0x0a, 0x06, 0x70, 0x72, 0x6f, - 0x6f, 0x66, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 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, 0x49, 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, - 0x6f, 0x66, 0x73, 0x4d, 0x61, 0x70, 0x52, 0x06, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x73, 0x12, 0x49, - 0x0a, 0x08, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x2d, 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, 0x49, 0x6e, 0x63, 0x6c, 0x75, - 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x4d, 0x61, 0x70, 0x52, - 0x08, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x97, 0x01, 0x0a, 0x19, 0x53, 0x79, - 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 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, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x09, 0x63, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x12, 0x43, - 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x27, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, - 0x64, 0x65, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x2e, 0x70, 0x62, 0x2e, 0x45, 0x64, 0x34, 0x34, 0x38, - 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0xaa, 0x02, 0x0a, 0x20, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6d, 0x70, - 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x4e, 0x0a, 0x09, 0x70, 0x72, 0x65, 0x66, - 0x6c, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 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, 0x50, 0x72, 0x65, 0x66, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x48, 0x00, 0x52, 0x09, 0x70, - 0x72, 0x65, 0x66, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x12, 0x48, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x71, 0x75, 0x69, 0x6c, + 0x6f, 0x1a, 0x0a, 0x6b, 0x65, 0x79, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0a, 0x6e, + 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x56, 0x0a, 0x14, 0x44, 0x61, 0x74, + 0x61, 0x50, 0x65, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6e, 0x6e, 0x6f, 0x75, 0x6e, 0x63, + 0x65, 0x12, 0x3e, 0x0a, 0x09, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 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, 0x44, + 0x61, 0x74, 0x61, 0x50, 0x65, 0x65, 0x72, 0x52, 0x08, 0x70, 0x65, 0x65, 0x72, 0x4c, 0x69, 0x73, + 0x74, 0x22, 0xfa, 0x01, 0x0a, 0x08, 0x44, 0x61, 0x74, 0x61, 0x50, 0x65, 0x65, 0x72, 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, 0x1c, 0x0a, 0x09, 0x6d, 0x75, 0x6c, 0x74, 0x69, + 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x75, 0x6c, 0x74, + 0x69, 0x61, 0x64, 0x64, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x61, 0x78, 0x5f, 0x66, 0x72, 0x61, + 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6d, 0x61, 0x78, 0x46, 0x72, 0x61, + 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, + 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, + 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, + 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, + 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x6f, 0x74, 0x61, 0x6c, + 0x5f, 0x64, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x0d, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x44, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x22, 0xd4, + 0x02, 0x0a, 0x12, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, + 0x64, 0x53, 0x79, 0x6e, 0x63, 0x12, 0x2a, 0x0a, 0x11, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x66, 0x72, + 0x61, 0x6d, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x0f, 0x66, 0x72, 0x6f, 0x6d, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, + 0x72, 0x12, 0x26, 0x0a, 0x0f, 0x74, 0x6f, 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x5f, 0x6e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x74, 0x6f, 0x46, 0x72, + 0x61, 0x6d, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x5a, 0x0a, 0x16, 0x74, 0x72, 0x75, + 0x6e, 0x63, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x66, 0x72, 0x61, + 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 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, 0x52, + 0x14, 0x74, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x46, + 0x72, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x43, 0x0a, 0x06, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x73, 0x18, + 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 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, + 0x49, 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x73, 0x4d, + 0x61, 0x70, 0x52, 0x06, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x73, 0x12, 0x49, 0x0a, 0x08, 0x73, 0x65, + 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 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, 0x49, 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, + 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x4d, 0x61, 0x70, 0x52, 0x08, 0x73, 0x65, 0x67, + 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x97, 0x01, 0x0a, 0x19, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 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, 0x1c, 0x0a, 0x09, + 0x63, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x09, 0x63, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x12, 0x43, 0x0a, 0x08, 0x72, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x71, + 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6b, + 0x65, 0x79, 0x73, 0x2e, 0x70, 0x62, 0x2e, 0x45, 0x64, 0x34, 0x34, 0x38, 0x53, 0x69, 0x67, 0x6e, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0xaa, 0x02, 0x0a, 0x20, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, + 0x65, 0x64, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x12, 0x4e, 0x0a, 0x09, 0x70, 0x72, 0x65, 0x66, 0x6c, 0x69, 0x67, 0x68, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 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, 0x50, 0x72, + 0x65, 0x66, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x48, 0x00, 0x52, 0x09, 0x70, 0x72, 0x65, 0x66, 0x6c, + 0x69, 0x67, 0x68, 0x74, 0x12, 0x48, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, + 0x02, 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, 0x48, 0x00, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x5c, + 0x0a, 0x0e, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 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, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x41, 0x75, 0x74, 0x68, + 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0e, 0x61, 0x75, + 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0e, 0x0a, 0x0c, + 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xce, 0x01, 0x0a, + 0x21, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x53, + 0x79, 0x6e, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x12, 0x4e, 0x0a, 0x09, 0x70, 0x72, 0x65, 0x66, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 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, 0x50, 0x72, 0x65, 0x66, + 0x6c, 0x69, 0x67, 0x68, 0x74, 0x48, 0x00, 0x52, 0x09, 0x70, 0x72, 0x65, 0x66, 0x6c, 0x69, 0x67, + 0x68, 0x74, 0x12, 0x49, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 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, 0x44, + 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x53, 0x79, 0x6e, + 0x63, 0x48, 0x00, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0e, 0x0a, + 0x0c, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xa1, 0x01, + 0x0a, 0x12, 0x49, 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x6f, 0x66, + 0x73, 0x4d, 0x61, 0x70, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x5f, 0x63, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x66, 0x72, 0x61, 0x6d, + 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x52, 0x0a, + 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x30, 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, 0x49, 0x6e, 0x63, + 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, + 0x73, 0x4d, 0x61, 0x70, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, + 0x73, 0x22, 0x3e, 0x0a, 0x14, 0x49, 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x65, + 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x4d, 0x61, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, + 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x12, 0x12, 0x0a, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, + 0x61, 0x22, 0x7b, 0x0a, 0x17, 0x49, 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x4d, 0x61, 0x70, 0x12, 0x1e, 0x0a, 0x0a, + 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x19, 0x0a, 0x08, + 0x74, 0x79, 0x70, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x74, 0x79, 0x70, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x65, 0x67, 0x6d, 0x65, + 0x6e, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, + 0x0d, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x22, 0x38, + 0x0a, 0x13, 0x47, 0x65, 0x74, 0x44, 0x61, 0x74, 0x61, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x5f, 0x6e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x66, 0x72, 0x61, + 0x6d, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x70, 0x0a, 0x11, 0x44, 0x61, 0x74, 0x61, + 0x46, 0x72, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, + 0x0b, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x24, 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, 0x52, 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x46, + 0x72, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x22, 0x51, 0x0a, 0x17, 0x50, 0x72, + 0x65, 0x4d, 0x69, 0x64, 0x6e, 0x69, 0x67, 0x68, 0x74, 0x4d, 0x69, 0x6e, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, + 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x09, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x34, 0x0a, + 0x1c, 0x50, 0x72, 0x65, 0x4d, 0x69, 0x64, 0x6e, 0x69, 0x67, 0x68, 0x74, 0x4d, 0x69, 0x6e, 0x74, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, + 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x6f, 0x77, + 0x6e, 0x65, 0x72, 0x22, 0x77, 0x0a, 0x15, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, + 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 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, 0x45, 0x0a, 0x0b, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x66, + 0x72, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 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, + 0x52, 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x46, 0x72, 0x61, 0x6d, 0x65, 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, 0xff, + 0x05, 0x0a, 0x0b, 0x44, 0x61, 0x74, 0x61, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x76, + 0x0a, 0x17, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x53, + 0x79, 0x6e, 0x63, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x12, 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, 0x48, 0x00, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x5c, 0x0a, 0x0e, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 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, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, - 0x52, 0x0e, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x42, 0x0e, 0x0a, 0x0c, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x22, 0xce, 0x01, 0x0a, 0x21, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, - 0x73, 0x65, 0x64, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x4e, 0x0a, 0x09, 0x70, 0x72, 0x65, 0x66, 0x6c, 0x69, - 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 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, - 0x50, 0x72, 0x65, 0x66, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x48, 0x00, 0x52, 0x09, 0x70, 0x72, 0x65, - 0x66, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x12, 0x49, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 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, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, + 0x53, 0x79, 0x6e, 0x63, 0x30, 0x01, 0x12, 0x9a, 0x01, 0x0a, 0x1d, 0x4e, 0x65, 0x67, 0x6f, 0x74, + 0x69, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x53, 0x79, + 0x6e, 0x63, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x39, 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, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, - 0x64, 0x53, 0x79, 0x6e, 0x63, 0x48, 0x00, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x42, 0x0e, 0x0a, 0x0c, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x22, 0xa1, 0x01, 0x0a, 0x12, 0x49, 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x50, - 0x72, 0x6f, 0x6f, 0x66, 0x73, 0x4d, 0x61, 0x70, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x72, 0x61, 0x6d, - 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, - 0x66, 0x72, 0x61, 0x6d, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x70, - 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x6f, - 0x66, 0x12, 0x52, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x30, 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, 0x49, 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, - 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x4d, 0x61, 0x70, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, - 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x3e, 0x0a, 0x14, 0x49, 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, - 0x6f, 0x6e, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x4d, 0x61, 0x70, 0x12, 0x12, 0x0a, - 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x68, 0x61, 0x73, - 0x68, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x7b, 0x0a, 0x17, 0x49, 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, - 0x6f, 0x6e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x4d, 0x61, 0x70, - 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, - 0x12, 0x19, 0x0a, 0x08, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x74, 0x79, 0x70, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x25, 0x0a, 0x0e, 0x73, - 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x65, 0x73, 0x18, 0x03, 0x20, - 0x03, 0x28, 0x0c, 0x52, 0x0d, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x48, 0x61, 0x73, 0x68, - 0x65, 0x73, 0x22, 0x38, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x44, 0x61, 0x74, 0x61, 0x46, 0x72, 0x61, - 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x72, 0x61, - 0x6d, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x0b, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x70, 0x0a, 0x11, - 0x44, 0x61, 0x74, 0x61, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x45, 0x0a, 0x0b, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 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, 0x52, 0x0a, 0x63, 0x6c, - 0x6f, 0x63, 0x6b, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, - 0x66, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x22, 0x77, - 0x0a, 0x15, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x6f, 0x66, - 0x52, 0x65, 0x71, 0x75, 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, 0x45, 0x0a, 0x0b, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 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, 0x52, 0x0a, 0x63, 0x6c, 0x6f, - 0x63, 0x6b, 0x46, 0x72, 0x61, 0x6d, 0x65, 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, 0x84, 0x04, 0x0a, 0x0b, 0x44, 0x61, - 0x74, 0x61, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x76, 0x0a, 0x17, 0x47, 0x65, 0x74, - 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x53, 0x79, 0x6e, 0x63, 0x46, 0x72, - 0x61, 0x6d, 0x65, 0x73, 0x12, 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, 0x1a, 0x2b, 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, 0x44, 0x61, 0x74, - 0x61, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x53, 0x79, 0x6e, 0x63, 0x30, - 0x01, 0x12, 0x9a, 0x01, 0x0a, 0x1d, 0x4e, 0x65, 0x67, 0x6f, 0x74, 0x69, 0x61, 0x74, 0x65, 0x43, - 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x53, 0x79, 0x6e, 0x63, 0x46, 0x72, 0x61, - 0x6d, 0x65, 0x73, 0x12, 0x39, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, + 0x64, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x1a, 0x3a, 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, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x53, 0x79, 0x6e, 0x63, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x3a, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x28, + 0x01, 0x30, 0x01, 0x12, 0x76, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, + 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x2e, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, + 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, + 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x32, 0x50, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x45, + 0x6e, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x1a, 0x2e, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, + 0x72, 0x69, 0x75, 0x6d, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, + 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x32, 0x50, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x45, + 0x6e, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x28, 0x01, 0x30, 0x01, 0x12, 0x68, 0x0a, 0x0c, 0x47, + 0x65, 0x74, 0x44, 0x61, 0x74, 0x61, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x12, 0x2c, 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, 0x47, 0x65, 0x74, 0x44, 0x61, 0x74, 0x61, 0x46, 0x72, 0x61, + 0x6d, 0x65, 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, 0x64, 0x61, 0x74, 0x61, + 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x73, 0x0a, 0x15, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x50, + 0x72, 0x65, 0x4d, 0x69, 0x64, 0x6e, 0x69, 0x67, 0x68, 0x74, 0x4d, 0x69, 0x6e, 0x74, 0x12, 0x28, 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, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6d, - 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x28, 0x01, 0x30, 0x01, 0x12, 0x76, - 0x0a, 0x10, 0x47, 0x65, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x43, 0x68, 0x61, 0x6e, 0x6e, - 0x65, 0x6c, 0x12, 0x2e, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, - 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x70, 0x62, 0x2e, - 0x50, 0x32, 0x50, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x45, 0x6e, 0x76, 0x65, 0x6c, 0x6f, - 0x70, 0x65, 0x1a, 0x2e, 0x2e, 0x71, 0x75, 0x69, 0x6c, 0x69, 0x62, 0x72, 0x69, 0x75, 0x6d, 0x2e, - 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x70, 0x62, 0x2e, - 0x50, 0x32, 0x50, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x45, 0x6e, 0x76, 0x65, 0x6c, 0x6f, - 0x70, 0x65, 0x28, 0x01, 0x30, 0x01, 0x12, 0x68, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x44, 0x61, 0x74, - 0x61, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x12, 0x2c, 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, 0x47, 0x65, 0x74, 0x44, 0x61, 0x74, 0x61, 0x46, 0x72, 0x61, 0x6d, 0x65, 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, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x62, 0x2e, 0x44, - 0x61, 0x74, 0x61, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x69, 0x6e, 0x74, 0x43, 0x6f, 0x69, + 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 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, 0x50, 0x72, 0x65, 0x4d, 0x69, 0x64, 0x6e, 0x69, 0x67, 0x68, 0x74, 0x4d, 0x69, + 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x83, 0x01, 0x0a, 0x18, 0x47, + 0x65, 0x74, 0x50, 0x72, 0x65, 0x4d, 0x69, 0x64, 0x6e, 0x69, 0x67, 0x68, 0x74, 0x4d, 0x69, 0x6e, + 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x35, 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, 0x50, 0x72, 0x65, 0x4d, 0x69, 0x64, 0x6e, 0x69, 0x67, 0x68, 0x74, 0x4d, 0x69, 0x6e, + 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, + 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, 0x50, 0x72, 0x65, 0x4d, 0x69, 0x64, 0x6e, + 0x69, 0x67, 0x68, 0x74, 0x4d, 0x69, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 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, @@ -1072,7 +1199,7 @@ func file_data_proto_rawDescGZIP() []byte { return file_data_proto_rawDescData } -var file_data_proto_msgTypes = make([]protoimpl.MessageInfo, 13) +var file_data_proto_msgTypes = make([]protoimpl.MessageInfo, 15) var file_data_proto_goTypes = []interface{}{ (*DataPeerListAnnounce)(nil), // 0: quilibrium.node.data.pb.DataPeerListAnnounce (*DataPeer)(nil), // 1: quilibrium.node.data.pb.DataPeer @@ -1085,40 +1212,47 @@ var file_data_proto_goTypes = []interface{}{ (*InclusionCommitmentsMap)(nil), // 8: quilibrium.node.data.pb.InclusionCommitmentsMap (*GetDataFrameRequest)(nil), // 9: quilibrium.node.data.pb.GetDataFrameRequest (*DataFrameResponse)(nil), // 10: quilibrium.node.data.pb.DataFrameResponse - (*ChallengeProofRequest)(nil), // 11: quilibrium.node.data.pb.ChallengeProofRequest - (*ChallengeProofResponse)(nil), // 12: quilibrium.node.data.pb.ChallengeProofResponse - (*ClockFrame)(nil), // 13: quilibrium.node.clock.pb.ClockFrame - (*Ed448Signature)(nil), // 14: quilibrium.node.keys.pb.Ed448Signature - (*ClockFramesPreflight)(nil), // 15: quilibrium.node.clock.pb.ClockFramesPreflight - (*ClockFramesRequest)(nil), // 16: quilibrium.node.clock.pb.ClockFramesRequest - (*P2PChannelEnvelope)(nil), // 17: quilibrium.node.channel.pb.P2PChannelEnvelope + (*PreMidnightMintResponse)(nil), // 11: quilibrium.node.data.pb.PreMidnightMintResponse + (*PreMidnightMintStatusRequest)(nil), // 12: quilibrium.node.data.pb.PreMidnightMintStatusRequest + (*ChallengeProofRequest)(nil), // 13: quilibrium.node.data.pb.ChallengeProofRequest + (*ChallengeProofResponse)(nil), // 14: quilibrium.node.data.pb.ChallengeProofResponse + (*ClockFrame)(nil), // 15: quilibrium.node.clock.pb.ClockFrame + (*Ed448Signature)(nil), // 16: quilibrium.node.keys.pb.Ed448Signature + (*ClockFramesPreflight)(nil), // 17: quilibrium.node.clock.pb.ClockFramesPreflight + (*ClockFramesRequest)(nil), // 18: quilibrium.node.clock.pb.ClockFramesRequest + (*P2PChannelEnvelope)(nil), // 19: quilibrium.node.channel.pb.P2PChannelEnvelope + (*MintCoinRequest)(nil), // 20: quilibrium.node.node.pb.MintCoinRequest } var file_data_proto_depIdxs = []int32{ 1, // 0: quilibrium.node.data.pb.DataPeerListAnnounce.peer_list:type_name -> quilibrium.node.data.pb.DataPeer - 13, // 1: quilibrium.node.data.pb.DataCompressedSync.truncated_clock_frames:type_name -> quilibrium.node.clock.pb.ClockFrame + 15, // 1: quilibrium.node.data.pb.DataCompressedSync.truncated_clock_frames:type_name -> quilibrium.node.clock.pb.ClockFrame 6, // 2: quilibrium.node.data.pb.DataCompressedSync.proofs:type_name -> quilibrium.node.data.pb.InclusionProofsMap 7, // 3: quilibrium.node.data.pb.DataCompressedSync.segments:type_name -> quilibrium.node.data.pb.InclusionSegmentsMap - 14, // 4: quilibrium.node.data.pb.SyncRequestAuthentication.response:type_name -> quilibrium.node.keys.pb.Ed448Signature - 15, // 5: quilibrium.node.data.pb.DataCompressedSyncRequestMessage.preflight:type_name -> quilibrium.node.clock.pb.ClockFramesPreflight - 16, // 6: quilibrium.node.data.pb.DataCompressedSyncRequestMessage.request:type_name -> quilibrium.node.clock.pb.ClockFramesRequest + 16, // 4: quilibrium.node.data.pb.SyncRequestAuthentication.response:type_name -> quilibrium.node.keys.pb.Ed448Signature + 17, // 5: quilibrium.node.data.pb.DataCompressedSyncRequestMessage.preflight:type_name -> quilibrium.node.clock.pb.ClockFramesPreflight + 18, // 6: quilibrium.node.data.pb.DataCompressedSyncRequestMessage.request:type_name -> quilibrium.node.clock.pb.ClockFramesRequest 3, // 7: quilibrium.node.data.pb.DataCompressedSyncRequestMessage.authentication:type_name -> quilibrium.node.data.pb.SyncRequestAuthentication - 15, // 8: quilibrium.node.data.pb.DataCompressedSyncResponseMessage.preflight:type_name -> quilibrium.node.clock.pb.ClockFramesPreflight + 17, // 8: quilibrium.node.data.pb.DataCompressedSyncResponseMessage.preflight:type_name -> quilibrium.node.clock.pb.ClockFramesPreflight 2, // 9: quilibrium.node.data.pb.DataCompressedSyncResponseMessage.response:type_name -> quilibrium.node.data.pb.DataCompressedSync 8, // 10: quilibrium.node.data.pb.InclusionProofsMap.commitments:type_name -> quilibrium.node.data.pb.InclusionCommitmentsMap - 13, // 11: quilibrium.node.data.pb.DataFrameResponse.clock_frame:type_name -> quilibrium.node.clock.pb.ClockFrame - 13, // 12: quilibrium.node.data.pb.ChallengeProofRequest.clock_frame:type_name -> quilibrium.node.clock.pb.ClockFrame - 16, // 13: quilibrium.node.data.pb.DataService.GetCompressedSyncFrames:input_type -> quilibrium.node.clock.pb.ClockFramesRequest + 15, // 11: quilibrium.node.data.pb.DataFrameResponse.clock_frame:type_name -> quilibrium.node.clock.pb.ClockFrame + 15, // 12: quilibrium.node.data.pb.ChallengeProofRequest.clock_frame:type_name -> quilibrium.node.clock.pb.ClockFrame + 18, // 13: quilibrium.node.data.pb.DataService.GetCompressedSyncFrames:input_type -> quilibrium.node.clock.pb.ClockFramesRequest 4, // 14: quilibrium.node.data.pb.DataService.NegotiateCompressedSyncFrames:input_type -> quilibrium.node.data.pb.DataCompressedSyncRequestMessage - 17, // 15: quilibrium.node.data.pb.DataService.GetPublicChannel:input_type -> quilibrium.node.channel.pb.P2PChannelEnvelope + 19, // 15: quilibrium.node.data.pb.DataService.GetPublicChannel:input_type -> quilibrium.node.channel.pb.P2PChannelEnvelope 9, // 16: quilibrium.node.data.pb.DataService.GetDataFrame:input_type -> quilibrium.node.data.pb.GetDataFrameRequest - 11, // 17: quilibrium.node.data.pb.DataIPCService.CalculateChallengeProof:input_type -> quilibrium.node.data.pb.ChallengeProofRequest - 2, // 18: quilibrium.node.data.pb.DataService.GetCompressedSyncFrames:output_type -> quilibrium.node.data.pb.DataCompressedSync - 5, // 19: quilibrium.node.data.pb.DataService.NegotiateCompressedSyncFrames:output_type -> quilibrium.node.data.pb.DataCompressedSyncResponseMessage - 17, // 20: quilibrium.node.data.pb.DataService.GetPublicChannel:output_type -> quilibrium.node.channel.pb.P2PChannelEnvelope - 10, // 21: quilibrium.node.data.pb.DataService.GetDataFrame:output_type -> quilibrium.node.data.pb.DataFrameResponse - 12, // 22: quilibrium.node.data.pb.DataIPCService.CalculateChallengeProof:output_type -> quilibrium.node.data.pb.ChallengeProofResponse - 18, // [18:23] is the sub-list for method output_type - 13, // [13:18] is the sub-list for method input_type + 20, // 17: quilibrium.node.data.pb.DataService.HandlePreMidnightMint:input_type -> quilibrium.node.node.pb.MintCoinRequest + 12, // 18: quilibrium.node.data.pb.DataService.GetPreMidnightMintStatus:input_type -> quilibrium.node.data.pb.PreMidnightMintStatusRequest + 13, // 19: quilibrium.node.data.pb.DataIPCService.CalculateChallengeProof:input_type -> quilibrium.node.data.pb.ChallengeProofRequest + 2, // 20: quilibrium.node.data.pb.DataService.GetCompressedSyncFrames:output_type -> quilibrium.node.data.pb.DataCompressedSync + 5, // 21: quilibrium.node.data.pb.DataService.NegotiateCompressedSyncFrames:output_type -> quilibrium.node.data.pb.DataCompressedSyncResponseMessage + 19, // 22: quilibrium.node.data.pb.DataService.GetPublicChannel:output_type -> quilibrium.node.channel.pb.P2PChannelEnvelope + 10, // 23: quilibrium.node.data.pb.DataService.GetDataFrame:output_type -> quilibrium.node.data.pb.DataFrameResponse + 11, // 24: quilibrium.node.data.pb.DataService.HandlePreMidnightMint:output_type -> quilibrium.node.data.pb.PreMidnightMintResponse + 11, // 25: quilibrium.node.data.pb.DataService.GetPreMidnightMintStatus:output_type -> quilibrium.node.data.pb.PreMidnightMintResponse + 14, // 26: quilibrium.node.data.pb.DataIPCService.CalculateChallengeProof:output_type -> quilibrium.node.data.pb.ChallengeProofResponse + 20, // [20:27] is the sub-list for method output_type + 13, // [13:20] is the sub-list for method input_type 13, // [13:13] is the sub-list for extension type_name 13, // [13:13] is the sub-list for extension extendee 0, // [0:13] is the sub-list for field type_name @@ -1132,6 +1266,7 @@ func file_data_proto_init() { file_channel_proto_init() file_clock_proto_init() file_keys_proto_init() + file_node_proto_init() if !protoimpl.UnsafeEnabled { file_data_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DataPeerListAnnounce); i { @@ -1266,7 +1401,7 @@ func file_data_proto_init() { } } file_data_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ChallengeProofRequest); i { + switch v := v.(*PreMidnightMintResponse); i { case 0: return &v.state case 1: @@ -1278,6 +1413,30 @@ func file_data_proto_init() { } } file_data_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PreMidnightMintStatusRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_data_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ChallengeProofRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_data_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ChallengeProofResponse); i { case 0: return &v.state @@ -1305,7 +1464,7 @@ func file_data_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_data_proto_rawDesc, NumEnums: 0, - NumMessages: 13, + NumMessages: 15, NumExtensions: 0, NumServices: 2, }, diff --git a/node/protobufs/data.pb.gw.go b/node/protobufs/data.pb.gw.go index eaff4fc..9ecb32a 100644 --- a/node/protobufs/data.pb.gw.go +++ b/node/protobufs/data.pb.gw.go @@ -176,6 +176,74 @@ func local_request_DataService_GetDataFrame_0(ctx context.Context, marshaler run } +func request_DataService_HandlePreMidnightMint_0(ctx context.Context, marshaler runtime.Marshaler, client DataServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MintCoinRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.HandlePreMidnightMint(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_DataService_HandlePreMidnightMint_0(ctx context.Context, marshaler runtime.Marshaler, server DataServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MintCoinRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.HandlePreMidnightMint(ctx, &protoReq) + return msg, metadata, err + +} + +func request_DataService_GetPreMidnightMintStatus_0(ctx context.Context, marshaler runtime.Marshaler, client DataServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq PreMidnightMintStatusRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetPreMidnightMintStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_DataService_GetPreMidnightMintStatus_0(ctx context.Context, marshaler runtime.Marshaler, server DataServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq PreMidnightMintStatusRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetPreMidnightMintStatus(ctx, &protoReq) + return msg, metadata, err + +} + func request_DataIPCService_CalculateChallengeProof_0(ctx context.Context, marshaler runtime.Marshaler, client DataIPCServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq ChallengeProofRequest var metadata runtime.ServerMetadata @@ -262,6 +330,56 @@ func RegisterDataServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux }) + mux.Handle("POST", pattern_DataService_HandlePreMidnightMint_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/quilibrium.node.data.pb.DataService/HandlePreMidnightMint", runtime.WithHTTPPathPattern("/quilibrium.node.data.pb.DataService/HandlePreMidnightMint")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DataService_HandlePreMidnightMint_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_DataService_HandlePreMidnightMint_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_DataService_GetPreMidnightMintStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/quilibrium.node.data.pb.DataService/GetPreMidnightMintStatus", runtime.WithHTTPPathPattern("/quilibrium.node.data.pb.DataService/GetPreMidnightMintStatus")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DataService_GetPreMidnightMintStatus_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_DataService_GetPreMidnightMintStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -425,6 +543,50 @@ func RegisterDataServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux }) + mux.Handle("POST", pattern_DataService_HandlePreMidnightMint_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/quilibrium.node.data.pb.DataService/HandlePreMidnightMint", runtime.WithHTTPPathPattern("/quilibrium.node.data.pb.DataService/HandlePreMidnightMint")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DataService_HandlePreMidnightMint_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_DataService_HandlePreMidnightMint_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_DataService_GetPreMidnightMintStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/quilibrium.node.data.pb.DataService/GetPreMidnightMintStatus", runtime.WithHTTPPathPattern("/quilibrium.node.data.pb.DataService/GetPreMidnightMintStatus")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DataService_GetPreMidnightMintStatus_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_DataService_GetPreMidnightMintStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -436,6 +598,10 @@ var ( pattern_DataService_GetPublicChannel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"quilibrium.node.data.pb.DataService", "GetPublicChannel"}, "")) pattern_DataService_GetDataFrame_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"quilibrium.node.data.pb.DataService", "GetDataFrame"}, "")) + + pattern_DataService_HandlePreMidnightMint_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"quilibrium.node.data.pb.DataService", "HandlePreMidnightMint"}, "")) + + pattern_DataService_GetPreMidnightMintStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"quilibrium.node.data.pb.DataService", "GetPreMidnightMintStatus"}, "")) ) var ( @@ -446,6 +612,10 @@ var ( forward_DataService_GetPublicChannel_0 = runtime.ForwardResponseStream forward_DataService_GetDataFrame_0 = runtime.ForwardResponseMessage + + forward_DataService_HandlePreMidnightMint_0 = runtime.ForwardResponseMessage + + forward_DataService_GetPreMidnightMintStatus_0 = runtime.ForwardResponseMessage ) // RegisterDataIPCServiceHandlerFromEndpoint is same as RegisterDataIPCServiceHandler but diff --git a/node/protobufs/data.proto b/node/protobufs/data.proto index fce0f47..518ab1a 100644 --- a/node/protobufs/data.proto +++ b/node/protobufs/data.proto @@ -7,6 +7,7 @@ option go_package = "source.quilibrium.com/quilibrium/monorepo/node/protobufs"; import "channel.proto"; import "clock.proto"; import "keys.proto"; +import "node.proto"; message DataPeerListAnnounce { repeated DataPeer peer_list = 1; @@ -78,11 +79,22 @@ message DataFrameResponse { bytes proof = 2; } +message PreMidnightMintResponse { + bytes address = 1; + uint32 increment = 2; +} + +message PreMidnightMintStatusRequest { + bytes owner = 1; +} + service DataService { rpc GetCompressedSyncFrames (quilibrium.node.clock.pb.ClockFramesRequest) returns (stream DataCompressedSync); rpc NegotiateCompressedSyncFrames (stream DataCompressedSyncRequestMessage) returns (stream DataCompressedSyncResponseMessage); rpc GetPublicChannel (stream quilibrium.node.channel.pb.P2PChannelEnvelope) returns (stream quilibrium.node.channel.pb.P2PChannelEnvelope); rpc GetDataFrame (GetDataFrameRequest) returns (DataFrameResponse); + rpc HandlePreMidnightMint (quilibrium.node.node.pb.MintCoinRequest) returns (PreMidnightMintResponse); + rpc GetPreMidnightMintStatus (PreMidnightMintStatusRequest) returns (PreMidnightMintResponse); } message ChallengeProofRequest { diff --git a/node/protobufs/data_grpc.pb.go b/node/protobufs/data_grpc.pb.go index 070803d..6589132 100644 --- a/node/protobufs/data_grpc.pb.go +++ b/node/protobufs/data_grpc.pb.go @@ -23,6 +23,8 @@ const ( DataService_NegotiateCompressedSyncFrames_FullMethodName = "/quilibrium.node.data.pb.DataService/NegotiateCompressedSyncFrames" DataService_GetPublicChannel_FullMethodName = "/quilibrium.node.data.pb.DataService/GetPublicChannel" DataService_GetDataFrame_FullMethodName = "/quilibrium.node.data.pb.DataService/GetDataFrame" + DataService_HandlePreMidnightMint_FullMethodName = "/quilibrium.node.data.pb.DataService/HandlePreMidnightMint" + DataService_GetPreMidnightMintStatus_FullMethodName = "/quilibrium.node.data.pb.DataService/GetPreMidnightMintStatus" ) // DataServiceClient is the client API for DataService service. @@ -33,6 +35,8 @@ type DataServiceClient interface { NegotiateCompressedSyncFrames(ctx context.Context, opts ...grpc.CallOption) (DataService_NegotiateCompressedSyncFramesClient, error) GetPublicChannel(ctx context.Context, opts ...grpc.CallOption) (DataService_GetPublicChannelClient, error) GetDataFrame(ctx context.Context, in *GetDataFrameRequest, opts ...grpc.CallOption) (*DataFrameResponse, error) + HandlePreMidnightMint(ctx context.Context, in *MintCoinRequest, opts ...grpc.CallOption) (*PreMidnightMintResponse, error) + GetPreMidnightMintStatus(ctx context.Context, in *PreMidnightMintStatusRequest, opts ...grpc.CallOption) (*PreMidnightMintResponse, error) } type dataServiceClient struct { @@ -146,6 +150,24 @@ func (c *dataServiceClient) GetDataFrame(ctx context.Context, in *GetDataFrameRe return out, nil } +func (c *dataServiceClient) HandlePreMidnightMint(ctx context.Context, in *MintCoinRequest, opts ...grpc.CallOption) (*PreMidnightMintResponse, error) { + out := new(PreMidnightMintResponse) + err := c.cc.Invoke(ctx, DataService_HandlePreMidnightMint_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *dataServiceClient) GetPreMidnightMintStatus(ctx context.Context, in *PreMidnightMintStatusRequest, opts ...grpc.CallOption) (*PreMidnightMintResponse, error) { + out := new(PreMidnightMintResponse) + err := c.cc.Invoke(ctx, DataService_GetPreMidnightMintStatus_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // DataServiceServer is the server API for DataService service. // All implementations must embed UnimplementedDataServiceServer // for forward compatibility @@ -154,6 +176,8 @@ type DataServiceServer interface { NegotiateCompressedSyncFrames(DataService_NegotiateCompressedSyncFramesServer) error GetPublicChannel(DataService_GetPublicChannelServer) error GetDataFrame(context.Context, *GetDataFrameRequest) (*DataFrameResponse, error) + HandlePreMidnightMint(context.Context, *MintCoinRequest) (*PreMidnightMintResponse, error) + GetPreMidnightMintStatus(context.Context, *PreMidnightMintStatusRequest) (*PreMidnightMintResponse, error) mustEmbedUnimplementedDataServiceServer() } @@ -173,6 +197,12 @@ func (UnimplementedDataServiceServer) GetPublicChannel(DataService_GetPublicChan func (UnimplementedDataServiceServer) GetDataFrame(context.Context, *GetDataFrameRequest) (*DataFrameResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetDataFrame not implemented") } +func (UnimplementedDataServiceServer) HandlePreMidnightMint(context.Context, *MintCoinRequest) (*PreMidnightMintResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method HandlePreMidnightMint not implemented") +} +func (UnimplementedDataServiceServer) GetPreMidnightMintStatus(context.Context, *PreMidnightMintStatusRequest) (*PreMidnightMintResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPreMidnightMintStatus not implemented") +} func (UnimplementedDataServiceServer) mustEmbedUnimplementedDataServiceServer() {} // UnsafeDataServiceServer may be embedded to opt out of forward compatibility for this service. @@ -277,6 +307,42 @@ func _DataService_GetDataFrame_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _DataService_HandlePreMidnightMint_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MintCoinRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DataServiceServer).HandlePreMidnightMint(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DataService_HandlePreMidnightMint_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DataServiceServer).HandlePreMidnightMint(ctx, req.(*MintCoinRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DataService_GetPreMidnightMintStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PreMidnightMintStatusRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DataServiceServer).GetPreMidnightMintStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DataService_GetPreMidnightMintStatus_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DataServiceServer).GetPreMidnightMintStatus(ctx, req.(*PreMidnightMintStatusRequest)) + } + return interceptor(ctx, in, info, handler) +} + // DataService_ServiceDesc is the grpc.ServiceDesc for DataService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -288,6 +354,14 @@ var DataService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetDataFrame", Handler: _DataService_GetDataFrame_Handler, }, + { + MethodName: "HandlePreMidnightMint", + Handler: _DataService_HandlePreMidnightMint_Handler, + }, + { + MethodName: "GetPreMidnightMintStatus", + Handler: _DataService_GetPreMidnightMintStatus_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/node/store/clock.go b/node/store/clock.go index 2c6653a..3ca41c3 100644 --- a/node/store/clock.go +++ b/node/store/clock.go @@ -1027,24 +1027,6 @@ func (p *PebbleClockStore) Compact( } if !cleared { - // If this node has been around since the early days, this is going to free - // up a lot of cruft. - if err := p.db.DeleteRange( - clockDataCandidateFrameKey( - make([]byte, 32), - 0, - make([]byte, 32), - make([]byte, 32), - ), - clockDataCandidateFrameKey( - bytes.Repeat([]byte{0xff}, 32), - 1000000, - bytes.Repeat([]byte{0xff}, 32), - bytes.Repeat([]byte{0xff}, 32), - ), - ); err != nil { - return errors.Wrap(err, "compact") - } if err := p.db.Compact( clockDataCandidateFrameKey( make([]byte, 32), diff --git a/node/store/coin.go b/node/store/coin.go index 469298b..6761698 100644 --- a/node/store/coin.go +++ b/node/store/coin.go @@ -3,6 +3,7 @@ package store import ( "bytes" "encoding/binary" + "encoding/hex" "io" "github.com/cockroachdb/pebble" @@ -46,8 +47,7 @@ type CoinStore interface { ) error GetLatestFrameProcessed() (uint64, error) SetLatestFrameProcessed(txn Transaction, frameNumber uint64) error - SetMigrationVersion() error - Migrate(filter []byte) error + Migrate(filter []byte, genesisSeedHex string) error } var _ CoinStore = (*PebbleCoinStore)(nil) @@ -73,6 +73,7 @@ const ( COIN_BY_ADDRESS = 0x00 COIN_BY_OWNER = 0x01 MIGRATION = 0x02 + GENESIS = 0xFE LATEST_EXECUTION = 0xFF ) @@ -110,6 +111,10 @@ func migrationKey() []byte { return []byte{COIN, MIGRATION} } +func genesisSeedKey() []byte { + return []byte{COIN, GENESIS} +} + func (p *PebbleCoinStore) NewTransaction() (Transaction, error) { return p.db.NewBatch(), nil } @@ -388,15 +393,119 @@ func (p *PebbleCoinStore) SetLatestFrameProcessed( return nil } -func (p *PebbleCoinStore) SetMigrationVersion() error { - if err := p.db.Set(migrationKey(), []byte{0x02, 0x00, 0x01, 0x03}); err != nil { - return errors.Wrap(err, "set migration version") +func (p *PebbleCoinStore) internalMigrate( + filter []byte, + genesisSeed []byte, +) error { + p.logger.Warn("incompatible state change detected, performing migration") + err := p.db.DeleteRange( + coinByOwnerKey( + bytes.Repeat([]byte{0x00}, 32), + bytes.Repeat([]byte{0x00}, 32), + ), + coinByOwnerKey( + bytes.Repeat([]byte{0xff}, 32), + bytes.Repeat([]byte{0xff}, 32), + ), + ) + if err != nil { + panic(err) + } + err = p.db.DeleteRange( + coinKey( + bytes.Repeat([]byte{0x00}, 32), + ), + coinKey( + bytes.Repeat([]byte{0xff}, 32), + ), + ) + if err != nil { + panic(err) + } + err = p.db.DeleteRange( + proofByOwnerKey( + bytes.Repeat([]byte{0x00}, 32), + bytes.Repeat([]byte{0x00}, 32), + ), + proofByOwnerKey( + bytes.Repeat([]byte{0xff}, 32), + bytes.Repeat([]byte{0xff}, 32), + ), + ) + if err != nil { + panic(err) + } + err = p.db.DeleteRange( + proofKey( + bytes.Repeat([]byte{0x00}, 32), + ), + proofKey( + bytes.Repeat([]byte{0xff}, 32), + ), + ) + if err != nil { + panic(err) + } + if err := p.db.DeleteRange( + clockDataFrameKey(filter, 0), + clockDataFrameKey(filter, 200000), + ); err != nil { + panic(err) } - return nil + if err := p.db.Delete(clockDataEarliestIndex(filter)); err != nil { + panic(err) + } + if err := p.db.Delete(clockDataLatestIndex(filter)); err != nil { + panic(err) + } + if err := p.db.Delete(clockMasterEarliestIndex( + make([]byte, 32), + )); err != nil { + panic(err) + } + if err := p.db.Delete(clockMasterLatestIndex(make([]byte, 32))); err != nil { + panic(err) + } + + txn, err := p.NewTransaction() + if err != nil { + return nil + } + + err = txn.Set(migrationKey(), []byte{0x02, 0x00, 0x01, 0x04}) + if err != nil { + panic(err) + } + + err = txn.Set(genesisSeedKey(), genesisSeed) + if err != nil { + panic(err) + } + + return txn.Commit() } -func (p *PebbleCoinStore) Migrate(filter []byte) error { +func (p *PebbleCoinStore) Migrate(filter []byte, genesisSeedHex string) error { + seed, err := hex.DecodeString(genesisSeedHex) + if err != nil { + return errors.Wrap(err, "migrate") + } + + compare, closer, err := p.db.Get(genesisSeedKey()) + if err != nil { + if !errors.Is(err, pebble.ErrNotFound) { + return errors.Wrap(err, "migrate") + } + return p.internalMigrate(filter, seed) + } + + if !bytes.Equal(compare, seed) { + return p.internalMigrate(filter, seed) + } + + closer.Close() + status, closer, err := p.db.Get(migrationKey()) if err != nil { if !errors.Is(err, pebble.ErrNotFound) { @@ -408,88 +517,17 @@ func (p *PebbleCoinStore) Migrate(filter []byte) error { return nil } - err = txn.Set(migrationKey(), []byte{0x02, 0x00, 0x01, 0x03}) + err = txn.Set(migrationKey(), []byte{0x02, 0x00, 0x01, 0x04}) if err != nil { panic(err) } return txn.Commit() } else { defer closer.Close() - if len(status) == 4 && bytes.Compare(status, []byte{0x02, 0x00, 0x01, 0x03}) > 0 { + if len(status) == 4 && bytes.Compare(status, []byte{0x02, 0x00, 0x01, 0x04}) > 0 { panic("database has been migrated to a newer version, do not rollback") - } else if len(status) == 3 || bytes.Compare(status, []byte{0x02, 0x00, 0x01, 0x03}) < 0 { - err = p.db.DeleteRange( - coinByOwnerKey( - bytes.Repeat([]byte{0x00}, 32), - bytes.Repeat([]byte{0x00}, 32), - ), - coinByOwnerKey( - bytes.Repeat([]byte{0xff}, 32), - bytes.Repeat([]byte{0xff}, 32), - ), - ) - if err != nil { - panic(err) - } - err = p.db.DeleteRange( - coinKey( - bytes.Repeat([]byte{0x00}, 32), - ), - coinKey( - bytes.Repeat([]byte{0xff}, 32), - ), - ) - if err != nil { - panic(err) - } - err = p.db.DeleteRange( - proofByOwnerKey( - bytes.Repeat([]byte{0x00}, 32), - bytes.Repeat([]byte{0x00}, 32), - ), - proofByOwnerKey( - bytes.Repeat([]byte{0xff}, 32), - bytes.Repeat([]byte{0xff}, 32), - ), - ) - if err != nil { - panic(err) - } - err = p.db.DeleteRange( - proofKey( - bytes.Repeat([]byte{0x00}, 32), - ), - proofKey( - bytes.Repeat([]byte{0xff}, 32), - ), - ) - if err != nil { - panic(err) - } - if err := p.db.DeleteRange( - clockDataFrameKey(filter, 0), - clockDataFrameKey(filter, 200000), - ); err != nil { - panic(err) - } - - if err := p.db.Delete(clockDataEarliestIndex(filter)); err != nil { - panic(err) - } - if err := p.db.Delete(clockDataLatestIndex(filter)); err != nil { - panic(err) - } - - txn, err := p.NewTransaction() - if err != nil { - return nil - } - - err = txn.Set(migrationKey(), []byte{0x02, 0x00, 0x01, 0x03}) - if err != nil { - panic(err) - } - return txn.Commit() + } else if len(status) == 3 || bytes.Compare(status, []byte{0x02, 0x00, 0x01, 0x04}) < 0 { + return p.internalMigrate(filter, seed) } return nil }