Merge pull request #1198 from tendermint/feature/genesisrawjson
SDK: AppOptions -> AppState
This commit is contained in:
commit
3b40b62d04
|
@ -25,6 +25,11 @@ BUG FIXES:
|
||||||
- Graceful handling/recovery for apps that have non-determinism or fail to halt
|
- Graceful handling/recovery for apps that have non-determinism or fail to halt
|
||||||
- Graceful handling/recovery for violations of safety, or liveness
|
- Graceful handling/recovery for violations of safety, or liveness
|
||||||
|
|
||||||
|
## 0.17.0 (TBD)
|
||||||
|
|
||||||
|
BREAKING:
|
||||||
|
- [genesis] rename `app_options` to `app_state`
|
||||||
|
|
||||||
## 0.16.1 (TBD)
|
## 0.16.1 (TBD)
|
||||||
|
|
||||||
IMPROVEMENTS:
|
IMPROVEMENTS:
|
||||||
|
|
|
@ -294,6 +294,7 @@
|
||||||
revision = "1875d0a70c90e57f11972aefd42276df65e895b9"
|
revision = "1875d0a70c90e57f11972aefd42276df65e895b9"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
name = "golang.org/x/net"
|
name = "golang.org/x/net"
|
||||||
packages = [
|
packages = [
|
||||||
"context",
|
"context",
|
||||||
|
@ -302,9 +303,10 @@
|
||||||
"idna",
|
"idna",
|
||||||
"internal/timeseries",
|
"internal/timeseries",
|
||||||
"lex/httplex",
|
"lex/httplex",
|
||||||
|
"netutil",
|
||||||
"trace"
|
"trace"
|
||||||
]
|
]
|
||||||
revision = "2fb46b16b8dda405028c50f7c7f0f9dd1fa6bfb1"
|
revision = "cbe0f9307d0156177f9dd5dc85da1a31abc5f2fb"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "golang.org/x/sys"
|
name = "golang.org/x/sys"
|
||||||
|
@ -369,6 +371,6 @@
|
||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
inputs-digest = "402db24a8ce0cac835f1d0d3c40d4066d57660acac43b647066d94913bfc3efc"
|
inputs-digest = "a65ef86e3db67769c1fa4ae1f67af8d5b95474f4b95ec799d8572e19b44b206a"
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
|
|
|
@ -89,6 +89,10 @@
|
||||||
name = "google.golang.org/grpc"
|
name = "google.golang.org/grpc"
|
||||||
version = "1.7.3"
|
version = "1.7.3"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
branch = "master"
|
||||||
|
name = "golang.org/x/net"
|
||||||
|
|
||||||
[prune]
|
[prune]
|
||||||
go-tests = true
|
go-tests = true
|
||||||
unused-packages = true
|
unused-packages = true
|
||||||
|
|
|
@ -5,12 +5,6 @@ The genesis.json file in ``$TMHOME/config`` defines the initial TendermintCore
|
||||||
state upon genesis of the blockchain (`see
|
state upon genesis of the blockchain (`see
|
||||||
definition <https://github.com/tendermint/tendermint/blob/master/types/genesis.go>`__).
|
definition <https://github.com/tendermint/tendermint/blob/master/types/genesis.go>`__).
|
||||||
|
|
||||||
NOTE: This does not (yet) specify the application state (e.g. initial
|
|
||||||
distribution of tokens). Currently we leave it up to the application to
|
|
||||||
load the initial application genesis state. In the future, we may
|
|
||||||
include genesis SetOption messages that get passed from TendermintCore
|
|
||||||
to the app upon genesis.
|
|
||||||
|
|
||||||
Fields
|
Fields
|
||||||
~~~~~~
|
~~~~~~
|
||||||
|
|
||||||
|
@ -26,6 +20,7 @@ Fields
|
||||||
- ``app_hash``: The expected application hash (as returned by the
|
- ``app_hash``: The expected application hash (as returned by the
|
||||||
``Commit`` ABCI message) upon genesis. If the app's hash does not
|
``Commit`` ABCI message) upon genesis. If the app's hash does not
|
||||||
match, a warning message is printed.
|
match, a warning message is printed.
|
||||||
|
- ``app_state``: The application state (e.g. initial distribution of tokens).
|
||||||
|
|
||||||
Sample genesis.json
|
Sample genesis.json
|
||||||
~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -69,5 +64,8 @@ Sample genesis.json
|
||||||
"name": "mach4"
|
"name": "mach4"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"app_hash": "15005165891224E721CB664D15CB972240F5703F"
|
"app_hash": "15005165891224E721CB664D15CB972240F5703F",
|
||||||
|
"app_state": {
|
||||||
|
{"account": "Bob", "coins": 5000}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ type GenesisDoc struct {
|
||||||
ConsensusParams *ConsensusParams `json:"consensus_params,omitempty"`
|
ConsensusParams *ConsensusParams `json:"consensus_params,omitempty"`
|
||||||
Validators []GenesisValidator `json:"validators"`
|
Validators []GenesisValidator `json:"validators"`
|
||||||
AppHash cmn.HexBytes `json:"app_hash"`
|
AppHash cmn.HexBytes `json:"app_hash"`
|
||||||
AppOptions interface{} `json:"app_options,omitempty"`
|
AppState json.RawMessage `json:"app_state,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SaveAs is a utility method for saving GenensisDoc as a JSON file.
|
// SaveAs is a utility method for saving GenensisDoc as a JSON file.
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGenesis(t *testing.T) {
|
func TestGenesis(t *testing.T) {
|
||||||
|
|
||||||
// test some bad ones from raw json
|
// test some bad ones from raw json
|
||||||
testCases := [][]byte{
|
testCases := [][]byte{
|
||||||
[]byte{}, // empty
|
[]byte{}, // empty
|
||||||
|
@ -30,7 +29,7 @@ func TestGenesis(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test a good one by raw json
|
// test a good one by raw json
|
||||||
genDocBytes := []byte(`{"genesis_time":"0001-01-01T00:00:00Z","chain_id":"test-chain-QDKdJr","consensus_params":null,"validators":[{"pub_key":{"type":"ed25519","data":"961EAB8752E51A03618502F55C2B6E09C38C65635C64CCF3173ED452CF86C957"},"power":10,"name":""}],"app_hash":"","app_options":{"account_owner": "Bob"}}`)
|
genDocBytes := []byte(`{"genesis_time":"0001-01-01T00:00:00Z","chain_id":"test-chain-QDKdJr","consensus_params":null,"validators":[{"pub_key":{"type":"ed25519","data":"961EAB8752E51A03618502F55C2B6E09C38C65635C64CCF3173ED452CF86C957"},"power":10,"name":""}],"app_hash":"","app_state":{"account_owner": "Bob"}}`)
|
||||||
_, err := GenesisDocFromJSON(genDocBytes)
|
_, err := GenesisDocFromJSON(genDocBytes)
|
||||||
assert.NoError(t, err, "expected no error for good genDoc json")
|
assert.NoError(t, err, "expected no error for good genDoc json")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue