8000 [Cmd] Added offline utils by hyunsooda · Pull Request #1691 · klaytn/klaytn · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Aug 19, 2024. It is now read-only.

[Cmd] Added offline utils #1691

Merged
merged 11 commits into from
Jul 24, 2023
Merged

[Cmd] Added offline utils #1691

merged 11 commits into from
Jul 24, 2023

Conversation

hyunsooda
Copy link
Contributor
@hyunsooda hyunsooda commented Nov 14, 2022

Proposed changes

The header struct contains byte arrays which is specific data in Klaytn implementation. This change adds a utility to easily decode them in a human-readable format.

  1. The size of binary increases, but not runtime memory.
  2. Rather than splitting core utilis to other software, offline provision in core binary seems better in my view.
Extra bytes parsing

./ken util extra header.json
{
  "committedSeal": [
    "0xb7fe0c34df70fd635a1cfab73eeed5e704b139979ad96664b61a36e68fdd4ea545335a4bd4ee8f384387262be644c04725e428f864c12eeae92ad103ec30f4c400",
    "0x5b746d7e7f3e9401587a0fdf4281ad5616c876d04a2dad39fb7ca047256cc8fd779560d7bb1cc60b3733269d244e4121f99516079563384d61dac2058d1cb42800",
    "0xf5b6cbc38e792914cba174b256b7118ca4a48e31e8d168459768adaefbe7f07c4648a96cb712dc169b5d772ad89271ccbad67adb4104e72daf97eead3c5ccb6500",
    "0x7b64d7a2b2badb28cc5354945b14b81aea66aac671bdc30895c65fee79ad6ffc3e6c0c609d0ffa887776af1d77279e662d121b191c2be60b1e32e9c315f17ac401",
    "0xa305b2feffabbf0daf7c9a990b59342f600aad5fc786836a5c96cb9f9169c8d54d519f66c380b36ecd40b81c6b57d342f6a174447d21648a3346fe67b9baf17f00",
    "0x2137d798141b249b6f72c3dc1961679bfa7cf720299c50163e317d662ca5ec6a36008b31f25ca4cc11cf1774dfa67c2791d8a7c7994c6a7e1743d6cd52fe572400",
    "0xbf8b1f071d1038e6119a5d6c9a807a5676aadac9b9d2f00c929680f4409eefe56381336d0604d66dfffa7651e1be15c15d282e45fb8f65027e7ba60881ae28a901",
    "0x823b8e2e1d9004d86ff223d0fbc81aac0bacd166ec4f73aa261138776f8fd70078f69e4090639be7cf2ffef3c49f8ad420cf901e852192aa7835c87319b00d4800",
    "0x74e454060a3203b25ff062c36729ea5d0e063585af9f8f765d907fa143aad7eb43289087008fead41cf1375937cb500d7917a74603c60c8a6d8930546868e5be00",
    "0x53b67a1a9d6fe69afe7a264f7c78670d655c46a58dfcc5a080e11ad5100c0f076de094929e8954d2a21529d3c7477e7296c074996c15790a863dfbe6c16045e100",
    "0x211e06bcdd83575802116edbed504b774273209563246272d300f0db9eda8c947d6cddf22d370f73cfdd568ee2a51cfbcb4ca243836d5b890b7fe3821d610ea301",
    "0x198a8731512f02670006255ea03db7112731e0f86b2885d2e451953906c56c154adc4ac5eefa414c312ca3ae966e08ceb4d0999b7bb9bd528880091e582145bf00",
    "0xee62ccfeeddfc21a4aa0d4435f2eba6360b920a7c37f1f047be58f1eb311bd03194c042ef88436afd641380c7d67ca512b147e21b04e32375c39c31a29a20ba601",
    "0x841fb2c2ec566e31954d9517669eedf2226ed0003b7db748d507c4b9f0182e61695717a2d6d409e93c6a7fb6c61f74bdc72d1c33749ed91c41247a73078cd4ba00",
    "0x00141537344e43779c3c9251f3962fb3c5e0f3216bc18f2075b1f8d72b37236a2830e7ab16d865bd0b7b59f4f96b50dce4fb37a11dce15d916f2bf45ac171dd901",
    "0x4b64903c0ecfd503ea24653307cd68061b8a76c5e1c0ecd18d3122382047e5fc51a49904ae24345a48e6985eed23eb787a8cdad40739d375ccdf1930172aa8ac00",
    "0xdce0a23e9713a9cb4517825a87de9db4b42478dab9f644be72ffa01de57d29626a00e600ed7ba437a7d6f395c5f88f6e9045a49e1dcd0c4a1dc74258bb0b70d001",
    "0xa611ab0cd54db268a05b875eed9887067fe661e377eb056e8844cadf1e5f81781ecc4fddd4c0565fe03f3e9516a76e878f1f3a2964c2647a94502d6cea365c9600",
    "0x8501a322787249ba18edf061b2041fe8d11a4127eb54c31ec6e75ce70f990ae47021de62f3bf35c84c7106bc52ee8291a51a807392b30c3b189d414b9e21e0e701",
    "0xd47f54fb7b79d7a35de31c802d4b07e2563c4f27278c20e30d293d11640a283470d34d76182a2e163673dc03cff4aaed1d4d2643c3ea92a4fed9285fdf46bb5501",
    "0xc36a5d574909805e5dac1c23a0aab91bfae4af4cfe68f6a604de7c62059854ae59ca2b2c60f9bc3f3baf1138188604fd8c8eef4f51e164af960f0d3b750ffa0200"
  ],
  "committedSealSize": 21,
  "proposer": "0x52d41cA72aF615a1ac3301b0A93EFA222EcC7541",
  "seal": "0x4200aca95c863b220f1c7cc549b876b5b55eb8d848d4a68ff69e522033c897b1727f726e678f7b901c1466d0f2c4bc49bb40cfd5a95231e75304041b49e63bf000",
  "validatorSize": 35,
  "validators": [
    "0x03497F51c31fE8b402DF0bDE90Fd5A85f87aA943",
    "0x0b59caE1F03534209FdB9dDF5eA65b310Cd7060c",
    "0x1390eAb3AD2e674646A8F92460098886409FD57B",
    "0x16C192585a0aB24B552783B4Bf7d8DC9F6855c35",
    "0x20685d7bBcb07DDdBd8dbDC824C31fe2bfB31c92",
    "0x2BDd279522b8a0843831fBB94cFBb24A913597C5",
    "0x36Ff2Aa21d5c6828EE12CD2bc3DE0E987bC0d4E7",
    "0x386Ca3Cb8bB13f48D1a6adC1fb8df09e7Bb7f9c8",
    "0x52c0F3654E9Ac47ba5e64FfcB398bE485718a74B",
    "0x52d41cA72aF615a1ac3301b0A93EFA222EcC7541",
    "0x53970bC504cbC41c2a0e6460AeF7D86655186284",
    "0x56E8C1463C341abf8B168c3079eA41cE8a387e18",
    "0x5e59DB28cEF098d5A2e877F84127aED10d7378F2",
    "0x6873352021FE9226884616dC6F189f289AEb0cC5",
    "0x74f64cb6c2dB9e0b270dF1D4E563920381AeC034",
    "0x7B065fBb3A9B6e97F2ba788d63700bD4B8B408Bc",
    "0x9419fA2E3b9EB1158De31bE66C586A52F49C5dE7",
    "0x9f10d38e650184142C1C791e1b8d03E5f14aE47f",
    "0xa2Ba8f7798649a778a1Fd66D3035904949FEC555",
    "0xa3b387b7B0dC914a4F106Ad645A0Ad079d70EBdC",
    "0xb9456fD65A6810B19dF24832C50b2E61a41867f8",
    "0xBCA8fFa45CC8e30bBC0522CdF1A1e0eBF540dfE2",
    "0xc032c34cB9FE064Fe435199e1078dD8756a166b5",
    "0xc180cA565B34b5b63877674f5fE647E7dA079022",
    "0xcB21b21B8948a26259775b88c14a7DdA9Eb09CE7",
    "0xd6D7762DD7FadF0512D83D0143685fC85488B64E",
    "0xE36eA146C05757A38eC1493eEA8c878677A9c19a",
    "0xe3d92072D8b9A59a0427485A1b5f459271Df457C",
    "0xE783Fc94FddAeEbeF7293D6c5864cff280f121E1",
    "0xE93A890fB7EC5E993b1A7FD77B0D13A0763Eff3D",
    "0xec6C1CEDE510Be308f0FDBbc8dBdF238829BDB34",
    "0xED6Ee8a1877f9582858dBE2509aBB0aC33E5f24E",
    "0xf113eC8c22765d485309cF1D025d1B975245b9F8",
    "0xf8C9C61c5E7f2B6219D1C28B94E5cB3cDC802594",
    "0xfb416E2A714A5d1e034BeACf0646a36876b72765"
  ]
}

