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

api: Print sigHash in getBlockWithConsensusInfo #2101

Merged
merged 1 commit into from Jan 29, 2024

Conversation

blukat29
Copy link
Contributor

@blukat29 blukat29 commented Jan 26, 2024

Proposed changes

  • Modify klay_getBlockWithConsensusInfo and ken util decode-extra to additionally print sigHash field
    • a proposer signs sigHash to create seal
    • a validator signs blockHash + 0x02 to create committedSeal
    • see TestRecoverCommittedSeal result below
  • Add a unit test with real data

Types of changes

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

  • 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

Further comments

$ go test -v -run=TestRecoverCommittedSeal
    api_test.go:36: 0f1c60a9847eb10cedc902507188262dc78f8d575d571ab1fdf472a9ad7252c2 dc7dca1dc15d06e83a0a39217052ad7915d3b0f0a68f49d4b53498130a1212327b9dd5514362eb3e5f0ebb277e7d38baecad9cd045d3627d3a1f322422eeee8a01 -> 5cb1a7dccbd0dc446e3640898ede8820368554c8
    api_test.go:43: 4d0a7bafd8a88c983431031270df6bfc0e9a0909b126f2a3f1ac5b3c03392eb702 0a3fb9227632261c8520f1ee859c503f017701fdb92c2e39f532e190779888a63cf112cf2e530f656153ab64103558c26fb9ca43d5cf31425e62569f891e1eca00 -> 5cb1a7dccbd0dc446e3640898ede8820368554c8
    api_test.go:43: 4d0a7bafd8a88c983431031270df6bfc0e9a0909b126f2a3f1ac5b3c03392eb702 4a32097b87c481f145ae75ded4e8ec2ea4230c7b2feb3f3afcd2d22ea0b7d4596f4354e185d4f1f93b4d758ddb97e9203e1d306413ad0db1f4a779156879baa300 -> 571e53df607be97431a5bbefca1dffe5aef56f4d
    api_test.go:43: 4d0a7bafd8a88c983431031270df6bfc0e9a0909b126f2a3f1ac5b3c03392eb702 fde66a2abb916bf314c82a2dfcd82ed356af829a98573d7cdb4a74cccb6ceecc22358750332ad31dccd9a890dbde7e0d4e21f173515011656f6c222169ba946200 -> 99fb17d324fa0e07f23b49d09028ac0919414db6
ken --exec "console.log(JSON.stringify(klay.getHeader(144654443)))" attach https://public-en-baobab.klaytn.net/ | head -1 > header.json
ken util decode-extra header.json
{
  "committedSeal": [
    "0x0a3fb9227632261c8520f1ee859c503f017701fdb92c2e39f532e190779888a63cf112cf2e530f656153ab64103558c26fb9ca43d5cf31425e62569f891e1eca00",
    "0x4a32097b87c481f145ae75ded4e8ec2ea4230c7b2feb3f3afcd2d22ea0b7d4596f4354e185d4f1f93b4d758ddb97e9203e1d306413ad0db1f4a779156879baa300",
    "0xfde66a2abb916bf314c82a2dfcd82ed356af829a98573d7cdb4a74cccb6ceecc22358750332ad31dccd9a890dbde7e0d4e21f173515011656f6c222169ba946200"
  ],
  "committedSealSize": 3,
  "committers": [
    "0x5cb1a7dccbd0dc446e3640898ede8820368554c8",
    "0x571e53df607be97431a5bbefca1dffe5aef56f4d",
    "0x99fb17d324fa0e07f23b49d09028ac0919414db6"
  ],
  "hash": "0x4d0a7bafd8a88c983431031270df6bfc0e9a0909b126f2a3f1ac5b3c03392eb7",
  "proposer": "0x5Cb1A7dccbd0Dc446e3640898EDE8820368554c8",
  "round": 0,
  "seal": "0xdc7dca1dc15d06e83a0a39217052ad7915d3b0f0a68f49d4b53498130a1212327b9dd5514362eb3e5f0ebb277e7d38baecad9cd045d3627d3a1f322422eeee8a01",
  "sigHash": "0x0f1c60a9847eb10cedc902507188262dc78f8d575d571ab1fdf472a9ad7252c2",
  "validatorSize": 4,
  "validators": [
    "0x571E53Df607bE97431a5bBeFcA1DFfE5aEF56F4d",
    "0x5Cb1A7dccbd0Dc446e3640898EDE8820368554c8",
    "0x99FB17d324fa0e07F23b49d09028Ac0919414dB6",
    "0xB74Ff9DEa397fE9E231df545eb53fE2ADF776cb2"
  ]
}

@blukat29
Copy link
Contributor Author

@jiseongnoh TestRecoverCommittedSeal is a correctness check for the committers field

Copy link
Contributor

@jiseongnoh jiseongnoh left a comment

Choose a reason for hiding this comment

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

thank you!

@blukat29 blukat29 merged commit bd7b0b0 into klaytn:dev Jan 29, 2024
11 checks passed
@blukat29 blukat29 deleted the consensus-api-sighash branch January 29, 2024 00:52
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.

None yet

6 participants