Skip to content

Commit

Permalink
Merge branch 'master' into snap-v4-final
Browse files Browse the repository at this point in the history
  • Loading branch information
RIT Release Bot committed Aug 20, 2024
2 parents 2d59ae7 + 9bee1a9 commit 1595bcd
Show file tree
Hide file tree
Showing 158 changed files with 14,636 additions and 9,943 deletions.
24 changes: 10 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,23 @@
[![CodeQL](https://github.com/rsksmart/rskj/workflows/CodeQL/badge.svg)](https://github.com/rsksmart/rskj/actions?query=workflow%3ACodeQL)

# About
RskJ is a Java implementation of the Rootstock node. For more information about Rootstock, visit [rootstock.io/](https://rootstock.io/). The [Rootstock white paper](https://rootstock.io/rsk-white-paper-updated.pdf) provides a complete conceptual overview of the platform.

If you have questions about the code please find us on [![Gitter](https://badges.gitter.im/rsksmart/rskj.svg)](https://gitter.im/rsksmart/rskj?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

You may also want to check [our blog](https://blog.rsk.co/) for articles and updates on the project.
RskJ is a Java implementation of the Rootstock node. For more information about Rootstock, visit [rootstock.io](https://rootstock.io/). The [Rootstock white paper](https://rootstock.io/rsk-white-paper-updated.pdf) provides a complete conceptual overview of the platform.

# Getting Started
Information about compiling and running a Rootstock node can be found in the [wiki](https://github.com/rsksmart/rskj/wiki).
The stable versions are the tags published in [releases tab](https://github.com/rsksmart/rskj/releases).
Information about compiling and running a Rootstock node can be found in the [Rootstock Developers Portal](https://dev.rootstock.io/).
The stable RskJ versions are published in the [Releases section](https://github.com/rsksmart/rskj/releases).

# Report Security Vulnerabilities
We have a [vulnerability reporting guideline](https://github.com/rsksmart/rskj/blob/master/SECURITY.md) for details on how to
See the [vulnerability reporting guideline](https://github.com/rsksmart/rskj/blob/master/SECURITY.md) for details on how to
contact us to report a vulnerability.

# License
RskJ is licensed under the GNU Lesser General Public License v3.0, also included in our repository in the COPYING.LESSER file.

# Your Pledge
RskJ has been developed with the intention to foster the progress of society. By using RskJ, you make a pledge not to use it to incur in:
- Any kind of illegal or criminal act, activity or business;
- Any kind of act, activity or business that requires any kind of governmental authorization or license to legally occur or exist, without previously obtaining such authorization or license;
- Any kind of act, activity or business that is expected to infringe upon intellectual property rights belonging to other people;
- Any kind of act, activity or business involving dangerous or controlled goods or substances, including stolen goods, firearms, radioactive materials or drugs.
Something will be considered illegal, criminal, or requiring any kind of governmental authorization or license, when either the laws or regulations of the country in which you reside, or the laws or regulations of the country from which you use RskJ, consider it illegal, criminal, or requiring any kind of governmental authorization or license.
RskJ has been developed with the intention of fostering the progress of society. By using RskJ, you make a pledge not to use it to incur in:
- Any kind of illegal or criminal act, activity, or business;
- Any kind of act, activity, or business that requires any kind of governmental authorization or license to legally occur or exist without previously obtaining such authorization or license;
- Any kind of act, activity, or business that is expected to infringe upon intellectual property rights belonging to other people;
- Any kind of act, activity, or business involving dangerous or controlled goods or substances, including stolen goods, firearms, radioactive materials, or drugs.
Something will be considered illegal, criminal, or requiring any kind of governmental authorization or license when either the laws or regulations of the country in which you reside or the laws or regulations of the country from which you use RskJ consider it illegal, criminal, or requiring any kind of governmental authorization or license.
8 changes: 7 additions & 1 deletion doc/rpc/components/schemas/Receipt.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"to",
"transactionHash",
"transactionIndex",
"type"
"type",
"effectiveGasPrice"
],
"properties": {
"blockHash": {
Expand Down Expand Up @@ -79,6 +80,11 @@
"description": "is a positive unsigned 8-bit number that represents the type of the transaction.",
"type": "string"
},
"effectiveGasPrice": {
"title": "ReceiptEffectiveGasPrice",
"description": "The actual value per gas deducted on the transaction.",
"$ref": "#/components/schemas/IntegerHex"
},
"root": {
"title": "Receipt Root",
"description": "32 bytes of post-transaction `stateroot` (pre Byzantium).",
Expand Down
3 changes: 2 additions & 1 deletion doc/rpc/methods/eth_getTransactionReceipt.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
],
"logsBloom": "0x00...0",
"status": "0x1",
"type": "0x0"
"type": "0x0",
"effectiveGasPrice": "0x1"
}
]
}
Expand Down
51 changes: 25 additions & 26 deletions rskj-core/src/main/java/co/rsk/peg/Bridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import co.rsk.peg.utils.BtcTransactionFormatUtils;
import co.rsk.peg.whitelist.LockWhitelistEntry;
import co.rsk.peg.whitelist.OneOffWhiteListEntry;
import co.rsk.peg.whitelist.WhitelistResponseCode;
import co.rsk.rpc.modules.trace.ProgramSubtrace;
import com.google.common.annotations.VisibleForTesting;
import org.ethereum.config.Constants;
Expand Down Expand Up @@ -70,7 +71,7 @@
*/
public class Bridge extends PrecompiledContracts.PrecompiledContract {

private static final Logger logger = LoggerFactory.getLogger("bridge");
private static final Logger logger = LoggerFactory.getLogger(Bridge.class);
private static final PanicProcessor panicProcessor = new PanicProcessor();

// No parameters
Expand Down Expand Up @@ -207,10 +208,6 @@ public class Bridge extends PrecompiledContracts.PrecompiledContract {

public static final CallTransaction.Function GET_ACTIVE_POWPEG_REDEEM_SCRIPT = BridgeMethods.GET_ACTIVE_POWPEG_REDEEM_SCRIPT.getFunction();

public static final int LOCK_WHITELIST_UNLIMITED_MODE_CODE = 0;
public static final int LOCK_WHITELIST_ENTRY_NOT_FOUND_CODE = -1;
public static final int LOCK_WHITELIST_INVALID_ADDRESS_FORMAT_ERROR_CODE = -2;

// Log topics used by Bridge Contract pre RSKIP146
public static final DataWord RELEASE_BTC_TOPIC = DataWord.fromString("release_btc_topic");
public static final DataWord UPDATE_COLLECTIONS_TOPIC = DataWord.fromString("update_collections_topic");
Expand Down Expand Up @@ -774,26 +771,26 @@ public Long getBtcTxHashProcessedHeight(Object[] args) throws VMException {
public String getFederationAddress(Object[] args) {
logger.trace("getFederationAddress");

return bridgeSupport.getFederationAddress().toBase58();
return bridgeSupport.getActiveFederationAddress().toBase58();
}

public Integer getFederationSize(Object[] args) {
logger.trace("getFederationSize");

return bridgeSupport.getFederationSize();
return bridgeSupport.getActiveFederationSize();
}

public Integer getFederationThreshold(Object[] args) {
logger.trace("getFederationThreshold");

return bridgeSupport.getFederationThreshold();
return bridgeSupport.getActiveFederationThreshold();
}

public byte[] getFederatorPublicKey(Object[] args) {
logger.trace("getFederatorPublicKey");

int index = ((BigInteger) args[0]).intValue();
return bridgeSupport.getFederatorPublicKey(index);
return bridgeSupport.getActiveFederatorBtcPublicKey(index);
}

public byte[] getFederatorPublicKeyOfType(Object[] args) throws VMException {
Expand All @@ -809,19 +806,19 @@ public byte[] getFederatorPublicKeyOfType(Object[] args) throws VMException {
throw new VMException("Exception in getFederatorPublicKeyOfType", e);
}

return bridgeSupport.getFederatorPublicKeyOfType(index, keyType);
return bridgeSupport.getActiveFederatorPublicKeyOfType(index, keyType);
}

public Long getFederationCreationTime(Object[] args) {
logger.trace("getFederationCreationTime");

// Return the creation time in milliseconds from the epoch
return bridgeSupport.getFederationCreationTime().toEpochMilli();
return bridgeSupport.getActiveFederationCreationTime().toEpochMilli();
}

public long getFederationCreationBlockNumber(Object[] args) {
logger.trace("getFederationCreationBlockNumber");
return bridgeSupport.getFederationCreationBlockNumber();
return bridgeSupport.getActiveFederationCreationBlockNumber();
}

public String getRetiringFederationAddress(Object[] args) {
Expand Down Expand Up @@ -853,7 +850,7 @@ public byte[] getRetiringFederatorPublicKey(Object[] args) {
logger.trace("getRetiringFederatorPublicKey");

int index = ((BigInteger) args[0]).intValue();
byte[] publicKey = bridgeSupport.getRetiringFederatorPublicKey(index);
byte[] publicKey = bridgeSupport.getRetiringFederatorBtcPublicKey(index);

if (publicKey == null) {
// Empty array is returned when public key is not found or there's no retiring federation
Expand Down Expand Up @@ -973,17 +970,17 @@ public Integer rollbackFederation(Object[] args) throws BridgeIllegalArgumentExc
);
}

public byte[] getPendingFederationHash(Object[] args) {
public byte[] getPendingFederationHashSerialized(Object[] args) {
logger.trace("getPendingFederationHash");

byte[] hash = bridgeSupport.getPendingFederationHash();
Keccak256 hash = bridgeSupport.getPendingFederationHash();

if (hash == null) {
// Empty array is returned when pending federation is not present
return new byte[]{};
}

return hash;
return hash.getBytes();
}

public Integer getPendingFederationSize(Object[] args) {
Expand All @@ -996,7 +993,7 @@ public byte[] getPendingFederatorPublicKey(Object[] args) {
logger.trace("getPendingFederatorPublicKey");

int index = ((BigInteger) args[0]).intValue();
byte[] publicKey = bridgeSupport.getPendingFederatorPublicKey(index);
byte[] publicKey = bridgeSupport.getPendingFederatorBtcPublicKey(index);

if (publicKey == null) {
// Empty array is returned when public key is not found
Expand Down Expand Up @@ -1056,20 +1053,21 @@ public long getLockWhitelistEntryByAddress(Object[] args) {
try {
addressBase58 = (String) args[0];
} catch (Exception e) {
logger.warn("Exception in getLockWhitelistEntryByAddress", e);
return LOCK_WHITELIST_INVALID_ADDRESS_FORMAT_ERROR_CODE;
logger.warn("[getLockWhitelistEntryByAddress] Error while parsing the provided address. {}", e.getMessage());
return WhitelistResponseCode.INVALID_ADDRESS_FORMAT.getCode();
}

LockWhitelistEntry entry = bridgeSupport.getLockWhitelistEntryByAddress(addressBase58);

if (entry == null) {
// Empty string is returned when address is not found
return LOCK_WHITELIST_ENTRY_NOT_FOUND_CODE;
logger.debug("[getLockWhitelistEntryByAddress] Address not found: {}", addressBase58);
return WhitelistResponseCode.ADDRESS_NOT_EXIST.getCode();
}

return entry.getClass() == OneOffWhiteListEntry.class ?
((OneOffWhiteListEntry)entry).maxTransferValue().getValue() :
LOCK_WHITELIST_UNLIMITED_MODE_CODE;
((OneOffWhiteListEntry)entry).maxTransferValue().getValue() :
WhitelistResponseCode.UNLIMITED_MODE.getCode();
}

public Integer addOneOffLockWhitelistAddress(Object[] args) {
Expand All @@ -1081,7 +1079,7 @@ public Integer addOneOffLockWhitelistAddress(Object[] args) {
addressBase58 = (String) args[0];
maxTransferValue = (BigInteger) args[1];
} catch (Exception e) {
logger.warn("Exception in addOneOffLockWhitelistAddress", e);
logger.warn("[addOneOffLockWhitelistAddress] Error while parsing the provided address and max value. {}", e.getMessage());
return 0;
}

Expand All @@ -1095,7 +1093,7 @@ public Integer addUnlimitedLockWhitelistAddress(Object[] args) {
try {
addressBase58 = (String) args[0];
} catch (Exception e) {
logger.warn("Exception in addUnlimitedLockWhitelistAddress", e);
logger.warn("[addUnlimitedLockWhitelistAddress] Exception in addUnlimitedLockWhitelistAddress", e);
return 0;
}

Expand All @@ -1109,7 +1107,7 @@ public Integer removeLockWhitelistAddress(Object[] args) {
try {
addressBase58 = (String) args[0];
} catch (Exception e) {
logger.warn("Exception in removeLockWhitelistAddress", e);
logger.warn("[removeLockWhitelistAddress] Error while parsing the provided address. {}", e.getMessage());
return 0;
}

Expand All @@ -1119,6 +1117,7 @@ public Integer removeLockWhitelistAddress(Object[] args) {
public Integer setLockWhitelistDisableBlockDelay(Object[] args) throws IOException, BlockStoreException {
logger.trace("setLockWhitelistDisableBlockDelay");
BigInteger lockWhitelistDisableBlockDelay = (BigInteger) args[0];

return bridgeSupport.setLockWhitelistDisableBlockDelay(rskTx, lockWhitelistDisableBlockDelay);
}

Expand Down Expand Up @@ -1153,7 +1152,7 @@ public long getLockingCap(Object[] args) {
public byte[] getActivePowpegRedeemScript(Object[] args) {
logger.debug("[getActivePowpegRedeemScript] started");
try {
Optional<Script> redeemScript = bridgeSupport.getActivePowpegRedeemScript();
Optional<Script> redeemScript = bridgeSupport.getActiveFederationRedeemScript();
logger.debug("[getActivePowpegRedeemScript] finished");
return redeemScript.orElse(new Script(new byte[]{})).getProgram();
} catch (Exception ex) {
Expand Down
2 changes: 1 addition & 1 deletion rskj-core/src/main/java/co/rsk/peg/BridgeMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public enum BridgeMethods {
new String[]{"bytes"}
),
fixedCost(3000L),
(BridgeMethodExecutorTyped) Bridge::getPendingFederationHash,
(BridgeMethodExecutorTyped) Bridge::getPendingFederationHashSerialized,
fixedPermission(true),
CallTypeHelper.ALLOW_STATIC_CALL
),
Expand Down
Loading

0 comments on commit 1595bcd

Please sign in to comment.