Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

[PAN-3126] add an override facility for genesis configs #1915

Merged
merged 7 commits into from
Sep 9, 2019

Conversation

shemnon
Copy link
Contributor

@shemnon shemnon commented Sep 9, 2019

PR description

Add a generalized genesis config override facility for command line use. Only useful for string or integer config values, not object values.

Sample use - enable Istanbul fork on block 99 million
--override-genesis-config=istanbulFork=99000000

Overriding a value with an empty string unsets the value

Sample use - disable Istanbul fork by un-setting istanbulFork:
--override-genesis-config=istanbulFork=

final String value = configOverrides.get(key);
return value == null || value.isEmpty()
? OptionalLong.empty()
: OptionalLong.of(Long.valueOf(configOverrides.get(key)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we explicitly specify the radix here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

final String value = configOverrides.get(key);
return value == null || value.isEmpty()
? OptionalInt.empty()
: OptionalInt.of(Integer.valueOf(configOverrides.get(key)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we explicitly specify the radix here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

final GenesisConfigFile config = GenesisConfigFile.development();
final int bigBlock = 999_999_999;
final String bigBlockString = Integer.toString(bigBlock);
final Map<String, String> override = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add some tests that use a case-sensitive Map with various casing strategies for the keys to verify that values are replaced in a case-insensitive way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@shemnon shemnon merged commit 4ba5c6e into PegaSysEng:master Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants