mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-29 12:41:44 +00:00
network > chain_id, put in genesis.json
This commit is contained in:
@ -23,8 +23,8 @@ type Block struct {
|
||||
// Basic validation that doesn't involve state data.
|
||||
func (b *Block) ValidateBasic(lastBlockHeight uint, lastBlockHash []byte,
|
||||
lastBlockParts PartSetHeader, lastBlockTime time.Time) error {
|
||||
if b.Network != config.GetString("network") {
|
||||
return errors.New("Wrong Block.Header.Network")
|
||||
if b.ChainID != config.GetString("chain_id") {
|
||||
return errors.New("Wrong Block.Header.ChainID")
|
||||
}
|
||||
if b.Height != lastBlockHeight+1 {
|
||||
return errors.New("Wrong Block.Header.Height")
|
||||
@ -122,7 +122,7 @@ func (b *Block) StringShort() string {
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
type Header struct {
|
||||
Network string `json:"network"`
|
||||
ChainID string `json:"chain_id"`
|
||||
Height uint `json:"height"`
|
||||
Time time.Time `json:"time"`
|
||||
Fees uint64 `json:"fees"`
|
||||
@ -154,7 +154,7 @@ func (h *Header) StringIndented(indent string) string {
|
||||
return "nil-Header"
|
||||
}
|
||||
return fmt.Sprintf(`Header{
|
||||
%s Network: %v
|
||||
%s ChainID: %v
|
||||
%s Height: %v
|
||||
%s Time: %v
|
||||
%s Fees: %v
|
||||
@ -163,7 +163,7 @@ func (h *Header) StringIndented(indent string) string {
|
||||
%s LastBlockParts: %v
|
||||
%s StateHash: %X
|
||||
%s}#%X`,
|
||||
indent, h.Network,
|
||||
indent, h.ChainID,
|
||||
indent, h.Height,
|
||||
indent, h.Time,
|
||||
indent, h.Fees,
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
|
||||
type NodeInfo struct {
|
||||
Moniker string `json:"moniker"`
|
||||
Network string `json:"network"`
|
||||
ChainID string `json:"chain_id"`
|
||||
Version string `json:"version"`
|
||||
|
||||
Host string `json:"host"`
|
||||
@ -39,9 +39,9 @@ func (ni *NodeInfo) CompatibleWith(no *NodeInfo) error {
|
||||
return fmt.Errorf("Peer is on a different minor version. Got %v, expected %v", om, im)
|
||||
}
|
||||
|
||||
// nodes must be on the same network
|
||||
if ni.Network != no.Network {
|
||||
return fmt.Errorf("Peer is on a different network. Got %v, expected %v", no.Network, ni.Network)
|
||||
// nodes must be on the same chain_id
|
||||
if ni.ChainID != no.ChainID {
|
||||
return fmt.Errorf("Peer is on a different chain_id. Got %v, expected %v", no.ChainID, ni.ChainID)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
20
types/tx.go
20
types/tx.go
@ -130,8 +130,8 @@ type SendTx struct {
|
||||
}
|
||||
|
||||
func (tx *SendTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
// We hex encode the network name so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.GetString("network"))), w, n, err)
|
||||
// We hex encode the chain_id so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"chain_id":"%X"`, config.GetString("chain_id"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"inputs":[`, TxTypeSend)), w, n, err)
|
||||
for i, in := range tx.Inputs {
|
||||
in.WriteSignBytes(w, n, err)
|
||||
@ -164,8 +164,8 @@ type CallTx struct {
|
||||
}
|
||||
|
||||
func (tx *CallTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
// We hex encode the network name so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.GetString("network"))), w, n, err)
|
||||
// We hex encode the chain_id so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"chain_id":"%X"`, config.GetString("chain_id"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"address":"%X","data":"%X"`, TxTypeCall, tx.Address, tx.Data)), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"fee":%v,"gas_limit":%v,"input":`, tx.Fee, tx.GasLimit)), w, n, err)
|
||||
tx.Input.WriteSignBytes(w, n, err)
|
||||
@ -186,8 +186,8 @@ type BondTx struct {
|
||||
}
|
||||
|
||||
func (tx *BondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
// We hex encode the network name so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.GetString("network"))), w, n, err)
|
||||
// We hex encode the chain_id so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"chain_id":"%X"`, config.GetString("chain_id"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"inputs":[`, TxTypeBond)), w, n, err)
|
||||
for i, in := range tx.Inputs {
|
||||
in.WriteSignBytes(w, n, err)
|
||||
@ -220,8 +220,8 @@ type UnbondTx struct {
|
||||
}
|
||||
|
||||
func (tx *UnbondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
// We hex encode the network name so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.GetString("network"))), w, n, err)
|
||||
// We hex encode the chain_id so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"chain_id":"%X"`, config.GetString("chain_id"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"address":"%X","height":%v}]}`, TxTypeUnbond, tx.Address, tx.Height)), w, n, err)
|
||||
}
|
||||
|
||||
@ -238,8 +238,8 @@ type RebondTx struct {
|
||||
}
|
||||
|
||||
func (tx *RebondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
// We hex encode the network name so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.GetString("network"))), w, n, err)
|
||||
// We hex encode the chain_id so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"chain_id":"%X"`, config.GetString("chain_id"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"address":"%X","height":%v}]}`, TxTypeRebond, tx.Address, tx.Height)), w, n, err)
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,8 @@ func TestSendTxSignable(t *testing.T) {
|
||||
}
|
||||
signBytes := account.SignBytes(sendTx)
|
||||
signStr := string(signBytes)
|
||||
expected := Fmt(`{"network":"%X","tx":[1,{"inputs":[{"address":"696E70757431","amount":12345,"sequence":67890},{"address":"696E70757432","amount":111,"sequence":222}],"outputs":[{"address":"6F757470757431","amount":333},{"address":"6F757470757432","amount":444}]}]}`,
|
||||
config.GetString("network"))
|
||||
expected := Fmt(`{"chain_id":"%X","tx":[1,{"inputs":[{"address":"696E70757431","amount":12345,"sequence":67890},{"address":"696E70757432","amount":111,"sequence":222}],"outputs":[{"address":"6F757470757431","amount":333},{"address":"6F757470757432","amount":444}]}]}`,
|
||||
config.GetString("chain_id"))
|
||||
if signStr != expected {
|
||||
t.Errorf("Got unexpected sign string for SendTx. Expected:\n%v\nGot:\n%v", expected, signStr)
|
||||
}
|
||||
@ -56,8 +56,8 @@ func TestCallTxSignable(t *testing.T) {
|
||||
}
|
||||
signBytes := account.SignBytes(callTx)
|
||||
signStr := string(signBytes)
|
||||
expected := Fmt(`{"network":"%X","tx":[2,{"address":"636F6E747261637431","data":"6461746131","fee":222,"gas_limit":111,"input":{"address":"696E70757431","amount":12345,"sequence":67890}}]}`,
|
||||
config.GetString("network"))
|
||||
expected := Fmt(`{"chain_id":"%X","tx":[2,{"address":"636F6E747261637431","data":"6461746131","fee":222,"gas_limit":111,"input":{"address":"696E70757431","amount":12345,"sequence":67890}}]}`,
|
||||
config.GetString("chain_id"))
|
||||
if signStr != expected {
|
||||
t.Errorf("Got unexpected sign string for CallTx. Expected:\n%v\nGot:\n%v", expected, signStr)
|
||||
}
|
||||
@ -92,8 +92,8 @@ func TestBondTxSignable(t *testing.T) {
|
||||
}
|
||||
signBytes := account.SignBytes(bondTx)
|
||||
signStr := string(signBytes)
|
||||
expected := Fmt(`{"network":"%X","tx":[17,{"inputs":[{"address":"696E70757431","amount":12345,"sequence":67890},{"address":"696E70757432","amount":111,"sequence":222}],"pub_key":[1,"3B6A27BCCEB6A42D62A3A8D02A6F0D73653215771DE243A63AC048A18B59DA29"],"unbond_to":[{"address":"6F757470757431","amount":333},{"address":"6F757470757432","amount":444}]}]}`,
|
||||
config.GetString("network"))
|
||||
expected := Fmt(`{"chain_id":"%X","tx":[17,{"inputs":[{"address":"696E70757431","amount":12345,"sequence":67890},{"address":"696E70757432","amount":111,"sequence":222}],"pub_key":[1,"3B6A27BCCEB6A42D62A3A8D02A6F0D73653215771DE243A63AC048A18B59DA29"],"unbond_to":[{"address":"6F757470757431","amount":333},{"address":"6F757470757432","amount":444}]}]}`,
|
||||
config.GetString("chain_id"))
|
||||
if signStr != expected {
|
||||
t.Errorf("Got unexpected sign string for BondTx")
|
||||
}
|
||||
@ -106,8 +106,8 @@ func TestUnbondTxSignable(t *testing.T) {
|
||||
}
|
||||
signBytes := account.SignBytes(unbondTx)
|
||||
signStr := string(signBytes)
|
||||
expected := Fmt(`{"network":"%X","tx":[18,{"address":"6164647265737331","height":111}]}`,
|
||||
config.GetString("network"))
|
||||
expected := Fmt(`{"chain_id":"%X","tx":[18,{"address":"6164647265737331","height":111}]}`,
|
||||
config.GetString("chain_id"))
|
||||
if signStr != expected {
|
||||
t.Errorf("Got unexpected sign string for UnbondTx")
|
||||
}
|
||||
@ -120,8 +120,8 @@ func TestRebondTxSignable(t *testing.T) {
|
||||
}
|
||||
signBytes := account.SignBytes(rebondTx)
|
||||
signStr := string(signBytes)
|
||||
expected := Fmt(`{"network":"%X","tx":[19,{"address":"6164647265737331","height":111}]}`,
|
||||
config.GetString("network"))
|
||||
expected := Fmt(`{"chain_id":"%X","tx":[19,{"address":"6164647265737331","height":111}]}`,
|
||||
config.GetString("chain_id"))
|
||||
if signStr != expected {
|
||||
t.Errorf("Got unexpected sign string for RebondTx")
|
||||
}
|
||||
|
@ -46,8 +46,8 @@ const (
|
||||
)
|
||||
|
||||
func (vote *Vote) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
// We hex encode the network name so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.GetString("network"))), w, n, err)
|
||||
// We hex encode the chain_id name so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"chain_id":"%X"`, config.GetString("chain_id"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"vote":{"block_hash":"%X","block_parts":%v`, vote.BlockHash, vote.BlockParts)), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"height":%v,"round":%v,"type":%v}}`, vote.Height, vote.Round, vote.Type)), w, n, err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user