-
Notifications
You must be signed in to change notification settings - Fork 366
Feat: added config variables for local snapshots #981
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,6 +80,15 @@ public abstract class BaseIotaConfig implements IotaConfig { | |
| protected double alpha = Defaults.ALPHA; | ||
| private int maxAnalyzedTransactions = Defaults.MAX_ANALYZED_TXS; | ||
|
|
||
| //Snapshot | ||
| protected boolean localSnapshotsEnabled = Defaults.LOCAL_SNAPSHOTS_ENABLED; | ||
| protected boolean localSnapshotsPruningEnabled = Defaults.LOCAL_SNAPSHOTS_PRUNING_ENABLED; | ||
| protected int localSnapshotsPruningDelay = Defaults.LOCAL_SNAPSHOTS_PRUNING_DELAY; | ||
| protected int localSnapshotsIntervalSynced = Defaults.LOCAL_SNAPSHOTS_INTERVAL_SYNCED; | ||
| protected int localSnapshotsIntervalUnsynced = Defaults.LOCAL_SNAPSHOTS_INTERVAL_UNSYNCED; | ||
| protected int localSnapshotsDepth = Defaults.LOCAL_SNAPSHOTS_DEPTH; | ||
| protected String localSnapshotsBasePath = Defaults.LOCAL_SNAPSHOTS_BASE_PATH; | ||
|
|
||
| public BaseIotaConfig() { | ||
| //empty constructor | ||
| } | ||
|
|
@@ -453,6 +462,83 @@ protected void setpPropagateRequest(double pPropagateRequest) { | |
| this.pPropagateRequest = pPropagateRequest; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean getLocalSnapshotsEnabled() { | ||
| return this.localSnapshotsEnabled; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| @Parameter(names = {"--local-snapshots-enabled"}, description = SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_ENABLED) | ||
| protected void setLocalSnapshotsEnabled(boolean localSnapshotsEnabled) { | ||
| this.localSnapshotsEnabled = localSnapshotsEnabled; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean getLocalSnapshotsPruningEnabled() { | ||
| return this.localSnapshotsPruningEnabled; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| @Parameter(names = {"--local-snapshots-pruning-enabled"}, description = SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_PRUNING_ENABLED) | ||
| protected void setLocalSnapshotsPruningEnabled(boolean localSnapshotsPruningEnabled) { | ||
| this.localSnapshotsPruningEnabled = localSnapshotsPruningEnabled; | ||
| } | ||
|
|
||
| @Override | ||
| public int getLocalSnapshotsPruningDelay() { | ||
| return this.localSnapshotsPruningDelay; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| @Parameter(names = {"--local-snapshots-pruning-delay"}, description = SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_PRUNING_DELAY) | ||
| protected void setLocalSnapshotsPruningDelay(int localSnapshotsPruningDelay) { | ||
| this.localSnapshotsPruningDelay = localSnapshotsPruningDelay; | ||
| } | ||
|
|
||
| @Override | ||
| public int getLocalSnapshotsIntervalSynced() { | ||
| return this.localSnapshotsIntervalSynced; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| @Parameter(names = {"--local-snapshots-interval-synced"}, description = SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_INTERVAL_SYNCED) | ||
| protected void setLocalSnapshotsIntervalSynced(int localSnapshotsIntervalSynced) { | ||
| this.localSnapshotsIntervalSynced = localSnapshotsIntervalSynced; | ||
| } | ||
|
|
||
| @Override | ||
| public int getLocalSnapshotsIntervalUnsynced() { | ||
| return this.localSnapshotsIntervalUnsynced; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| @Parameter(names = {"--local-snapshots-interval-unsynced"}, description = SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_INTERVAL_UNSYNCED) | ||
| protected void setLocalSnapshotsIntervalUnsynced(int localSnapshotsIntervalUnsynced) { | ||
| this.localSnapshotsIntervalUnsynced = localSnapshotsIntervalUnsynced; | ||
| } | ||
|
|
||
| @Override | ||
| public int getLocalSnapshotsDepth() { | ||
| return this.localSnapshotsDepth; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| @Parameter(names = {"--local-snapshots-depth"}, description = SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_DEPTH) | ||
| protected void setLocalSnapshotsDepth(int localSnapshotsDepth) { | ||
| this.localSnapshotsDepth = localSnapshotsDepth; | ||
| } | ||
|
|
||
| @Override | ||
| public String getLocalSnapshotsBasePath() { | ||
| return this.localSnapshotsBasePath; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| @Parameter(names = {"--local-snapshots-base-path"}, description = SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_BASE_PATH) | ||
| protected void setLocalSnapshotsBasePath(String localSnapshotsBasePath) { | ||
| this.localSnapshotsBasePath = localSnapshotsBasePath; | ||
| } | ||
|
|
||
| @Override | ||
| public long getSnapshotTime() { | ||
| return Defaults.GLOBAL_SNAPSHOT_TIME; | ||
|
|
@@ -669,6 +755,13 @@ public interface Defaults { | |
| "KPWCHICGJZXKE9GSUDXZYUAPLHAKAHYHDXNPHENTERYMMBQOPSQIDENXKLKCEYCPVTZQLEEJVYJZV9BWU"; | ||
|
|
||
| //Snapshot | ||
| boolean LOCAL_SNAPSHOTS_ENABLED = true; | ||
| boolean LOCAL_SNAPSHOTS_PRUNING_ENABLED = false; | ||
| int LOCAL_SNAPSHOTS_PRUNING_DELAY = 1000; | ||
| int LOCAL_SNAPSHOTS_INTERVAL_SYNCED = 10; | ||
| int LOCAL_SNAPSHOTS_INTERVAL_UNSYNCED = 5000; | ||
| String LOCAL_SNAPSHOTS_BASE_PATH = "mainnet"; | ||
| int LOCAL_SNAPSHOTS_DEPTH = 500; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have any sort of "story" backing up these default values?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LOCAL_SNAPSHOTS_INTERVAL_SYNCED = 10 LOCAL_SNAPSHOTS_INTERVAL_UNSYNCED = 5000 int LOCAL_SNAPSHOTS_DEPTH = 500;
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So effectively you will be able to reference data up to
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep |
||
| String SNAPSHOT_FILE = "/snapshotMainnet.txt"; | ||
| String SNAPSHOT_SIG_FILE = "/snapshotMainnet.sig"; | ||
| String PREVIOUS_EPOCHS_SPENT_ADDRESSES_TXT = "/previousEpochsSpentAddresses.txt"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,36 @@ | |
| */ | ||
| public interface SnapshotConfig extends Config { | ||
|
|
||
| /** | ||
| * @return {@value Descriptions#LOCAL_SNAPSHOTS_ENABLED} | ||
| */ | ||
| boolean getLocalSnapshotsEnabled(); | ||
|
|
||
| /** | ||
| * @return {@value Descriptions#LOCAL_SNAPSHOTS_PRUNING_ENABLED} | ||
| */ | ||
| boolean getLocalSnapshotsPruningEnabled(); | ||
|
|
||
| /** | ||
| * @return {@value Descriptions#LOCAL_SNAPSHOTS_PRUNING_DELAY} | ||
| */ | ||
| int getLocalSnapshotsPruningDelay(); | ||
|
|
||
| /** | ||
| * @return {@value Descriptions#LOCAL_SNAPSHOTS_INTERVAL_SYNCED} | ||
| */ | ||
| int getLocalSnapshotsIntervalSynced(); | ||
|
|
||
| /** | ||
| * @return {@value Descriptions#LOCAL_SNAPSHOTS_INTERVAL_UNSYNCED} | ||
| */ | ||
| int getLocalSnapshotsIntervalUnsynced(); | ||
|
|
||
| /** | ||
| * @return {@value Descriptions#LOCAL_SNAPSHOTS_DEPTH} | ||
| */ | ||
| int getLocalSnapshotsDepth(); | ||
|
|
||
| /** | ||
| * @return {@value Descriptions#SNAPSHOT_TIME} | ||
| */ | ||
|
|
@@ -25,6 +55,11 @@ public interface SnapshotConfig extends Config { | |
| */ | ||
| int getMilestoneStartIndex(); | ||
|
|
||
| /** | ||
| * @return {@value Descriptions#LOCAL_SNAPSHOTS_BASE_PATH} | ||
| */ | ||
| String getLocalSnapshotsBasePath(); | ||
|
|
||
| /** | ||
| * @return {@value Descriptions#NUMBER_OF_KEYS_IN_A_MILESTONE} | ||
| */ | ||
|
|
@@ -42,6 +77,13 @@ public interface SnapshotConfig extends Config { | |
|
|
||
| interface Descriptions { | ||
|
|
||
| String LOCAL_SNAPSHOTS_ENABLED = "Flag that determines if local snapshots are enabled."; | ||
| String LOCAL_SNAPSHOTS_PRUNING_ENABLED = "Flag that determines if pruning of old data is enabled."; | ||
| String LOCAL_SNAPSHOTS_PRUNING_DELAY = "Only prune data that precedes the local snapshot by n milestones."; | ||
| String LOCAL_SNAPSHOTS_INTERVAL_SYNCED = "Take local snapshots every n milestones if the node is fully synced."; | ||
| String LOCAL_SNAPSHOTS_INTERVAL_UNSYNCED = "Take local snapshots every n milestones if the node is syncing."; | ||
| String LOCAL_SNAPSHOTS_DEPTH = "Number of milestones to keep."; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the number of milestones to keep prior to latest local snapshot? Can you elaborate the description a bit?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes - if the milestone was taken with a depth of 500 and we have a pruning delay that is set to 5000, then we only prune data that is 5500 milestones in the past. This allows us to create local snapshot files that are suitable for very fast syncs (new nodes) and still maintain enough old data to never run into issues with the coordinator suddenly approving stuff that is really old.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, that's clear; just to be more verbose in the doc.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that this description should be more informative.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe also create a separate issue after merging so we can get these changes in first - its kind of tricky to break the whole shit down anyway |
||
| String LOCAL_SNAPSHOTS_BASE_PATH = "Path to the snapshot files (without file extensions)."; | ||
| String SNAPSHOT_TIME = "Epoch time of the last snapshot."; | ||
| String SNAPSHOT_FILE = "Path of the file that contains the state of the ledger at the last snapshot."; | ||
| String SNAPSHOT_SIGNATURE_FILE = "Path to the file that contains a signature for the snapshot file."; | ||
|
|
||
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 actually need this configuration variable? This should be automatically be adjusted depending to the network you are using. This way we can also always rely on a standard location for local snapshot files.
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.
since the file is currently persisted in the filesystem i would want to give the user the option to have control over the location of the file.
It might for example be possible that people run IOTA nodes with the folder of the binary being mounted as read only to secure the iri.jar against manipulations. In this case you might want to give a path to another directory where you store the working data like the db or the snapshot files.
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 already allow users to specify a data directory for their IRI nodes, I believe the local snapshots should be just dropped into that same folder; without giving the user this option, which I don't find the use for.
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.
the DB/persistable folder structure should be revisited, but as a different issue IMO.
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.
Can we create issues for minor things like this so i can change it afterwards? because once we have it merged i can more easily work on changes since i don't have to do them in 10 different branches.
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, please, create an issue for this.