diff --git a/README.md b/README.md index 58a990653a6..5c3c672e3f9 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/doc/rpc/components/schemas/Receipt.json b/doc/rpc/components/schemas/Receipt.json index 24bec42347a..c788d04d81e 100644 --- a/doc/rpc/components/schemas/Receipt.json +++ b/doc/rpc/components/schemas/Receipt.json @@ -15,7 +15,8 @@ "to", "transactionHash", "transactionIndex", - "type" + "type", + "effectiveGasPrice" ], "properties": { "blockHash": { @@ -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).", diff --git a/doc/rpc/methods/eth_getTransactionReceipt.json b/doc/rpc/methods/eth_getTransactionReceipt.json index e27c9c31e1c..b143f8f276f 100644 --- a/doc/rpc/methods/eth_getTransactionReceipt.json +++ b/doc/rpc/methods/eth_getTransactionReceipt.json @@ -58,7 +58,8 @@ ], "logsBloom": "0x00...0", "status": "0x1", - "type": "0x0" + "type": "0x0", + "effectiveGasPrice": "0x1" } ] } diff --git a/rskj-core/src/main/java/co/rsk/peg/Bridge.java b/rskj-core/src/main/java/co/rsk/peg/Bridge.java index 6af54db63e1..da79afb75f0 100644 --- a/rskj-core/src/main/java/co/rsk/peg/Bridge.java +++ b/rskj-core/src/main/java/co/rsk/peg/Bridge.java @@ -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; @@ -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 @@ -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"); @@ -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 { @@ -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) { @@ -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 @@ -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) { @@ -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 @@ -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) { @@ -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; } @@ -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; } @@ -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; } @@ -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); } @@ -1153,7 +1152,7 @@ public long getLockingCap(Object[] args) { public byte[] getActivePowpegRedeemScript(Object[] args) { logger.debug("[getActivePowpegRedeemScript] started"); try { - Optional