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

Extra data passed with blocks should be ignored #75

Closed
alexdovzhanyn opened this issue Nov 19, 2018 · 1 comment
Closed

Extra data passed with blocks should be ignored #75

alexdovzhanyn opened this issue Nov 19, 2018 · 1 comment
Assignees
Labels
Enhancement New feature or request Good First Issue Good for newcomers Help Wanted Extra attention is needed

Comments

@alexdovzhanyn
Copy link
Owner

Currently, a block with literally any arbitrary data is accepted as valid. We expect blocks to look something like:

%{
  difficulty: 18775743.58334009,
  hash: "0000000D0E89D9A13DE616FEC8B12A62B646B2B5D0E1419C1A460442474E2AF0",
  index: 2324,
  merkle_root: "9084BB7F7D5A722FC2075644E71C2A518545E33C27402376D19863721EF0063B",
  nonce: 32535345,
  previous_hash: "0000003987CE7A874B760D50B183232A8C910C29CC7342E858503656D687BEE2",
  timestamp: 1542634035,
  version: 1,
  transactions: []
}

This block is considered a valid block, and when a miner or node (or wallet) receives this block, they'll take the received data verbatim and store it. This approach is naive. A miner can include any data they want onto this block, and it will still be deemed valid, and still be stored verbatim, wasting resources on a machine storing data that may be irrelevant. An example of this is the following:

%{
  difficulty: 18775743.58334009,
  hash: "0000000D0E89D9A13DE616FEC8B12A62B646B2B5D0E1419C1A460442474E2AF0",
  index: 2324,
  merkle_root: "9084BB7F7D5A722FC2075644E71C2A518545E33C27402376D19863721EF0063B",
  nonce: 32535345,
  previous_hash: "0000003987CE7A874B760D50B183232A8C910C29CC7342E858503656D687BEE2",
  timestamp: 1542634035,
  version: 1,
  transactions: [],
  my_favorite_food: "Pizza",
  my_favorite_binary: <<0, 12, 122, 255, 1, 4, 0, 23, 231>>
}

In this case, miners would store the extra fields my_favorite_food and my_favorite_binary on their disk, even though this benefits the chain in no way.

I propose we prune fields that we expect from received blocks and only store those. In this case, the above block would still be deemed valid, as it is, but we wouldn't store the extra data.

@alexdovzhanyn alexdovzhanyn added Enhancement New feature or request Help Wanted Extra attention is needed Good First Issue Good for newcomers labels Nov 19, 2018
@alexdovzhanyn alexdovzhanyn self-assigned this Nov 21, 2018
@alexdovzhanyn
Copy link
Owner Author

Fixed in #77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Good First Issue Good for newcomers Help Wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant