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

[dev] fix dev sleep command do not update on chain timestamp #3477

Merged
merged 1 commit into from
Jun 24, 2022

Conversation

coldnight
Copy link
Contributor

@coldnight coldnight commented Jun 21, 2022

Add GenerateSleepBlockEvent to generate empty block by dev sleep command without check disable-mint-empty-block. To fix dev sleep command didn't update on chain timestamp.

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

As the disable_mint_empty_block flag is true in Dev network, and the dev sleep command just trigger it to update on chain timestamp, then eventually, the dev sleep command didn't update on chain timestamp.

Issue Number: #3329

What is the new behavior?

  • Add an new event GenerateSleepBlockEvent that will add block directly without check disable_mint_empty_block

Other information

Result of chain info before dev sleep:

Click to expand/collapse
{
  "ok": {
    "block_info": {
      "block_accumulator_info": {
        "accumulator_root": "0x155fff75365299de34f6c17a941936f4873ff6a6ce263a38d51cc49bcdd05002",
        "frozen_subtree_roots": [
          "0x155fff75365299de34f6c17a941936f4873ff6a6ce263a38d51cc49bcdd05002"
        ],
        "num_leaves": "1",
        "num_nodes": "1"
      },
      "block_hash": "0x155fff75365299de34f6c17a941936f4873ff6a6ce263a38d51cc49bcdd05002",
      "total_difficulty": "0x01",
      "txn_accumulator_info": {
        "accumulator_root": "0xd9d8bfad3b1d05486ff3b0831c4cbd94c6ede35598cd76a69c0e3879aaf12090",
        "frozen_subtree_roots": [
          "0xd9d8bfad3b1d05486ff3b0831c4cbd94c6ede35598cd76a69c0e3879aaf12090"
        ],
        "num_leaves": "1",
        "num_nodes": "1"
      }
    },
    "chain_id": 254,
    "genesis_hash": "0x155fff75365299de34f6c17a941936f4873ff6a6ce263a38d51cc49bcdd05002",
    "head": {
      "author": "0x00000000000000000000000000000001",
      "author_auth_key": null,
      "block_accumulator_root": "0x414343554d554c41544f525f504c414345484f4c4445525f4841534800000000",
      "block_hash": "0x155fff75365299de34f6c17a941936f4873ff6a6ce263a38d51cc49bcdd05002",
      "body_hash": "0xd54136a5c1455409ef22392f2b2451e730222fd2ff8297ab3e47db8dc6d7afab",
      "chain_id": 254,
      "difficulty": "0x01",
      "extra": "0x00000000",
      "gas_used": "0",
      "nonce": 0,
      "number": "0",
      "parent_hash": "0x3a9c4141b1893c28c96eda9dd937145fe3cee63c0160b91a391b9afe789c5fd5",
      "state_root": "0x1ee14fb341b111b6fcd822f97a6b718b88e6dcd930d69e7b7620e1f4f31a2afc",
      "timestamp": "0",
      "txn_accumulator_root": "0xd9d8bfad3b1d05486ff3b0831c4cbd94c6ede35598cd76a69c0e3879aaf12090"
    }
  }
}

After ran dev sleep -t 1000 command:

Click to expand/collapse
{
  "ok": {
    "block_info": {
      "block_accumulator_info": {
        "accumulator_root": "0xb1a362f2546aafaacb6a8cf11f4fa6a813652e9a488d016364960a250326a661",
        "frozen_subtree_roots": [
          "0xb1a362f2546aafaacb6a8cf11f4fa6a813652e9a488d016364960a250326a661"
        ],
        "num_leaves": "2",
        "num_nodes": "3"
      },
      "block_hash": "0xd504e1ebbde7c7dd20387d0bc5bd1b094c1d913b20b6121c5432aa6b1bb0a111",
      "total_difficulty": "0x2711",
      "txn_accumulator_info": {
        "accumulator_root": "0xee2ccdb3ffc30051d618cb8e35a07ada6a346ecdd784de59eb59942183a71aa6",
        "frozen_subtree_roots": [
          "0xee2ccdb3ffc30051d618cb8e35a07ada6a346ecdd784de59eb59942183a71aa6"
        ],
        "num_leaves": "2",
        "num_nodes": "3"
      }
    },
    "chain_id": 254,
    "genesis_hash": "0x155fff75365299de34f6c17a941936f4873ff6a6ce263a38d51cc49bcdd05002",
    "head": {
      "author": "0x631f393a37777058f4f0845d5555e57b",
      "author_auth_key": null,
      "block_accumulator_root": "0x155fff75365299de34f6c17a941936f4873ff6a6ce263a38d51cc49bcdd05002",
      "block_hash": "0xd504e1ebbde7c7dd20387d0bc5bd1b094c1d913b20b6121c5432aa6b1bb0a111",
      "body_hash": "0xc01e0329de6d899348a8ef4bd51db56175b3fa0988e57c3dcec8eaf13a164d97",
      "chain_id": 254,
      "difficulty": "0x2710",
      "extra": "0x00000000",
      "gas_used": "0",
      "nonce": 11011,
      "number": "1",
      "parent_hash": "0x155fff75365299de34f6c17a941936f4873ff6a6ce263a38d51cc49bcdd05002",
      "state_root": "0x601996d1cf89c0062caee8bb32197c5608e3b593346f38225ca12e00f24b520c",
      "timestamp": "1001",
      "txn_accumulator_root": "0xee2ccdb3ffc30051d618cb8e35a07ada6a346ecdd784de59eb59942183a71aa6"
    }
  }
}

The `GenerateBlockEvent` will be ignored, as the
`disable_mint_empty_block` flag is true in Dev network.

So this commit adds an new event `GenerateSleepBlockEvent` that will
generate block directly.
@codecov
Copy link

codecov bot commented Jun 21, 2022

Codecov Report

Merging #3477 (62a70be) into master (cf59287) will decrease coverage by 0.08%.
The diff coverage is 40.39%.

❗ Current head 62a70be differs from pull request most recent head de04306. Consider uploading reports for the commit de04306 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3477      +/-   ##
==========================================
- Coverage   32.00%   31.93%   -0.07%     
==========================================
  Files         500      500              
  Lines       46868    46901      +33     
  Branches    21373    21388      +15     
==========================================
- Hits        14997    14972      -25     
+ Misses      17752    17720      -32     
- Partials    14119    14209      +90     
Flag Coverage Δ
unittests 31.93% <40.39%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
vm/types/src/time.rs 73.96% <ø> (ø)
miner/src/lib.rs 35.41% <32.61%> (-2.94%) ⬇️
rpc/server/src/module/debug_rpc.rs 20.00% <100.00%> (ø)
types/src/system_events.rs 67.45% <100.00%> (+4.29%) ⬆️
executor/src/block_executor.rs 22.23% <0.00%> (-15.55%) ⬇️
commons/accumulator/src/tree.rs 55.67% <0.00%> (-4.92%) ⬇️
storage/src/transaction_info/mod.rs 50.00% <0.00%> (-4.34%) ⬇️
commons/accumulator/src/lib.rs 58.95% <0.00%> (-4.21%) ⬇️
config/src/helper.rs 49.02% <0.00%> (-3.92%) ⬇️
commons/service-registry/src/service_actor.rs 38.71% <0.00%> (-3.22%) ⬇️
... and 68 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cf59287...de04306. Read the comment docs.

Copy link
Member

@jolestar jolestar left a comment

Choose a reason for hiding this comment

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

LGTM

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