From 53a776686faae9abe7373db3fac4c6519468ef51 Mon Sep 17 00:00:00 2001 From: Warren He Date: Wed, 17 Jul 2019 17:58:22 -0700 Subject: [PATCH] (scratch) create custom tendermint instance --- .buildkite/scripts/test_e2e.sh | 2 +- go/ekiden/cmd/debug/byzantine/byzantine.go | 15 +++++++++++++-- go/ekiden/cmd/debug/byzantine/steps.go | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.buildkite/scripts/test_e2e.sh b/.buildkite/scripts/test_e2e.sh index f6bd366e952..24563abad14 100755 --- a/.buildkite/scripts/test_e2e.sh +++ b/.buildkite/scripts/test_e2e.sh @@ -122,8 +122,8 @@ scenario_byzantine_compute_honest() { --genesis.file ${EKIDEN_GENESIS_FILE} \ --tendermint.core.listen_address tcp://0.0.0.0:13004 \ --tendermint.consensus.timeout_commit 250ms \ - --tendermint.debug.addr_book_lenient \ --tendermint.seeds "${EKIDEN_SEED_NODE_ID}@127.0.0.1:${EKIDEN_SEED_NODE_PORT}" \ + --tendermint.debug.addr_book_lenient \ --datadir untracked/byz-run/data \ --debug.allow_test_keys \ 2>&1 | python ../private-ops/untracked/color-log.py | sed "s/^/[byzantine] /" & diff --git a/go/ekiden/cmd/debug/byzantine/byzantine.go b/go/ekiden/cmd/debug/byzantine/byzantine.go index 12f9aa52571..7556041aa03 100644 --- a/go/ekiden/cmd/debug/byzantine/byzantine.go +++ b/go/ekiden/cmd/debug/byzantine/byzantine.go @@ -4,12 +4,12 @@ import ( "fmt" "github.com/spf13/cobra" - // "github.com/spf13/viper" + "github.com/spf13/viper" "github.com/oasislabs/ekiden/go/common/logging" "github.com/oasislabs/ekiden/go/ekiden/cmd/common" - "github.com/oasislabs/ekiden/go/tendermint" "github.com/oasislabs/ekiden/go/genesis" + "github.com/oasislabs/ekiden/go/tendermint" ) var ( @@ -23,6 +23,12 @@ var ( Short: "act as an honest compute worker", Run: doComputeHonest, } + + cfgGenesisFile = "genesis.file" + cfgCoreListenAddress = "tendermint.core.listen_address" + cfgConsensusTimeoutCommit = "tendermint.consensus.timeout_commit" + cfgP2PSeeds = "tendermint.seeds" + cfgDebugP2PAddrBookLenient = "tendermint.debug.addr_book_lenient" ) func doComputeHonest(cmd *cobra.Command, args []string) { @@ -47,6 +53,11 @@ func Register(parentCmd *cobra.Command) { } func init() { + byzantineCmd.PersistentFlags().String(cfgCoreListenAddress, "tcp://0.0.0.0:26656", "tendermint core listen address") + viper.BindPFlag(cfgCoreListenAddress, ) + byzantineCmd.PersistentFlags().Duration(cfgConsensusTimeoutCommit, 1*time.Second, "tendermint commit timeout") + byzantineCmd.PersistentFlags().String(cfgP2PSeeds, "", "comma-delimited id@host:port tendermint seed nodes") + byzantineCmd.PersistentFlags().Bool(cfgDebugP2PAddrBookLenient, false, "allow non-routable addresses") genesis.RegisterFlags(computeHonestCmd) fmt.Println("this should call RegisterFlags %%%") tendermint.RegisterFlags(computeHonestCmd) diff --git a/go/ekiden/cmd/debug/byzantine/steps.go b/go/ekiden/cmd/debug/byzantine/steps.go index 842178b7cc0..12a2859c709 100644 --- a/go/ekiden/cmd/debug/byzantine/steps.go +++ b/go/ekiden/cmd/debug/byzantine/steps.go @@ -2,8 +2,11 @@ package byzantine import ( "context" + "strings" "time" + "github.com/spf13/viper" + beacon "github.com/oasislabs/ekiden/go/beacon/api" "github.com/oasislabs/ekiden/go/common/crypto/signature" fileSigner "github.com/oasislabs/ekiden/go/common/crypto/signature/signers/file" @@ -15,6 +18,7 @@ import ( registry "github.com/oasislabs/ekiden/go/registry/api" scheduler "github.com/oasislabs/ekiden/go/scheduler/api" "github.com/oasislabs/ekiden/go/tendermint" + "github.com/oasislabs/ekiden/go/tendermint/abci" beaconapp "github.com/oasislabs/ekiden/go/tendermint/apps/beacon" registryapp "github.com/oasislabs/ekiden/go/tendermint/apps/registry" roothashapp "github.com/oasislabs/ekiden/go/tendermint/apps/roothash" @@ -68,7 +72,16 @@ func startHonestTendermint() { if err != nil { panic("genesis.New: " + err.Error()) } - honestTendermint = tendermint.New(context.Background(), dataDir, identity, genesis) + honestTendermint = tendermint.NewFromConfig(context.Background(), dataDir, &tendermint.Config{ + CoreListenAddress: viper.GetString(cfgCoreListenAddress), + ConsensusTimeoutCommit: viper.GetDuration(cfgConsensusTimeoutCommit), + ABCIPruneConfig: abci.PruneConfig{ + Strategy: abci.PruneNone, + NumKept: 3600, + }, + P2PSeeds: strings.ToLower(viper.GetString(cfgP2PSeeds)), + DebugP2PAddrBookLenient: viper.GetBool(cfgDebugP2PAddrBookLenient), + }, identity, genesis) logger.Debug("honest Tendermint service instantiated %%%", "honestTendermint", honestTendermint) if err := honestTendermint.ForceInitialize(); err != nil {