-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip ahead to future rounds when justified
Implement a rebroadcast protocol improvement where upon receiving sufficient justification a participant jumps ahead to future rounds. Justification from a future rounds is considered sufficient when the participant receives: * at least one `CONVERGE` message, and * a weak quorum of `PREPARE` messages for that round. Fixes #241
- Loading branch information
Showing
3 changed files
with
208 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package adversary | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/filecoin-project/go-f3/gpbft" | ||
) | ||
|
||
var _ Receiver = (*Deny)(nil) | ||
|
||
// Deny adversary denies all messages to a given set of participants for a | ||
// configured duration of time through the experiment. | ||
type Deny struct { | ||
id gpbft.ActorID | ||
host Host | ||
targetsByID map[gpbft.ActorID]struct{} | ||
gst time.Time | ||
} | ||
|
||
func NewDeny(id gpbft.ActorID, host Host, denialDuration time.Duration, targets ...gpbft.ActorID) *Deny { | ||
targetsByID := make(map[gpbft.ActorID]struct{}) | ||
for _, target := range targets { | ||
targetsByID[target] = struct{}{} | ||
} | ||
return &Deny{ | ||
id: id, | ||
host: host, | ||
targetsByID: targetsByID, | ||
gst: time.Time{}.Add(denialDuration), | ||
} | ||
} | ||
|
||
func NewDenyGenerator(power *gpbft.StoragePower, denialDuration time.Duration, targets ...gpbft.ActorID) Generator { | ||
return func(id gpbft.ActorID, host Host) *Adversary { | ||
wc := NewDeny(id, host, denialDuration, targets...) | ||
return &Adversary{ | ||
Receiver: wc, | ||
Power: power, | ||
} | ||
} | ||
} | ||
|
||
func (d *Deny) ID() gpbft.ActorID { | ||
return d.id | ||
} | ||
|
||
func (d *Deny) AllowMessage(from gpbft.ActorID, to gpbft.ActorID, msg gpbft.GMessage) bool { | ||
// Deny all messages to or from targets until Global Stabilisation Time has elapsed. | ||
if d.host.Time().Before(d.gst) { | ||
if d.isTarget(from) || d.isTarget(to) { | ||
return false | ||
} | ||
} | ||
return true | ||
} | ||
|
||
func (d *Deny) isTarget(id gpbft.ActorID) bool { | ||
_, found := d.targetsByID[id] | ||
return found | ||
} | ||
|
||
func (*Deny) Start() error { return nil } | ||
func (*Deny) ValidateMessage(*gpbft.GMessage) (bool, error) { return true, nil } | ||
func (*Deny) ReceiveMessage(*gpbft.GMessage, bool) (bool, error) { return true, nil } | ||
func (*Deny) ReceiveAlarm() error { return nil } |
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,39 @@ | ||
package test | ||
|
||
import ( | ||
"math" | ||
"testing" | ||
|
||
"github.com/filecoin-project/go-f3/gpbft" | ||
"github.com/filecoin-project/go-f3/sim" | ||
"github.com/filecoin-project/go-f3/sim/adversary" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestHonest_JumpsRounds(t *testing.T) { | ||
|
||
t.Skip("WIP") | ||
|
||
const ( | ||
instanceCount = 2000 | ||
denialTarget = 0 | ||
denialDuration = 200 * EcEpochDuration | ||
) | ||
|
||
tsg := sim.NewTipSetGenerator(86523) | ||
baseChain := generateECChain(t, tsg) | ||
ecChainGenerator := sim.NewUniformECChainGenerator(54445, 1, 5) | ||
//fixedEcChain := sim.NewFixedECChainGenerator(baseChain) | ||
sm, err := sim.NewSimulation( | ||
syncOptions( | ||
sim.AddHonestParticipants(6, ecChainGenerator, uniformOneStoragePower), | ||
sim.WithBaseChain(&baseChain), | ||
sim.WithAdversary(adversary.NewDenyGenerator(oneStoragePower, denialDuration, denialTarget)), | ||
sim.WithGlobalStabilizationTime(denialDuration/2), | ||
)..., | ||
) | ||
require.NoError(t, err) | ||
require.NoErrorf(t, sm.Run(instanceCount, maxRounds), "%s", sm.Describe()) | ||
chain := ecChainGenerator.GenerateECChain(instanceCount-1, gpbft.TipSet{}, math.MaxUint64) | ||
requireConsensusAtInstance(t, sm, instanceCount-1, *chain.Head()) | ||
} |