Skip to content

[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

Merged
merged 2 commits into from
Sep 28, 2020

Conversation

pslaski
Copy link
Contributor

@pslaski pslaski commented Sep 24, 2020

Description

Ported checkpoint domain and configuration

Important Changes Introduced

Testing

  • sync with mainnet with a fresh database

@pslaski pslaski added the BREAKS STATE Affects self state retro-compatibility, needs data wiping label Sep 24, 2020
@pslaski pslaski requested review from kapke and ntallar September 24, 2020 09:01
@pslaski pslaski force-pushed the etcm-70-etcm-71-checkpoint-domain-and-config branch from 793249b to 4110fad Compare September 24, 2020 09:12
@pslaski pslaski requested review from rtkaczyk and removed request for kapke September 24, 2020 11:48
@ntallar ntallar added BREAKS CONFIG Affects the default configuration BREAKS PROTOCOL Affects Node2Node interactions in a way that makes them not interoperate labels Sep 24, 2020
case Some(value) => RLPList(enc.encode(value))
}

implicit def optionDec[T](implicit dec: RLPDecoder[T]): RLPDecoder[Option[T]] = {
Copy link

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 🤔

Copy link
Contributor Author

@pslaski pslaski Sep 25, 2020

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.

Copy link

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

Copy link
Contributor Author

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 {
Copy link
Contributor

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 {
Copy link
Contributor

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)
Copy link
Contributor

@rtkaczyk rtkaczyk Sep 25, 2020

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link

@ntallar ntallar Sep 25, 2020

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)

Copy link
Contributor

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 💯

@pslaski pslaski force-pushed the etcm-70-etcm-71-checkpoint-domain-and-config branch from 4110fad to 33e15ed Compare September 25, 2020 12:41
Copy link

@ntallar ntallar left a 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 

@pslaski pslaski force-pushed the etcm-70-etcm-71-checkpoint-domain-and-config branch from 33e15ed to d2e159e Compare September 28, 2020 12:12
@pslaski pslaski merged commit e2d301f into develop Sep 28, 2020
@pslaski pslaski deleted the etcm-70-etcm-71-checkpoint-domain-and-config branch September 28, 2020 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BREAKS CONFIG Affects the default configuration BREAKS PROTOCOL Affects Node2Node interactions in a way that makes them not interoperate BREAKS STATE Affects self state retro-compatibility, needs data wiping
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants