mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-25 18:51:39 +00:00
config: unexpose chainID
This commit is contained in:
committed by
Zach Ramsay
parent
a92a32b862
commit
a8e625e99d
@ -78,13 +78,14 @@ func (cfg *Config) SetRoot(root string) *Config {
|
|||||||
|
|
||||||
// BaseConfig defines the base configuration for a Tendermint node
|
// BaseConfig defines the base configuration for a Tendermint node
|
||||||
type BaseConfig struct {
|
type BaseConfig struct {
|
||||||
|
|
||||||
|
// chainID is unexposed and immutable but here for convenience
|
||||||
|
chainID string
|
||||||
|
|
||||||
// The root directory for all data.
|
// The root directory for all data.
|
||||||
// This should be set in viper so it can unmarshal into this struct
|
// This should be set in viper so it can unmarshal into this struct
|
||||||
RootDir string `mapstructure:"home"`
|
RootDir string `mapstructure:"home"`
|
||||||
|
|
||||||
// The ID of the chain to join (should be signed with every transaction and vote)
|
|
||||||
ChainID string `mapstructure:"chain_id"`
|
|
||||||
|
|
||||||
// Path to the JSON file containing the initial validator set and other meta data
|
// Path to the JSON file containing the initial validator set and other meta data
|
||||||
Genesis string `mapstructure:"genesis_file"`
|
Genesis string `mapstructure:"genesis_file"`
|
||||||
|
|
||||||
@ -123,6 +124,10 @@ type BaseConfig struct {
|
|||||||
DBPath string `mapstructure:"db_dir"`
|
DBPath string `mapstructure:"db_dir"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c BaseConfig) ChainID() string {
|
||||||
|
return c.chainID
|
||||||
|
}
|
||||||
|
|
||||||
// DefaultBaseConfig returns a default base configuration for a Tendermint node
|
// DefaultBaseConfig returns a default base configuration for a Tendermint node
|
||||||
func DefaultBaseConfig() BaseConfig {
|
func DefaultBaseConfig() BaseConfig {
|
||||||
return BaseConfig{
|
return BaseConfig{
|
||||||
@ -143,7 +148,7 @@ func DefaultBaseConfig() BaseConfig {
|
|||||||
// TestBaseConfig returns a base configuration for testing a Tendermint node
|
// TestBaseConfig returns a base configuration for testing a Tendermint node
|
||||||
func TestBaseConfig() BaseConfig {
|
func TestBaseConfig() BaseConfig {
|
||||||
conf := DefaultBaseConfig()
|
conf := DefaultBaseConfig()
|
||||||
conf.ChainID = "tendermint_test"
|
conf.chainID = "tendermint_test"
|
||||||
conf.ProxyApp = "dummy"
|
conf.ProxyApp = "dummy"
|
||||||
conf.FastSync = false
|
conf.FastSync = false
|
||||||
conf.DBBackend = "memdb"
|
conf.DBBackend = "memdb"
|
||||||
|
@ -76,14 +76,11 @@ db_backend = "{{ .BaseConfig.DBBackend }}"
|
|||||||
# Database directory
|
# Database directory
|
||||||
db_path = "{{ .BaseConfig.DBPath }}"
|
db_path = "{{ .BaseConfig.DBPath }}"
|
||||||
|
|
||||||
# Output level for logging
|
# Output level for logging, including package level options
|
||||||
log_level = "{{ .BaseConfig.LogLevel }}"
|
log_level = "{{ .BaseConfig.LogLevel }}"
|
||||||
|
|
||||||
##### additional base config options #####
|
##### additional base config options #####
|
||||||
|
|
||||||
# The ID of the chain to join (should be signed with every transaction and vote)
|
|
||||||
chain_id = "{{ .BaseConfig.ChainID }}"
|
|
||||||
|
|
||||||
# Path to the JSON file containing the initial validator set and other meta data
|
# Path to the JSON file containing the initial validator set and other meta data
|
||||||
genesis_file = "{{ .BaseConfig.Genesis }}"
|
genesis_file = "{{ .BaseConfig.Genesis }}"
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ func (vs *validatorStub) signVote(voteType byte, hash []byte, header types.PartS
|
|||||||
Type: voteType,
|
Type: voteType,
|
||||||
BlockID: types.BlockID{hash, header},
|
BlockID: types.BlockID{hash, header},
|
||||||
}
|
}
|
||||||
err := vs.PrivValidator.SignVote(config.ChainID, vote)
|
err := vs.PrivValidator.SignVote(config.ChainID(), vote)
|
||||||
return vote, err
|
return vote, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ func decideProposal(cs1 *ConsensusState, vs *validatorStub, height int64, round
|
|||||||
// Make proposal
|
// Make proposal
|
||||||
polRound, polBlockID := cs1.Votes.POLInfo()
|
polRound, polBlockID := cs1.Votes.POLInfo()
|
||||||
proposal = types.NewProposal(height, round, blockParts.Header(), polRound, polBlockID)
|
proposal = types.NewProposal(height, round, blockParts.Header(), polRound, polBlockID)
|
||||||
if err := vs.SignProposal(config.ChainID, proposal); err != nil {
|
if err := vs.SignProposal(cs1.state.ChainID, proposal); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -430,9 +430,10 @@ func randGenesisDoc(numValidators int, randPower bool, minPower int64) (*types.G
|
|||||||
privValidators[i] = privVal
|
privValidators[i] = privVal
|
||||||
}
|
}
|
||||||
sort.Sort(types.PrivValidatorsByAddress(privValidators))
|
sort.Sort(types.PrivValidatorsByAddress(privValidators))
|
||||||
|
|
||||||
return &types.GenesisDoc{
|
return &types.GenesisDoc{
|
||||||
GenesisTime: time.Now(),
|
GenesisTime: time.Now(),
|
||||||
ChainID: config.ChainID,
|
ChainID: config.ChainID(),
|
||||||
Validators: validators,
|
Validators: validators,
|
||||||
}, privValidators
|
}, privValidators
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ func TestBadProposal(t *testing.T) {
|
|||||||
propBlock.AppHash = stateHash
|
propBlock.AppHash = stateHash
|
||||||
propBlockParts := propBlock.MakePartSet(partSize)
|
propBlockParts := propBlock.MakePartSet(partSize)
|
||||||
proposal := types.NewProposal(vs2.Height, round, propBlockParts.Header(), -1, types.BlockID{})
|
proposal := types.NewProposal(vs2.Height, round, propBlockParts.Header(), -1, types.BlockID{})
|
||||||
if err := vs2.SignProposal(config.ChainID, proposal); err != nil {
|
if err := vs2.SignProposal(config.ChainID(), proposal); err != nil {
|
||||||
t.Fatal("failed to sign bad proposal", err)
|
t.Fatal("failed to sign bad proposal", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -900,7 +900,7 @@ func TestLockPOLSafety2(t *testing.T) {
|
|||||||
|
|
||||||
// in round 2 we see the polkad block from round 0
|
// in round 2 we see the polkad block from round 0
|
||||||
newProp := types.NewProposal(height, 2, propBlockParts0.Header(), 0, propBlockID1)
|
newProp := types.NewProposal(height, 2, propBlockParts0.Header(), 0, propBlockID1)
|
||||||
if err := vs3.SignProposal(config.ChainID, newProp); err != nil {
|
if err := vs3.SignProposal(config.ChainID(), newProp); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := cs1.SetProposalAndBlock(newProp, propBlock0, propBlockParts0, "some peer"); err != nil {
|
if err := cs1.SetProposalAndBlock(newProp, propBlock0, propBlockParts0, "some peer"); err != nil {
|
||||||
|
@ -18,7 +18,7 @@ func init() {
|
|||||||
func TestPeerCatchupRounds(t *testing.T) {
|
func TestPeerCatchupRounds(t *testing.T) {
|
||||||
valSet, privVals := types.RandValidatorSet(10, 1)
|
valSet, privVals := types.RandValidatorSet(10, 1)
|
||||||
|
|
||||||
hvs := NewHeightVoteSet(config.ChainID, 1, valSet)
|
hvs := NewHeightVoteSet(config.ChainID(), 1, valSet)
|
||||||
|
|
||||||
vote999_0 := makeVoteHR(t, 1, 999, privVals, 0)
|
vote999_0 := makeVoteHR(t, 1, 999, privVals, 0)
|
||||||
added, err := hvs.AddVote(vote999_0, "peer1")
|
added, err := hvs.AddVote(vote999_0, "peer1")
|
||||||
@ -59,7 +59,7 @@ func makeVoteHR(t *testing.T, height int64, round int, privVals []*types.PrivVal
|
|||||||
Type: types.VoteTypePrecommit,
|
Type: types.VoteTypePrecommit,
|
||||||
BlockID: types.BlockID{[]byte("fakehash"), types.PartSetHeader{}},
|
BlockID: types.BlockID{[]byte("fakehash"), types.PartSetHeader{}},
|
||||||
}
|
}
|
||||||
chainID := config.ChainID
|
chainID := config.ChainID()
|
||||||
err := privVal.SignVote(chainID, vote)
|
err := privVal.SignVote(chainID, vote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(cmn.Fmt("Error signing vote: %v", err))
|
panic(cmn.Fmt("Error signing vote: %v", err))
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
liteErr "github.com/tendermint/tendermint/lite/errors"
|
liteErr "github.com/tendermint/tendermint/lite/errors"
|
||||||
rpcclient "github.com/tendermint/tendermint/rpc/client"
|
rpcclient "github.com/tendermint/tendermint/rpc/client"
|
||||||
rpctest "github.com/tendermint/tendermint/rpc/test"
|
rpctest "github.com/tendermint/tendermint/rpc/test"
|
||||||
|
"github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestProvider(t *testing.T) {
|
func TestProvider(t *testing.T) {
|
||||||
@ -17,7 +18,8 @@ func TestProvider(t *testing.T) {
|
|||||||
|
|
||||||
cfg := rpctest.GetConfig()
|
cfg := rpctest.GetConfig()
|
||||||
rpcAddr := cfg.RPC.ListenAddress
|
rpcAddr := cfg.RPC.ListenAddress
|
||||||
chainID := cfg.ChainID
|
genDoc, _ := types.GenesisDocFromFile(cfg.GenesisFile())
|
||||||
|
chainID := genDoc.ChainID
|
||||||
p := NewHTTPProvider(rpcAddr)
|
p := NewHTTPProvider(rpcAddr)
|
||||||
require.NotNil(t, p)
|
require.NotNil(t, p)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user