-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implementation is splitted into several files: #### protocol.go implements protocol execution logic close to the original paper, baring several differences in syntax and things that we need but are not covered in the paper. interface for interacting with protocol has two methods: - onMessage - next(active bool) only active nodes are publishing messages #### types.go types that go over the wire ```go type Message struct { Body Sender types.NodeID Signature types.EdSignature } type Body struct { Layer types.LayerID IterRound Value Value Eligibility types.HareEligibility } type Value struct { // Proposals is set in messages for preround and propose rounds. Proposals []types.ProposalID `scale:"max=200"` // Reference is set in messages for commit and notify rounds. Reference *types.Hash32 } ``` signature domain and malfeasance proof remains the same, as we don't intend to run more than one hare in parallel. #### hare.go integrates protocol with spacemesh data model, network, synchronization. manages multiple protocol instances (one per layer). #### legacy_oracle.go wrapper for oracle that uses active set in consensus, it outputs maximum grades for identities that are in consensus and 0 for everyone else. #### compat intergration for weakcoin and hare results to avoid changes across the app remaining: - [ ] test commit with different locked value in protocol_test.go (remaining for 100%)
- Loading branch information
Showing
23 changed files
with
3,171 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package compat | ||
|
||
import ( | ||
"context" | ||
|
||
"go.uber.org/zap" | ||
|
||
"github.com/spacemeshos/go-spacemesh/hare" | ||
"github.com/spacemeshos/go-spacemesh/hare3" | ||
) | ||
|
||
func ReportResult(ctx context.Context, logger *zap.Logger, from <-chan hare3.ConsensusOutput, to chan<- hare.LayerOutput) { | ||
for { | ||
select { | ||
case <-ctx.Done(): | ||
logger.Info("hare3 results reporter exited") | ||
return | ||
case out := <-from: | ||
select { | ||
case to <- hare.LayerOutput{ | ||
Ctx: ctx, | ||
Layer: out.Layer, | ||
Proposals: out.Proposals, | ||
}: | ||
case <-ctx.Done(): | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package compat | ||
|
||
import ( | ||
"context" | ||
|
||
"go.uber.org/zap" | ||
|
||
"github.com/spacemeshos/go-spacemesh/common/types" | ||
"github.com/spacemeshos/go-spacemesh/hare3" | ||
) | ||
|
||
type weakCoin interface { | ||
Set(types.LayerID, bool) error | ||
} | ||
|
||
func ReportWeakcoin(ctx context.Context, logger *zap.Logger, from <-chan hare3.WeakCoinOutput, to weakCoin) { | ||
for { | ||
select { | ||
case <-ctx.Done(): | ||
logger.Info("weak coin reporter exited") | ||
return | ||
case out := <-from: | ||
if err := to.Set(out.Layer, out.Coin); err != nil { | ||
logger.Error("failed to update weakcoin", | ||
zap.Uint32("lid", out.Layer.Uint32()), | ||
zap.Error(err), | ||
) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.