Skip to content

Commit

Permalink
go beacon: change dummy entropy
Browse files Browse the repository at this point in the history
This is so that we have more usable testing schedules with a compute-only
role and a merge-only role.
  • Loading branch information
pro-wh committed Jan 16, 2020
1 parent bdbe959 commit db985d3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
7 changes: 6 additions & 1 deletion go/consensus/tendermint/apps/beacon/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ func (app *beaconApplication) onBeaconEpochChange(ctx *abci.Context, epoch epoch
case true:
// UNSAFE/DEBUG - Deterministic beacon.
entropyCtx = DebugEntropyCtx
entropy = []byte("If you change this, you will fuck up the byzantine tests!!!")
// We're setting this random seed so that we have suitable committee schedules for Byzantine E2E scenarios,
// where we want nodes to be scheduled for only one committee. The permutations derived from this on the first
// epoch need to have (i) an index that's compute worker only and (ii) an index that's merge worker only. See
// /go/oasis-test-runner/scenario/e2e/byzantine.go for the permutations generated from this seed. These
// permutations are generated independently of the deterministic node IDs.
entropy = []byte("If you change this, you will fuck up the byzantine tests!!")
}

b := GetBeacon(epoch, entropyCtx, entropy)
Expand Down
4 changes: 2 additions & 2 deletions go/oasis-node/cmd/debug/byzantine/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ func hasSuitablePermutations(t *testing.T, beacon []byte, runtimeID common.Names
}

