Skip to content
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

Powpeg-node Configuration Refactor #301

Merged
merged 30 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6bcf5a2
refactor(config): refactor PowHsmBookkeping class to be more consiste…
apancorb Jun 6, 2024
876839a
refactor(config): refactor and add missing tests for PowHSMBookkeepin…
apancorb Jun 6, 2024
161d6a0
fix(config): remove shadow variables and add lambda method reference
apancorb Jun 6, 2024
3784ebf
refactor(config): make paths for config keys constants
apancorb Jun 7, 2024
e040a0d
feat(config): revisit default PowHSM config values
apancorb Jun 12, 2024
cf57143
feat(config): get minimum difficulty target from the PowHSM
apancorb Jun 11, 2024
9de7d79
feat(test): add tests for getting difficulty from PowHSM
apancorb Jun 11, 2024
1bfb7cb
feat(config): add try-catch for getting the difficulty target from th…
apancorb Jun 17, 2024
230b115
feat(config): add tests to not allow node to start when difficulty ta…
apancorb Jun 18, 2024
764a9b6
refactor(config): main refactor of PowHSM config logic
apancorb Jun 20, 2024
c739609
refactor(config): default config values should be empty strings
apancorb Jun 24, 2024
5b0ed2d
refactor(config): throw exception if PowHSM config not found
apancorb Jun 25, 2024
f02fff8
refactor(config): make number default values literal for PowHSM confi…
apancorb Jun 25, 2024
68abdbc
refactor(config): use constructor to create PowHSM config
apancorb Jun 26, 2024
d5a8c83
refactor(config): tests for PowHSM config
apancorb Jun 25, 2024
c9b48af
feat(config): add new update bridge configurations
apancorb Jul 4, 2024
262ba50
refactor(config): powpeg-node main config
apancorb Jun 27, 2024
c5887af
refactor(config): powpeg-node tests config
apancorb Jun 27, 2024
0b71353
feat(config): add config builder for tests
apancorb Jul 1, 2024
f781132
refactor(config): include new builder methods for PowpegConfigBuilder
apancorb Jul 16, 2024
98b5151
refactor(config): add signer config to builder
apancorb Jul 18, 2024
4b730e8
Remove KEY_ID suffix from elements in PowPegNodeKeyId
marcos-iov Jul 23, 2024
648de30
feat(config): update default config values
apancorb Jul 30, 2024
8d8339b
feat(config): add all verifications to update unit test
apancorb Jul 31, 2024
0e16acf
Config fix wip
marcos-iov Aug 16, 2024
3d5e1cc
feat(config): create signer type enum
apancorb Aug 22, 2024
44f8af6
Use equalsIgnoreCase in SignerType enum
marcos-iov Aug 22, 2024
f2ac38a
Use SignerType enum instead of string literals
marcos-iov Aug 22, 2024
7723f41
Change exception thrown in SignerType
marcos-iov Aug 22, 2024
1b6f810
Refactor ECDSASignerFactory to encapsulate logic in methods
marcos-iov Aug 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/main/java/co/rsk/federate/BridgeTransactionSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import co.rsk.core.ReversibleTransactionExecutor;
import co.rsk.core.RskAddress;
import co.rsk.core.bc.PendingState;
import co.rsk.federate.config.FedNodeSystemProperties;
import co.rsk.federate.config.PowpegNodeSystemProperties;
import co.rsk.federate.gas.GasPriceProviderFactory;
import co.rsk.federate.gas.IGasPriceProvider;
import co.rsk.federate.signing.ECDSASigner;
Expand All @@ -20,7 +20,7 @@

import java.math.BigInteger;

import static co.rsk.federate.signing.PowPegNodeKeyId.RSK_KEY_ID;
import static co.rsk.federate.signing.PowPegNodeKeyId.RSK;

