From 042848e7cb672d43efe2a6f5008562aefb502e8c Mon Sep 17 00:00:00 2001 From: Cassandra Heart Date: Sat, 9 Nov 2024 16:04:12 -0600 Subject: [PATCH] minor nice-to-haves --- node/config/engine.go | 3 + .../data/data_clock_consensus_engine.go | 73 ++++++++++--------- 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/node/config/engine.go b/node/config/engine.go index 028a2a5..3c72803 100644 --- a/node/config/engine.go +++ b/node/config/engine.go @@ -21,6 +21,9 @@ type EngineConfig struct { MultisigProverEnrollmentPaths []string `yaml:"multisigProverEnrollmentPaths"` // Does not verify execution, enables light provers LightNode bool + // Automatically merges coins after minting once a sufficient number has been + // accrued + AutoMergeCoins bool // Values used only for testing – do not override these in production, your // node will get kicked out diff --git a/node/consensus/data/data_clock_consensus_engine.go b/node/consensus/data/data_clock_consensus_engine.go index fa585ac..6aa9565 100644 --- a/node/consensus/data/data_clock_consensus_engine.go +++ b/node/consensus/data/data_clock_consensus_engine.go @@ -616,8 +616,7 @@ func (e *DataClockConsensusEngine) Start() <-chan error { for i, trie := range e.GetFrameProverTries()[1:] { if trie.Contains(peerProvingKeyAddress) { - e.logger.Info("creating data shard ring proof", zap.Int("ring", i)) - outputs := e.PerformTimeProof(frame, frame.Difficulty) + outputs := e.PerformTimeProof(frame, frame.Difficulty, i) if outputs == nil || len(outputs) < 3 { e.logger.Error("could not successfully build proof, reattempting") break @@ -659,44 +658,46 @@ func (e *DataClockConsensusEngine) Start() <-chan error { }, }) - _, addrs, _, err := e.coinStore.GetCoinsForOwner( - peerProvingKeyAddress, - ) - if err != nil { - e.logger.Error( - "received error while iterating coins", - zap.Error(err), + if e.config.Engine.AutoMergeCoins { + _, addrs, _, err := e.coinStore.GetCoinsForOwner( + peerProvingKeyAddress, ) - break - } - - if len(addrs) > 10 { - message := []byte("merge") - refs := []*protobufs.CoinRef{} - for _, addr := range addrs { - message = append(message, addr...) - refs = append(refs, &protobufs.CoinRef{ - Address: addr, - }) + if err != nil { + e.logger.Error( + "received error while iterating coins", + zap.Error(err), + ) + break } - sig, _ := e.pubSub.SignMessage( - message, - ) + if len(addrs) > 25 { + message := []byte("merge") + refs := []*protobufs.CoinRef{} + for _, addr := range addrs { + message = append(message, addr...) + refs = append(refs, &protobufs.CoinRef{ + Address: addr, + }) + } - e.publishMessage(e.txFilter, &protobufs.TokenRequest{ - Request: &protobufs.TokenRequest_Merge{ - Merge: &protobufs.MergeCoinRequest{ - Coins: refs, - Signature: &protobufs.Ed448Signature{ - PublicKey: &protobufs.Ed448PublicKey{ - KeyValue: e.pubSub.GetPublicKey(), + sig, _ := e.pubSub.SignMessage( + message, + ) + + e.publishMessage(e.txFilter, &protobufs.TokenRequest{ + Request: &protobufs.TokenRequest_Merge{ + Merge: &protobufs.MergeCoinRequest{ + Coins: refs, + Signature: &protobufs.Ed448Signature{ + PublicKey: &protobufs.Ed448PublicKey{ + KeyValue: e.pubSub.GetPublicKey(), + }, + Signature: sig, }, - Signature: sig, }, }, - }, - }) + }) + } } break @@ -711,6 +712,7 @@ func (e *DataClockConsensusEngine) Start() <-chan error { func (e *DataClockConsensusEngine) PerformTimeProof( frame *protobufs.ClockFrame, difficulty uint32, + ring int, ) []mt.DataBlock { type clientInfo struct { client protobufs.DataIPCServiceClient @@ -728,6 +730,11 @@ func (e *DataClockConsensusEngine) PerformTimeProof( } } output := make([]mt.DataBlock, len(actives)) + e.logger.Info( + "creating data shard ring proof", + zap.Int("ring", ring), + zap.Int("active_workers", len(actives)), + ) wg := sync.WaitGroup{} wg.Add(len(actives))