Skip to content

Commit

Permalink
Cli option to specify Hikari configuration for pruning db connection (#…
Browse files Browse the repository at this point in the history
…663)

* Added cli option `--slashing-protection-pruning-db-pool-configuration-file`
  • Loading branch information
usmansaleem authored Oct 31, 2022
1 parent 7fceb32 commit 99f048b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ out/
docker/reports/*
.vscode
.lh/*
.fleet/
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Next Release

### Features Added
- Introduced cli option to specify Hikari configuration for pruning database connection [#661](https://github.com/ConsenSys/web3signer/issues/661)

## 22.10.0

### Features Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ public class PicoCliSlashingProtectionParameters implements SlashingProtectionPa
paramLabel = "<hikari configuration properties file>")
private Path dbPoolConfigurationFile = null;

@Option(
names = "--slashing-protection-pruning-db-pool-configuration-file",
description =
"Optional configuration file for Hikari database connection pool used by pruning process.",
paramLabel = "<hikari configuration properties file>")
private Path pruningDbPoolConfigurationFile = null;

@Option(
names = {"--slashing-protection-pruning-enabled"},
description =
Expand Down Expand Up @@ -133,6 +140,11 @@ public Path getDbPoolConfigurationFile() {
return dbPoolConfigurationFile;
}

@Override
public Path getPruningDbPoolConfigurationFile() {
return pruningDbPoolConfigurationFile;
}

@Override
public boolean isPruningEnabled() {
return pruningEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static SlashingProtectionContext create(
slashingProtectionParameters.getDbUrl(),
slashingProtectionParameters.getDbUsername(),
slashingProtectionParameters.getDbPassword(),
slashingProtectionParameters.getDbPoolConfigurationFile());
slashingProtectionParameters.getPruningDbPoolConfigurationFile());

final ValidatorsDao validatorsDao = new ValidatorsDao();
final RegisteredValidators registeredValidators = new RegisteredValidators(jdbi, validatorsDao);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public interface SlashingProtectionParameters {

Path getDbPoolConfigurationFile();

Path getPruningDbPoolConfigurationFile();

boolean isPruningEnabled();

long getPruningEpochsToKeep();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class TestSlashingProtectionParameters implements SlashingProtectionParam
private final long pruningInterval;
private final Path dbPoolConfigurationFile;

private final Path pruningDbPoolConfigurationFile;

private final int dbHealthCheckTimeoutMilliseconds;

private final int dbHealthCheckIntervalMilliseconds;
Expand All @@ -38,14 +40,6 @@ public TestSlashingProtectionParameters(
this(dbUrl, dbUser, dbPassword, 0, 0);
}

public TestSlashingProtectionParameters(
final String dbUrl,
final String dbUser,
final String dbPassword,
Path dbPoolConfigurationFile) {
this(dbUrl, dbUser, dbPassword, dbPoolConfigurationFile, 0, 0, Long.MAX_VALUE, 3000, 3000);
}

public TestSlashingProtectionParameters(
final String dbUrl,
final String dbUser,
Expand All @@ -67,6 +61,7 @@ public TestSlashingProtectionParameters(
dbUser,
dbPassword,
null,
null,
pruningEpochsToKeep,
pruningSlotsPerEpoch,
pruningInterval,
Expand All @@ -79,6 +74,7 @@ public TestSlashingProtectionParameters(
final String dbUser,
final String dbPassword,
final Path dbPoolConfigurationFile,
final Path pruningDbPoolConfigurationFile,
final int pruningEpochsToKeep,
final int pruningSlotsPerEpoch,
final long pruningInterval,
Expand All @@ -88,6 +84,7 @@ public TestSlashingProtectionParameters(
this.dbUser = dbUser;
this.dbPassword = dbPassword;
this.dbPoolConfigurationFile = dbPoolConfigurationFile;
this.pruningDbPoolConfigurationFile = pruningDbPoolConfigurationFile;
this.pruningEnabled = true;
this.pruningAtBootEnabled = true;
this.pruningEpochsToKeep = pruningEpochsToKeep;
Expand Down Expand Up @@ -147,6 +144,11 @@ public Path getDbPoolConfigurationFile() {
return dbPoolConfigurationFile;
}

@Override
public Path getPruningDbPoolConfigurationFile() {
return pruningDbPoolConfigurationFile;
}

@Override
public boolean isPruningAtBootEnabled() {
return pruningAtBootEnabled;
Expand Down

0 comments on commit 99f048b

Please sign in to comment.