public class BridgeTransactionSender {

Expand All @@ -31,14 +31,14 @@ public class BridgeTransactionSender {
private final TransactionPool transactionPool;
private final ReversibleTransactionExecutor reversibleTransactionExecutor;
private final Coin gasPrice;
private final FedNodeSystemProperties config;
private final PowpegNodeSystemProperties config;
private final IGasPriceProvider gasPriceProvider;

public BridgeTransactionSender(Ethereum ethereum,
Blockchain blockchain,
TransactionPool transactionPool,
ReversibleTransactionExecutor reversibleTransactionExecutor,
FedNodeSystemProperties config) {
PowpegNodeSystemProperties config) {
this.ethereum = ethereum;
this.blockchain = blockchain;
this.transactionPool = transactionPool;
Expand Down Expand Up @@ -111,7 +111,7 @@ public synchronized void sendRskTx(RskAddress federatorAddress,
functionArgs);
try {
SignerMessageV1 messageToSign = new SignerMessageV1(rskTx.getRawHash().getBytes());
ECKey.ECDSASignature txSignature = signer.sign(RSK_KEY_ID.getKeyId(), messageToSign);
ECKey.ECDSASignature txSignature = signer.sign(RSK.getKeyId(), messageToSign);
rskTx.setSignature(txSignature);
LOGGER.debug("[tx={} | nonce={} | method={}] Submit to Bridge", rskTx.getHash(), nonce, function.name);
ethereum.submitTransaction(rskTx);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/co/rsk/federate/BtcToRskClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static com.google.common.base.Preconditions.checkNotNull;

import co.rsk.bitcoinj.core.BtcTransaction;
import co.rsk.federate.config.FedNodeSystemProperties;
import co.rsk.federate.config.PowpegNodeSystemProperties;
import co.rsk.peg.constants.BridgeConstants;
import co.rsk.federate.adapter.ThinConverter;
import co.rsk.federate.bitcoin.BitcoinWrapper;
Expand Down Expand Up @@ -94,7 +94,7 @@ protected BtcToRskClient(
BtcLockSenderProvider btcLockSenderProvider,
PeginInstructionsProvider peginInstructionsProvider,
Federation federation,
FedNodeSystemProperties config
PowpegNodeSystemProperties config
) throws Exception {
this.bitcoinWrapper = bitcoinWrapper;
this.federatorSupport = federatorSupport;
Expand All @@ -113,7 +113,7 @@ public synchronized void setup(
BtcToRskClientFileStorage btcToRskClientFileStorage,
BtcLockSenderProvider btcLockSenderProvider,
PeginInstructionsProvider peginInstructionsProvider,
FedNodeSystemProperties config
PowpegNodeSystemProperties config
) throws Exception {
this.bridgeConstants = bridgeConstants;
this.btcToRskClientFileStorage = btcToRskClientFileStorage;
Expand Down Expand Up @@ -820,7 +820,7 @@ protected PartialMerkleTree generatePMT(Block block, Transaction transaction) {
return generatePMT(block, transaction, transaction.hasWitnesses());
}

private void setConfigVariables(FedNodeSystemProperties config) {
private void setConfigVariables(PowpegNodeSystemProperties config) {
this.activationConfig = config.getActivationConfig();
this.isUpdateBridgeTimerEnabled = config.isUpdateBridgeTimerEnabled();
this.isUpdateBridgeTimerEnabled = config.isUpdateBridgeTimerEnabled();
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/co/rsk/federate/FedNodeContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import co.rsk.config.ConfigLoader;
import co.rsk.config.RskSystemProperties;
import co.rsk.federate.btcreleaseclient.BtcReleaseClient;
import co.rsk.federate.config.FedNodeSystemProperties;
import co.rsk.federate.config.PowpegNodeSystemProperties;
import co.rsk.federate.log.FederateLogger;
import co.rsk.federate.log.RskLogMonitor;
import co.rsk.federate.rpc.Web3FederateImpl;
Expand All @@ -39,7 +39,7 @@
*/
public class FedNodeContext extends RskContext {

private FedNodeSystemProperties fedNodeSystemProperties;
private PowpegNodeSystemProperties powpegNodeSystemProperties;
private BtcToRskClient.Factory btcToRskClientFactory;
private BtcToRskClient btcToRskClientActive;
private BtcToRskClient btcToRskClientRetiring;
Expand All @@ -59,15 +59,15 @@ public NodeRunner buildNodeRunner() {
new BtcReleaseClient(
getRsk(),
getFederatorSupport(),
getFedNodeSystemProperties(),
getPowpegNodeSystemProperties(),
getNodeBlockProcessor()
),
getFederationWatcher(),
getFederatorSupport(),
getFederateLogger(),
new RskLogMonitor(getRsk(), getFederateLogger()),
super.buildNodeRunner(),
getFedNodeSystemProperties(),
getPowpegNodeSystemProperties(),
new HSMClientProtocolFactory(),
new HSMBookKeepingClientProvider(),
this
Expand All @@ -76,7 +76,7 @@ public NodeRunner buildNodeRunner() {

@Override
public RskSystemProperties getRskSystemProperties() {
return getFedNodeSystemProperties();
return getPowpegNodeSystemProperties();
}

@Override
Expand Down Expand Up @@ -175,23 +175,23 @@ private FederatorSupport getFederatorSupport() {
getBlockchain(),
getTransactionPool(),
getReversibleTransactionExecutor(),
getFedNodeSystemProperties()
getPowpegNodeSystemProperties()
);
federatorSupport = new FederatorSupport(
getBlockchain(),
getFedNodeSystemProperties(),
getPowpegNodeSystemProperties(),
bridgeTransactionSender
);
}

return federatorSupport;
}

private FedNodeSystemProperties getFedNodeSystemProperties() {
if (fedNodeSystemProperties == null) {
fedNodeSystemProperties = new FedNodeSystemProperties(new ConfigLoader(getCliArgs()));
private PowpegNodeSystemProperties getPowpegNodeSystemProperties() {
if (powpegNodeSystemProperties == null) {
powpegNodeSystemProperties = new PowpegNodeSystemProperties(new ConfigLoader(getCliArgs()));
}

return fedNodeSystemProperties;
return powpegNodeSystemProperties;
}
}
Loading
Loading