From 9307d93e11f05e2753dd18c7618a806ba79726e1 Mon Sep 17 00:00:00 2001 From: sahith-narahari Date: Tue, 18 Aug 2020 20:03:32 +0530 Subject: [PATCH 1/6] Fix skip confirm logic --- client/tx/tx.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/tx/tx.go b/client/tx/tx.go index bcffbc321ec3..790bf89ce1d0 100644 --- a/client/tx/tx.go +++ b/client/tx/tx.go @@ -100,7 +100,7 @@ func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error { } if !clientCtx.SkipConfirm { - out, err := clientCtx.JSONMarshaler.MarshalJSON(tx) + out, err := clientCtx.TxConfig.TxJSONEncoder()(tx.GetTx()) if err != nil { return err } From 78bf07492327728aa076b15e097529026ab68fee Mon Sep 17 00:00:00 2001 From: sahith-narahari Date: Tue, 18 Aug 2020 20:18:23 +0530 Subject: [PATCH 2/6] Fix dry run --- std/pubkey.go | 4 ++++ std/pubkey_test.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/std/pubkey.go b/std/pubkey.go index ff7a636b7877..15f03340d272 100644 --- a/std/pubkey.go +++ b/std/pubkey.go @@ -21,6 +21,8 @@ var _ types.PublicKeyCodec = DefaultPublicKeyCodec{} // Decode implements the PublicKeyCodec.Decode method func (cdc DefaultPublicKeyCodec) Decode(key *types.PublicKey) (crypto.PubKey, error) { switch key := key.Sum.(type) { + case nil: + return crypto.PubKey(nil), nil case *types.PublicKey_Secp256K1: n := len(key.Secp256K1) if n != secp256k1.PubKeySize { @@ -69,6 +71,8 @@ func (cdc DefaultPublicKeyCodec) Decode(key *types.PublicKey) (crypto.PubKey, er // Encode implements the PublicKeyCodec.Encode method func (cdc DefaultPublicKeyCodec) Encode(key crypto.PubKey) (*types.PublicKey, error) { switch key := key.(type) { + case nil: + return &types.PublicKey{}, nil case secp256k1.PubKey: return &types.PublicKey{Sum: &types.PublicKey_Secp256K1{Secp256K1: key}}, nil case ed255192.PubKey: diff --git a/std/pubkey_test.go b/std/pubkey_test.go index 22397a4b78c4..859fbf34c884 100644 --- a/std/pubkey_test.go +++ b/std/pubkey_test.go @@ -25,6 +25,8 @@ func roundTripTest(t *testing.T, pubKey crypto.PubKey) { } func TestDefaultPublicKeyCodec(t *testing.T) { + roundTripTest(t, nil) + pubKeySecp256k1 := secp256k1.GenPrivKey().PubKey() roundTripTest(t, pubKeySecp256k1) From 8392e5f5e31ca72e0ec8a30a024ca2bb37340d07 Mon Sep 17 00:00:00 2001 From: sahith-narahari Date: Tue, 18 Aug 2020 20:25:53 +0530 Subject: [PATCH 3/6] Update gh actions --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 14865c91d23a..59321bce2b8b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -211,7 +211,7 @@ jobs: make build-docker-local-simapp - name: start localnet run: | - make clean build-sim-linux localnet-start + make clean build-simd-linux localnet-start if: "env.GIT_DIFF != ''" - name: test liveness run: | From 979187c052f547fd5abc164af011631de684fdff Mon Sep 17 00:00:00 2001 From: sahith-narahari Date: Tue, 18 Aug 2020 23:20:24 +0530 Subject: [PATCH 4/6] Replace switch with if --- std/pubkey.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/std/pubkey.go b/std/pubkey.go index 15f03340d272..6353ba5a782d 100644 --- a/std/pubkey.go +++ b/std/pubkey.go @@ -20,6 +20,9 @@ var _ types.PublicKeyCodec = DefaultPublicKeyCodec{} // Decode implements the PublicKeyCodec.Decode method func (cdc DefaultPublicKeyCodec) Decode(key *types.PublicKey) (crypto.PubKey, error) { + if key == nil { + return nil, nil + } switch key := key.Sum.(type) { case nil: return crypto.PubKey(nil), nil @@ -70,9 +73,10 @@ func (cdc DefaultPublicKeyCodec) Decode(key *types.PublicKey) (crypto.PubKey, er // Encode implements the PublicKeyCodec.Encode method func (cdc DefaultPublicKeyCodec) Encode(key crypto.PubKey) (*types.PublicKey, error) { - switch key := key.(type) { - case nil: + if key == nil { return &types.PublicKey{}, nil + } + switch key := key.(type) { case secp256k1.PubKey: return &types.PublicKey{Sum: &types.PublicKey_Secp256K1{Secp256K1: key}}, nil case ed255192.PubKey: From 5c3e94891450ffcb6abcd8599e703b22fc316982 Mon Sep 17 00:00:00 2001 From: sahith-narahari Date: Wed, 19 Aug 2020 01:17:38 +0530 Subject: [PATCH 5/6] revert liveness fix --- .github/workflows/test.yml | 2 +- std/pubkey.go | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 59321bce2b8b..14865c91d23a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -211,7 +211,7 @@ jobs: make build-docker-local-simapp - name: start localnet run: | - make clean build-simd-linux localnet-start + make clean build-sim-linux localnet-start if: "env.GIT_DIFF != ''" - name: test liveness run: | diff --git a/std/pubkey.go b/std/pubkey.go index 6353ba5a782d..84de89e751bf 100644 --- a/std/pubkey.go +++ b/std/pubkey.go @@ -24,8 +24,6 @@ func (cdc DefaultPublicKeyCodec) Decode(key *types.PublicKey) (crypto.PubKey, er return nil, nil } switch key := key.Sum.(type) { - case nil: - return crypto.PubKey(nil), nil case *types.PublicKey_Secp256K1: n := len(key.Secp256K1) if n != secp256k1.PubKeySize { From dda702bc3d6af40054b15beb26239befdb64fede Mon Sep 17 00:00:00 2001 From: sahith-narahari Date: Fri, 21 Aug 2020 21:04:56 +0530 Subject: [PATCH 6/6] Add key.Sum validation --- std/pubkey.go | 4 ++++ std/pubkey_test.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/std/pubkey.go b/std/pubkey.go index 84de89e751bf..cac6ef8837b7 100644 --- a/std/pubkey.go +++ b/std/pubkey.go @@ -20,9 +20,13 @@ var _ types.PublicKeyCodec = DefaultPublicKeyCodec{} // Decode implements the PublicKeyCodec.Decode method func (cdc DefaultPublicKeyCodec) Decode(key *types.PublicKey) (crypto.PubKey, error) { + // key being nil is allowed as all fields in proto are optional if key == nil { return nil, nil } + if key.Sum == nil { + return nil, nil + } switch key := key.Sum.(type) { case *types.PublicKey_Secp256K1: n := len(key.Secp256K1) diff --git a/std/pubkey_test.go b/std/pubkey_test.go index 859fbf34c884..484a5d8990c9 100644 --- a/std/pubkey_test.go +++ b/std/pubkey_test.go @@ -27,6 +27,8 @@ func roundTripTest(t *testing.T, pubKey crypto.PubKey) { func TestDefaultPublicKeyCodec(t *testing.T) { roundTripTest(t, nil) + roundTripTest(t, crypto.PubKey(nil)) + pubKeySecp256k1 := secp256k1.GenPrivKey().PubKey() roundTripTest(t, pubKeySecp256k1)