Governance bytes parsing

./ken util gov 0x9d7b22697374616e62756c2e636f6d6d697474656573697a65223a32317d
{
  "istanbul.committeesize": 21
}

Vote bytes parsing

./ken util vote 0xf8459452d41ca72af615a1ac3301b0a93efa222ecc75419a676f7665726e616e63652e72656d6f766576616c696461746f729416c192585a0ab24b552783b4bf7d8dc9f6855c35
{
  "key": "governance.removevalidator",
  "validator": "0x52d41cA72aF615a1ac3301b0A93EFA222EcC7541",
  "value": "0x16C192585a0aB24B552783B4Bf7d8DC9F6855c35"
}

Extract keys

./ken util key ~/mykey/UTC--2022-10-27T03-46-47.010808172Z--96f88b4e427ece99584d7bc8f711b8213a512b30 }5pCr55dRkwMJk9w

{
  "addr": "0x96F88B4e427eCE99584d7bC8F711B8213a512B30",
  "privkey": "f910a483d14a98083367e8ae815937b8a1df794046be49188e863ee9b5b72b49",
  "pubkey": "0440c641121c3f0be4b7411c00ec3a3e61a24267ae7098e4b14722c2fca38fb798c8d09693bd41c577aa6e122e7ec396eca6f39ed515c1c9a99350e184155418c8"
}

