Skip to content

[ETCM-43][ETCM-46] Add opt-out field #675

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 11 commits into from
Sep 22, 2020
Merged

Conversation

ntallar
Copy link

@ntallar ntallar commented Sep 16, 2020

Description

First changes for supporting treasury (as specified here)

Depends on #674

Proposed Solution

  • Adds opt-out field on block headers
  • Gives possibility for miner to selecting whether to opt-out or not of supporting treasury

Pending

  • Adds tests for validation changes
  • Test on the mainnet
  • Test on a private network with ECIP activation

Testing

  • Mantis shouldn't change it's behaviour when connected to the ETC mainnet or mordor
  • Creating a private network with lower ECIP1098 number should result in only blocks after ECIP1098 having the selected opt-out

@ntallar ntallar added BREAKS CONFIG Affects the default configuration BREAKS PROTOCOL Affects Node2Node interactions in a way that makes them not interoperate labels Sep 16, 2020
@ntallar ntallar changed the title [ETCM-43] Add opt-out field [ETCM-43][ETCM-46] Add opt-out field Sep 16, 2020
@ntallar ntallar force-pushed the etcm-43-opt-out-header-field branch from 3f62ec0 to 0bea179 Compare September 16, 2020 13:53
@ntallar ntallar force-pushed the etcm-43-opt-out-header-field branch from 0bea179 to da98f44 Compare September 16, 2020 19:17
Base automatically changed from chore/blockchainconfig-as-caseclass to develop September 17, 2020 13:39
@ntallar ntallar force-pushed the etcm-43-opt-out-header-field branch from be1e679 to a97f773 Compare September 17, 2020 15:36
@ntallar ntallar marked this pull request as ready for review September 17, 2020 15:36
@@ -11,6 +11,8 @@
atlantis-block-number = "0"
agharta-block-number = "0"
phoenix-block-number = "0"
# FIXME: Once the testnet is up an running we should determine this value
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should provide a new file especially for the new testnet, WDTY?

Copy link
Author

Choose a reason for hiding this comment

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

Should we still keep the configurations for a private testnet? It could get a bit messy given that we have private.conf, private.json and private-testnet.conf

We could have for our chains/ files:

  • Keep private-testnet.conf (current private.conf) and private-testnet.json (current private.json), with private-testnet.conf having ecip1098 activated at block 0 as currently
  • Add internal-testnet.conf and internal-tesnet.json for our testnet

We could have for our conf/ files:

  • Have a testnet-changes.conf file with the testnet configuration overrides (i.e. disabling pruning and discovery)
  • Have a private-testnet.conf and a internal-testnet.conf that would just select the correct chain

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we could discuss this in a call.

Copy link
Author

Choose a reason for hiding this comment

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

Conclusion from call: #681

val isEcip1098Activated = blockHeader.number >= blockchainConfig.ecip1098BlockNumber
val isOptOutDefined = blockHeader.optOut.isDefined

if(isEcip1098Activated && isOptOutDefined) Right(BlockHeaderValid)
Copy link
Contributor

Choose a reason for hiding this comment

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

(formatting) if (

val emptyOmmerHash = ByteString(Hex.decode("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"))

def getEncodedWithoutNonce(blockHeader: BlockHeader): Array[Byte] = {
val rlpEncoded = blockHeader.toRLPEncodable match {
case rlpList: RLPList =>
case rlpList: RLPList if rlpList.items.length == (NumberOfFields - 1) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

i prefer something like: if (isPreviousToEcip1089(rlpList) => WDYT?

Copy link
Author

Choose a reason for hiding this comment

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

I found a way I preferred most, to not require the NumberOfFields value, I'll soon push it

RLPList(rlpList.items.dropRight(2): _*)

case rlpList: RLPList if rlpList.items.length == NumberOfFields =>
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@@ -73,8 +81,17 @@ object BlockHeader {
implicit class BlockHeaderEnc(blockHeader: BlockHeader) 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.

A comment regarding the reason behind optOut match { will help future generations i guess..hehe.

val headerWithOptOutInvalidlyOn = validBlockHeader.copy(optOut = Some(true))

val validationResult = blockHeaderValidator.validate(headerWithOptOutInvalidlyOn, validParentBlockHeader)
validationResult shouldBe Left(HeaderOptOutError)
Copy link
Contributor

Choose a reason for hiding this comment

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

(minor) maybe we could provide differenciation between this scenario and the following one, i mean in terms of HeaderOptOutError description. Still not sure if is worthy, wdyt?

Copy link
Contributor

@mirkoAlic mirkoAlic left a comment

Choose a reason for hiding this comment

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

LGTM!

@ntallar ntallar requested a review from mmrozek September 22, 2020 13:20
Copy link
Contributor

@mmrozek mmrozek left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -135,7 +135,7 @@ class GenesisDataLoader(
extraData = genesisData.extraData,
mixHash = genesisData.mixHash.getOrElse(zeros(hashLength)),
nonce = genesisData.nonce,
optOut = None
treasuryOptOut = None
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@ntallar ntallar merged commit fb29d58 into develop Sep 22, 2020
@ntallar ntallar deleted the etcm-43-opt-out-header-field branch September 22, 2020 20:00
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants