parent
15c209324f
commit
50926fffff
@ -752,7 +752,7 @@ Update to Tendermint v0.19.4 (fixes a consensus bug and improves logging)
|
||||
|
||||
BREAKING CHANGES
|
||||
|
||||
* [stake] MarshalJSON -> MarshalBinary
|
||||
* [stake] MarshalJSON -> MarshalBinaryLengthPrefixed
|
||||
* Queries against the store must be prefixed with the path "/store"
|
||||
|
||||
FEATURES
|
||||
|
||||
75
Gopkg.lock
generated
75
Gopkg.lock
generated
@ -10,6 +10,7 @@
|
||||
revision = "48b08affede2cea076a3cf13b2e3f72ed262b743"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:09a7f74eb6bb3c0f14d8926610c87f569c5cff68e978d30e9a3540aeb626fdf0"
|
||||
name = "github.com/bartekn/go-bip39"
|
||||
packages = ["."]
|
||||
@ -38,7 +39,7 @@
|
||||
name = "github.com/btcsuite/btcd"
|
||||
packages = ["btcec"]
|
||||
pruneopts = "UT"
|
||||
revision = "2a560b2036bee5e3679ec2133eb6520b2f195213"
|
||||
revision = "67e573d211ace594f1366b4ce9d39726c4b19bd0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:386de157f7d19259a7f9c81f26ce011223ce0f090353c1152ffdf730d7d10ac2"
|
||||
@ -62,13 +63,6 @@
|
||||
revision = "346938d642f2ec3594ed81d874461961cd0faa76"
|
||||
version = "v1.1.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:c7644c73a3d23741fdba8a99b1464e021a224b7e205be497271a8003a15ca41b"
|
||||
name = "github.com/ebuchman/fail-test"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "95f809107225be108efcf10a3509e4ea6ceef3c4"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:abeb38ade3f32a92943e5be54f55ed6d6e3b6602761d74b4aab4c9dd45c18abd"
|
||||
name = "github.com/fsnotify/fsnotify"
|
||||
@ -171,12 +165,13 @@
|
||||
version = "v1.2.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:ea40c24cdbacd054a6ae9de03e62c5f252479b96c716375aace5c120d68647c8"
|
||||
digest = "1:c0d19ab64b32ce9fe5cf4ddceba78d5bc9807f0016db6b1183599da3dcc24d10"
|
||||
name = "github.com/hashicorp/hcl"
|
||||
packages = [
|
||||
".",
|
||||
"hcl/ast",
|
||||
"hcl/parser",
|
||||
"hcl/printer",
|
||||
"hcl/scanner",
|
||||
"hcl/strconv",
|
||||
"hcl/token",
|
||||
@ -245,12 +240,12 @@
|
||||
version = "v1.0.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:e32dfc6abff6a3633ef4d9a1022fd707c8ef26f1e1e8f855dc58dc415ce7c8f3"
|
||||
digest = "1:53bc4cd4914cd7cd52139990d5170d6dc99067ae31c56530621b18b35fc30318"
|
||||
name = "github.com/mitchellh/mapstructure"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "fe40af7a9c397fa3ddba203c38a5042c5d0475ad"
|
||||
version = "v1.1.1"
|
||||
revision = "3536a929edddb9a5b34bd6861dc4a9647cb459fe"
|
||||
version = "v1.1.2"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:95741de3af260a92cc5c7f3f3061e85273f5a81b5db20d4bd68da74bd521675e"
|
||||
@ -296,7 +291,7 @@
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:63b68062b8968092eb86bedc4e68894bd096ea6b24920faca8b9dcf451f54bb5"
|
||||
digest = "1:db712fde5d12d6cdbdf14b777f0c230f4ff5ab0be8e35b239fc319953ed577a4"
|
||||
name = "github.com/prometheus/common"
|
||||
packages = [
|
||||
"expfmt",
|
||||
@ -304,11 +299,11 @@
|
||||
"model",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "c7de2306084e37d54b8be01f3541a8464345e9a5"
|
||||
revision = "7e9e6cabbd393fc208072eedef99188d0ce788b6"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:ef1dd9945e58ee9b635273d28c0ef3fa3742a7dedc038ebe207fd63e6ce000ef"
|
||||
digest = "1:ef74914912f99c79434d9c09658274678bc85080ebe3ab32bec3940ebce5e1fc"
|
||||
name = "github.com/prometheus/procfs"
|
||||
packages = [
|
||||
".",
|
||||
@ -317,7 +312,7 @@
|
||||
"xfs",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "418d78d0b9a7b7de3a6bbc8a23def624cc977bb2"
|
||||
revision = "185b4288413d2a0dd0806f78c90dde719829e5ae"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:ea0700160aca4ef099f4e06686a665a87691f4248dddd40796925eda2e46bd64"
|
||||
@ -346,12 +341,12 @@
|
||||
version = "v1.1.2"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:516e71bed754268937f57d4ecb190e01958452336fa73dbac880894164e91c1f"
|
||||
digest = "1:08d65904057412fc0270fc4812a1c90c594186819243160dc779a402d4b6d0bc"
|
||||
name = "github.com/spf13/cast"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "8965335b8c7107321228e3e3702cab9832751bac"
|
||||
version = "v1.2.0"
|
||||
revision = "8c9545af88b134710ab1cd196795e7f2388358d7"
|
||||
version = "v1.3.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:7ffc0983035bc7e297da3688d9fe19d60a420e9c38bef23f845c53788ed6a05e"
|
||||
@ -370,12 +365,12 @@
|
||||
version = "v1.0.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:dab83a1bbc7ad3d7a6ba1a1cc1760f25ac38cdf7d96a5cdd55cd915a4f5ceaf9"
|
||||
digest = "1:c1b1102241e7f645bc8e0c22ae352e8f0dc6484b6cb4d132fa9f24174e0119e2"
|
||||
name = "github.com/spf13/pflag"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "9a97c102cda95a86cec2345a6f09f55a939babf5"
|
||||
version = "v1.0.2"
|
||||
revision = "298182f68c66c05229eb03ac171abe6e309ee79a"
|
||||
version = "v1.0.3"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:f8e1a678a2571e265f4bf91a3e5e32aa6b1474a55cb0ea849750cc177b664d96"
|
||||
@ -424,35 +419,23 @@
|
||||
revision = "e5840949ff4fff0c56f9b6a541e22b63581ea9df"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:087aaa7920e5d0bf79586feb57ce01c35c830396ab4392798112e8aae8c47722"
|
||||
name = "github.com/tendermint/ed25519"
|
||||
packages = [
|
||||
".",
|
||||
"edwards25519",
|
||||
"extra25519",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "d8387025d2b9d158cf4efb07e7ebf814bcce2057"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:2c971a45c89ca2ccc735af50919cdee05fbdc54d4bf50625073693300e31ead8"
|
||||
digest = "1:10b3a599325740c84a7c81f3f3cb2e1fdb70b3ea01b7fa28495567a2519df431"
|
||||
name = "github.com/tendermint/go-amino"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "faa6e731944e2b7b6a46ad202902851e8ce85bee"
|
||||
version = "v0.12.0"
|
||||
revision = "6dcc6ddc143e116455c94b25c1004c99e0d0ca12"
|
||||
version = "v0.14.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:53397098d6acb7613358683cc84ae59281a60c6033f0bff62fa8d3f279c6c430"
|
||||
digest = "1:9f8c4c93658315a795ffd3e0c943d39f78067dd8382b8d7bcfaf6686b92f3978"
|
||||
name = "github.com/tendermint/iavl"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "3acc91fb8811db2c5409a855ae1f8e441fe98e2d"
|
||||
version = "v0.11.0"
|
||||
revision = "fa74114f764f9827c4ad5573f990ed25bf8c4bac"
|
||||
version = "v0.11.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:f9c7a1f3ee087476f4883c33cc7c1bdbe56b9670b2fb27855ea2f386393272f5"
|
||||
digest = "1:aeef94796024739a6d2fb3df26450a1e3d9dbaeee0e7d896b180b1ae6a7e342e"
|
||||
name = "github.com/tendermint/tendermint"
|
||||
packages = [
|
||||
"abci/client",
|
||||
@ -485,6 +468,7 @@
|
||||
"libs/db",
|
||||
"libs/errors",
|
||||
"libs/events",
|
||||
"libs/fail",
|
||||
"libs/flowrate",
|
||||
"libs/log",
|
||||
"libs/pubsub",
|
||||
@ -505,7 +489,6 @@
|
||||
"rpc/core",
|
||||
"rpc/core/types",
|
||||
"rpc/grpc",
|
||||
"rpc/lib",
|
||||
"rpc/lib/client",
|
||||
"rpc/lib/server",
|
||||
"rpc/lib/types",
|
||||
@ -518,8 +501,8 @@
|
||||
"version",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "90eda9bfb6e6daeed1c8015df41cb36772d91778"
|
||||
version = "v0.25.1-rc0"
|
||||
revision = "c086d0a34102bd42873d20445673ea1d18a539cd"
|
||||
version = "v0.26.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:7886f86064faff6f8d08a3eb0e8c773648ff5a2e27730831e2bfbf07467f6666"
|
||||
@ -530,13 +513,15 @@
|
||||
version = "v0.1.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:aaff04fa01d9b824fde6799759cc597b3ac3671b9ad31924c28b6557d0ee5284"
|
||||
digest = "1:6f6dc6060c4e9ba73cf28aa88f12a69a030d3d19d518ef8e931879eaa099628d"
|
||||
name = "golang.org/x/crypto"
|
||||
packages = [
|
||||
"bcrypt",
|
||||
"blowfish",
|
||||
"chacha20poly1305",
|
||||
"curve25519",
|
||||
"ed25519",
|
||||
"ed25519/internal/edwards25519",
|
||||
"hkdf",
|
||||
"internal/chacha20",
|
||||
"internal/subtle",
|
||||
|
||||
28
Gopkg.toml
28
Gopkg.toml
@ -1,24 +1,3 @@
|
||||
# Gopkg.toml example
|
||||
#
|
||||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
|
||||
# for detailed Gopkg.toml documentation.
|
||||
#
|
||||
# required = ["github.com/user/thing/cmd/thing"]
|
||||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project"
|
||||
# version = "1.0.0"
|
||||
#
|
||||
# [[override]]
|
||||
# name = "github.com/x/y"
|
||||
# version = "2.4.0"
|
||||
#
|
||||
# [prune]
|
||||
# non-go = false
|
||||
# go-tests = true
|
||||
# unused-packages = true
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/bgentry/speakeasy"
|
||||
version = "~0.1.0"
|
||||
@ -49,15 +28,15 @@
|
||||
|
||||
[[override]]
|
||||
name = "github.com/tendermint/go-amino"
|
||||
version = "=v0.12.0"
|
||||
version = "v0.14.0"
|
||||
|
||||
[[override]]
|
||||
name = "github.com/tendermint/iavl"
|
||||
version = "=v0.11.0"
|
||||
version = "=v0.11.1"
|
||||
|
||||
[[override]]
|
||||
name = "github.com/tendermint/tendermint"
|
||||
version = "=0.25.1-rc0"
|
||||
version = "v0.26.0"
|
||||
|
||||
## deps without releases:
|
||||
|
||||
@ -89,7 +68,6 @@
|
||||
version = "1.0.0"
|
||||
|
||||
## transitive deps, without releases:
|
||||
#
|
||||
|
||||
[[override]]
|
||||
name = "github.com/syndtr/goleveldb"
|
||||
|
||||
@ -337,7 +337,7 @@ func handleQueryApp(app *BaseApp, path []string, req abci.RequestQuery) (res abc
|
||||
}
|
||||
|
||||
// Encode with json
|
||||
value := codec.Cdc.MustMarshalBinary(result)
|
||||
value := codec.Cdc.MustMarshalBinaryLengthPrefixed(result)
|
||||
return abci.ResponseQuery{
|
||||
Code: uint32(sdk.ABCICodeOK),
|
||||
Value: value,
|
||||
|
||||
@ -358,7 +358,7 @@ func testTxDecoder(cdc *codec.Codec) sdk.TxDecoder {
|
||||
if len(txBytes) == 0 {
|
||||
return nil, sdk.ErrTxDecode("txBytes are empty")
|
||||
}
|
||||
err := cdc.UnmarshalBinary(txBytes, &tx)
|
||||
err := cdc.UnmarshalBinaryLengthPrefixed(txBytes, &tx)
|
||||
if err != nil {
|
||||
return nil, sdk.ErrTxDecode("").TraceSDK(err.Error())
|
||||
}
|
||||
@ -455,7 +455,7 @@ func TestCheckTx(t *testing.T) {
|
||||
|
||||
for i := int64(0); i < nTxs; i++ {
|
||||
tx := newTxCounter(i, 0)
|
||||
txBytes, err := codec.MarshalBinary(tx)
|
||||
txBytes, err := codec.MarshalBinaryLengthPrefixed(tx)
|
||||
require.NoError(t, err)
|
||||
r := app.CheckTx(txBytes)
|
||||
assert.True(t, r.IsOK(), fmt.Sprintf("%v", r))
|
||||
@ -503,7 +503,7 @@ func TestDeliverTx(t *testing.T) {
|
||||
for i := 0; i < txPerHeight; i++ {
|
||||
counter := int64(blockN*txPerHeight + i)
|
||||
tx := newTxCounter(counter, counter)
|
||||
txBytes, err := codec.MarshalBinary(tx)
|
||||
txBytes, err := codec.MarshalBinaryLengthPrefixed(tx)
|
||||
require.NoError(t, err)
|
||||
res := app.DeliverTx(txBytes)
|
||||
require.True(t, res.IsOK(), fmt.Sprintf("%v", res))
|
||||
@ -544,7 +544,7 @@ func TestMultiMsgDeliverTx(t *testing.T) {
|
||||
{
|
||||
app.BeginBlock(abci.RequestBeginBlock{})
|
||||
tx := newTxCounter(0, 0, 1, 2)
|
||||
txBytes, err := codec.MarshalBinary(tx)
|
||||
txBytes, err := codec.MarshalBinaryLengthPrefixed(tx)
|
||||
require.NoError(t, err)
|
||||
res := app.DeliverTx(txBytes)
|
||||
require.True(t, res.IsOK(), fmt.Sprintf("%v", res))
|
||||
@ -565,7 +565,7 @@ func TestMultiMsgDeliverTx(t *testing.T) {
|
||||
tx := newTxCounter(1, 3)
|
||||
tx.Msgs = append(tx.Msgs, msgCounter2{0})
|
||||
tx.Msgs = append(tx.Msgs, msgCounter2{1})
|
||||
txBytes, err := codec.MarshalBinary(tx)
|
||||
txBytes, err := codec.MarshalBinaryLengthPrefixed(tx)
|
||||
require.NoError(t, err)
|
||||
res := app.DeliverTx(txBytes)
|
||||
require.True(t, res.IsOK(), fmt.Sprintf("%v", res))
|
||||
@ -638,7 +638,7 @@ func TestSimulateTx(t *testing.T) {
|
||||
require.Equal(t, gasConsumed, result.GasUsed)
|
||||
|
||||
// simulate by calling Query with encoded tx
|
||||
txBytes, err := cdc.MarshalBinary(tx)
|
||||
txBytes, err := cdc.MarshalBinaryLengthPrefixed(tx)
|
||||
require.Nil(t, err)
|
||||
query := abci.RequestQuery{
|
||||
Path: "/app/simulate",
|
||||
@ -648,7 +648,7 @@ func TestSimulateTx(t *testing.T) {
|
||||
require.True(t, queryResult.IsOK(), queryResult.Log)
|
||||
|
||||
var res sdk.Result
|
||||
codec.Cdc.MustUnmarshalBinary(queryResult.Value, &res)
|
||||
codec.Cdc.MustUnmarshalBinaryLengthPrefixed(queryResult.Value, &res)
|
||||
require.Nil(t, err, "Result unmarshalling failed")
|
||||
require.True(t, res.IsOK(), res.Log)
|
||||
require.Equal(t, gasConsumed, res.GasUsed, res.Log)
|
||||
@ -729,7 +729,7 @@ func TestRunInvalidTransaction(t *testing.T) {
|
||||
registerTestCodec(newCdc)
|
||||
newCdc.RegisterConcrete(&msgNoDecode{}, "cosmos-sdk/baseapp/msgNoDecode", nil)
|
||||
|
||||
txBytes, err := newCdc.MarshalBinary(tx)
|
||||
txBytes, err := newCdc.MarshalBinaryLengthPrefixed(tx)
|
||||
require.NoError(t, err)
|
||||
res := app.DeliverTx(txBytes)
|
||||
require.EqualValues(t, sdk.ToABCICode(sdk.CodespaceRoot, sdk.CodeTxDecode), res.Code)
|
||||
|
||||
@ -121,8 +121,13 @@ func createVerifier() tmlite.Verifier {
|
||||
fmt.Printf("Must specify these options: %s when --trust-node is false\n", errMsg.String())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
node := rpcclient.NewHTTP(nodeURI, "/websocket")
|
||||
verifier, err := tmliteProxy.NewVerifier(chainID, filepath.Join(home, ".gaialite"), node, log.NewNopLogger())
|
||||
cacheSize := 10 // TODO: determine appropriate cache size
|
||||
verifier, err := tmliteProxy.NewVerifier(
|
||||
chainID, filepath.Join(home, ".gaialite"),
|
||||
node, log.NewNopLogger(), cacheSize,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("Create verifier failed: %s\n", err.Error())
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
|
||||
"strings"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
@ -54,7 +53,7 @@ func (ctx CLIContext) QuerySubspace(subspace []byte, storeName string) (res []sd
|
||||
return res, err
|
||||
}
|
||||
|
||||
ctx.Codec.MustUnmarshalBinary(resRaw, &res)
|
||||
ctx.Codec.MustUnmarshalBinaryLengthPrefixed(resRaw, &res)
|
||||
return
|
||||
}
|
||||
|
||||
@ -157,8 +156,8 @@ func (ctx CLIContext) query(path string, key cmn.HexBytes) (res []byte, err erro
|
||||
}
|
||||
|
||||
opts := rpcclient.ABCIQueryOptions{
|
||||
Height: ctx.Height,
|
||||
Trusted: ctx.TrustNode,
|
||||
Height: ctx.Height,
|
||||
Prove: !ctx.TrustNode,
|
||||
}
|
||||
|
||||
result, err := node.ABCIQueryWithOptions(path, key, opts)
|
||||
@ -203,32 +202,33 @@ func (ctx CLIContext) verifyProof(_ string, resp abci.ResponseQuery) error {
|
||||
return fmt.Errorf("missing valid certifier to verify data from distrusted node")
|
||||
}
|
||||
|
||||
// the AppHash for height H is in header H+1
|
||||
commit, err := ctx.Verify(resp.Height + 1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// TODO: handle in another TM v0.26 update PR
|
||||
// // the AppHash for height H is in header H+1
|
||||
// commit, err := ctx.Verify(resp.Height + 1)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
var multiStoreProof store.MultiStoreProof
|
||||
cdc := codec.New()
|
||||
// var multiStoreProof store.MultiStoreProof
|
||||
// cdc := codec.New()
|
||||
|
||||
err = cdc.UnmarshalBinary(resp.Proof, &multiStoreProof)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to unmarshalBinary rangeProof")
|
||||
}
|
||||
// err = cdc.UnmarshalBinaryLengthPrefixed(resp.Proof, &multiStoreProof)
|
||||
// if err != nil {
|
||||
// return errors.Wrap(err, "failed to unmarshalBinary rangeProof")
|
||||
// }
|
||||
|
||||
// verify the substore commit hash against trusted appHash
|
||||
substoreCommitHash, err := store.VerifyMultiStoreCommitInfo(
|
||||
multiStoreProof.StoreName, multiStoreProof.StoreInfos, commit.Header.AppHash,
|
||||
)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed in verifying the proof against appHash")
|
||||
}
|
||||
// // verify the substore commit hash against trusted appHash
|
||||
// substoreCommitHash, err := store.VerifyMultiStoreCommitInfo(
|
||||
// multiStoreProof.StoreName, multiStoreProof.StoreInfos, commit.Header.AppHash,
|
||||
// )
|
||||
// if err != nil {
|
||||
// return errors.Wrap(err, "failed in verifying the proof against appHash")
|
||||
// }
|
||||
|
||||
err = store.VerifyRangeProof(resp.Key, resp.Value, substoreCommitHash, &multiStoreProof.RangeProof)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed in the range proof verification")
|
||||
}
|
||||
// err = store.VerifyRangeProof(resp.Key, resp.Value, substoreCommitHash, &multiStoreProof.RangeProof)
|
||||
// if err != nil {
|
||||
// return errors.Wrap(err, "failed in the range proof verification")
|
||||
// }
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -158,11 +158,11 @@ func TestNodeStatus(t *testing.T) {
|
||||
res, body := Request(t, port, "GET", "/node_info", nil)
|
||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||
|
||||
var nodeInfo p2p.NodeInfo
|
||||
var nodeInfo p2p.DefaultNodeInfo
|
||||
err := cdc.UnmarshalJSON([]byte(body), &nodeInfo)
|
||||
require.Nil(t, err, "Couldn't parse node info")
|
||||
|
||||
require.NotEqual(t, p2p.NodeInfo{}, nodeInfo, "res: %v", res)
|
||||
require.NotEqual(t, p2p.DefaultNodeInfo{}, nodeInfo, "res: %v", res)
|
||||
|
||||
// syncing
|
||||
res, body = Request(t, port, "GET", "/syncing", nil)
|
||||
|
||||
@ -125,7 +125,7 @@ type Info struct {
|
||||
func parseTx(cdc *codec.Codec, txBytes []byte) (sdk.Tx, error) {
|
||||
var tx auth.StdTx
|
||||
|
||||
err := cdc.UnmarshalBinary(txBytes, &tx)
|
||||
err := cdc.UnmarshalBinaryLengthPrefixed(txBytes, &tx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ func adjustGasEstimate(estimate int64, adjustment float64) int64 {
|
||||
|
||||
func parseQueryResponse(cdc *amino.Codec, rawRes []byte) (int64, error) {
|
||||
var simulationResult sdk.Result
|
||||
if err := cdc.UnmarshalBinary(rawRes, &simulationResult); err != nil {
|
||||
if err := cdc.UnmarshalBinaryLengthPrefixed(rawRes, &simulationResult); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return simulationResult.GasUsed, nil
|
||||
|
||||
@ -12,7 +12,7 @@ import (
|
||||
|
||||
func TestParseQueryResponse(t *testing.T) {
|
||||
cdc := app.MakeCodec()
|
||||
sdkResBytes := cdc.MustMarshalBinary(sdk.Result{GasUsed: 10})
|
||||
sdkResBytes := cdc.MustMarshalBinaryLengthPrefixed(sdk.Result{GasUsed: 10})
|
||||
gas, err := parseQueryResponse(cdc, sdkResBytes)
|
||||
assert.Equal(t, gas, int64(10))
|
||||
assert.Nil(t, err)
|
||||
@ -28,7 +28,7 @@ func TestCalculateGas(t *testing.T) {
|
||||
if wantErr {
|
||||
return nil, errors.New("")
|
||||
}
|
||||
return cdc.MustMarshalBinary(sdk.Result{GasUsed: gasUsed}), nil
|
||||
return cdc.MustMarshalBinaryLengthPrefixed(sdk.Result{GasUsed: gasUsed}), nil
|
||||
}
|
||||
}
|
||||
type args struct {
|
||||
|
||||
@ -259,7 +259,7 @@ func (app *GaiaApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
bz := app.cdc.MustMarshalBinary(tx)
|
||||
bz := app.cdc.MustMarshalBinaryLengthPrefixed(tx)
|
||||
res := app.BaseApp.DeliverTx(bz)
|
||||
if !res.IsOK() {
|
||||
panic(res.Log)
|
||||
|
||||
@ -220,7 +220,7 @@ func runTxCmd(cmd *cobra.Command, args []string) error {
|
||||
var tx = auth.StdTx{}
|
||||
cdc := gaia.MakeCodec()
|
||||
|
||||
err = cdc.UnmarshalBinary(txBytes, &tx)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(txBytes, &tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ func (kb dbKeybase) Sign(name, passphrase string, msg []byte) (sig []byte, pub t
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
cdc.MustUnmarshalBinary([]byte(signed), sig)
|
||||
cdc.MustUnmarshalBinaryLengthPrefixed([]byte(signed), sig)
|
||||
return sig, linfo.GetPubKey(), nil
|
||||
}
|
||||
sig, err = priv.Sign(msg)
|
||||
|
||||
@ -182,11 +182,11 @@ func (i offlineInfo) GetAddress() types.AccAddress {
|
||||
|
||||
// encoding info
|
||||
func writeInfo(i Info) []byte {
|
||||
return cdc.MustMarshalBinary(i)
|
||||
return cdc.MustMarshalBinaryLengthPrefixed(i)
|
||||
}
|
||||
|
||||
// decoding info
|
||||
func readInfo(bz []byte) (info Info, err error) {
|
||||
err = cdc.UnmarshalBinary(bz, &info)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(bz, &info)
|
||||
return
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ func (tx app2Tx) GetMsgs() []sdk.Msg {
|
||||
func tx2Decoder(cdc *codec.Codec) sdk.TxDecoder {
|
||||
return func(txBytes []byte) (sdk.Tx, sdk.Error) {
|
||||
var tx app2Tx
|
||||
err := cdc.UnmarshalBinary(txBytes, &tx)
|
||||
err := cdc.UnmarshalBinaryLengthPrefixed(txBytes, &tx)
|
||||
if err != nil {
|
||||
return nil, sdk.ErrTxDecode(err.Error())
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@ func (tx app2Tx) GetSignature() []byte {
|
||||
func tx2Decoder(cdc *codec.Codec) sdk.TxDecoder {
|
||||
return func(txBytes []byte) (sdk.Tx, sdk.Error) {
|
||||
var tx app2Tx
|
||||
err := cdc.UnmarshalBinary(txBytes, &tx)
|
||||
err := cdc.UnmarshalBinaryLengthPrefixed(txBytes, &tx)
|
||||
if err != nil {
|
||||
return nil, sdk.ErrTxDecode(err.Error())
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ func TestEncoding(t *testing.T) {
|
||||
cdc := NewCodec()
|
||||
testTxDecoder := tx2Decoder(cdc)
|
||||
|
||||
encodedSendTx, err := cdc.MarshalBinary(sendTxBefore)
|
||||
encodedSendTx, err := cdc.MarshalBinaryLengthPrefixed(sendTxBefore)
|
||||
|
||||
require.Nil(t, err, "Error encoding sendTx")
|
||||
|
||||
@ -69,7 +69,7 @@ func TestEncoding(t *testing.T) {
|
||||
Signature: sig,
|
||||
}
|
||||
|
||||
encodedIssueTx, err2 := cdc.MarshalBinary(issueTxBefore)
|
||||
encodedIssueTx, err2 := cdc.MarshalBinaryLengthPrefixed(issueTxBefore)
|
||||
|
||||
require.Nil(t, err2, "Error encoding issueTx")
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ func (keeper Keeper) Info(ctx sdk.Context, p Payload) (res Info) {
|
||||
if bz == nil {
|
||||
return EmptyInfo(ctx)
|
||||
}
|
||||
keeper.cdc.MustUnmarshalBinary(bz, &res)
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &res)
|
||||
|
||||
return
|
||||
}
|
||||
@ -80,7 +80,7 @@ func (keeper Keeper) setInfo(ctx sdk.Context, p Payload, info Info) {
|
||||
store := ctx.KVStore(keeper.key)
|
||||
|
||||
key := GetInfoKey(p, keeper.cdc)
|
||||
bz := keeper.cdc.MustMarshalBinary(info)
|
||||
bz := keeper.cdc.MustMarshalBinaryLengthPrefixed(info)
|
||||
store.Set(key, bz)
|
||||
}
|
||||
|
||||
|
||||
@ -7,13 +7,13 @@ import (
|
||||
|
||||
// GetInfoKey returns the key for OracleInfo
|
||||
func GetInfoKey(p Payload, cdc *codec.Codec) []byte {
|
||||
bz := cdc.MustMarshalBinary(p)
|
||||
bz := cdc.MustMarshalBinaryLengthPrefixed(p)
|
||||
return append([]byte{0x00}, bz...)
|
||||
}
|
||||
|
||||
// GetSignPrefix returns the prefix for signs
|
||||
func GetSignPrefix(p Payload, cdc *codec.Codec) []byte {
|
||||
bz := cdc.MustMarshalBinary(p)
|
||||
bz := cdc.MustMarshalBinaryLengthPrefixed(p)
|
||||
return append([]byte{0x01}, bz...)
|
||||
}
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ func getSequence(ctx sdk.Context, key sdk.StoreKey) int {
|
||||
if seqbz == nil {
|
||||
seq = 0
|
||||
} else {
|
||||
codec.New().MustUnmarshalBinary(seqbz, &seq)
|
||||
codec.New().MustUnmarshalBinaryLengthPrefixed(seqbz, &seq)
|
||||
}
|
||||
|
||||
return seq
|
||||
@ -96,7 +96,7 @@ func handleSeqOracle(ctx sdk.Context, key sdk.StoreKey, o seqOracle) sdk.Error {
|
||||
return sdk.NewError(sdk.CodespaceRoot, 1, "")
|
||||
}
|
||||
|
||||
bz := codec.New().MustMarshalBinary(seq + 1)
|
||||
bz := codec.New().MustMarshalBinaryLengthPrefixed(seq + 1)
|
||||
store.Set([]byte("seq"), bz)
|
||||
|
||||
return nil
|
||||
|
||||
@ -39,7 +39,7 @@ func (k Keeper) getBondInfo(ctx sdk.Context, addr sdk.AccAddress) bondInfo {
|
||||
return bondInfo{}
|
||||
}
|
||||
var bi bondInfo
|
||||
err := k.cdc.UnmarshalBinary(bz, &bi)
|
||||
err := k.cdc.UnmarshalBinaryLengthPrefixed(bz, &bi)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -48,7 +48,7 @@ func (k Keeper) getBondInfo(ctx sdk.Context, addr sdk.AccAddress) bondInfo {
|
||||
|
||||
func (k Keeper) setBondInfo(ctx sdk.Context, addr sdk.AccAddress, bi bondInfo) {
|
||||
store := ctx.KVStore(k.key)
|
||||
bz, err := k.cdc.MarshalBinary(bi)
|
||||
bz, err := k.cdc.MarshalBinaryLengthPrefixed(bi)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -93,7 +93,6 @@ func startStandAlone(ctx *Context, appCreator AppCreator) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// nolint: unparam
|
||||
func startInProcess(ctx *Context, appCreator AppCreator) (*node.Node, error) {
|
||||
cfg := ctx.Config
|
||||
home := cfg.RootDir
|
||||
@ -135,7 +134,12 @@ func startInProcess(ctx *Context, appCreator AppCreator) (*node.Node, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// trap signal (run forever)
|
||||
tmNode.RunForever()
|
||||
return tmNode, nil
|
||||
TrapSignal(func() {
|
||||
if tmNode.IsRunning() {
|
||||
_ = tmNode.Stop()
|
||||
}
|
||||
})
|
||||
|
||||
// run forever (the node will not be returned)
|
||||
select {}
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
"github.com/tendermint/go-amino"
|
||||
"github.com/tendermint/iavl"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
@ -210,44 +209,56 @@ func (st *iavlStore) Query(req abci.RequestQuery) (res abci.ResponseQuery) {
|
||||
res.Height = getHeight(tree, req)
|
||||
|
||||
switch req.Path {
|
||||
case "/store", "/key": // Get by key
|
||||
case "/key":
|
||||
key := req.Data // Data holds the key bytes
|
||||
|
||||
res.Key = key
|
||||
if !st.VersionExists(res.Height) {
|
||||
res.Log = cmn.ErrorWrap(iavl.ErrVersionDoesNotExist, "").Error()
|
||||
break
|
||||
}
|
||||
|
||||
if req.Prove {
|
||||
value, proof, err := tree.GetVersionedWithProof(key, res.Height)
|
||||
value, _, err := tree.GetVersionedWithProof(key, res.Height)
|
||||
if err != nil {
|
||||
res.Log = err.Error()
|
||||
break
|
||||
}
|
||||
|
||||
res.Value = value
|
||||
cdc := amino.NewCodec()
|
||||
p, err := cdc.MarshalBinary(proof)
|
||||
if err != nil {
|
||||
res.Log = err.Error()
|
||||
break
|
||||
}
|
||||
res.Proof = p
|
||||
// cdc := amino.NewCodec()
|
||||
|
||||
// p, err := cdc.MarshalBinaryLengthPrefixed(proof)
|
||||
// if err != nil {
|
||||
// res.Log = err.Error()
|
||||
// break
|
||||
// }
|
||||
|
||||
// TODO: handle in another TM v0.26 update PR
|
||||
// res.Proof = p
|
||||
} else {
|
||||
_, res.Value = tree.GetVersioned(key, res.Height)
|
||||
}
|
||||
|
||||
case "/subspace":
|
||||
var KVs []KVPair
|
||||
|
||||
subspace := req.Data
|
||||
res.Key = subspace
|
||||
var KVs []KVPair
|
||||
|
||||
iterator := sdk.KVStorePrefixIterator(st, subspace)
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
KVs = append(KVs, KVPair{Key: iterator.Key(), Value: iterator.Value()})
|
||||
}
|
||||
|
||||
iterator.Close()
|
||||
res.Value = cdc.MustMarshalBinary(KVs)
|
||||
res.Value = cdc.MustMarshalBinaryLengthPrefixed(KVs)
|
||||
|
||||
default:
|
||||
msg := fmt.Sprintf("Unexpected Query path: %v", req.Path)
|
||||
return sdk.ErrUnknownRequest(msg).QueryResult()
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -394,9 +394,9 @@ func TestIAVLStoreQuery(t *testing.T) {
|
||||
{Key: k1, Value: v3},
|
||||
{Key: k2, Value: v2},
|
||||
}
|
||||
valExpSubEmpty := cdc.MustMarshalBinary(KVs0)
|
||||
valExpSub1 := cdc.MustMarshalBinary(KVs1)
|
||||
valExpSub2 := cdc.MustMarshalBinary(KVs2)
|
||||
valExpSubEmpty := cdc.MustMarshalBinaryLengthPrefixed(KVs0)
|
||||
valExpSub1 := cdc.MustMarshalBinaryLengthPrefixed(KVs1)
|
||||
valExpSub2 := cdc.MustMarshalBinaryLengthPrefixed(KVs2)
|
||||
|
||||
cid := iavlStore.Commit()
|
||||
ver := cid.Version
|
||||
@ -459,7 +459,7 @@ func TestIAVLStoreQuery(t *testing.T) {
|
||||
require.Equal(t, valExpSub2, qres.Value)
|
||||
|
||||
// default (height 0) will show latest -1
|
||||
query0 := abci.RequestQuery{Path: "/store", Data: k1}
|
||||
query0 := abci.RequestQuery{Path: "/key", Data: k1}
|
||||
qres = iavlStore.Query(query0)
|
||||
require.Equal(t, uint32(sdk.CodeOK), qres.Code)
|
||||
require.Equal(t, v1, qres.Value)
|
||||
|
||||
@ -42,21 +42,22 @@ func (m List) Len() (res uint64) {
|
||||
if bz == nil {
|
||||
return 0
|
||||
}
|
||||
m.cdc.MustUnmarshalBinary(bz, &res)
|
||||
|
||||
m.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &res)
|
||||
return
|
||||
}
|
||||
|
||||
// Get() returns the element by its index
|
||||
func (m List) Get(index uint64, ptr interface{}) error {
|
||||
bz := m.store.Get(ElemKey(index))
|
||||
return m.cdc.UnmarshalBinary(bz, ptr)
|
||||
return m.cdc.UnmarshalBinaryLengthPrefixed(bz, ptr)
|
||||
}
|
||||
|
||||
// Set() stores the element to the given position
|
||||
// Setting element out of range will break length counting
|
||||
// Use Push() instead of Set() to append a new element
|
||||
func (m List) Set(index uint64, value interface{}) {
|
||||
bz := m.cdc.MustMarshalBinary(value)
|
||||
bz := m.cdc.MustMarshalBinaryLengthPrefixed(value)
|
||||
m.store.Set(ElemKey(index), bz)
|
||||
}
|
||||
|
||||
@ -72,7 +73,7 @@ func (m List) Delete(index uint64) {
|
||||
func (m List) Push(value interface{}) {
|
||||
length := m.Len()
|
||||
m.Set(length, value)
|
||||
m.store.Set(LengthKey(), m.cdc.MustMarshalBinary(length+1))
|
||||
m.store.Set(LengthKey(), m.cdc.MustMarshalBinaryLengthPrefixed(length+1))
|
||||
}
|
||||
|
||||
// Iterate() is used to iterate over all existing elements in the list
|
||||
@ -85,13 +86,16 @@ func (m List) Iterate(ptr interface{}, fn func(uint64) bool) {
|
||||
iter := sdk.KVStorePrefixIterator(m.store, []byte{0x01})
|
||||
for ; iter.Valid(); iter.Next() {
|
||||
v := iter.Value()
|
||||
m.cdc.MustUnmarshalBinary(v, ptr)
|
||||
m.cdc.MustUnmarshalBinaryLengthPrefixed(v, ptr)
|
||||
|
||||
k := iter.Key()
|
||||
s := string(k[len(k)-20:])
|
||||
|
||||
index, err := strconv.ParseUint(s, 10, 64)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if fn(index) {
|
||||
break
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ type MultiStoreProof struct {
|
||||
// buildMultiStoreProof build MultiStoreProof based on iavl proof and storeInfos
|
||||
func buildMultiStoreProof(iavlProof []byte, storeName string, storeInfos []storeInfo) []byte {
|
||||
var rangeProof iavl.RangeProof
|
||||
cdc.MustUnmarshalBinary(iavlProof, &rangeProof)
|
||||
cdc.MustUnmarshalBinaryLengthPrefixed(iavlProof, &rangeProof)
|
||||
|
||||
msp := MultiStoreProof{
|
||||
StoreInfos: storeInfos,
|
||||
@ -26,7 +26,7 @@ func buildMultiStoreProof(iavlProof []byte, storeName string, storeInfos []store
|
||||
RangeProof: rangeProof,
|
||||
}
|
||||
|
||||
proof := cdc.MustMarshalBinary(msp)
|
||||
proof := cdc.MustMarshalBinaryLengthPrefixed(msp)
|
||||
return proof
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,8 @@ import (
|
||||
)
|
||||
|
||||
func TestVerifyMultiStoreCommitInfo(t *testing.T) {
|
||||
// TODO: handle in another TM v0.26 update PR
|
||||
t.SkipNow()
|
||||
appHash, _ := hex.DecodeString("69959B1B4E68E0F7BD3551A50C8F849B81801AF2")
|
||||
|
||||
substoreRootHash, _ := hex.DecodeString("ea5d468431015c2cd6295e9a0bb1fc0e49033828")
|
||||
|
||||
@ -27,12 +27,12 @@ func (m Queue) getTop() (res uint64) {
|
||||
return 0
|
||||
}
|
||||
|
||||
m.List.cdc.MustUnmarshalBinary(bz, &res)
|
||||
m.List.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &res)
|
||||
return
|
||||
}
|
||||
|
||||
func (m Queue) setTop(top uint64) {
|
||||
bz := m.List.cdc.MustMarshalBinary(top)
|
||||
bz := m.List.cdc.MustMarshalBinaryLengthPrefixed(top)
|
||||
m.List.store.Set(TopKey(), bz)
|
||||
}
|
||||
|
||||
|
||||
@ -81,7 +81,7 @@ func TestKeys(t *testing.T) {
|
||||
var actual int
|
||||
|
||||
// Checking keys.LengthKey
|
||||
err := cdc.UnmarshalBinary(store.Get(LengthKey()), &len)
|
||||
err := cdc.UnmarshalBinaryLengthPrefixed(store.Get(LengthKey()), &len)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, len, queue.List.Len())
|
||||
|
||||
@ -89,14 +89,14 @@ func TestKeys(t *testing.T) {
|
||||
for i := 0; i < 10; i++ {
|
||||
queue.List.Get(uint64(i), &expected)
|
||||
bz := store.Get(ElemKey(uint64(i)))
|
||||
err = cdc.UnmarshalBinary(bz, &actual)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(bz, &actual)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
queue.Pop()
|
||||
|
||||
err = cdc.UnmarshalBinary(store.Get(TopKey()), &top)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(store.Get(TopKey()), &top)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, top, queue.getTop())
|
||||
}
|
||||
|
||||
@ -295,13 +295,13 @@ func (rs *rootMultiStore) Query(req abci.RequestQuery) abci.ResponseQuery {
|
||||
return res
|
||||
}
|
||||
|
||||
commitInfo, errMsg := getCommitInfo(rs.db, res.Height)
|
||||
if errMsg != nil {
|
||||
return sdk.ErrInternal(errMsg.Error()).QueryResult()
|
||||
}
|
||||
|
||||
res.Proof = buildMultiStoreProof(res.Proof, storeName, commitInfo.StoreInfos)
|
||||
// commitInfo, errMsg := getCommitInfo(rs.db, res.Height)
|
||||
// if errMsg != nil {
|
||||
// return sdk.ErrInternal(errMsg.Error()).QueryResult()
|
||||
// }
|
||||
|
||||
// TODO: handle in another TM v0.26 update PR
|
||||
// res.Proof = buildMultiStoreProof(res.Proof, storeName, commitInfo.StoreInfos)
|
||||
return res
|
||||
}
|
||||
|
||||
@ -386,11 +386,12 @@ type commitInfo struct {
|
||||
|
||||
// Hash returns the simple merkle root hash of the stores sorted by name.
|
||||
func (ci commitInfo) Hash() []byte {
|
||||
// TODO cache to ci.hash []byte
|
||||
m := make(map[string]merkle.Hasher, len(ci.StoreInfos))
|
||||
// TODO: cache to ci.hash []byte
|
||||
m := make(map[string][]byte, len(ci.StoreInfos))
|
||||
for _, storeInfo := range ci.StoreInfos {
|
||||
m[storeInfo.Name] = storeInfo
|
||||
m[storeInfo.Name] = storeInfo.Hash()
|
||||
}
|
||||
|
||||
return merkle.SimpleHashFromMap(m)
|
||||
}
|
||||
|
||||
@ -422,13 +423,15 @@ type storeCore struct {
|
||||
func (si storeInfo) Hash() []byte {
|
||||
// Doesn't write Name, since merkle.SimpleHashFromMap() will
|
||||
// include them via the keys.
|
||||
bz, _ := cdc.MarshalBinary(si.Core) // Does not error
|
||||
bz, _ := cdc.MarshalBinaryLengthPrefixed(si.Core)
|
||||
hasher := tmhash.New()
|
||||
|
||||
_, err := hasher.Write(bz)
|
||||
if err != nil {
|
||||
// TODO: Handle with #870
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return hasher.Sum(nil)
|
||||
}
|
||||
|
||||
@ -441,16 +444,18 @@ func getLatestVersion(db dbm.DB) int64 {
|
||||
if latestBytes == nil {
|
||||
return 0
|
||||
}
|
||||
err := cdc.UnmarshalBinary(latestBytes, &latest)
|
||||
|
||||
err := cdc.UnmarshalBinaryLengthPrefixed(latestBytes, &latest)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return latest
|
||||
}
|
||||
|
||||
// Set the latest version.
|
||||
func setLatestVersion(batch dbm.Batch, version int64) {
|
||||
latestBytes, _ := cdc.MarshalBinary(version) // Does not error
|
||||
latestBytes, _ := cdc.MarshalBinaryLengthPrefixed(version)
|
||||
batch.Set([]byte(latestVersionKey), latestBytes)
|
||||
}
|
||||
|
||||
@ -491,21 +496,19 @@ func getCommitInfo(db dbm.DB, ver int64) (commitInfo, error) {
|
||||
return commitInfo{}, fmt.Errorf("failed to get rootMultiStore: no data")
|
||||
}
|
||||
|
||||
// Parse bytes.
|
||||
var cInfo commitInfo
|
||||
err := cdc.UnmarshalBinary(cInfoBytes, &cInfo)
|
||||
|
||||
err := cdc.UnmarshalBinaryLengthPrefixed(cInfoBytes, &cInfo)
|
||||
if err != nil {
|
||||
return commitInfo{}, fmt.Errorf("failed to get rootMultiStore: %v", err)
|
||||
}
|
||||
|
||||
return cInfo, nil
|
||||
}
|
||||
|
||||
// Set a commitInfo for given version.
|
||||
func setCommitInfo(batch dbm.Batch, version int64, cInfo commitInfo) {
|
||||
cInfoBytes, err := cdc.MarshalBinary(cInfo)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cInfoBytes := cdc.MustMarshalBinaryLengthPrefixed(cInfo)
|
||||
cInfoKey := fmt.Sprintf(commitInfoKeyFmt, version)
|
||||
batch.Set([]byte(cInfoKey), cInfoBytes)
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ func getExpectedCommitID(store *rootMultiStore, ver int64) CommitID {
|
||||
}
|
||||
|
||||
func hashStores(stores map[StoreKey]CommitStore) []byte {
|
||||
m := make(map[string]merkle.Hasher, len(stores))
|
||||
m := make(map[string][]byte, len(stores))
|
||||
for key, store := range stores {
|
||||
name := key.Name()
|
||||
m[name] = storeInfo{
|
||||
@ -224,7 +224,7 @@ func hashStores(stores map[StoreKey]CommitStore) []byte {
|
||||
CommitID: store.LastCommitID(),
|
||||
// StoreType: store.GetStoreType(),
|
||||
},
|
||||
}
|
||||
}.Hash()
|
||||
}
|
||||
return merkle.SimpleHashFromMap(m)
|
||||
}
|
||||
|
||||
@ -305,11 +305,11 @@ func TestSerializationGocodecJSON(t *testing.T) {
|
||||
func TestSerializationGocodecBinary(t *testing.T) {
|
||||
d := mustNewDecFromStr(t, "0.333")
|
||||
|
||||
bz, err := cdc.MarshalBinary(d)
|
||||
bz, err := cdc.MarshalBinaryLengthPrefixed(d)
|
||||
require.NoError(t, err)
|
||||
|
||||
var d2 Dec
|
||||
err = cdc.UnmarshalBinary(bz, &d2)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(bz, &d2)
|
||||
require.NoError(t, err)
|
||||
require.True(t, d.Equal(d2), "original: %v, unmarshalled: %v", d, d2)
|
||||
}
|
||||
@ -323,11 +323,11 @@ type testDEmbedStruct struct {
|
||||
// TODO make work for UnmarshalJSON
|
||||
func TestEmbeddedStructSerializationGocodec(t *testing.T) {
|
||||
obj := testDEmbedStruct{"foo", 10, NewDecWithPrec(1, 3)}
|
||||
bz, err := cdc.MarshalBinary(obj)
|
||||
bz, err := cdc.MarshalBinaryLengthPrefixed(obj)
|
||||
require.Nil(t, err)
|
||||
|
||||
var obj2 testDEmbedStruct
|
||||
err = cdc.UnmarshalBinary(bz, &obj2)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(bz, &obj2)
|
||||
require.Nil(t, err)
|
||||
|
||||
require.Equal(t, obj.Field1, obj2.Field1)
|
||||
|
||||
@ -93,16 +93,16 @@ func TestBaseAccountMarshal(t *testing.T) {
|
||||
cdc := codec.New()
|
||||
codec.RegisterCrypto(cdc)
|
||||
|
||||
b, err := cdc.MarshalBinary(acc)
|
||||
b, err := cdc.MarshalBinaryLengthPrefixed(acc)
|
||||
require.Nil(t, err)
|
||||
|
||||
acc2 := BaseAccount{}
|
||||
err = cdc.UnmarshalBinary(b, &acc2)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(b, &acc2)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, acc, acc2)
|
||||
|
||||
// error on bad bytes
|
||||
acc2 = BaseAccount{}
|
||||
err = cdc.UnmarshalBinary(b[:len(b)/2], &acc2)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(b[:len(b)/2], &acc2)
|
||||
require.NotNil(t, err)
|
||||
}
|
||||
|
||||
@ -125,7 +125,8 @@ func (bldr TxBuilder) Sign(name, passphrase string, msg StdSignMsg) ([]byte, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bldr.Codec.MarshalBinary(auth.NewStdTx(msg.Msgs, msg.Fee, []auth.StdSignature{sig}, msg.Memo))
|
||||
|
||||
return bldr.Codec.MarshalBinaryLengthPrefixed(auth.NewStdTx(msg.Msgs, msg.Fee, []auth.StdSignature{sig}, msg.Memo))
|
||||
}
|
||||
|
||||
// BuildAndSign builds a single message to be signed, and signs a transaction
|
||||
@ -166,7 +167,7 @@ func (bldr TxBuilder) BuildWithPubKey(name string, msgs []sdk.Msg) ([]byte, erro
|
||||
PubKey: info.GetPubKey(),
|
||||
}}
|
||||
|
||||
return bldr.Codec.MarshalBinary(auth.NewStdTx(msg.Msgs, msg.Fee, sigs, msg.Memo))
|
||||
return bldr.Codec.MarshalBinaryLengthPrefixed(auth.NewStdTx(msg.Msgs, msg.Fee, sigs, msg.Memo))
|
||||
}
|
||||
|
||||
// SignStdTx appends a signature to a StdTx and returns a copy of a it. If append
|
||||
|
||||
@ -36,12 +36,12 @@ func (fck FeeCollectionKeeper) GetCollectedFees(ctx sdk.Context) sdk.Coins {
|
||||
}
|
||||
|
||||
feePool := &(sdk.Coins{})
|
||||
fck.cdc.MustUnmarshalBinary(bz, feePool)
|
||||
fck.cdc.MustUnmarshalBinaryLengthPrefixed(bz, feePool)
|
||||
return *feePool
|
||||
}
|
||||
|
||||
func (fck FeeCollectionKeeper) setCollectedFees(ctx sdk.Context, coins sdk.Coins) {
|
||||
bz := fck.cdc.MustMarshalBinary(coins)
|
||||
bz := fck.cdc.MustMarshalBinaryLengthPrefixed(coins)
|
||||
store := ctx.KVStore(fck.key)
|
||||
store.Set(collectedFeesKey, bz)
|
||||
}
|
||||
|
||||
@ -148,13 +148,13 @@ func (am AccountKeeper) GetNextAccountNumber(ctx sdk.Context) int64 {
|
||||
if bz == nil {
|
||||
accNumber = 0
|
||||
} else {
|
||||
err := am.cdc.UnmarshalBinary(bz, &accNumber)
|
||||
err := am.cdc.UnmarshalBinaryLengthPrefixed(bz, &accNumber)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
bz = am.cdc.MustMarshalBinary(accNumber + 1)
|
||||
bz = am.cdc.MustMarshalBinaryLengthPrefixed(accNumber + 1)
|
||||
store.Set(globalAccountNumberKey, bz)
|
||||
|
||||
return accNumber
|
||||
|
||||
@ -151,10 +151,11 @@ func DefaultTxDecoder(cdc *codec.Codec) sdk.TxDecoder {
|
||||
|
||||
// StdTx.Msg is an interface. The concrete types
|
||||
// are registered by MakeTxCodec
|
||||
err := cdc.UnmarshalBinary(txBytes, &tx)
|
||||
err := cdc.UnmarshalBinaryLengthPrefixed(txBytes, &tx)
|
||||
if err != nil {
|
||||
return nil, sdk.ErrTxDecode("").TraceSDK(err.Error())
|
||||
}
|
||||
|
||||
return tx, nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,7 +25,8 @@ in place of an input filename, the command reads from standard input.`,
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
txBytes, err := cliCtx.Codec.MarshalBinary(stdTx)
|
||||
|
||||
txBytes, err := cliCtx.Codec.MarshalBinaryLengthPrefixed(stdTx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@ -22,11 +22,12 @@ func BroadcastTxRequestHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) ht
|
||||
return
|
||||
}
|
||||
|
||||
txBytes, err := cliCtx.Codec.MarshalBinary(m.Tx)
|
||||
txBytes, err := cliCtx.Codec.MarshalBinaryLengthPrefixed(m.Tx)
|
||||
if err != nil {
|
||||
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
res, err := cliCtx.BroadcastTx(txBytes)
|
||||
if err != nil {
|
||||
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
|
||||
@ -23,14 +23,14 @@ func (k Keeper) GetDelegationDistInfo(ctx sdk.Context, delAddr sdk.AccAddress,
|
||||
panic("Stored delegation-distribution info should not have been nil")
|
||||
}
|
||||
|
||||
k.cdc.MustUnmarshalBinary(b, &ddi)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(b, &ddi)
|
||||
return
|
||||
}
|
||||
|
||||
// set the delegator distribution info
|
||||
func (k Keeper) SetDelegationDistInfo(ctx sdk.Context, ddi types.DelegationDistInfo) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
b := k.cdc.MustMarshalBinary(ddi)
|
||||
b := k.cdc.MustMarshalBinaryLengthPrefixed(ddi)
|
||||
store.Set(GetDelegationDistInfoKey(ddi.DelegatorAddr, ddi.ValOperatorAddr), b)
|
||||
}
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ func (k Keeper) GetAllValidatorDistInfos(ctx sdk.Context) (vdis []types.Validato
|
||||
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
var vdi types.ValidatorDistInfo
|
||||
k.cdc.MustUnmarshalBinary(iterator.Value(), &vdi)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(iterator.Value(), &vdi)
|
||||
vdis = append(vdis, vdi)
|
||||
}
|
||||
return vdis
|
||||
@ -27,7 +27,7 @@ func (k Keeper) GetAllDelegationDistInfos(ctx sdk.Context) (ddis []types.Delegat
|
||||
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
var ddi types.DelegationDistInfo
|
||||
k.cdc.MustUnmarshalBinary(iterator.Value(), &ddi)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(iterator.Value(), &ddi)
|
||||
ddis = append(ddis, ddi)
|
||||
}
|
||||
return ddis
|
||||
|
||||
@ -44,14 +44,14 @@ func (k Keeper) GetFeePool(ctx sdk.Context) (feePool types.FeePool) {
|
||||
if b == nil {
|
||||
panic("Stored fee pool should not have been nil")
|
||||
}
|
||||
k.cdc.MustUnmarshalBinary(b, &feePool)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(b, &feePool)
|
||||
return
|
||||
}
|
||||
|
||||
// set the global fee pool distribution info
|
||||
func (k Keeper) SetFeePool(ctx sdk.Context, feePool types.FeePool) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
b := k.cdc.MustMarshalBinary(feePool)
|
||||
b := k.cdc.MustMarshalBinaryLengthPrefixed(feePool)
|
||||
store.Set(FeePoolKey, b)
|
||||
}
|
||||
|
||||
@ -77,14 +77,14 @@ func (k Keeper) GetPreviousProposerConsAddr(ctx sdk.Context) (consAddr sdk.ConsA
|
||||
panic("Previous proposer not set")
|
||||
}
|
||||
|
||||
k.cdc.MustUnmarshalBinary(b, &consAddr)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(b, &consAddr)
|
||||
return
|
||||
}
|
||||
|
||||
// get the proposer public key for this block
|
||||
func (k Keeper) SetPreviousProposerConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
b := k.cdc.MustMarshalBinary(consAddr)
|
||||
b := k.cdc.MustMarshalBinaryLengthPrefixed(consAddr)
|
||||
store.Set(ProposerKey, b)
|
||||
}
|
||||
|
||||
|
||||
@ -172,7 +172,7 @@ func (k Keeper) IterateValidatorDistInfos(ctx sdk.Context,
|
||||
index := int64(0)
|
||||
for ; iter.Valid(); iter.Next() {
|
||||
var vdi types.ValidatorDistInfo
|
||||
k.cdc.MustUnmarshalBinary(iter.Value(), &vdi)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(iter.Value(), &vdi)
|
||||
if fn(index, vdi) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -23,14 +23,14 @@ func (k Keeper) GetValidatorDistInfo(ctx sdk.Context,
|
||||
panic("Stored validator-distribution info should not have been nil")
|
||||
}
|
||||
|
||||
k.cdc.MustUnmarshalBinary(b, &vdi)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(b, &vdi)
|
||||
return
|
||||
}
|
||||
|
||||
// set the validator distribution info
|
||||
func (k Keeper) SetValidatorDistInfo(ctx sdk.Context, vdi types.ValidatorDistInfo) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
b := k.cdc.MustMarshalBinary(vdi)
|
||||
b := k.cdc.MustMarshalBinaryLengthPrefixed(vdi)
|
||||
store.Set(GetValidatorDistInfoKey(vdi.OperatorAddr), b)
|
||||
}
|
||||
|
||||
|
||||
@ -292,7 +292,7 @@ func queryDepositHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.Han
|
||||
var deposit gov.Deposit
|
||||
cdc.UnmarshalJSON(res, &deposit)
|
||||
if deposit.Empty() {
|
||||
res, err := cliCtx.QueryWithData("custom/gov/proposal", cdc.MustMarshalBinary(gov.QueryProposalParams{params.ProposalID}))
|
||||
res, err := cliCtx.QueryWithData("custom/gov/proposal", cdc.MustMarshalBinaryLengthPrefixed(gov.QueryProposalParams{params.ProposalID}))
|
||||
if err != nil || len(res) == 0 {
|
||||
err := errors.Errorf("proposalID [%d] does not exist", proposalID)
|
||||
utils.WriteErrorResponse(w, http.StatusNotFound, err.Error())
|
||||
|
||||
@ -106,7 +106,7 @@ func (keeper Keeper) GetProposal(ctx sdk.Context, proposalID int64) Proposal {
|
||||
}
|
||||
|
||||
var proposal Proposal
|
||||
keeper.cdc.MustUnmarshalBinary(bz, &proposal)
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &proposal)
|
||||
|
||||
return proposal
|
||||
}
|
||||
@ -114,7 +114,7 @@ func (keeper Keeper) GetProposal(ctx sdk.Context, proposalID int64) Proposal {
|
||||
// Implements sdk.AccountKeeper.
|
||||
func (keeper Keeper) SetProposal(ctx sdk.Context, proposal Proposal) {
|
||||
store := ctx.KVStore(keeper.storeKey)
|
||||
bz := keeper.cdc.MustMarshalBinary(proposal)
|
||||
bz := keeper.cdc.MustMarshalBinaryLengthPrefixed(proposal)
|
||||
store.Set(KeyProposal(proposal.GetProposalID()), bz)
|
||||
}
|
||||
|
||||
@ -175,7 +175,7 @@ func (keeper Keeper) setInitialProposalID(ctx sdk.Context, proposalID int64) sdk
|
||||
if bz != nil {
|
||||
return ErrInvalidGenesis(keeper.codespace, "Initial ProposalID already set")
|
||||
}
|
||||
bz = keeper.cdc.MustMarshalBinary(proposalID)
|
||||
bz = keeper.cdc.MustMarshalBinaryLengthPrefixed(proposalID)
|
||||
store.Set(KeyNextProposalID, bz)
|
||||
return nil
|
||||
}
|
||||
@ -197,8 +197,8 @@ func (keeper Keeper) getNewProposalID(ctx sdk.Context) (proposalID int64, err sd
|
||||
if bz == nil {
|
||||
return -1, ErrInvalidGenesis(keeper.codespace, "InitialProposalID never set")
|
||||
}
|
||||
keeper.cdc.MustUnmarshalBinary(bz, &proposalID)
|
||||
bz = keeper.cdc.MustMarshalBinary(proposalID + 1)
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &proposalID)
|
||||
bz = keeper.cdc.MustMarshalBinaryLengthPrefixed(proposalID + 1)
|
||||
store.Set(KeyNextProposalID, bz)
|
||||
return proposalID, nil
|
||||
}
|
||||
@ -210,7 +210,7 @@ func (keeper Keeper) peekCurrentProposalID(ctx sdk.Context) (proposalID int64, e
|
||||
if bz == nil {
|
||||
return -1, ErrInvalidGenesis(keeper.codespace, "InitialProposalID never set")
|
||||
}
|
||||
keeper.cdc.MustUnmarshalBinary(bz, &proposalID)
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &proposalID)
|
||||
return proposalID, nil
|
||||
}
|
||||
|
||||
@ -298,13 +298,13 @@ func (keeper Keeper) GetVote(ctx sdk.Context, proposalID int64, voterAddr sdk.Ac
|
||||
return Vote{}, false
|
||||
}
|
||||
var vote Vote
|
||||
keeper.cdc.MustUnmarshalBinary(bz, &vote)
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &vote)
|
||||
return vote, true
|
||||
}
|
||||
|
||||
func (keeper Keeper) setVote(ctx sdk.Context, proposalID int64, voterAddr sdk.AccAddress, vote Vote) {
|
||||
store := ctx.KVStore(keeper.storeKey)
|
||||
bz := keeper.cdc.MustMarshalBinary(vote)
|
||||
bz := keeper.cdc.MustMarshalBinaryLengthPrefixed(vote)
|
||||
store.Set(KeyVote(proposalID, voterAddr), bz)
|
||||
}
|
||||
|
||||
@ -330,13 +330,13 @@ func (keeper Keeper) GetDeposit(ctx sdk.Context, proposalID int64, depositerAddr
|
||||
return Deposit{}, false
|
||||
}
|
||||
var deposit Deposit
|
||||
keeper.cdc.MustUnmarshalBinary(bz, &deposit)
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &deposit)
|
||||
return deposit, true
|
||||
}
|
||||
|
||||
func (keeper Keeper) setDeposit(ctx sdk.Context, proposalID int64, depositerAddr sdk.AccAddress, deposit Deposit) {
|
||||
store := ctx.KVStore(keeper.storeKey)
|
||||
bz := keeper.cdc.MustMarshalBinary(deposit)
|
||||
bz := keeper.cdc.MustMarshalBinaryLengthPrefixed(deposit)
|
||||
store.Set(KeyDeposit(proposalID, depositerAddr), bz)
|
||||
}
|
||||
|
||||
@ -398,7 +398,7 @@ func (keeper Keeper) RefundDeposits(ctx sdk.Context, proposalID int64) {
|
||||
|
||||
for ; depositsIterator.Valid(); depositsIterator.Next() {
|
||||
deposit := &Deposit{}
|
||||
keeper.cdc.MustUnmarshalBinary(depositsIterator.Value(), deposit)
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), deposit)
|
||||
|
||||
_, _, err := keeper.ck.AddCoins(ctx, deposit.Depositer, deposit.Amount)
|
||||
if err != nil {
|
||||
@ -434,14 +434,14 @@ func (keeper Keeper) getActiveProposalQueue(ctx sdk.Context) ProposalQueue {
|
||||
}
|
||||
|
||||
var proposalQueue ProposalQueue
|
||||
keeper.cdc.MustUnmarshalBinary(bz, &proposalQueue)
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &proposalQueue)
|
||||
|
||||
return proposalQueue
|
||||
}
|
||||
|
||||
func (keeper Keeper) setActiveProposalQueue(ctx sdk.Context, proposalQueue ProposalQueue) {
|
||||
store := ctx.KVStore(keeper.storeKey)
|
||||
bz := keeper.cdc.MustMarshalBinary(proposalQueue)
|
||||
bz := keeper.cdc.MustMarshalBinaryLengthPrefixed(proposalQueue)
|
||||
store.Set(KeyActiveProposalQueue, bz)
|
||||
}
|
||||
|
||||
@ -480,14 +480,14 @@ func (keeper Keeper) getInactiveProposalQueue(ctx sdk.Context) ProposalQueue {
|
||||
|
||||
var proposalQueue ProposalQueue
|
||||
|
||||
keeper.cdc.MustUnmarshalBinary(bz, &proposalQueue)
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &proposalQueue)
|
||||
|
||||
return proposalQueue
|
||||
}
|
||||
|
||||
func (keeper Keeper) setInactiveProposalQueue(ctx sdk.Context, proposalQueue ProposalQueue) {
|
||||
store := ctx.KVStore(keeper.storeKey)
|
||||
bz := keeper.cdc.MustMarshalBinary(proposalQueue)
|
||||
bz := keeper.cdc.MustMarshalBinaryLengthPrefixed(proposalQueue)
|
||||
store.Set(KeyInactiveProposalQueue, bz)
|
||||
}
|
||||
|
||||
|
||||
@ -122,11 +122,11 @@ func TestDeposits(t *testing.T) {
|
||||
// Test deposit iterator
|
||||
depositsIterator := keeper.GetDeposits(ctx, proposalID)
|
||||
require.True(t, depositsIterator.Valid())
|
||||
keeper.cdc.MustUnmarshalBinary(depositsIterator.Value(), &deposit)
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), &deposit)
|
||||
require.Equal(t, addrs[0], deposit.Depositer)
|
||||
require.Equal(t, fourSteak.Plus(fiveSteak), deposit.Amount)
|
||||
depositsIterator.Next()
|
||||
keeper.cdc.MustUnmarshalBinary(depositsIterator.Value(), &deposit)
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), &deposit)
|
||||
require.Equal(t, addrs[1], deposit.Depositer)
|
||||
require.Equal(t, fourSteak, deposit.Amount)
|
||||
depositsIterator.Next()
|
||||
@ -184,14 +184,14 @@ func TestVotes(t *testing.T) {
|
||||
// Test vote iterator
|
||||
votesIterator := keeper.GetVotes(ctx, proposalID)
|
||||
require.True(t, votesIterator.Valid())
|
||||
keeper.cdc.MustUnmarshalBinary(votesIterator.Value(), &vote)
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(votesIterator.Value(), &vote)
|
||||
require.True(t, votesIterator.Valid())
|
||||
require.Equal(t, addrs[0], vote.Voter)
|
||||
require.Equal(t, proposalID, vote.ProposalID)
|
||||
require.Equal(t, OptionYes, vote.Option)
|
||||
votesIterator.Next()
|
||||
require.True(t, votesIterator.Valid())
|
||||
keeper.cdc.MustUnmarshalBinary(votesIterator.Value(), &vote)
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(votesIterator.Value(), &vote)
|
||||
require.True(t, votesIterator.Valid())
|
||||
require.Equal(t, addrs[1], vote.Voter)
|
||||
require.Equal(t, proposalID, vote.ProposalID)
|
||||
|
||||
@ -126,7 +126,7 @@ func queryDeposits(ctx sdk.Context, path []string, req abci.RequestQuery, keeper
|
||||
depositsIterator := keeper.GetDeposits(ctx, params.ProposalID)
|
||||
for ; depositsIterator.Valid(); depositsIterator.Next() {
|
||||
deposit := Deposit{}
|
||||
keeper.cdc.MustUnmarshalBinary(depositsIterator.Value(), &deposit)
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), &deposit)
|
||||
deposits = append(deposits, deposit)
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ func queryVotes(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Ke
|
||||
votesIterator := keeper.GetVotes(ctx, params.ProposalID)
|
||||
for ; votesIterator.Valid(); votesIterator.Next() {
|
||||
vote := Vote{}
|
||||
keeper.cdc.MustUnmarshalBinary(votesIterator.Value(), &vote)
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(votesIterator.Value(), &vote)
|
||||
votes = append(votes, vote)
|
||||
}
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ func tally(ctx sdk.Context, keeper Keeper, proposal Proposal) (passes bool, tall
|
||||
defer votesIterator.Close()
|
||||
for ; votesIterator.Valid(); votesIterator.Next() {
|
||||
vote := &Vote{}
|
||||
keeper.cdc.MustUnmarshalBinary(votesIterator.Value(), vote)
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(votesIterator.Value(), vote)
|
||||
|
||||
// if validator, just record it in the map
|
||||
// if delegator tally voting power
|
||||
|
||||
@ -117,7 +117,7 @@ OUTER:
|
||||
var processed int64
|
||||
if processedbz == nil {
|
||||
processed = 0
|
||||
} else if err = c.cdc.UnmarshalBinary(processedbz, &processed); err != nil {
|
||||
} else if err = c.cdc.UnmarshalBinaryLengthPrefixed(processedbz, &processed); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ OUTER:
|
||||
var egressLength int64
|
||||
if egressLengthbz == nil {
|
||||
egressLength = 0
|
||||
} else if err = c.cdc.UnmarshalBinary(egressLengthbz, &egressLength); err != nil {
|
||||
} else if err = c.cdc.UnmarshalBinaryLengthPrefixed(egressLengthbz, &egressLength); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ func (c relayCommander) getSequence(node string) int64 {
|
||||
|
||||
func (c relayCommander) refine(bz []byte, sequence int64, passphrase string) []byte {
|
||||
var packet ibc.IBCPacket
|
||||
if err := c.cdc.UnmarshalBinary(bz, &packet); err != nil {
|
||||
if err := c.cdc.UnmarshalBinaryLengthPrefixed(bz, &packet); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
@ -33,13 +33,13 @@ func (ibcm Mapper) PostIBCPacket(ctx sdk.Context, packet IBCPacket) sdk.Error {
|
||||
// write everything into the state
|
||||
store := ctx.KVStore(ibcm.key)
|
||||
index := ibcm.getEgressLength(store, packet.DestChain)
|
||||
bz, err := ibcm.cdc.MarshalBinary(packet)
|
||||
bz, err := ibcm.cdc.MarshalBinaryLengthPrefixed(packet)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
store.Set(EgressKey(packet.DestChain, index), bz)
|
||||
bz, err = ibcm.cdc.MarshalBinary(index + 1)
|
||||
bz, err = ibcm.cdc.MarshalBinaryLengthPrefixed(index + 1)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -61,7 +61,7 @@ func (ibcm Mapper) ReceiveIBCPacket(ctx sdk.Context, packet IBCPacket) sdk.Error
|
||||
// Functions for accessing the underlying KVStore.
|
||||
|
||||
func marshalBinaryPanic(cdc *codec.Codec, value interface{}) []byte {
|
||||
res, err := cdc.MarshalBinary(value)
|
||||
res, err := cdc.MarshalBinaryLengthPrefixed(value)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -69,7 +69,7 @@ func marshalBinaryPanic(cdc *codec.Codec, value interface{}) []byte {
|
||||
}
|
||||
|
||||
func unmarshalBinaryPanic(cdc *codec.Codec, bz []byte, ptr interface{}) {
|
||||
err := cdc.UnmarshalBinary(bz, ptr)
|
||||
err := cdc.UnmarshalBinaryLengthPrefixed(bz, ptr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -59,14 +59,14 @@ func (k Keeper) GetMinter(ctx sdk.Context) (minter Minter) {
|
||||
if b == nil {
|
||||
panic("Stored fee pool should not have been nil")
|
||||
}
|
||||
k.cdc.MustUnmarshalBinary(b, &minter)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(b, &minter)
|
||||
return
|
||||
}
|
||||
|
||||
// set the minter
|
||||
func (k Keeper) SetMinter(ctx sdk.Context, minter Minter) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
b := k.cdc.MustMarshalBinary(minter)
|
||||
b := k.cdc.MustMarshalBinaryLengthPrefixed(minter)
|
||||
store.Set(minterKey, b)
|
||||
}
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ func GetCmdQuerySigningInfo(storeName string, cdc *codec.Codec) *cobra.Command {
|
||||
}
|
||||
|
||||
signingInfo := new(slashing.ValidatorSigningInfo)
|
||||
cdc.MustUnmarshalBinary(res, signingInfo)
|
||||
cdc.MustUnmarshalBinaryLengthPrefixed(res, signingInfo)
|
||||
|
||||
switch viper.Get(cli.OutputFlag) {
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ func signingInfoHandlerFn(cliCtx context.CLIContext, storeName string, cdc *code
|
||||
|
||||
var signingInfo slashing.ValidatorSigningInfo
|
||||
|
||||
err = cdc.UnmarshalBinary(res, &signingInfo)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(res, &signingInfo)
|
||||
if err != nil {
|
||||
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
|
||||
@ -187,7 +187,7 @@ func (k Keeper) addPubkey(ctx sdk.Context, pubkey crypto.PubKey) {
|
||||
func (k Keeper) getPubkey(ctx sdk.Context, address crypto.Address) (crypto.PubKey, error) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
var pubkey crypto.PubKey
|
||||
err := k.cdc.UnmarshalBinary(store.Get(getAddrPubkeyRelationKey(address)), &pubkey)
|
||||
err := k.cdc.UnmarshalBinaryLengthPrefixed(store.Get(getAddrPubkeyRelationKey(address)), &pubkey)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("address %v not found", address)
|
||||
}
|
||||
@ -196,7 +196,7 @@ func (k Keeper) getPubkey(ctx sdk.Context, address crypto.Address) (crypto.PubKe
|
||||
|
||||
func (k Keeper) setAddrPubkeyRelation(ctx sdk.Context, addr crypto.Address, pubkey crypto.PubKey) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := k.cdc.MustMarshalBinary(pubkey)
|
||||
bz := k.cdc.MustMarshalBinaryLengthPrefixed(pubkey)
|
||||
store.Set(getAddrPubkeyRelationKey(addr), bz)
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ func (k Keeper) getValidatorSigningInfo(ctx sdk.Context, address sdk.ConsAddress
|
||||
found = false
|
||||
return
|
||||
}
|
||||
k.cdc.MustUnmarshalBinary(bz, &info)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &info)
|
||||
found = true
|
||||
return
|
||||
}
|
||||
@ -23,7 +23,7 @@ func (k Keeper) getValidatorSigningInfo(ctx sdk.Context, address sdk.ConsAddress
|
||||
// Stored by *validator* address (not operator address)
|
||||
func (k Keeper) setValidatorSigningInfo(ctx sdk.Context, address sdk.ConsAddress, info ValidatorSigningInfo) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := k.cdc.MustMarshalBinary(info)
|
||||
bz := k.cdc.MustMarshalBinaryLengthPrefixed(info)
|
||||
store.Set(GetValidatorSigningInfoKey(address), bz)
|
||||
}
|
||||
|
||||
@ -36,14 +36,14 @@ func (k Keeper) getValidatorMissedBlockBitArray(ctx sdk.Context, address sdk.Con
|
||||
missed = false
|
||||
return
|
||||
}
|
||||
k.cdc.MustUnmarshalBinary(bz, &missed)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &missed)
|
||||
return
|
||||
}
|
||||
|
||||
// Stored by *validator* address (not operator address)
|
||||
func (k Keeper) setValidatorMissedBlockBitArray(ctx sdk.Context, address sdk.ConsAddress, index int64, missed bool) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := k.cdc.MustMarshalBinary(missed)
|
||||
bz := k.cdc.MustMarshalBinaryLengthPrefixed(missed)
|
||||
store.Set(GetValidatorMissedBlockBitArrayKey(address, index), bz)
|
||||
}
|
||||
|
||||
|
||||
@ -61,14 +61,14 @@ func (k Keeper) addOrUpdateValidatorSlashingPeriod(ctx sdk.Context, slashingPeri
|
||||
SlashedSoFar: slashingPeriod.SlashedSoFar,
|
||||
}
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := k.cdc.MustMarshalBinary(slashingPeriodValue)
|
||||
bz := k.cdc.MustMarshalBinaryLengthPrefixed(slashingPeriodValue)
|
||||
store.Set(GetValidatorSlashingPeriodKey(slashingPeriod.ValidatorAddr, slashingPeriod.StartHeight), bz)
|
||||
}
|
||||
|
||||
// Unmarshal key/value into a ValidatorSlashingPeriod
|
||||
func (k Keeper) unmarshalSlashingPeriodKeyValue(key []byte, value []byte) ValidatorSlashingPeriod {
|
||||
var slashingPeriodValue ValidatorSlashingPeriodValue
|
||||
k.cdc.MustUnmarshalBinary(value, &slashingPeriodValue)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(value, &slashingPeriodValue)
|
||||
address := sdk.ConsAddress(key[1 : 1+sdk.AddrLen])
|
||||
startHeight := int64(binary.BigEndian.Uint64(key[1+sdk.AddrLen:1+sdk.AddrLen+8]) - uint64(stake.ValidatorUpdateDelay))
|
||||
return ValidatorSlashingPeriod{
|
||||
|
||||
@ -201,7 +201,7 @@ func handleMsgBeginUnbonding(ctx sdk.Context, msg types.MsgBeginUnbonding, k kee
|
||||
return err.Result()
|
||||
}
|
||||
|
||||
finishTime := types.MsgCdc.MustMarshalBinary(ubd.MinTime)
|
||||
finishTime := types.MsgCdc.MustMarshalBinaryLengthPrefixed(ubd.MinTime)
|
||||
|
||||
tags := sdk.NewTags(
|
||||
tags.Action, tags.ActionBeginUnbonding,
|
||||
@ -219,7 +219,7 @@ func handleMsgBeginRedelegate(ctx sdk.Context, msg types.MsgBeginRedelegate, k k
|
||||
return err.Result()
|
||||
}
|
||||
|
||||
finishTime := types.MsgCdc.MustMarshalBinary(red.MinTime)
|
||||
finishTime := types.MsgCdc.MustMarshalBinaryLengthPrefixed(red.MinTime)
|
||||
|
||||
tags := sdk.NewTags(
|
||||
tags.Action, tags.ActionBeginRedelegation,
|
||||
|
||||
@ -94,7 +94,7 @@ func TestValidatorByPowerIndex(t *testing.T) {
|
||||
got = handleMsgBeginUnbonding(ctx, msgBeginUnbonding, keeper)
|
||||
require.True(t, got.IsOK(), "expected msg to be ok, got %v", got)
|
||||
var finishTime time.Time
|
||||
types.MsgCdc.MustUnmarshalBinary(got.Data, &finishTime)
|
||||
types.MsgCdc.MustUnmarshalBinaryLengthPrefixed(got.Data, &finishTime)
|
||||
ctx = ctx.WithBlockTime(finishTime)
|
||||
EndBlocker(ctx, keeper)
|
||||
|
||||
@ -232,7 +232,7 @@ func TestLegacyValidatorDelegations(t *testing.T) {
|
||||
require.True(t, got.IsOK(), "expected begin unbonding validator msg to be ok, got %v", got)
|
||||
|
||||
var finishTime time.Time
|
||||
types.MsgCdc.MustUnmarshalBinary(got.Data, &finishTime)
|
||||
types.MsgCdc.MustUnmarshalBinaryLengthPrefixed(got.Data, &finishTime)
|
||||
ctx = ctx.WithBlockTime(finishTime)
|
||||
EndBlocker(ctx, keeper)
|
||||
|
||||
@ -400,7 +400,7 @@ func TestIncrementsMsgUnbond(t *testing.T) {
|
||||
got := handleMsgBeginUnbonding(ctx, msgBeginUnbonding, keeper)
|
||||
require.True(t, got.IsOK(), "expected msg %d to be ok, got %v", i, got)
|
||||
var finishTime time.Time
|
||||
types.MsgCdc.MustUnmarshalBinary(got.Data, &finishTime)
|
||||
types.MsgCdc.MustUnmarshalBinaryLengthPrefixed(got.Data, &finishTime)
|
||||
ctx = ctx.WithBlockTime(finishTime)
|
||||
EndBlocker(ctx, keeper)
|
||||
|
||||
@ -494,7 +494,7 @@ func TestMultipleMsgCreateValidator(t *testing.T) {
|
||||
got := handleMsgBeginUnbonding(ctx, msgBeginUnbonding, keeper)
|
||||
require.True(t, got.IsOK(), "expected msg %d to be ok, got %v", i, got)
|
||||
var finishTime time.Time
|
||||
types.MsgCdc.MustUnmarshalBinary(got.Data, &finishTime)
|
||||
types.MsgCdc.MustUnmarshalBinaryLengthPrefixed(got.Data, &finishTime)
|
||||
ctx = ctx.WithBlockTime(finishTime)
|
||||
EndBlocker(ctx, keeper)
|
||||
|
||||
@ -540,7 +540,7 @@ func TestMultipleMsgDelegate(t *testing.T) {
|
||||
got := handleMsgBeginUnbonding(ctx, msgBeginUnbonding, keeper)
|
||||
require.True(t, got.IsOK(), "expected msg %d to be ok, got %v", i, got)
|
||||
var finishTime time.Time
|
||||
types.MsgCdc.MustUnmarshalBinary(got.Data, &finishTime)
|
||||
types.MsgCdc.MustUnmarshalBinaryLengthPrefixed(got.Data, &finishTime)
|
||||
ctx = ctx.WithBlockTime(finishTime)
|
||||
EndBlocker(ctx, keeper)
|
||||
|
||||
@ -570,7 +570,7 @@ func TestJailValidator(t *testing.T) {
|
||||
got = handleMsgBeginUnbonding(ctx, msgBeginUnbondingValidator, keeper)
|
||||
require.True(t, got.IsOK(), "expected no error: %v", got)
|
||||
var finishTime time.Time
|
||||
types.MsgCdc.MustUnmarshalBinary(got.Data, &finishTime)
|
||||
types.MsgCdc.MustUnmarshalBinaryLengthPrefixed(got.Data, &finishTime)
|
||||
ctx = ctx.WithBlockTime(finishTime)
|
||||
EndBlocker(ctx, keeper)
|
||||
|
||||
@ -586,7 +586,7 @@ func TestJailValidator(t *testing.T) {
|
||||
msgBeginUnbondingDelegator := NewMsgBeginUnbonding(delegatorAddr, validatorAddr, sdk.NewDec(10))
|
||||
got = handleMsgBeginUnbonding(ctx, msgBeginUnbondingDelegator, keeper)
|
||||
require.True(t, got.IsOK(), "expected no error")
|
||||
types.MsgCdc.MustUnmarshalBinary(got.Data, &finishTime)
|
||||
types.MsgCdc.MustUnmarshalBinaryLengthPrefixed(got.Data, &finishTime)
|
||||
ctx = ctx.WithBlockTime(finishTime)
|
||||
EndBlocker(ctx, keeper)
|
||||
|
||||
@ -621,7 +621,7 @@ func TestValidatorQueue(t *testing.T) {
|
||||
got = handleMsgBeginUnbonding(ctx, msgBeginUnbondingValidator, keeper)
|
||||
require.True(t, got.IsOK(), "expected no error: %v", got)
|
||||
var finishTime time.Time
|
||||
types.MsgCdc.MustUnmarshalBinary(got.Data, &finishTime)
|
||||
types.MsgCdc.MustUnmarshalBinaryLengthPrefixed(got.Data, &finishTime)
|
||||
ctx = ctx.WithBlockTime(finishTime)
|
||||
EndBlocker(ctx, keeper)
|
||||
origHeader := ctx.BlockHeader()
|
||||
@ -709,7 +709,7 @@ func TestUnbondingFromUnbondingValidator(t *testing.T) {
|
||||
|
||||
// change the ctx to Block Time one second before the validator would have unbonded
|
||||
var finishTime time.Time
|
||||
types.MsgCdc.MustUnmarshalBinary(got.Data, &finishTime)
|
||||
types.MsgCdc.MustUnmarshalBinaryLengthPrefixed(got.Data, &finishTime)
|
||||
ctx = ctx.WithBlockTime(finishTime.Add(time.Second * -1))
|
||||
|
||||
// unbond the delegator from the validator
|
||||
|
||||
@ -163,14 +163,14 @@ func (k Keeper) GetUnbondingQueueTimeSlice(ctx sdk.Context, timestamp time.Time)
|
||||
if bz == nil {
|
||||
return []types.DVPair{}
|
||||
}
|
||||
k.cdc.MustUnmarshalBinary(bz, &dvPairs)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &dvPairs)
|
||||
return dvPairs
|
||||
}
|
||||
|
||||
// Sets a specific unbonding queue timeslice.
|
||||
func (k Keeper) SetUnbondingQueueTimeSlice(ctx sdk.Context, timestamp time.Time, keys []types.DVPair) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := k.cdc.MustMarshalBinary(keys)
|
||||
bz := k.cdc.MustMarshalBinaryLengthPrefixed(keys)
|
||||
store.Set(GetUnbondingDelegationTimeKey(timestamp), bz)
|
||||
}
|
||||
|
||||
@ -199,7 +199,7 @@ func (k Keeper) DequeueAllMatureUnbondingQueue(ctx sdk.Context, currTime time.Ti
|
||||
unbondingTimesliceIterator := k.UnbondingQueueIterator(ctx, ctx.BlockHeader().Time)
|
||||
for ; unbondingTimesliceIterator.Valid(); unbondingTimesliceIterator.Next() {
|
||||
timeslice := []types.DVPair{}
|
||||
k.cdc.MustUnmarshalBinary(unbondingTimesliceIterator.Value(), ×lice)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(unbondingTimesliceIterator.Value(), ×lice)
|
||||
matureUnbonds = append(matureUnbonds, timeslice...)
|
||||
store.Delete(unbondingTimesliceIterator.Key())
|
||||
}
|
||||
@ -300,14 +300,14 @@ func (k Keeper) GetRedelegationQueueTimeSlice(ctx sdk.Context, timestamp time.Ti
|
||||
if bz == nil {
|
||||
return []types.DVVTriplet{}
|
||||
}
|
||||
k.cdc.MustUnmarshalBinary(bz, &dvvTriplets)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &dvvTriplets)
|
||||
return dvvTriplets
|
||||
}
|
||||
|
||||
// Sets a specific redelegation queue timeslice.
|
||||
func (k Keeper) SetRedelegationQueueTimeSlice(ctx sdk.Context, timestamp time.Time, keys []types.DVVTriplet) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := k.cdc.MustMarshalBinary(keys)
|
||||
bz := k.cdc.MustMarshalBinaryLengthPrefixed(keys)
|
||||
store.Set(GetRedelegationTimeKey(timestamp), bz)
|
||||
}
|
||||
|
||||
@ -336,7 +336,7 @@ func (k Keeper) DequeueAllMatureRedelegationQueue(ctx sdk.Context, currTime time
|
||||
redelegationTimesliceIterator := k.RedelegationQueueIterator(ctx, ctx.BlockHeader().Time)
|
||||
for ; redelegationTimesliceIterator.Valid(); redelegationTimesliceIterator.Next() {
|
||||
timeslice := []types.DVVTriplet{}
|
||||
k.cdc.MustUnmarshalBinary(redelegationTimesliceIterator.Value(), ×lice)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(redelegationTimesliceIterator.Value(), ×lice)
|
||||
matureRedelegations = append(matureRedelegations, timeslice...)
|
||||
store.Delete(redelegationTimesliceIterator.Key())
|
||||
}
|
||||
|
||||
@ -60,14 +60,14 @@ func (k Keeper) GetPool(ctx sdk.Context) (pool types.Pool) {
|
||||
if b == nil {
|
||||
panic("stored pool should not have been nil")
|
||||
}
|
||||
k.cdc.MustUnmarshalBinary(b, &pool)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(b, &pool)
|
||||
return
|
||||
}
|
||||
|
||||
// set the pool
|
||||
func (k Keeper) SetPool(ctx sdk.Context, pool types.Pool) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
b := k.cdc.MustMarshalBinary(pool)
|
||||
b := k.cdc.MustMarshalBinaryLengthPrefixed(pool)
|
||||
store.Set(PoolKey, b)
|
||||
}
|
||||
|
||||
@ -80,14 +80,14 @@ func (k Keeper) GetLastTotalPower(ctx sdk.Context) (power sdk.Int) {
|
||||
if b == nil {
|
||||
return sdk.ZeroInt()
|
||||
}
|
||||
k.cdc.MustUnmarshalBinary(b, &power)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(b, &power)
|
||||
return
|
||||
}
|
||||
|
||||
// Set the last total validator power.
|
||||
func (k Keeper) SetLastTotalPower(ctx sdk.Context, power sdk.Int) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
b := k.cdc.MustMarshalBinary(power)
|
||||
b := k.cdc.MustMarshalBinaryLengthPrefixed(power)
|
||||
store.Set(LastTotalPowerKey, b)
|
||||
}
|
||||
|
||||
@ -101,14 +101,14 @@ func (k Keeper) GetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress)
|
||||
if bz == nil {
|
||||
return sdk.ZeroInt()
|
||||
}
|
||||
k.cdc.MustUnmarshalBinary(bz, &power)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &power)
|
||||
return
|
||||
}
|
||||
|
||||
// Set the last validator power.
|
||||
func (k Keeper) SetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress, power sdk.Int) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := k.cdc.MustMarshalBinary(power)
|
||||
bz := k.cdc.MustMarshalBinaryLengthPrefixed(power)
|
||||
store.Set(GetLastValidatorPowerKey(operator), bz)
|
||||
}
|
||||
|
||||
@ -128,13 +128,13 @@ func (k Keeper) GetIntraTxCounter(ctx sdk.Context) int16 {
|
||||
return 0
|
||||
}
|
||||
var counter int16
|
||||
k.cdc.MustUnmarshalBinary(b, &counter)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(b, &counter)
|
||||
return counter
|
||||
}
|
||||
|
||||
// set the current in-block validator operation counter
|
||||
func (k Keeper) SetIntraTxCounter(ctx sdk.Context, counter int16) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := k.cdc.MustMarshalBinary(counter)
|
||||
bz := k.cdc.MustMarshalBinaryLengthPrefixed(counter)
|
||||
store.Set(IntraTxCounterKey, bz)
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab
|
||||
|
||||
// calculate the new power bytes
|
||||
newPower := validator.BondedTokens().RoundInt64()
|
||||
newPowerBytes := k.cdc.MustMarshalBinary(sdk.NewInt(newPower))
|
||||
newPowerBytes := k.cdc.MustMarshalBinaryLengthPrefixed(sdk.NewInt(newPower))
|
||||
// update the validator set if power has changed
|
||||
if !found || !bytes.Equal(oldPowerBytes, newPowerBytes) {
|
||||
updates = append(updates, validator.ABCIValidatorUpdate())
|
||||
|
||||
@ -291,14 +291,14 @@ func (k Keeper) GetValidatorQueueTimeSlice(ctx sdk.Context, timestamp time.Time)
|
||||
if bz == nil {
|
||||
return []sdk.ValAddress{}
|
||||
}
|
||||
k.cdc.MustUnmarshalBinary(bz, &valAddrs)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &valAddrs)
|
||||
return valAddrs
|
||||
}
|
||||
|
||||
// Sets a specific validator queue timeslice.
|
||||
func (k Keeper) SetValidatorQueueTimeSlice(ctx sdk.Context, timestamp time.Time, keys []sdk.ValAddress) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := k.cdc.MustMarshalBinary(keys)
|
||||
bz := k.cdc.MustMarshalBinaryLengthPrefixed(keys)
|
||||
store.Set(GetValidatorQueueTimeKey(timestamp), bz)
|
||||
}
|
||||
|
||||
@ -325,7 +325,7 @@ func (k Keeper) GetAllMatureValidatorQueue(ctx sdk.Context, currTime time.Time)
|
||||
validatorTimesliceIterator := k.ValidatorQueueIterator(ctx, ctx.BlockHeader().Time)
|
||||
for ; validatorTimesliceIterator.Valid(); validatorTimesliceIterator.Next() {
|
||||
timeslice := []sdk.ValAddress{}
|
||||
k.cdc.MustUnmarshalBinary(validatorTimesliceIterator.Value(), ×lice)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(validatorTimesliceIterator.Value(), ×lice)
|
||||
matureValsAddrs = append(matureValsAddrs, timeslice...)
|
||||
}
|
||||
return matureValsAddrs
|
||||
@ -337,7 +337,7 @@ func (k Keeper) UnbondAllMatureValidatorQueue(ctx sdk.Context) {
|
||||
validatorTimesliceIterator := k.ValidatorQueueIterator(ctx, ctx.BlockHeader().Time)
|
||||
for ; validatorTimesliceIterator.Valid(); validatorTimesliceIterator.Next() {
|
||||
timeslice := []sdk.ValAddress{}
|
||||
k.cdc.MustUnmarshalBinary(validatorTimesliceIterator.Value(), ×lice)
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(validatorTimesliceIterator.Value(), ×lice)
|
||||
for _, valAddr := range timeslice {
|
||||
val, found := k.GetValidator(ctx, valAddr)
|
||||
if !found || val.GetStatus() != sdk.Unbonding {
|
||||
|
||||
@ -47,7 +47,7 @@ func MustMarshalDelegation(cdc *codec.Codec, delegation Delegation) []byte {
|
||||
delegation.Shares,
|
||||
delegation.Height,
|
||||
}
|
||||
return cdc.MustMarshalBinary(val)
|
||||
return cdc.MustMarshalBinaryLengthPrefixed(val)
|
||||
}
|
||||
|
||||
// return the delegation without fields contained within the key for the store
|
||||
@ -62,7 +62,7 @@ func MustUnmarshalDelegation(cdc *codec.Codec, key, value []byte) Delegation {
|
||||
// return the delegation without fields contained within the key for the store
|
||||
func UnmarshalDelegation(cdc *codec.Codec, key, value []byte) (delegation Delegation, err error) {
|
||||
var storeValue delegationValue
|
||||
err = cdc.UnmarshalBinary(value, &storeValue)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(value, &storeValue)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("%v: %v", ErrNoDelegation(DefaultCodespace).Data(), err)
|
||||
return
|
||||
@ -139,7 +139,7 @@ func MustMarshalUBD(cdc *codec.Codec, ubd UnbondingDelegation) []byte {
|
||||
ubd.InitialBalance,
|
||||
ubd.Balance,
|
||||
}
|
||||
return cdc.MustMarshalBinary(val)
|
||||
return cdc.MustMarshalBinaryLengthPrefixed(val)
|
||||
}
|
||||
|
||||
// unmarshal a unbonding delegation from a store key and value
|
||||
@ -154,7 +154,7 @@ func MustUnmarshalUBD(cdc *codec.Codec, key, value []byte) UnbondingDelegation {
|
||||
// unmarshal a unbonding delegation from a store key and value
|
||||
func UnmarshalUBD(cdc *codec.Codec, key, value []byte) (ubd UnbondingDelegation, err error) {
|
||||
var storeValue ubdValue
|
||||
err = cdc.UnmarshalBinary(value, &storeValue)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(value, &storeValue)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -179,8 +179,8 @@ func UnmarshalUBD(cdc *codec.Codec, key, value []byte) (ubd UnbondingDelegation,
|
||||
|
||||
// nolint
|
||||
func (d UnbondingDelegation) Equal(d2 UnbondingDelegation) bool {
|
||||
bz1 := MsgCdc.MustMarshalBinary(&d)
|
||||
bz2 := MsgCdc.MustMarshalBinary(&d2)
|
||||
bz1 := MsgCdc.MustMarshalBinaryLengthPrefixed(&d)
|
||||
bz2 := MsgCdc.MustMarshalBinaryLengthPrefixed(&d2)
|
||||
return bytes.Equal(bz1, bz2)
|
||||
}
|
||||
|
||||
@ -231,7 +231,7 @@ func MustMarshalRED(cdc *codec.Codec, red Redelegation) []byte {
|
||||
red.SharesSrc,
|
||||
red.SharesDst,
|
||||
}
|
||||
return cdc.MustMarshalBinary(val)
|
||||
return cdc.MustMarshalBinaryLengthPrefixed(val)
|
||||
}
|
||||
|
||||
// unmarshal a redelegation from a store key and value
|
||||
@ -246,7 +246,7 @@ func MustUnmarshalRED(cdc *codec.Codec, key, value []byte) Redelegation {
|
||||
// unmarshal a redelegation from a store key and value
|
||||
func UnmarshalRED(cdc *codec.Codec, key, value []byte) (red Redelegation, err error) {
|
||||
var storeValue redValue
|
||||
err = cdc.UnmarshalBinary(value, &storeValue)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(value, &storeValue)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -275,8 +275,8 @@ func UnmarshalRED(cdc *codec.Codec, key, value []byte) (red Redelegation, err er
|
||||
|
||||
// nolint
|
||||
func (d Redelegation) Equal(d2 Redelegation) bool {
|
||||
bz1 := MsgCdc.MustMarshalBinary(&d)
|
||||
bz2 := MsgCdc.MustMarshalBinary(&d2)
|
||||
bz1 := MsgCdc.MustMarshalBinaryLengthPrefixed(&d)
|
||||
bz2 := MsgCdc.MustMarshalBinaryLengthPrefixed(&d2)
|
||||
return bytes.Equal(bz1, bz2)
|
||||
}
|
||||
|
||||
|
||||
@ -49,8 +49,8 @@ func (p *Params) KeyValuePairs() params.KeyValuePairs {
|
||||
|
||||
// Equal returns a boolean determining if two Param types are identical.
|
||||
func (p Params) Equal(p2 Params) bool {
|
||||
bz1 := MsgCdc.MustMarshalBinary(&p)
|
||||
bz2 := MsgCdc.MustMarshalBinary(&p2)
|
||||
bz1 := MsgCdc.MustMarshalBinaryLengthPrefixed(&p)
|
||||
bz2 := MsgCdc.MustMarshalBinaryLengthPrefixed(&p2)
|
||||
return bytes.Equal(bz1, bz2)
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ func MustUnmarshalParams(cdc *codec.Codec, value []byte) Params {
|
||||
|
||||
// unmarshal the current staking params value from store key
|
||||
func UnmarshalParams(cdc *codec.Codec, value []byte) (params Params, err error) {
|
||||
err = cdc.UnmarshalBinary(value, ¶ms)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(value, ¶ms)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@ -16,8 +16,8 @@ type Pool struct {
|
||||
|
||||
// nolint
|
||||
func (p Pool) Equal(p2 Pool) bool {
|
||||
bz1 := MsgCdc.MustMarshalBinary(&p)
|
||||
bz2 := MsgCdc.MustMarshalBinary(&p2)
|
||||
bz1 := MsgCdc.MustMarshalBinaryLengthPrefixed(&p)
|
||||
bz2 := MsgCdc.MustMarshalBinaryLengthPrefixed(&p2)
|
||||
return bytes.Equal(bz1, bz2)
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ func MustUnmarshalPool(cdc *codec.Codec, value []byte) Pool {
|
||||
|
||||
// unmarshal the current pool value from store key
|
||||
func UnmarshalPool(cdc *codec.Codec, value []byte) (pool Pool, err error) {
|
||||
err = cdc.UnmarshalBinary(value, &pool)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(value, &pool)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ func MustMarshalValidator(cdc *codec.Codec, validator Validator) []byte {
|
||||
UnbondingMinTime: validator.UnbondingMinTime,
|
||||
Commission: validator.Commission,
|
||||
}
|
||||
return cdc.MustMarshalBinary(val)
|
||||
return cdc.MustMarshalBinaryLengthPrefixed(val)
|
||||
}
|
||||
|
||||
// unmarshal a redelegation from a store key and value
|
||||
@ -106,7 +106,7 @@ func UnmarshalValidator(cdc *codec.Codec, operatorAddr, value []byte) (validator
|
||||
return
|
||||
}
|
||||
var storeValue validatorValue
|
||||
err = cdc.UnmarshalBinary(value, &storeValue)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(value, &storeValue)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user