func TestDebugSchedule(t *testing.T) {
var epoch epochtime.EpochTime = 1
var epoch epochtime.EpochTime = 2
var runtimeID common.Namespace
require.NoError(t, runtimeID.UnmarshalHex("8000000000000000000000000000000000000000000000000000000000000000"), "runtimeID.UnmarshalHex")
deterministicBeaconEntropy := []byte("If you change this, you will fuck up the byzantine tests!!!")
deterministicBeaconEntropy := []byte("If you change this, you will fuck up the byzantine tests!!")
for {
fmt.Printf("assessing seed %s\n", deterministicBeaconEntropy)

Expand Down
8 changes: 4 additions & 4 deletions go/oasis-test-runner/oasis/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
const (
computeIdentitySeedTemplate = "ekiden node worker %d"

ByzantineDefaultIdentitySeed = "ekiden byzantine node worker" // index 0
ByzantineIndex1IdentitySeed = "ekiden byzantine node worker, luck=1"
ByzantineIndex2IdentitySeed = "ekiden byzantine node worker, luck=11"
ByzantineIndex3IdentitySeed = "ekiden byzantine node worker, luck=6"
ByzantineDefaultIdentitySeed = "ekiden byzantine node worker" // slot 0
ByzantineSlot1IdentitySeed = "ekiden byzantine node worker, luck=1"
ByzantineSlot2IdentitySeed = "ekiden byzantine node worker, luck=11"
ByzantineSlot3IdentitySeed = "ekiden byzantine node worker, luck=6"
)

// Compute is an Oasis compute node.
Expand Down
6 changes: 3 additions & 3 deletions go/oasis-test-runner/oasis/oasis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ func TestNodeIdentity(t *testing.T) {
require.Equal(t, 1, bytes.Compare(c1, c2))

b0, _ := generateDeterministicNodeKeys(t, ByzantineDefaultIdentitySeed)
b1, _ := generateDeterministicNodeKeys(t, ByzantineIndex1IdentitySeed)
b2, _ := generateDeterministicNodeKeys(t, ByzantineIndex2IdentitySeed)
b3, _ := generateDeterministicNodeKeys(t, ByzantineIndex3IdentitySeed)
b1, _ := generateDeterministicNodeKeys(t, ByzantineSlot1IdentitySeed)
b2, _ := generateDeterministicNodeKeys(t, ByzantineSlot2IdentitySeed)
b3, _ := generateDeterministicNodeKeys(t, ByzantineSlot3IdentitySeed)
require.Equal(t, 1, bytes.Compare(c0, b0))
require.Equal(t, 1, bytes.Compare(b1, c0))
require.Equal(t, 1, bytes.Compare(c2, b1))
Expand Down
22 changes: 16 additions & 6 deletions go/oasis-test-runner/scenario/e2e/byzantine.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,49 @@ import (
// TODO: Consider referencing script names directly from the Byzantine node.

var (
// Permutations generated in the epoch 2 election are
// compute: 3 (w), 0 (w), 2 (b), 1 (i)
// transaction scheduler: 0 (w), 3 (i), 1 (i), 2 (i)
// merge: 1 (w), 2 (w), 0 (b), 3 (i)
// w = worker; b = backup; i = invalid
// For compute scripts, it suffices to be index 3.
// For merge scripts, it suffices to be index 1.
// No index is transaction scheduler only.
// Indices are by order of node ID.

// ByzantineComputeHonest is the byzantine compute honest scenario.
ByzantineComputeHonest scenario.Scenario = newByzantineImpl("compute-honest", nil, oasis.ByzantineDefaultIdentitySeed)
ByzantineComputeHonest scenario.Scenario = newByzantineImpl("compute-honest", nil, oasis.ByzantineSlot3IdentitySeed)
// ByzantineComputeWrong is the byzantine compute wrong scenario.
ByzantineComputeWrong scenario.Scenario = newByzantineImpl("compute-wrong", []log.WatcherHandlerFactory{
oasis.LogAssertNoTimeouts(),
oasis.LogAssertNoRoundFailures(),
oasis.LogAssertComputeDiscrepancyDetected(),
oasis.LogAssertNoMergeDiscrepancyDetected(),
}, oasis.ByzantineDefaultIdentitySeed)
}, oasis.ByzantineSlot3IdentitySeed)
// ByzantineComputeStraggler is the byzantine compute straggler scenario.
ByzantineComputeStraggler scenario.Scenario = newByzantineImpl("compute-straggler", []log.WatcherHandlerFactory{
oasis.LogAssertTimeouts(),
oasis.LogAssertNoRoundFailures(),
oasis.LogAssertComputeDiscrepancyDetected(),
oasis.LogAssertNoMergeDiscrepancyDetected(),
}, oasis.ByzantineDefaultIdentitySeed)
}, oasis.ByzantineSlot3IdentitySeed)

// ByzantineMergeHonest is the byzantine merge honest scenario.
ByzantineMergeHonest scenario.Scenario = newByzantineImpl("merge-honest", nil, oasis.ByzantineDefaultIdentitySeed)
ByzantineMergeHonest scenario.Scenario = newByzantineImpl("merge-honest", nil, oasis.ByzantineSlot1IdentitySeed)
// ByzantineMergeWrong is the byzantine merge wrong scenario.
ByzantineMergeWrong scenario.Scenario = newByzantineImpl("merge-wrong", []log.WatcherHandlerFactory{
oasis.LogAssertNoTimeouts(),
oasis.LogAssertNoRoundFailures(),
oasis.LogAssertNoComputeDiscrepancyDetected(),
oasis.LogAssertMergeDiscrepancyDetected(),
}, oasis.ByzantineDefaultIdentitySeed)
}, oasis.ByzantineSlot1IdentitySeed)
// ByzantineMergeStraggler is the byzantine merge straggler scenario.
ByzantineMergeStraggler scenario.Scenario = newByzantineImpl("merge-straggler", []log.WatcherHandlerFactory{
oasis.LogAssertTimeouts(),
oasis.LogAssertNoRoundFailures(),
oasis.LogAssertNoComputeDiscrepancyDetected(),
oasis.LogAssertMergeDiscrepancyDetected(),
}, oasis.ByzantineDefaultIdentitySeed)
}, oasis.ByzantineSlot1IdentitySeed)
)

type byzantineImpl struct {
Expand Down

0 comments on commit db985d3

Please sign in to comment.