-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[WIP] include raw bytes
in Ethcore::BlockError
#11493
Conversation
af1057c
to
143e949
Compare
Is it possible to introduce a new error |
The main motivation behind this change is to include `raw rlp block bytes` in `BlockError`. Instead of at runtime have to ensure that it is returned every time a `BadBlock` is detected. This commit doesn't solve it completly because in a few major traits (Engine, ValidatorSet, EpochVerfier) returns `EthcoreError`. Thus, that is why we have `Option<Bytes>` in `BlockErrorWithData` and still have to ensure that it is not `None` at runtime which is unfortunate. Related to this, all functions/methods that I have detected that could return more precise error have been changed. Also, this commit includes a bunch of `nit fixes` that are unrelated to #11403.
143e949
to
e0a50c6
Compare
I think so but where to add it then? For example, if it would go in Explain the intention I don't get the point :) EDIT: I think draft description was bad, I meant |
I'll have to read the code first, but I meant adding a new enum variant to |
#[display(fmt = "Block error: {}", _0)] | ||
Block(BlockError), | ||
#[display(fmt = "{}", _0)] | ||
Block(BlockErrorWithData), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if instead of replacing Block(BlockError)
with Block(BlockErrorWithData)
, we add an additional variant
BadBlock(BlockErrorWithData)
and do the conversion in the import/create function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good, thanks
@niklasad1 could you extract nice but unrelated changes to a separate PR so we can focus the review on the actual fix? |
Sure, sorry for the noise |
* master: (27 commits) Faster kill_garbage (#11514) [EngineSigner]: don't sign message with only zeroes (#11524) fix compilation warnings (#11522) [ethcore cleanup]: various unrelated fixes from `#11493` (#11507) Add benchmark for transaction execution (#11509) Add Smart Contract License v1.0 Misc fixes (#11510) [dependencies]: unify `rustc-hex` (#11506) Activate on-chain randomness in POA Sokol (#11505) Grab bag of cleanup (#11504) Implement eth/64 (EIP-2364) and drop support for eth/62 (#11472) [dependencies]: remove `util/macros` (#11501) OpenEthereum bootnodes are added (#11499) [ci benches]: use `all-features` (#11496) [verification]: make test-build compile standalone (#11495) complete null-signatures removal (#11491) Include the seal when populating the header for a new block (#11475) fix compilation warnings (#11492) cargo update -p cmake (#11490) update to published rlp-derive (#11489) ...
This is a draft PR to fix #11403, i.e, include
raw rlp block bytes
inBlockError
instead of at runtime have to ensure that it is returned every time aBadBlock
is detected.But, this doesn't solve #11403 completely because in a few major traits (Engine, ValidatorSet, EpochVerfier) returns
EthcoreError
without passingraw_bytes
. Thus, it is not possible to returnBlockError
withraw_bytes
in some scenarios such as header verification. That is why this PR introduces two redundant patternsBlock(BlockError)
andBadBlock((BlockError, Bytes))
to deal with that.Another approach could be split
Block
andBadBlock
into something more logical such asHeader
andBlock
but it is quite hard to know where to draw the line and it will requite lots of refactoring.//cc @ordian @dvdplm (don't read the code, the description should be enough to reason about the basic idea, I need your help)
Benchmarks on
goerli
blocksbranch: na-ethcore-blockerror
2020-02-14 14:26:24 Import completed in 516 seconds, 1488674 blocks, 2883 blk/s, 627666 transactions, 1215 tx/s, 88240 Mgas, 170 Mgas/s
branch: master
2020-02-14 14:51:50 Import completed in 531 seconds, 1488674 blocks, 2802 blk/s, 627666 transactions, 1181 tx/s, 88240 Mgas, 166 Mgas/s
branch: stable
2020-02-14 15:35:56 Import completed in 493 seconds, 1488674 blocks, 3015 blk/s, 627666 transactions, 1271 tx/s, 88240 Mgas, 178 Mgas/s