-
Notifications
You must be signed in to change notification settings - Fork 75
[ETCM-70-71] Checkpointing domain + Checkpointing configuration #695
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
[ETCM-70-71] Checkpointing domain + Checkpointing configuration #695
Conversation
793249b
to
4110fad
Compare
src/main/scala/io/iohk/ethereum/consensus/ConsensusConfig.scala
Outdated
Show resolved
Hide resolved
case Some(value) => RLPList(enc.encode(value)) | ||
} | ||
|
||
implicit def optionDec[T](implicit dec: RLPDecoder[T]): RLPDecoder[Option[T]] = { |
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.
Maybe we should start using this for the optOut field eventually 🤔
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.
I think we can't as we are using custom Boolean encoding/decoding here.
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.
Is it custom? I copied it from how it's done on the reverse field of GetBlockHeaders
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.
we don't have any default one, but IMHO default Boolean could be true/false not 1/0 ;)
@@ -102,24 +128,42 @@ object BlockHeader { | |||
} | |||
|
|||
implicit class BlockheaderEncodableDec(val rlpEncodeable: RLPEncodeable) extends AnyVal { |
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.
Not directly related to this PR, but I'm not fond of this naming: BlockheaderEncodableDec
is by types symmetrical to BlockHeaderEnc
(RLPEncodable => BlockHeader
vs BlockHeader => RLPEncodable
), so it should be named BlockHeaderDec
.
What is currently BlockheaderDec
should be renamed to BlockHeaderByteArrayDec
, especially that it's only used in tests.
Note: Blockheader*
-> BlockHeader*
case _ => throw new RuntimeException("Cannot decode Checkpoint") | ||
} | ||
|
||
implicit class CheckpointEnc(checkpoint: Checkpoint) extends RLPSerializable { |
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.
Do we need this class? It would be more concise to express it as a SAM type (same as the decoder).
case (None, Some(_)) => | ||
// Post ECIP1097 block with checkpoint, treasury disabled, block with checkpoint is encoded | ||
RLPList(parentHash, ommersHash, beneficiary, stateRoot, transactionsRoot, receiptsRoot, | ||
logsBloom, difficulty, number, gasLimit, gasUsed, unixTimestamp, extraData, mixHash, nonce, RLPList(), checkpoint) |
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.
It's a bit awkward. I wonder how other clients would deal with this - if they can easily switch encoding on a basis of block number then they might contest this design as unintuitive.
What if we had a single optional field interpreted as "block header extensions"? It would be always present after ECIP-X. Then we could explicitly state optionality of the new extensions in all cases, and it would be safe for any future extensions as well.
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.
do you mean one additional field for BlockHeader where we will pack all extensions ? I'm ok with that, but as it will touch also treasury opt, IMHO it should be done in different PR as it will add a lot of noise to the PR.
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.
Yes, definitely. This would be an important breaking change, so I'd like to consult that with others and plan it as proper a task.
I'm also not sure if this is the best we can do. @ntallar WDYT?
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.
IMHO it would be also good to do something similar in BlockchainConfig
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.
Wouldn't a block header extensions field only move this complexity there, with the same matching on it's size as here? Why would that simplify any future extensions?
The only thing I think would simplify quite a lot the enconding/decoding design is having a block version field as with bitcoin (we could add it as the optional 17th field). Then:
- Version 1: no version field, traditional ETC block
- Version 2: treasuryOptOut as 18th field + checkpoint as 19th field
- Future version 3: sth as 20th field, ...
- ...
The spec didn't include that as I thought it might be an overkill, I haven't heard of future block headers changes for now
(I would also add any changes resulting from this discussion in a separate PR)
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.
Why would that simplify any future extensions?
Not necessarily simplify, but we would always have explicitness regarding optionality. Anyway, I do like the version field idea better. I think this is the way to go 💯
4110fad
to
33e15ed
Compare
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.
Apart from the discussion on versioning (for a separate PR I think), LGTM!
.\\ //.
. \ \ / /.
.\ ,\ /` /,.-
-. \ /'/ / .
` - `-' \ -
'. /.\`
- .-
:`//.'
.`.'
.' BP
…encoder + added checkpointing config
33e15ed
to
d2e159e
Compare
Description
Ported checkpoint domain and configuration
Important Changes Introduced
Testing