Types of changes

Please put an x in the boxes related to your change.

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes ($ make test)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Related issues

  • Please leave the issue numbers or links related to this PR here.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@yoomee1313 yoomee1313 requested review from ian0371, kjeom and kjhman21 and removed request for nohkwak and henry-will December 27, 2022 08:45
@hyunsooda
Copy link
Contributor Author

@ian0371, New one pushed again for all of your comments. Please resolve the comment one by one if they are okay.

ian0371
ian0371 previously approved these changes Jan 16, 2023
Copy link
Contributor
@ian0371 ian0371 left a comment

Choose a reason for hiding this comment

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

all resolved. LGTM

return nil
}

func decode(ctx *cli.Context) error {
Copy link
@kjeom kjeom Jan 16, 2023

Choose a reason for hiding this comment

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

You have added some utility functions for decode, right?
If I understand right, you can rename this command as decode and use subcommands pattern.
Reference https://github.com/klaytn/klaytn/blob/dev/cmd/utils/nodecmd/accountcmd.go#L60

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Smarter way :) Refactored. Thanks.

Copy link

Choose a reason for hiding this comment

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

You can just put the actual function name to the action field of the subcommand. You don't need to switch each cases.

aidan-kwon
aidan-kwon previously approved these changes Jul 18, 2023
@aidan-kwon aidan-kwon requested review from kjeom and 2dvorak July 18, 2023 02:59
@aidan-kwon aidan-kwon requested a review from ian0371 July 18, 2023 02:59
ian0371
ian0371 previously approved these changes Jul 18, 2023
@aidan-kwon
Copy link
Member

@hyunsooda Please proceed this PR if you don't have additional concerns

@hyunsooda hyunsooda dismissed stale reviews from ian0371 and aidan-kwon via f52aa53 July 20, 2023 08:00
@aidan-kwon aidan-kwon requested a review from ian0371 July 21, 2023 09:29
@aidan-kwon aidan-kwon merged commit 228dc06 into klaytn:dev Jul 24, 2023
@aidan-kwon
Copy link
Member

@markyim-klaytn This command can be used to parse voting data and governance data. Please see the command example in the description.

@aidan-kwon aidan-kwon mentioned this pull request Aug 3, 2023
20 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0