Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/go data #40

Merged
merged 4 commits into from
Feb 26, 2017
Merged

Feature/go data #40

merged 4 commits into from
Feb 26, 2017

Conversation

ethanfrey
Copy link
Contributor

Use new go-data enhanced go-crypto data structures, so we can play better with json.

go-wire encodings will remain the same as they are now. encoding/json creates nice human readable json formats, fit for a public api. Along with bringing the rpc client into tendermint, this will remove a large chunk of the boilerplate in light-client.

All json encodings can be parsed again to recover the original structure. Here is an example:

Unsigned sendtx transaction (from client)

{
  "type": "send",
  "data": {
    "gas": 1,
    "fee": {
      "denom": "foo",
      "amount": 2
    },
    "inputs": [
      {
        "address": "ac7de62488962adc31f0416612e814e291e0765e",
        "coins": [
          {
            "denom": "foo",
            "amount": 10
          }
        ],
        "sequence": 1,
        "signature": null,
        "pub_key": {
          "type": "ed25519",
          "data": "31fb78b7b5b39b0c7e25877ca5148b4ff5b4cad0c81dd9e82db50e3723f2897c"
        }
      }
    ],
    "outputs": [
      {
        "address": "1eda813cf2871fceaf2d0ffbc8c810614fbb99ff",
        "coins": [
          {
            "denom": "foo",
            "amount": 8
          }
        ]
      }
    ]
  }
}

Signed sendtx transaction. Note that this can be deterministically parsed into the original stucture and the signature valiadated, without requiring a binary interchange format - just a consistent in-memory representation (same data structures):

{
  "type": "send",
  "data": {
    "gas": 1,
    "fee": {
      "denom": "foo",
      "amount": 2
    },
    "inputs": [
      {
        "address": "ac7de62488962adc31f0416612e814e291e0765e",
        "coins": [
          {
            "denom": "foo",
            "amount": 10
          }
        ],
        "sequence": 1,
        "signature": {
          "type": "ed25519",
          "data": "b36baf76d715ff20c09b3dbf26bcb5fd9cb6db13ae5056cbf1032620962b3624cca7b9da245e042498b440c9fb13d471a45f5b30ae0350466bf492c909b21a0c"
        },
        "pub_key": {
          "type": "ed25519",
          "data": "31fb78b7b5b39b0c7e25877ca5148b4ff5b4cad0c81dd9e82db50e3723f2897c"
        }
      }
    ],
    "outputs": [
      {
        "address": "1eda813cf2871fceaf2d0ffbc8c810614fbb99ff",
        "coins": [
          {
            "denom": "foo",
            "amount": 8
          }
        ]
      }
    ]
  }
}

@ethanfrey ethanfrey requested a review from ebuchman February 23, 2017 17:39
@ebuchman
Copy link
Member

Should we use the XxS structs for cmd/commands/key.go ?

Copy link
Member

@ebuchman ebuchman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great.

types/tx_test.go Outdated
@@ -62,3 +66,71 @@ func TestAppTxSignable(t *testing.T) {
t.Errorf("Got unexpected sign string for AppTx. Expected:\n%v\nGot:\n%v", expected, signBytesHex)
}
}

// d'oh, can't use the version in testutils due to circular imports :(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move testutils into basecoin/types - no need for the extra tiny package

@ebuchman
Copy link
Member

I just tried to merge into develop locally. I was having trouble actually running a real basecoin with old genesis files - and when I tried to update to use the new json format for the pubkeys, I started getting issues with the int64 in the Coin being treated as some float and not co-operating. Would you mind rebasing on develop and fixing this stuff up?

Note you should make sure the ibc demo works as part of testing. We should add it to the circle piece, but just

cd demo
bash start.sh

Sometimes you need to run start.sh twice. See genesis files in ./demo/data/chainX/basecoin/genesis.json.

Run bash clean.sh before you try again

@ebuchman ebuchman merged commit ce5ecc7 into develop Feb 26, 2017
@ebuchman ebuchman deleted the feature/go-data branch February 26, 2017 17:46
Raumo0 pushed a commit to mapofzones/cosmos-sdk that referenced this pull request Aug 6, 2021
Add ledger/multisig detection in SignTx functions
luchenqun pushed a commit to luchenqun/cosmos-sdk that referenced this pull request Sep 29, 2023
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Robert Zaremba <[email protected]>
Co-authored-by: Marko <[email protected]>
Co-authored-by: Julien Robert <[email protected]>
Co-authored-by: atheeshp <[email protected]>
Co-authored-by: yihuang <[email protected]>
Co-authored-by: Daniel Wedul <[email protected]>
Co-authored-by: Aleksandr Bezobchuk <[email protected]>
Co-authored-by: Javier Su <[email protected]>
Co-authored-by: khanh-notional <[email protected]>
Co-authored-by: mmsqe <[email protected]>
Co-authored-by: Jeancarlo Barrios <[email protected]>
Co-authored-by: Facundo Medica <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants