Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ConsenSys/handel
Browse files Browse the repository at this point in the history
  • Loading branch information
nikkolasg committed May 21, 2019
2 parents 038abae + 838cc67 commit 0373ba7
Show file tree
Hide file tree
Showing 11 changed files with 240 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Handel is a fast multi-signature aggregation protocol for large Byzantine
committees. This is the reference implementation in Go.

You can find the [slides](https://docs.google.com/presentation/d/1fL0mBF5At4ojW0HhbvBQ2yJHA3_q8q8kiioC6WvY9g4/edit?usp=sharing) presented at [Stanford Blockchain Conference 2019](https://cyber.stanford.edu/sbc19
You can find the [slides](https://docs.google.com/presentation/d/1fL0mBF5At4ojW0HhbvBQ2yJHA3_q8q8kiioC6WvY9g4/edit?usp=sharing) presented at [Stanford Blockchain Conference 2019](https://cyber.stanford.edu/sbc19)

This implementation was used to demonstrate the results presented at SBC19, aggregating BLS signatures on 4000 hande nodes.
Its designed to be easily extensible, with interfaces for add aggregations methods, curves, etc.
Expand Down
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Config struct {

// NewEvaluatorStrategy returns the signature evaluator to use during the
// Handel round.
NewEvaluatorStrategy func(s signatureStore, h *Handel) SigEvaluator
NewEvaluatorStrategy func(s SignatureStore, h *Handel) SigEvaluator

// NewTimeoutStrategy returns the Timeout strategy to use during the Handel
// round. By default, it uses the linear timeout strategy.
Expand Down Expand Up @@ -107,7 +107,7 @@ var DefaultPartitioner = func(id int32, reg Registry, logger Logger) Partitioner

// DefaultEvaluatorStrategy returns an evaluator based on the store's own
// evaluation strategy.
var DefaultEvaluatorStrategy = func(store signatureStore, h *Handel) SigEvaluator {
var DefaultEvaluatorStrategy = func(store SignatureStore, h *Handel) SigEvaluator {
return newEvaluatorStore(store)
}

Expand Down
2 changes: 1 addition & 1 deletion handel.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ type Handel struct {
// signature over the message
sig Signature
// signature store with different merging/caching strategy
store signatureStore
store SignatureStore
// processing of signature - verification strategy
proc signatureProcessing
// all actors registered that acts on a new signature
Expand Down
9 changes: 5 additions & 4 deletions processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type incomingSig struct {
func (is *incomingSig) Individual() bool {
return is.isInd
}

// signatureProcessing is an interface responsible for verifying incoming
// multi-signature. It can decides to drop some incoming signatures if deemed
// useless. It outputs verified signatures to the main handel processing logic
Expand Down Expand Up @@ -77,15 +78,15 @@ func newEvaluator1() SigEvaluator {

// EvaluatorStore is a wrapper around the store's evaluate strategy.
type EvaluatorStore struct {
store signatureStore
store SignatureStore
}

// Evaluate implements the SigEvaluator strategy.
func (f *EvaluatorStore) Evaluate(sp *incomingSig) int {
return f.store.Evaluate(sp)
}

func newEvaluatorStore(store signatureStore) SigEvaluator {
func newEvaluatorStore(store SignatureStore) SigEvaluator {
return &EvaluatorStore{store: store}
}

Expand Down Expand Up @@ -334,7 +335,7 @@ func (f *evaluatorProcessing) verifyAndPublish(sp *incomingSig) {
// fifo queue, verifying all incoming signatures, not matter relevant or not.
type fifoProcessing struct {
sync.Mutex
store signatureStore
store SignatureStore
part Partitioner
cons Constructor
msg []byte
Expand All @@ -346,7 +347,7 @@ type fifoProcessing struct {
// newFifoProcessing returns a signatureProcessing implementation using a fifo
// queue. It needs the store to store the valid signatures, the partitioner +
// constructor + msg to verify the signatures.
func newFifoProcessing(store signatureStore, part Partitioner,
func newFifoProcessing(store SignatureStore, part Partitioner,
c Constructor, msg []byte) signatureProcessing {
return &fifoProcessing{
part: part,
Expand Down
8 changes: 4 additions & 4 deletions report.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,22 @@ func (r *ReportHandel) Processing() Reporter {

// ReportStore is a Store that can report some statistics about the storage
type ReportStore struct {
signatureStore
SignatureStore
sucessReplaced int64
replacedTrial int64
}

// newReportStore returns a signatureStore with som eadditional reporting
// capabilities
func newReportStore(s signatureStore) signatureStore {
func newReportStore(s SignatureStore) SignatureStore {
return &ReportStore{
signatureStore: s,
SignatureStore: s,
}
}

// Store implements the signatureStore interface
func (r *ReportStore) Store(sp *incomingSig) *MultiSignature {
ms := r.signatureStore.Store(sp)
ms := r.SignatureStore.Store(sp)
if ms != nil {
r.sucessReplaced++
} else {
Expand Down
34 changes: 34 additions & 0 deletions simul/confgenerator/confgenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func main() {
//baseNodes := []int{100, 300, 500, 1000, 1500, 2000, 2500,4000 3000, 4000}
baseNodes := []int{100, 300, 500, 1000, 1500, 2000}

evaluatorScenario(configDir, defaultConf, handel, baseNodes, getProcessF(2))
nodeCountScenario(configDir, defaultConf, handel, baseNodes, getProcessF(1))
updateCountScenario(configDir, defaultConf, handel, baseNodes, getProcessF(1))
practicalScenario(configDir, defaultConf, handel, baseNodes, thresholdProcessF(2000))
Expand All @@ -65,6 +66,39 @@ func main() {
timeoutIncScenario(configDir, defaultConf, handel, baseNodes, fixedProcesses)
periodIncScenario(configDir, defaultConf, handel, baseNodes, fixedProcesses)
}
func evaluatorScenario(dir string, defaultConf lib.Config, handel *lib.HandelConfig, baseNodes []int, procF func(int) int) {
nodes := baseNodes
thr := 0.99
failing := 0
evaluators := []string{"store", "equal"}
for _, evaluator := range evaluators {
var runs []lib.RunConfig
for _, node := range nodes {
handelConf := &lib.HandelConfig{
Period: handel.Period,
UpdateCount: handel.UpdateCount,
NodeCount: handel.NodeCount,
Timeout: handel.Timeout,
UnsafeSleepTimeOnSigVerify: handel.UnsafeSleepTimeOnSigVerify,
Evaluator: evaluator,
}

run := lib.RunConfig{
Nodes: node,
Threshold: thrF(thr)(node),
Failing: failing,
Processes: procF(node),
Handel: handelConf,
}
runs = append(runs, run)
}
defaultConf.Runs = runs
fileName := fmt.Sprintf("2000evaluator_%s.toml", evaluator)
if err := defaultConf.WriteTo(filepath.Join(dir, fileName)); err != nil {
panic(err)
}
}
}
func nodeCountScenario(dir string, defaultConf lib.Config, handel *lib.HandelConfig, baseNodes []int, procF func(int) int) {
nodes := baseNodes
thr := 0.99
Expand Down
88 changes: 88 additions & 0 deletions simul/confgenerator/final_configs/2000evaluator_equal.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
Network = "udp"
Curve = "bn256"
Encoding = "gob"
Allocator = "random"
MonitorPort = 10000
Debug = 0
Simulation = "handel"
MaxTimeout = "5m"
Retrials = 1
ResultFile = ""

[[Runs]]
Nodes = 100
Threshold = 99
Failing = 0
Processes = 50
[Runs.Handel]
Period = "50ms"
UpdateCount = 1
NodeCount = 10
Timeout = "50ms"
UnsafeSleepTimeOnSigVerify = 0
Evaluator = "equal"

[[Runs]]
Nodes = 300
Threshold = 297
Failing = 0
Processes = 150
[Runs.Handel]
Period = "50ms"
UpdateCount = 1
NodeCount = 10
Timeout = "50ms"
UnsafeSleepTimeOnSigVerify = 0
Evaluator = "equal"

[[Runs]]
Nodes = 500
Threshold = 495
Failing = 0
Processes = 250
[Runs.Handel]
Period = "50ms"
UpdateCount = 1
NodeCount = 10
Timeout = "50ms"
UnsafeSleepTimeOnSigVerify = 0
Evaluator = "equal"

[[Runs]]
Nodes = 1000
Threshold = 990
Failing = 0
Processes = 500
[Runs.Handel]
Period = "50ms"
UpdateCount = 1
NodeCount = 10
Timeout = "50ms"
UnsafeSleepTimeOnSigVerify = 0
Evaluator = "equal"

[[Runs]]
Nodes = 1500
Threshold = 1485
Failing = 0
Processes = 750
[Runs.Handel]
Period = "50ms"
UpdateCount = 1
NodeCount = 10
Timeout = "50ms"
UnsafeSleepTimeOnSigVerify = 0
Evaluator = "equal"

[[Runs]]
Nodes = 2000
Threshold = 1980
Failing = 0
Processes = 1000
[Runs.Handel]
Period = "50ms"
UpdateCount = 1
NodeCount = 10
Timeout = "50ms"
UnsafeSleepTimeOnSigVerify = 0
Evaluator = "equal"
88 changes: 88 additions & 0 deletions simul/confgenerator/final_configs/2000evaluator_store.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
Network = "udp"
Curve = "bn256"
Encoding = "gob"
Allocator = "random"
MonitorPort = 10000
Debug = 0
Simulation = "handel"
MaxTimeout = "5m"
Retrials = 1
ResultFile = ""

[[Runs]]
Nodes = 100
Threshold = 99
Failing = 0
Processes = 50
[Runs.Handel]
Period = "50ms"
UpdateCount = 1
NodeCount = 10
Timeout = "50ms"
UnsafeSleepTimeOnSigVerify = 0
Evaluator = "store"

[[Runs]]
Nodes = 300
Threshold = 297
Failing = 0
Processes = 150
[Runs.Handel]
Period = "50ms"
UpdateCount = 1
NodeCount = 10
Timeout = "50ms"
UnsafeSleepTimeOnSigVerify = 0
Evaluator = "store"

[[Runs]]
Nodes = 500
Threshold = 495
Failing = 0
Processes = 250
[Runs.Handel]
Period = "50ms"
UpdateCount = 1
NodeCount = 10
Timeout = "50ms"
UnsafeSleepTimeOnSigVerify = 0
Evaluator = "store"

[[Runs]]
Nodes = 1000
Threshold = 990
Failing = 0
Processes = 500
[Runs.Handel]
Period = "50ms"
UpdateCount = 1
NodeCount = 10
Timeout = "50ms"
UnsafeSleepTimeOnSigVerify = 0
Evaluator = "store"

[[Runs]]
Nodes = 1500
Threshold = 1485
Failing = 0
Processes = 750
[Runs.Handel]
Period = "50ms"
UpdateCount = 1
NodeCount = 10
Timeout = "50ms"
UnsafeSleepTimeOnSigVerify = 0
Evaluator = "store"

[[Runs]]
Nodes = 2000
Threshold = 1980
Failing = 0
Processes = 1000
[Runs.Handel]
Period = "50ms"
UpdateCount = 1
NodeCount = 10
Timeout = "50ms"
UnsafeSleepTimeOnSigVerify = 0
Evaluator = "store"
1 change: 1 addition & 0 deletions simul/config_example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Retrials = 1
NodeCount = 10
Timeout = "50ms"
UnsafeSleepTimeOnSigVerify = 0
Evaluator = "store"
9 changes: 9 additions & 0 deletions simul/lib/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ type HandelConfig struct {
Timeout string
// UnsafeSleepTimeOnSigVerify
UnsafeSleepTimeOnSigVerify int

// which queue evaluator are we choosing
Evaluator string
}

// LoadConfig looks up the given file to unmarshal a TOML encoded Config.
Expand Down Expand Up @@ -306,6 +309,12 @@ func (r *RunConfig) GetHandelConfig() *handel.Config {
if err == nil {
ch.NewTimeoutStrategy = handel.LinearTimeoutConstructor(dd)
}
switch r.Handel.Evaluator {
case "store":
ch.NewEvaluatorStrategy = handel.DefaultEvaluatorStrategy
case "equal":
ch.NewEvaluatorStrategy = func(handel.SignatureStore, *handel.Handel) handel.SigEvaluator { return new(handel.Evaluator1) }
}
return ch
}

Expand Down
Loading

0 comments on commit 0373ba7

Please sign in to comment.