Skip to content

Commit

Permalink
Merge pull request #301 from rsksmart/powhsm-bookkeping-config-integr…
Browse files Browse the repository at this point in the history
…ation

Powpeg-node Configuration Refactor
  • Loading branch information
marcos-iov authored Aug 23, 2024
2 parents 0a9d699 + 1b6f810 commit fe97bd7
Show file tree
Hide file tree
Showing 44 changed files with 1,591 additions and 1,190 deletions.
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

0 comments on commit fe97bd7

Please sign in to comment.