target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test(expected = IllegalArgumentException.class) public void hexadecimalStringToLongFailBis() { Utils.hexadecimalStringToLong("zzz"); }
|
public static long hexadecimalStringToLong(String s) { if (!s.startsWith("0x")) { throw new IllegalArgumentException(String.format("Invalid hexadecimal number: %s", s)); } try { return Long.parseLong(s.substring(2), 16); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Invalid hexadecimal number: %s", s), e); } }
|
Utils { public static long hexadecimalStringToLong(String s) { if (!s.startsWith("0x")) { throw new IllegalArgumentException(String.format("Invalid hexadecimal number: %s", s)); } try { return Long.parseLong(s.substring(2), 16); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Invalid hexadecimal number: %s", s), e); } } }
|
Utils { public static long hexadecimalStringToLong(String s) { if (!s.startsWith("0x")) { throw new IllegalArgumentException(String.format("Invalid hexadecimal number: %s", s)); } try { return Long.parseLong(s.substring(2), 16); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Invalid hexadecimal number: %s", s), e); } } }
|
Utils { public static long hexadecimalStringToLong(String s) { if (!s.startsWith("0x")) { throw new IllegalArgumentException(String.format("Invalid hexadecimal number: %s", s)); } try { return Long.parseLong(s.substring(2), 16); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Invalid hexadecimal number: %s", s), e); } } static BigInteger unifiedNumericToBigInteger(String number); static String longToDateTime(long timestamp); static String getValueShortString(BigInteger number); static byte[] addressStringToBytes(String hex); static boolean isValidAddress(byte[] addr); static String getAddressShortString(byte[] addr); static SecureRandom getRandom(); static String getHashListShort(List<byte[]> blockHashes); static long toUnixTime(long javaTime); static long fromUnixTime(long unixTime); static T[] mergeArrays(T[] ... arr); static String align(String s, char fillChar, int targetLen, boolean alignRight); static String repeat(String s, int n); static boolean contains(List<byte[]> list, byte[] valueToFind); static void validateArrayAllegedSize(byte[] data, int offset, int allegedSize); static byte[] safeCopyOfRange(byte[] data, int from, int size); static boolean isDecimalString(String s); static boolean isHexadecimalString(String s); static long decimalStringToLong(String s); static long hexadecimalStringToLong(String s); static int significantBitCount(int number); }
|
Utils { public static long hexadecimalStringToLong(String s) { if (!s.startsWith("0x")) { throw new IllegalArgumentException(String.format("Invalid hexadecimal number: %s", s)); } try { return Long.parseLong(s.substring(2), 16); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Invalid hexadecimal number: %s", s), e); } } static BigInteger unifiedNumericToBigInteger(String number); static String longToDateTime(long timestamp); static String getValueShortString(BigInteger number); static byte[] addressStringToBytes(String hex); static boolean isValidAddress(byte[] addr); static String getAddressShortString(byte[] addr); static SecureRandom getRandom(); static String getHashListShort(List<byte[]> blockHashes); static long toUnixTime(long javaTime); static long fromUnixTime(long unixTime); static T[] mergeArrays(T[] ... arr); static String align(String s, char fillChar, int targetLen, boolean alignRight); static String repeat(String s, int n); static boolean contains(List<byte[]> list, byte[] valueToFind); static void validateArrayAllegedSize(byte[] data, int offset, int allegedSize); static byte[] safeCopyOfRange(byte[] data, int from, int size); static boolean isDecimalString(String s); static boolean isHexadecimalString(String s); static long decimalStringToLong(String s); static long hexadecimalStringToLong(String s); static int significantBitCount(int number); static final double JAVA_VERSION; }
|
@Test public void significantBitCount() { Assert.assertEquals(0, Utils.significantBitCount(0b0)); Assert.assertEquals(1, Utils.significantBitCount(0b1)); Assert.assertEquals(2, Utils.significantBitCount(0b10)); Assert.assertEquals(2, Utils.significantBitCount(0b11)); Assert.assertEquals(3, Utils.significantBitCount(0b111)); Assert.assertEquals(3, Utils.significantBitCount(0b100)); Assert.assertEquals(3, Utils.significantBitCount(0b101)); Assert.assertEquals(13, Utils.significantBitCount(0b1000111000101)); Assert.assertEquals(9, Utils.significantBitCount(0b000111000101)); }
|
public static int significantBitCount(int number) { int result = 0; while (number > 0) { result++; number >>= 1; } return result; }
|
Utils { public static int significantBitCount(int number) { int result = 0; while (number > 0) { result++; number >>= 1; } return result; } }
|
Utils { public static int significantBitCount(int number) { int result = 0; while (number > 0) { result++; number >>= 1; } return result; } }
|
Utils { public static int significantBitCount(int number) { int result = 0; while (number > 0) { result++; number >>= 1; } return result; } static BigInteger unifiedNumericToBigInteger(String number); static String longToDateTime(long timestamp); static String getValueShortString(BigInteger number); static byte[] addressStringToBytes(String hex); static boolean isValidAddress(byte[] addr); static String getAddressShortString(byte[] addr); static SecureRandom getRandom(); static String getHashListShort(List<byte[]> blockHashes); static long toUnixTime(long javaTime); static long fromUnixTime(long unixTime); static T[] mergeArrays(T[] ... arr); static String align(String s, char fillChar, int targetLen, boolean alignRight); static String repeat(String s, int n); static boolean contains(List<byte[]> list, byte[] valueToFind); static void validateArrayAllegedSize(byte[] data, int offset, int allegedSize); static byte[] safeCopyOfRange(byte[] data, int from, int size); static boolean isDecimalString(String s); static boolean isHexadecimalString(String s); static long decimalStringToLong(String s); static long hexadecimalStringToLong(String s); static int significantBitCount(int number); }
|
Utils { public static int significantBitCount(int number) { int result = 0; while (number > 0) { result++; number >>= 1; } return result; } static BigInteger unifiedNumericToBigInteger(String number); static String longToDateTime(long timestamp); static String getValueShortString(BigInteger number); static byte[] addressStringToBytes(String hex); static boolean isValidAddress(byte[] addr); static String getAddressShortString(byte[] addr); static SecureRandom getRandom(); static String getHashListShort(List<byte[]> blockHashes); static long toUnixTime(long javaTime); static long fromUnixTime(long unixTime); static T[] mergeArrays(T[] ... arr); static String align(String s, char fillChar, int targetLen, boolean alignRight); static String repeat(String s, int n); static boolean contains(List<byte[]> list, byte[] valueToFind); static void validateArrayAllegedSize(byte[] data, int offset, int allegedSize); static byte[] safeCopyOfRange(byte[] data, int from, int size); static boolean isDecimalString(String s); static boolean isHexadecimalString(String s); static long decimalStringToLong(String s); static long hexadecimalStringToLong(String s); static int significantBitCount(int number); static final double JAVA_VERSION; }
|
@Test public void testEqualsObject() { assertTrue(wrapper1.equals(wrapper2)); assertFalse(wrapper1.equals(wrapper3)); assertFalse(wrapper1.equals(wrapper4)); assertFalse(wrapper1.equals(null)); assertFalse(wrapper2.equals(wrapper3)); }
|
public boolean equals(Object other) { if (!(other instanceof ByteArrayWrapper)) { return false; } byte[] otherData = ((ByteArrayWrapper) other).data; return ByteUtil.fastEquals(data, otherData); }
|
ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { public boolean equals(Object other) { if (!(other instanceof ByteArrayWrapper)) { return false; } byte[] otherData = ((ByteArrayWrapper) other).data; return ByteUtil.fastEquals(data, otherData); } }
|
ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { public boolean equals(Object other) { if (!(other instanceof ByteArrayWrapper)) { return false; } byte[] otherData = ((ByteArrayWrapper) other).data; return ByteUtil.fastEquals(data, otherData); } ByteArrayWrapper(byte[] data); }
|
ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { public boolean equals(Object other) { if (!(other instanceof ByteArrayWrapper)) { return false; } byte[] otherData = ((ByteArrayWrapper) other).data; return ByteUtil.fastEquals(data, otherData); } ByteArrayWrapper(byte[] data); boolean equals(Object other); @Override int hashCode(); @Override int compareTo(ByteArrayWrapper o); byte[] getData(); @Override String toString(); boolean equalsToByteArray(byte[] otherData); }
|
ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { public boolean equals(Object other) { if (!(other instanceof ByteArrayWrapper)) { return false; } byte[] otherData = ((ByteArrayWrapper) other).data; return ByteUtil.fastEquals(data, otherData); } ByteArrayWrapper(byte[] data); boolean equals(Object other); @Override int hashCode(); @Override int compareTo(ByteArrayWrapper o); byte[] getData(); @Override String toString(); boolean equalsToByteArray(byte[] otherData); }
|
@Test public void getBalanceWithAccountAndGenesisBlock() throws Exception { World world = new World(); Account acc1 = new AccountBuilder(world).name("acc1").balance(Coin.valueOf(10000)).build(); Web3Impl web3 = createWeb3(world); String accountAddress = ByteUtil.toHexString(acc1.getAddress().getBytes()); String balanceString = "0x" + ByteUtil.toHexString(BigInteger.valueOf(10000).toByteArray()); org.junit.Assert.assertEquals(balanceString, web3.eth_getBalance(accountAddress, "0x0")); }
|
@Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.asBigInteger()); }
|
Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.asBigInteger()); } }
|
Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.asBigInteger()); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); }
|
Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.asBigInteger()); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); }
|
Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.asBigInteger()); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); public Ethereum eth; }
|
@Test public void testCompareTo() { assertTrue(wrapper1.compareTo(wrapper2) == 0); assertTrue(wrapper1.compareTo(wrapper3) > 1); assertTrue(wrapper1.compareTo(wrapper4) > 1); assertTrue(wrapper2.compareTo(wrapper3) > 1); }
|
@Override public int compareTo(ByteArrayWrapper o) { return FastByteComparisons.compareTo( data, 0, data.length, o.data, 0, o.data.length); }
|
ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { @Override public int compareTo(ByteArrayWrapper o) { return FastByteComparisons.compareTo( data, 0, data.length, o.data, 0, o.data.length); } }
|
ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { @Override public int compareTo(ByteArrayWrapper o) { return FastByteComparisons.compareTo( data, 0, data.length, o.data, 0, o.data.length); } ByteArrayWrapper(byte[] data); }
|
ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { @Override public int compareTo(ByteArrayWrapper o) { return FastByteComparisons.compareTo( data, 0, data.length, o.data, 0, o.data.length); } ByteArrayWrapper(byte[] data); boolean equals(Object other); @Override int hashCode(); @Override int compareTo(ByteArrayWrapper o); byte[] getData(); @Override String toString(); boolean equalsToByteArray(byte[] otherData); }
|
ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { @Override public int compareTo(ByteArrayWrapper o) { return FastByteComparisons.compareTo( data, 0, data.length, o.data, 0, o.data.length); } ByteArrayWrapper(byte[] data); boolean equals(Object other); @Override int hashCode(); @Override int compareTo(ByteArrayWrapper o); byte[] getData(); @Override String toString(); boolean equalsToByteArray(byte[] otherData); }
|
@Test public void getUnknownKey() { ReceiptStore store = new ReceiptStoreImpl(new HashMapDB()); byte[] key = new byte[] { 0x01, 0x02 }; TransactionInfo result = store.get(key); Assert.assertNull(result); }
|
@Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); }
|
ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } }
|
ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } ReceiptStoreImpl(KeyValueDataSource receiptsDS); }
|
ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } ReceiptStoreImpl(KeyValueDataSource receiptsDS); @Override void add(byte[] blockHash, int transactionIndex, TransactionReceipt receipt); @Override TransactionInfo get(byte[] transactionHash); @Override Optional<TransactionInfo> get(Keccak256 transactionHash, Keccak256 blockHash); @Override TransactionInfo getInMainChain(byte[] transactionHash, BlockStore store); @Override List<TransactionInfo> getAll(byte[] transactionHash); @Override void saveMultiple(byte[] blockHash, List<TransactionReceipt> receipts); @Override void flush(); }
|
ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } ReceiptStoreImpl(KeyValueDataSource receiptsDS); @Override void add(byte[] blockHash, int transactionIndex, TransactionReceipt receipt); @Override TransactionInfo get(byte[] transactionHash); @Override Optional<TransactionInfo> get(Keccak256 transactionHash, Keccak256 blockHash); @Override TransactionInfo getInMainChain(byte[] transactionHash, BlockStore store); @Override List<TransactionInfo> getAll(byte[] transactionHash); @Override void saveMultiple(byte[] blockHash, List<TransactionReceipt> receipts); @Override void flush(); }
|
@Test public void getUnknownTransactionByBlock() { ReceiptStore store = new ReceiptStoreImpl(new HashMapDB()); TransactionReceipt receipt = createReceipt(); Keccak256 blockHash = TestUtils.randomHash(); Optional<TransactionInfo> resultOpt = store.get(receipt.getTransaction().getHash(), blockHash); Assert.assertFalse(resultOpt.isPresent()); }
|
@Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); }
|
ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } }
|
ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } ReceiptStoreImpl(KeyValueDataSource receiptsDS); }
|
ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } ReceiptStoreImpl(KeyValueDataSource receiptsDS); @Override void add(byte[] blockHash, int transactionIndex, TransactionReceipt receipt); @Override TransactionInfo get(byte[] transactionHash); @Override Optional<TransactionInfo> get(Keccak256 transactionHash, Keccak256 blockHash); @Override TransactionInfo getInMainChain(byte[] transactionHash, BlockStore store); @Override List<TransactionInfo> getAll(byte[] transactionHash); @Override void saveMultiple(byte[] blockHash, List<TransactionReceipt> receipts); @Override void flush(); }
|
ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } ReceiptStoreImpl(KeyValueDataSource receiptsDS); @Override void add(byte[] blockHash, int transactionIndex, TransactionReceipt receipt); @Override TransactionInfo get(byte[] transactionHash); @Override Optional<TransactionInfo> get(Keccak256 transactionHash, Keccak256 blockHash); @Override TransactionInfo getInMainChain(byte[] transactionHash, BlockStore store); @Override List<TransactionInfo> getAll(byte[] transactionHash); @Override void saveMultiple(byte[] blockHash, List<TransactionReceipt> receipts); @Override void flush(); }
|
@Test public void rewind() { IndexedBlockStore indexedBlockStore = new IndexedBlockStore( mock(BlockFactory.class), mock(KeyValueDataSource.class), new HashMapBlocksIndex()); long blocksToGenerate = 14; for (long i = 0; i < blocksToGenerate; i++) { Block block = mock(Block.class); Keccak256 blockHash = randomHash(); when(block.getHash()).thenReturn(blockHash); when(block.getNumber()).thenReturn(i); indexedBlockStore.saveBlock(block, ZERO, true); } Block bestBlock = indexedBlockStore.getBestBlock(); assertThat(bestBlock.getNumber(), is(blocksToGenerate - 1)); long blockToRewind = blocksToGenerate / 2; indexedBlockStore.rewind(blockToRewind); bestBlock = indexedBlockStore.getBestBlock(); assertThat(bestBlock.getNumber(), is(blockToRewind)); }
|
public void rewind(long blockNumber) { if (index.isEmpty()) { return; } long maxNumber = getMaxNumber(); for (long i = maxNumber; i > blockNumber; i--) { List<BlockInfo> blockInfos = index.removeLast(); for (BlockInfo blockInfo : blockInfos) { this.blocks.delete(blockInfo.getHash().getBytes()); } } flush(); }
|
IndexedBlockStore implements BlockStore { public void rewind(long blockNumber) { if (index.isEmpty()) { return; } long maxNumber = getMaxNumber(); for (long i = maxNumber; i > blockNumber; i--) { List<BlockInfo> blockInfos = index.removeLast(); for (BlockInfo blockInfo : blockInfos) { this.blocks.delete(blockInfo.getHash().getBytes()); } } flush(); } }
|
IndexedBlockStore implements BlockStore { public void rewind(long blockNumber) { if (index.isEmpty()) { return; } long maxNumber = getMaxNumber(); for (long i = maxNumber; i > blockNumber; i--) { List<BlockInfo> blockInfos = index.removeLast(); for (BlockInfo blockInfo : blockInfos) { this.blocks.delete(blockInfo.getHash().getBytes()); } } flush(); } IndexedBlockStore(
BlockFactory blockFactory,
KeyValueDataSource blocks,
BlocksIndex index); }
|
IndexedBlockStore implements BlockStore { public void rewind(long blockNumber) { if (index.isEmpty()) { return; } long maxNumber = getMaxNumber(); for (long i = maxNumber; i > blockNumber; i--) { List<BlockInfo> blockInfos = index.removeLast(); for (BlockInfo blockInfo : blockInfos) { this.blocks.delete(blockInfo.getHash().getBytes()); } } flush(); } IndexedBlockStore(
BlockFactory blockFactory,
KeyValueDataSource blocks,
BlocksIndex index); @Override synchronized void removeBlock(Block block); @Override synchronized Block getBestBlock(); @Override byte[] getBlockHashByNumber(long blockNumber, byte[] branchBlockHash); @Override // This method is an optimized way to traverse a branch in search for a block at a given depth. Starting at a given // block (by hash) it tries to find the first block that is part of the best chain, when it finds one we now that // we can jump to the block that is at the remaining depth. If not block is found then it continues traversing the // branch from parent to parent. The search is limited by the maximum depth received as parameter. // This method either needs to traverse the parent chain or if a block in the parent chain is part of the best chain // then it can skip the traversal by going directly to the block at the remaining depth. Block getBlockAtDepthStartingAt(long depth, byte[] hash); boolean isBlockInMainChain(long blockNumber, Keccak256 blockHash); @Override synchronized void flush(); void close(); @Override synchronized void saveBlock(Block block, BlockDifficulty cummDifficulty, boolean mainChain); @Override synchronized List<BlockInformation> getBlocksInformationByNumber(long number); @Override boolean isEmpty(); @Override synchronized Block getChainBlockByNumber(long number); @Override synchronized Block getBlockByHash(byte[] hash); @Override synchronized Map<Long, List<Sibling>> getSiblingsFromBlockByHash(Keccak256 hash); @Override synchronized boolean isBlockExist(byte[] hash); @Override synchronized BlockDifficulty getTotalDifficultyForHash(byte[] hash); @Override long getMaxNumber(); @Override long getMinNumber(); @Override synchronized List<byte[]> getListHashesEndWith(byte[] hash, long number); @Override synchronized void reBranch(Block forkBlock); @VisibleForTesting synchronized List<byte[]> getListHashesStartWith(long number, long maxBlocks); @Override synchronized List<Block> getChainBlocksByNumber(long number); void rewind(long blockNumber); }
|
IndexedBlockStore implements BlockStore { public void rewind(long blockNumber) { if (index.isEmpty()) { return; } long maxNumber = getMaxNumber(); for (long i = maxNumber; i > blockNumber; i--) { List<BlockInfo> blockInfos = index.removeLast(); for (BlockInfo blockInfo : blockInfos) { this.blocks.delete(blockInfo.getHash().getBytes()); } } flush(); } IndexedBlockStore(
BlockFactory blockFactory,
KeyValueDataSource blocks,
BlocksIndex index); @Override synchronized void removeBlock(Block block); @Override synchronized Block getBestBlock(); @Override byte[] getBlockHashByNumber(long blockNumber, byte[] branchBlockHash); @Override // This method is an optimized way to traverse a branch in search for a block at a given depth. Starting at a given // block (by hash) it tries to find the first block that is part of the best chain, when it finds one we now that // we can jump to the block that is at the remaining depth. If not block is found then it continues traversing the // branch from parent to parent. The search is limited by the maximum depth received as parameter. // This method either needs to traverse the parent chain or if a block in the parent chain is part of the best chain // then it can skip the traversal by going directly to the block at the remaining depth. Block getBlockAtDepthStartingAt(long depth, byte[] hash); boolean isBlockInMainChain(long blockNumber, Keccak256 blockHash); @Override synchronized void flush(); void close(); @Override synchronized void saveBlock(Block block, BlockDifficulty cummDifficulty, boolean mainChain); @Override synchronized List<BlockInformation> getBlocksInformationByNumber(long number); @Override boolean isEmpty(); @Override synchronized Block getChainBlockByNumber(long number); @Override synchronized Block getBlockByHash(byte[] hash); @Override synchronized Map<Long, List<Sibling>> getSiblingsFromBlockByHash(Keccak256 hash); @Override synchronized boolean isBlockExist(byte[] hash); @Override synchronized BlockDifficulty getTotalDifficultyForHash(byte[] hash); @Override long getMaxNumber(); @Override long getMinNumber(); @Override synchronized List<byte[]> getListHashesEndWith(byte[] hash, long number); @Override synchronized void reBranch(Block forkBlock); @VisibleForTesting synchronized List<byte[]> getListHashesStartWith(long number, long maxBlocks); @Override synchronized List<Block> getChainBlocksByNumber(long number); void rewind(long blockNumber); static final Serializer<List<BlockInfo>> BLOCK_INFO_SERIALIZER; }
|
@Test public void devnetWithFederationTest() { Constants constants = Constants.devnetWithFederation(TEST_FED_KEYS.subList(0, 3)); assertThat(constants.getBridgeConstants().getGenesisFederation().hasBtcPublicKey(TEST_FED_KEYS.get(0)), is(true)); assertThat(constants.getBridgeConstants().getGenesisFederation().hasBtcPublicKey(TEST_FED_KEYS.get(1)), is(true)); assertThat(constants.getBridgeConstants().getGenesisFederation().hasBtcPublicKey(TEST_FED_KEYS.get(2)), is(true)); assertThat(constants.getBridgeConstants().getGenesisFederation().hasBtcPublicKey(TEST_FED_KEYS.get(3)), is(false)); }
|
public static Constants devnetWithFederation(List<BtcECKey> federationPublicKeys) { return new Constants( DEVNET_CHAIN_ID, false, 14, new BlockDifficulty(BigInteger.valueOf(131072)), new BlockDifficulty(BigInteger.valueOf((long) 14E15)), BigInteger.valueOf(50), 540, new BridgeDevNetConstants(federationPublicKeys) ); }
|
Constants { public static Constants devnetWithFederation(List<BtcECKey> federationPublicKeys) { return new Constants( DEVNET_CHAIN_ID, false, 14, new BlockDifficulty(BigInteger.valueOf(131072)), new BlockDifficulty(BigInteger.valueOf((long) 14E15)), BigInteger.valueOf(50), 540, new BridgeDevNetConstants(federationPublicKeys) ); } }
|
Constants { public static Constants devnetWithFederation(List<BtcECKey> federationPublicKeys) { return new Constants( DEVNET_CHAIN_ID, false, 14, new BlockDifficulty(BigInteger.valueOf(131072)), new BlockDifficulty(BigInteger.valueOf((long) 14E15)), BigInteger.valueOf(50), 540, new BridgeDevNetConstants(federationPublicKeys) ); } Constants(
byte chainId,
boolean seedCowAccounts,
int durationLimit,
BlockDifficulty minimumDifficulty,
BlockDifficulty fallbackMiningDifficulty,
BigInteger difficultyBoundDivisor,
int newBlockMaxSecondsInTheFuture,
BridgeConstants bridgeConstants); }
|
Constants { public static Constants devnetWithFederation(List<BtcECKey> federationPublicKeys) { return new Constants( DEVNET_CHAIN_ID, false, 14, new BlockDifficulty(BigInteger.valueOf(131072)), new BlockDifficulty(BigInteger.valueOf((long) 14E15)), BigInteger.valueOf(50), 540, new BridgeDevNetConstants(federationPublicKeys) ); } Constants(
byte chainId,
boolean seedCowAccounts,
int durationLimit,
BlockDifficulty minimumDifficulty,
BlockDifficulty fallbackMiningDifficulty,
BigInteger difficultyBoundDivisor,
int newBlockMaxSecondsInTheFuture,
BridgeConstants bridgeConstants); boolean seedCowAccounts(); int getDurationLimit(); BlockDifficulty getMinimumDifficulty(); BlockDifficulty getFallbackMiningDifficulty(); BigInteger getDifficultyBoundDivisor(ActivationConfig.ForBlock activationConfig); byte getChainId(); int getNewBlockMaxSecondsInTheFuture(); BridgeConstants getBridgeConstants(); BigInteger getInitialNonce(); byte[] getFallbackMiningPubKey0(); byte[] getFallbackMiningPubKey1(); int getMaximumExtraDataSize(); int getMinGasLimit(); int getGasLimitBoundDivisor(); int getExpDifficultyPeriod(); int getUncleGenerationLimit(); int getUncleListLimit(); int getBestNumberDiffLimit(); BigInteger getMinimumPayableGas(); BigInteger getFederatorMinimumPayableGas(); static BigInteger getSECP256K1N(); static BigInteger getTransactionGasCap(); static int getMaxContractSize(); static int getMaxAddressByteLength(); static Constants mainnet(); static Constants devnetWithFederation(List<BtcECKey> federationPublicKeys); static Constants testnet(); static Constants regtest(); static Constants regtestWithFederation(List<BtcECKey> genesisFederationPublicKeys); }
|
Constants { public static Constants devnetWithFederation(List<BtcECKey> federationPublicKeys) { return new Constants( DEVNET_CHAIN_ID, false, 14, new BlockDifficulty(BigInteger.valueOf(131072)), new BlockDifficulty(BigInteger.valueOf((long) 14E15)), BigInteger.valueOf(50), 540, new BridgeDevNetConstants(federationPublicKeys) ); } Constants(
byte chainId,
boolean seedCowAccounts,
int durationLimit,
BlockDifficulty minimumDifficulty,
BlockDifficulty fallbackMiningDifficulty,
BigInteger difficultyBoundDivisor,
int newBlockMaxSecondsInTheFuture,
BridgeConstants bridgeConstants); boolean seedCowAccounts(); int getDurationLimit(); BlockDifficulty getMinimumDifficulty(); BlockDifficulty getFallbackMiningDifficulty(); BigInteger getDifficultyBoundDivisor(ActivationConfig.ForBlock activationConfig); byte getChainId(); int getNewBlockMaxSecondsInTheFuture(); BridgeConstants getBridgeConstants(); BigInteger getInitialNonce(); byte[] getFallbackMiningPubKey0(); byte[] getFallbackMiningPubKey1(); int getMaximumExtraDataSize(); int getMinGasLimit(); int getGasLimitBoundDivisor(); int getExpDifficultyPeriod(); int getUncleGenerationLimit(); int getUncleListLimit(); int getBestNumberDiffLimit(); BigInteger getMinimumPayableGas(); BigInteger getFederatorMinimumPayableGas(); static BigInteger getSECP256K1N(); static BigInteger getTransactionGasCap(); static int getMaxContractSize(); static int getMaxAddressByteLength(); static Constants mainnet(); static Constants devnetWithFederation(List<BtcECKey> federationPublicKeys); static Constants testnet(); static Constants regtest(); static Constants regtestWithFederation(List<BtcECKey> genesisFederationPublicKeys); static final byte MAINNET_CHAIN_ID; static final byte TESTNET_CHAIN_ID; static final byte DEVNET_CHAIN_ID; static final byte REGTEST_CHAIN_ID; final BridgeConstants bridgeConstants; }
|
@Test(expected = IllegalArgumentException.class) public void failsReadingWithMissingNetworkUpgrade() { ActivationConfig.read(BASE_CONFIG .withoutPath("consensusRules.rskip85") ); }
|
public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); }
|
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); } }
|
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); } ActivationConfig(Map<ConsensusRule, Long> activationHeights); }
|
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); } ActivationConfig(Map<ConsensusRule, Long> activationHeights); boolean isActive(ConsensusRule consensusRule, long blockNumber); ForBlock forBlock(long blockNumber); static ActivationConfig read(Config config); }
|
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); } ActivationConfig(Map<ConsensusRule, Long> activationHeights); boolean isActive(ConsensusRule consensusRule, long blockNumber); ForBlock forBlock(long blockNumber); static ActivationConfig read(Config config); }
|
@Test(expected = IllegalArgumentException.class) public void failsReadingWithMissingHardFork() { ActivationConfig.read(BASE_CONFIG .withoutPath("hardforkActivationHeights.orchid") ); }
|
public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); }
|
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); } }
|
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); } ActivationConfig(Map<ConsensusRule, Long> activationHeights); }
|
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); } ActivationConfig(Map<ConsensusRule, Long> activationHeights); boolean isActive(ConsensusRule consensusRule, long blockNumber); ForBlock forBlock(long blockNumber); static ActivationConfig read(Config config); }
|
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); } ActivationConfig(Map<ConsensusRule, Long> activationHeights); boolean isActive(ConsensusRule consensusRule, long blockNumber); ForBlock forBlock(long blockNumber); static ActivationConfig read(Config config); }
|
@Test(expected = IllegalArgumentException.class) public void failsReadingWithUnknownForkConfiguration() { ActivationConfig.read(BASE_CONFIG .withValue("hardforkActivationHeights.orkid", ConfigValueFactory.fromAnyRef(200)) ); }
|
public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); }
|
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); } }
|
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); } ActivationConfig(Map<ConsensusRule, Long> activationHeights); }
|
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); } ActivationConfig(Map<ConsensusRule, Long> activationHeights); boolean isActive(ConsensusRule consensusRule, long blockNumber); ForBlock forBlock(long blockNumber); static ActivationConfig read(Config config); }
|
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); } ActivationConfig(Map<ConsensusRule, Long> activationHeights); boolean isActive(ConsensusRule consensusRule, long blockNumber); ForBlock forBlock(long blockNumber); static ActivationConfig read(Config config); }
|
@Test(expected = IllegalArgumentException.class) public void failsReadingWithUnknownUpgradeConfiguration() { ActivationConfig.read(BASE_CONFIG .withValue("consensusRules.rskip420", ConfigValueFactory.fromAnyRef("orchid")) ); }
|
public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); }
|
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); } }
|
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); } ActivationConfig(Map<ConsensusRule, Long> activationHeights); }
|
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); } ActivationConfig(Map<ConsensusRule, Long> activationHeights); boolean isActive(ConsensusRule consensusRule, long blockNumber); ForBlock forBlock(long blockNumber); static ActivationConfig read(Config config); }
|
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = NetworkUpgrade.named(e.getKey()); long activationHeight = networkUpgradesConfig.getLong(networkUpgrade.getName()); networkUpgrades.put(networkUpgrade, activationHeight); } Map<ConsensusRule, Long> activationHeights = new EnumMap<>(ConsensusRule.class); Config consensusRulesConfig = config.getConfig(PROPERTY_CONSENSUS_RULES); for (Map.Entry<String, ConfigValue> e : consensusRulesConfig.entrySet()) { ConsensusRule consensusRule = ConsensusRule.fromConfigKey(e.getKey()); long activationHeight = parseActivationHeight(networkUpgrades, consensusRulesConfig, consensusRule); activationHeights.put(consensusRule, activationHeight); } return new ActivationConfig(activationHeights); } ActivationConfig(Map<ConsensusRule, Long> activationHeights); boolean isActive(ConsensusRule consensusRule, long blockNumber); ForBlock forBlock(long blockNumber); static ActivationConfig read(Config config); }
|
@Test public void testCreateAuthInitiate() throws Exception { AuthInitiateMessage message = initiator.createAuthInitiate(new byte[32], myKey); int expectedLength = 65+32+64+32+1; byte[] buffer = message.encode(); assertEquals(expectedLength, buffer.length); }
|
public AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key) { AuthInitiateMessage message = new AuthInitiateMessage(); boolean isToken; if (token == null) { isToken = false; BigInteger secretScalar = remotePublicKey.multiply(key.getPrivKey()).normalize().getXCoord().toBigInteger(); token = ByteUtil.bigIntegerToBytes(secretScalar, NONCE_SIZE); } else { isToken = true; } byte[] nonce = initiatorNonce; byte[] signed = xor(token, nonce); message.setSignature(ECDSASignature.fromSignature(ephemeralKey.sign(signed))); message.isTokenUsed = isToken; message.ephemeralPublicHash = keccak256(ephemeralKey.getPubKeyPoint().getEncoded(false), 1, 64); message.publicKey = key.getPubKeyPoint(); message.nonce = initiatorNonce; return message; }
|
EncryptionHandshake { public AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key) { AuthInitiateMessage message = new AuthInitiateMessage(); boolean isToken; if (token == null) { isToken = false; BigInteger secretScalar = remotePublicKey.multiply(key.getPrivKey()).normalize().getXCoord().toBigInteger(); token = ByteUtil.bigIntegerToBytes(secretScalar, NONCE_SIZE); } else { isToken = true; } byte[] nonce = initiatorNonce; byte[] signed = xor(token, nonce); message.setSignature(ECDSASignature.fromSignature(ephemeralKey.sign(signed))); message.isTokenUsed = isToken; message.ephemeralPublicHash = keccak256(ephemeralKey.getPubKeyPoint().getEncoded(false), 1, 64); message.publicKey = key.getPubKeyPoint(); message.nonce = initiatorNonce; return message; } }
|
EncryptionHandshake { public AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key) { AuthInitiateMessage message = new AuthInitiateMessage(); boolean isToken; if (token == null) { isToken = false; BigInteger secretScalar = remotePublicKey.multiply(key.getPrivKey()).normalize().getXCoord().toBigInteger(); token = ByteUtil.bigIntegerToBytes(secretScalar, NONCE_SIZE); } else { isToken = true; } byte[] nonce = initiatorNonce; byte[] signed = xor(token, nonce); message.setSignature(ECDSASignature.fromSignature(ephemeralKey.sign(signed))); message.isTokenUsed = isToken; message.ephemeralPublicHash = keccak256(ephemeralKey.getPubKeyPoint().getEncoded(false), 1, 64); message.publicKey = key.getPubKeyPoint(); message.nonce = initiatorNonce; return message; } EncryptionHandshake(ECPoint remotePublicKey); EncryptionHandshake(ECPoint remotePublicKey, ECKey ephemeralKey, byte[] initiatorNonce, byte[] responderNonce, boolean isInitiator); EncryptionHandshake(); }
|
EncryptionHandshake { public AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key) { AuthInitiateMessage message = new AuthInitiateMessage(); boolean isToken; if (token == null) { isToken = false; BigInteger secretScalar = remotePublicKey.multiply(key.getPrivKey()).normalize().getXCoord().toBigInteger(); token = ByteUtil.bigIntegerToBytes(secretScalar, NONCE_SIZE); } else { isToken = true; } byte[] nonce = initiatorNonce; byte[] signed = xor(token, nonce); message.setSignature(ECDSASignature.fromSignature(ephemeralKey.sign(signed))); message.isTokenUsed = isToken; message.ephemeralPublicHash = keccak256(ephemeralKey.getPubKeyPoint().getEncoded(false), 1, 64); message.publicKey = key.getPubKeyPoint(); message.nonce = initiatorNonce; return message; } EncryptionHandshake(ECPoint remotePublicKey); EncryptionHandshake(ECPoint remotePublicKey, ECKey ephemeralKey, byte[] initiatorNonce, byte[] responderNonce, boolean isInitiator); EncryptionHandshake(); AuthInitiateMessageV4 createAuthInitiateV4(ECKey key); byte[] encryptAuthInitiateV4(AuthInitiateMessageV4 message); AuthInitiateMessageV4 decryptAuthInitiateV4(byte[] in, ECKey myKey); byte[] encryptAuthResponseV4(AuthResponseMessageV4 message); AuthResponseMessageV4 decryptAuthResponseV4(byte[] in, ECKey myKey); AuthResponseMessageV4 handleAuthResponseV4(ECKey myKey, byte[] initiatePacket, byte[] responsePacket); AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key); byte[] encryptAuthMessage(AuthInitiateMessage message); byte[] encryptAuthResponse(AuthResponseMessage message); AuthResponseMessage decryptAuthResponse(byte[] ciphertext, ECKey myKey); AuthInitiateMessage decryptAuthInitiate(byte[] ciphertext, ECKey myKey); AuthResponseMessage handleAuthResponse(ECKey myKey, byte[] initiatePacket, byte[] responsePacket); byte[] handleAuthInitiate(byte[] initiatePacket, ECKey key); static byte recIdFromSignatureV(int v); Secrets getSecrets(); ECPoint getRemotePublicKey(); boolean isInitiator(); }
|
EncryptionHandshake { public AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key) { AuthInitiateMessage message = new AuthInitiateMessage(); boolean isToken; if (token == null) { isToken = false; BigInteger secretScalar = remotePublicKey.multiply(key.getPrivKey()).normalize().getXCoord().toBigInteger(); token = ByteUtil.bigIntegerToBytes(secretScalar, NONCE_SIZE); } else { isToken = true; } byte[] nonce = initiatorNonce; byte[] signed = xor(token, nonce); message.setSignature(ECDSASignature.fromSignature(ephemeralKey.sign(signed))); message.isTokenUsed = isToken; message.ephemeralPublicHash = keccak256(ephemeralKey.getPubKeyPoint().getEncoded(false), 1, 64); message.publicKey = key.getPubKeyPoint(); message.nonce = initiatorNonce; return message; } EncryptionHandshake(ECPoint remotePublicKey); EncryptionHandshake(ECPoint remotePublicKey, ECKey ephemeralKey, byte[] initiatorNonce, byte[] responderNonce, boolean isInitiator); EncryptionHandshake(); AuthInitiateMessageV4 createAuthInitiateV4(ECKey key); byte[] encryptAuthInitiateV4(AuthInitiateMessageV4 message); AuthInitiateMessageV4 decryptAuthInitiateV4(byte[] in, ECKey myKey); byte[] encryptAuthResponseV4(AuthResponseMessageV4 message); AuthResponseMessageV4 decryptAuthResponseV4(byte[] in, ECKey myKey); AuthResponseMessageV4 handleAuthResponseV4(ECKey myKey, byte[] initiatePacket, byte[] responsePacket); AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key); byte[] encryptAuthMessage(AuthInitiateMessage message); byte[] encryptAuthResponse(AuthResponseMessage message); AuthResponseMessage decryptAuthResponse(byte[] ciphertext, ECKey myKey); AuthInitiateMessage decryptAuthInitiate(byte[] ciphertext, ECKey myKey); AuthResponseMessage handleAuthResponse(ECKey myKey, byte[] initiatePacket, byte[] responsePacket); byte[] handleAuthInitiate(byte[] initiatePacket, ECKey key); static byte recIdFromSignatureV(int v); Secrets getSecrets(); ECPoint getRemotePublicKey(); boolean isInitiator(); static final int NONCE_SIZE; static final int MAC_SIZE; static final int SECRET_SIZE; }
|
@Test public void getBalanceWithAccountAndBlock() throws Exception { World world = new World(); Account acc1 = new AccountBuilder(world).name("acc1").balance(Coin.valueOf(10000)).build(); Block genesis = world.getBlockByName("g00"); Block block1 = new BlockBuilder(null, null, null).parent(genesis).build(); world.getBlockChain().tryToConnect(block1); Web3Impl web3 = createWeb3(world); String accountAddress = ByteUtil.toHexString(acc1.getAddress().getBytes()); String balanceString = "0x" + ByteUtil.toHexString(BigInteger.valueOf(10000).toByteArray()); org.junit.Assert.assertEquals(balanceString, web3.eth_getBalance(accountAddress, "0x1")); }
|
@Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.asBigInteger()); }
|
Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.asBigInteger()); } }
|
Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.asBigInteger()); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); }
|
Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.asBigInteger()); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); }
|
Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.asBigInteger()); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); public Ethereum eth; }
|
@Test public void getGasPriceWhenValueIsEmpty() throws Exception { Web3.CallArguments args = new Web3.CallArguments(); args.gasPrice = ""; CallArgumentsToByteArray byteArrayArgs = new CallArgumentsToByteArray(args); Assert.assertArrayEquals(new byte[] {0}, byteArrayArgs.getGasPrice()); }
|
public byte[] getGasPrice() { byte[] gasPrice = new byte[] {0}; if (args.gasPrice != null && args.gasPrice.length() != 0) { gasPrice = stringHexToByteArray(args.gasPrice); } return gasPrice; }
|
CallArgumentsToByteArray { public byte[] getGasPrice() { byte[] gasPrice = new byte[] {0}; if (args.gasPrice != null && args.gasPrice.length() != 0) { gasPrice = stringHexToByteArray(args.gasPrice); } return gasPrice; } }
|
CallArgumentsToByteArray { public byte[] getGasPrice() { byte[] gasPrice = new byte[] {0}; if (args.gasPrice != null && args.gasPrice.length() != 0) { gasPrice = stringHexToByteArray(args.gasPrice); } return gasPrice; } CallArgumentsToByteArray(Web3.CallArguments args); }
|
CallArgumentsToByteArray { public byte[] getGasPrice() { byte[] gasPrice = new byte[] {0}; if (args.gasPrice != null && args.gasPrice.length() != 0) { gasPrice = stringHexToByteArray(args.gasPrice); } return gasPrice; } CallArgumentsToByteArray(Web3.CallArguments args); byte[] getGasPrice(); byte[] getGasLimit(); byte[] getToAddress(); byte[] getValue(); byte[] getData(); RskAddress getFromAddress(); }
|
CallArgumentsToByteArray { public byte[] getGasPrice() { byte[] gasPrice = new byte[] {0}; if (args.gasPrice != null && args.gasPrice.length() != 0) { gasPrice = stringHexToByteArray(args.gasPrice); } return gasPrice; } CallArgumentsToByteArray(Web3.CallArguments args); byte[] getGasPrice(); byte[] getGasLimit(); byte[] getToAddress(); byte[] getValue(); byte[] getData(); RskAddress getFromAddress(); }
|
@Test public void getAddress() { Node node = new Node(NODE_ID_1, GOOGLE, GOOGLE_PORT); Pattern pattern = Pattern.compile(IP_ADDRESS_PATTERN); String address = node.getAddress().getAddress().getHostAddress(); Matcher matcher = pattern.matcher(address); Assert.assertTrue(StringUtils.isNotBlank(address)); Assert.assertTrue(address, matcher.matches()); node = new Node(NODE_ID_1, NODE_HOST_1, NODE_PORT_1); address = node.getAddressAsString(); Assert.assertTrue(StringUtils.isNotBlank(address)); Assert.assertTrue(address.startsWith(NODE_HOST_1)); }
|
public InetSocketAddress getAddress() { return new InetSocketAddress(this.getHost(), this.getPort()); }
|
Node implements Serializable { public InetSocketAddress getAddress() { return new InetSocketAddress(this.getHost(), this.getPort()); } }
|
Node implements Serializable { public InetSocketAddress getAddress() { return new InetSocketAddress(this.getHost(), this.getPort()); } Node(String enodeURL); Node(byte[] id, String host, int port); Node(byte[] rlp); }
|
Node implements Serializable { public InetSocketAddress getAddress() { return new InetSocketAddress(this.getHost(), this.getPort()); } Node(String enodeURL); Node(byte[] id, String host, int port); Node(byte[] rlp); NodeID getId(); String getHexId(); String getHost(); int getPort(); byte[] getRLP(); InetSocketAddress getAddress(); String getAddressAsString(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object o); }
|
Node implements Serializable { public InetSocketAddress getAddress() { return new InetSocketAddress(this.getHost(), this.getPort()); } Node(String enodeURL); Node(byte[] id, String host, int port); Node(byte[] rlp); NodeID getId(); String getHexId(); String getHost(); int getPort(); byte[] getRLP(); InetSocketAddress getAddress(); String getAddressAsString(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object o); }
|
@Test public void getNodesPeerDiscoveryDisable() { List<Node> activePeers = new ArrayList<>(); activePeers.add(new Node(Hex.decode(NODE_ID_2), "127.0.0.2", 8081)); List<Node> bootNodes = new ArrayList<>(); bootNodes.add(new Node(Hex.decode(NODE_ID_3), "127.0.0.3", 8083)); Mockito.when(config.peerActive()).thenReturn(activePeers); Mockito.when(peerExplorer.getNodes()).thenReturn(bootNodes); Mockito.when(config.isPeerDiscoveryEnabled()).thenReturn(false); NodeManager nodeManager = new NodeManager(peerExplorer, config); Set<String> nodesInUse = new HashSet<>(); List<NodeHandler> availableNodes = nodeManager.getNodes(nodesInUse); Assert.assertEquals(1, availableNodes.size()); Assert.assertEquals(NODE_ID_2, availableNodes.get(0).getNode().getHexId()); nodesInUse.add(NODE_ID_2); availableNodes = nodeManager.getNodes(nodesInUse); Assert.assertEquals(0, availableNodes.size()); }
|
public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().filter(n -> !nodeHandlerMap.containsKey(n.getHexId())).forEach(this::createNodeHandler); } for(NodeHandler handler : this.nodeHandlerMap.values()) { if(!nodesInUse.contains(handler.getNode().getHexId())) { handlers.add(handler); } } return handlers; }
|
NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().filter(n -> !nodeHandlerMap.containsKey(n.getHexId())).forEach(this::createNodeHandler); } for(NodeHandler handler : this.nodeHandlerMap.values()) { if(!nodesInUse.contains(handler.getNode().getHexId())) { handlers.add(handler); } } return handlers; } }
|
NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().filter(n -> !nodeHandlerMap.containsKey(n.getHexId())).forEach(this::createNodeHandler); } for(NodeHandler handler : this.nodeHandlerMap.values()) { if(!nodesInUse.contains(handler.getNode().getHexId())) { handlers.add(handler); } } return handlers; } NodeManager(PeerExplorer peerExplorer, SystemProperties config); }
|
NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().filter(n -> !nodeHandlerMap.containsKey(n.getHexId())).forEach(this::createNodeHandler); } for(NodeHandler handler : this.nodeHandlerMap.values()) { if(!nodesInUse.contains(handler.getNode().getHexId())) { handlers.add(handler); } } return handlers; } NodeManager(PeerExplorer peerExplorer, SystemProperties config); NodeStatistics getNodeStatistics(Node n); synchronized List<NodeHandler> getNodes(Set<String> nodesInUse); }
|
NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().filter(n -> !nodeHandlerMap.containsKey(n.getHexId())).forEach(this::createNodeHandler); } for(NodeHandler handler : this.nodeHandlerMap.values()) { if(!nodesInUse.contains(handler.getNode().getHexId())) { handlers.add(handler); } } return handlers; } NodeManager(PeerExplorer peerExplorer, SystemProperties config); NodeStatistics getNodeStatistics(Node n); synchronized List<NodeHandler> getNodes(Set<String> nodesInUse); }
|
@Test public void getNodesPeerDiscoveryEnableNoPeersFound() { List<Node> activePeers = new ArrayList<>(); List<Node> bootNodes = new ArrayList<>(); Mockito.when(config.peerActive()).thenReturn(activePeers); Mockito.when(peerExplorer.getNodes()).thenReturn(bootNodes); Mockito.when(config.isPeerDiscoveryEnabled()).thenReturn(true); NodeManager nodeManager = new NodeManager(peerExplorer, config); Set<String> nodesInUse = new HashSet<>(); List<NodeHandler> availableNodes = nodeManager.getNodes(nodesInUse); Assert.assertEquals(0, availableNodes.size()); }
|
public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().filter(n -> !nodeHandlerMap.containsKey(n.getHexId())).forEach(this::createNodeHandler); } for(NodeHandler handler : this.nodeHandlerMap.values()) { if(!nodesInUse.contains(handler.getNode().getHexId())) { handlers.add(handler); } } return handlers; }
|
NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().filter(n -> !nodeHandlerMap.containsKey(n.getHexId())).forEach(this::createNodeHandler); } for(NodeHandler handler : this.nodeHandlerMap.values()) { if(!nodesInUse.contains(handler.getNode().getHexId())) { handlers.add(handler); } } return handlers; } }
|
NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().filter(n -> !nodeHandlerMap.containsKey(n.getHexId())).forEach(this::createNodeHandler); } for(NodeHandler handler : this.nodeHandlerMap.values()) { if(!nodesInUse.contains(handler.getNode().getHexId())) { handlers.add(handler); } } return handlers; } NodeManager(PeerExplorer peerExplorer, SystemProperties config); }
|
NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().filter(n -> !nodeHandlerMap.containsKey(n.getHexId())).forEach(this::createNodeHandler); } for(NodeHandler handler : this.nodeHandlerMap.values()) { if(!nodesInUse.contains(handler.getNode().getHexId())) { handlers.add(handler); } } return handlers; } NodeManager(PeerExplorer peerExplorer, SystemProperties config); NodeStatistics getNodeStatistics(Node n); synchronized List<NodeHandler> getNodes(Set<String> nodesInUse); }
|
NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().filter(n -> !nodeHandlerMap.containsKey(n.getHexId())).forEach(this::createNodeHandler); } for(NodeHandler handler : this.nodeHandlerMap.values()) { if(!nodesInUse.contains(handler.getNode().getHexId())) { handlers.add(handler); } } return handlers; } NodeManager(PeerExplorer peerExplorer, SystemProperties config); NodeStatistics getNodeStatistics(Node n); synchronized List<NodeHandler> getNodes(Set<String> nodesInUse); }
|
@Test public void getNodesPeerDiscoveryEnable() { List<Node> activePeers = new ArrayList<>(); activePeers.add(new Node(Hex.decode(NODE_ID_2), "127.0.0.2", 8081)); List<Node> bootNodes = new ArrayList<>(); bootNodes.add(new Node(Hex.decode(NODE_ID_3), "127.0.0.3", 8083)); Mockito.when(config.peerActive()).thenReturn(activePeers); Mockito.when(peerExplorer.getNodes()).thenReturn(bootNodes); Mockito.when(config.isPeerDiscoveryEnabled()).thenReturn(true); NodeManager nodeManager = new NodeManager(peerExplorer, config); Set<String> nodesInUse = new HashSet<>(); List<NodeHandler> availableNodes = nodeManager.getNodes(nodesInUse); Assert.assertEquals(2, availableNodes.size()); }
|
public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().filter(n -> !nodeHandlerMap.containsKey(n.getHexId())).forEach(this::createNodeHandler); } for(NodeHandler handler : this.nodeHandlerMap.values()) { if(!nodesInUse.contains(handler.getNode().getHexId())) { handlers.add(handler); } } return handlers; }
|
NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().filter(n -> !nodeHandlerMap.containsKey(n.getHexId())).forEach(this::createNodeHandler); } for(NodeHandler handler : this.nodeHandlerMap.values()) { if(!nodesInUse.contains(handler.getNode().getHexId())) { handlers.add(handler); } } return handlers; } }
|
NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().filter(n -> !nodeHandlerMap.containsKey(n.getHexId())).forEach(this::createNodeHandler); } for(NodeHandler handler : this.nodeHandlerMap.values()) { if(!nodesInUse.contains(handler.getNode().getHexId())) { handlers.add(handler); } } return handlers; } NodeManager(PeerExplorer peerExplorer, SystemProperties config); }
|
NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().filter(n -> !nodeHandlerMap.containsKey(n.getHexId())).forEach(this::createNodeHandler); } for(NodeHandler handler : this.nodeHandlerMap.values()) { if(!nodesInUse.contains(handler.getNode().getHexId())) { handlers.add(handler); } } return handlers; } NodeManager(PeerExplorer peerExplorer, SystemProperties config); NodeStatistics getNodeStatistics(Node n); synchronized List<NodeHandler> getNodes(Set<String> nodesInUse); }
|
NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().filter(n -> !nodeHandlerMap.containsKey(n.getHexId())).forEach(this::createNodeHandler); } for(NodeHandler handler : this.nodeHandlerMap.values()) { if(!nodesInUse.contains(handler.getNode().getHexId())) { handlers.add(handler); } } return handlers; } NodeManager(PeerExplorer peerExplorer, SystemProperties config); NodeStatistics getNodeStatistics(Node n); synchronized List<NodeHandler> getNodes(Set<String> nodesInUse); }
|
@Test public void purgeNodesTest() { Random random = new Random(); Mockito.when(config.isPeerDiscoveryEnabled()).thenReturn(true); NodeManager nodeManager = new NodeManager(peerExplorer, config); Set<String> keys = new HashSet<>(); for (int i = 0; i <= NodeManager.NODES_TRIM_THRESHOLD+1;i++) { byte[] nodeId = new byte[32]; random.nextBytes(nodeId); Node node = new Node(nodeId, "127.0.0.1", 8080); keys.add(node.getHexId()); nodeManager.getNodeStatistics(node); } Map<String, NodeHandler> nodeHandlerMap = Whitebox.getInternalState(nodeManager, "nodeHandlerMap"); Assert.assertTrue(nodeHandlerMap.size() <= NodeManager.NODES_TRIM_THRESHOLD); }
|
public NodeStatistics getNodeStatistics(Node n) { return discoveryEnabled ? getNodeHandler(n).getNodeStatistics() : DUMMY_STAT; }
|
NodeManager { public NodeStatistics getNodeStatistics(Node n) { return discoveryEnabled ? getNodeHandler(n).getNodeStatistics() : DUMMY_STAT; } }
|
NodeManager { public NodeStatistics getNodeStatistics(Node n) { return discoveryEnabled ? getNodeHandler(n).getNodeStatistics() : DUMMY_STAT; } NodeManager(PeerExplorer peerExplorer, SystemProperties config); }
|
NodeManager { public NodeStatistics getNodeStatistics(Node n) { return discoveryEnabled ? getNodeHandler(n).getNodeStatistics() : DUMMY_STAT; } NodeManager(PeerExplorer peerExplorer, SystemProperties config); NodeStatistics getNodeStatistics(Node n); synchronized List<NodeHandler> getNodes(Set<String> nodesInUse); }
|
NodeManager { public NodeStatistics getNodeStatistics(Node n) { return discoveryEnabled ? getNodeHandler(n).getNodeStatistics() : DUMMY_STAT; } NodeManager(PeerExplorer peerExplorer, SystemProperties config); NodeStatistics getNodeStatistics(Node n); synchronized List<NodeHandler> getNodes(Set<String> nodesInUse); }
|
@Test public void equals_true() { InetSocketAddress inetSocketAddress = mock(InetSocketAddress.class); Channel otherChannel = new Channel( messageQueue, messageCodec, nodeManager, rskWireProtocolFactory, eth62MessageFactory, staticMessages, remoteId); target.setInetSocketAddress(inetSocketAddress); otherChannel.setInetSocketAddress(inetSocketAddress); assertEquals(target, otherChannel); }
|
public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; }
|
Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } }
|
Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } Channel(MessageQueue msgQueue,
MessageCodec messageCodec,
NodeManager nodeManager,
RskWireProtocol.Factory rskWireProtocolFactory,
Eth62MessageFactory eth62MessageFactory,
StaticMessages staticMessages,
String remoteId); }
|
Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } Channel(MessageQueue msgQueue,
MessageCodec messageCodec,
NodeManager nodeManager,
RskWireProtocol.Factory rskWireProtocolFactory,
Eth62MessageFactory eth62MessageFactory,
StaticMessages staticMessages,
String remoteId); void sendHelloMessage(ChannelHandlerContext ctx, FrameCodec frameCodec, String nodeId,
HelloMessage inboundHelloMessage); void activateEth(ChannelHandlerContext ctx, EthVersion version); void setInetSocketAddress(InetSocketAddress inetSocketAddress); NodeStatistics getNodeStatistics(); void setNode(byte[] nodeId); Node getNode(); void initMessageCodes(List<Capability> caps); boolean isProtocolsInitialized(); boolean isUsingNewProtocol(); void onDisconnect(); String getPeerId(); boolean isActive(); NodeID getNodeId(); void disconnect(ReasonCode reason); InetSocketAddress getInetSocketAddress(); PeerStatistics getPeerStats(); boolean hasEthStatusSucceeded(); BigInteger getTotalDifficulty(); SyncStatistics getSyncStats(); void dropConnection(); void sendMessage(Message message); @Override NodeID getPeerNodeID(); @Override InetAddress getAddress(); Stats getStats(); @Override boolean equals(Object o); @Override int hashCode(); @Override double score(long currentTime, MessageType type); @Override void imported(boolean best); @Override String toString(); }
|
Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } Channel(MessageQueue msgQueue,
MessageCodec messageCodec,
NodeManager nodeManager,
RskWireProtocol.Factory rskWireProtocolFactory,
Eth62MessageFactory eth62MessageFactory,
StaticMessages staticMessages,
String remoteId); void sendHelloMessage(ChannelHandlerContext ctx, FrameCodec frameCodec, String nodeId,
HelloMessage inboundHelloMessage); void activateEth(ChannelHandlerContext ctx, EthVersion version); void setInetSocketAddress(InetSocketAddress inetSocketAddress); NodeStatistics getNodeStatistics(); void setNode(byte[] nodeId); Node getNode(); void initMessageCodes(List<Capability> caps); boolean isProtocolsInitialized(); boolean isUsingNewProtocol(); void onDisconnect(); String getPeerId(); boolean isActive(); NodeID getNodeId(); void disconnect(ReasonCode reason); InetSocketAddress getInetSocketAddress(); PeerStatistics getPeerStats(); boolean hasEthStatusSucceeded(); BigInteger getTotalDifficulty(); SyncStatistics getSyncStats(); void dropConnection(); void sendMessage(Message message); @Override NodeID getPeerNodeID(); @Override InetAddress getAddress(); Stats getStats(); @Override boolean equals(Object o); @Override int hashCode(); @Override double score(long currentTime, MessageType type); @Override void imported(boolean best); @Override String toString(); }
|
@Test public void equals_false() { InetSocketAddress inetSocketAddress = mock(InetSocketAddress.class); Channel otherChannel = new Channel( messageQueue, messageCodec, nodeManager, rskWireProtocolFactory, eth62MessageFactory, staticMessages, remoteId); target.setInetSocketAddress(inetSocketAddress); assertNotEquals(target, otherChannel); }
|
public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; }
|
Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } }
|
Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } Channel(MessageQueue msgQueue,
MessageCodec messageCodec,
NodeManager nodeManager,
RskWireProtocol.Factory rskWireProtocolFactory,
Eth62MessageFactory eth62MessageFactory,
StaticMessages staticMessages,
String remoteId); }
|
Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } Channel(MessageQueue msgQueue,
MessageCodec messageCodec,
NodeManager nodeManager,
RskWireProtocol.Factory rskWireProtocolFactory,
Eth62MessageFactory eth62MessageFactory,
StaticMessages staticMessages,
String remoteId); void sendHelloMessage(ChannelHandlerContext ctx, FrameCodec frameCodec, String nodeId,
HelloMessage inboundHelloMessage); void activateEth(ChannelHandlerContext ctx, EthVersion version); void setInetSocketAddress(InetSocketAddress inetSocketAddress); NodeStatistics getNodeStatistics(); void setNode(byte[] nodeId); Node getNode(); void initMessageCodes(List<Capability> caps); boolean isProtocolsInitialized(); boolean isUsingNewProtocol(); void onDisconnect(); String getPeerId(); boolean isActive(); NodeID getNodeId(); void disconnect(ReasonCode reason); InetSocketAddress getInetSocketAddress(); PeerStatistics getPeerStats(); boolean hasEthStatusSucceeded(); BigInteger getTotalDifficulty(); SyncStatistics getSyncStats(); void dropConnection(); void sendMessage(Message message); @Override NodeID getPeerNodeID(); @Override InetAddress getAddress(); Stats getStats(); @Override boolean equals(Object o); @Override int hashCode(); @Override double score(long currentTime, MessageType type); @Override void imported(boolean best); @Override String toString(); }
|
Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } Channel(MessageQueue msgQueue,
MessageCodec messageCodec,
NodeManager nodeManager,
RskWireProtocol.Factory rskWireProtocolFactory,
Eth62MessageFactory eth62MessageFactory,
StaticMessages staticMessages,
String remoteId); void sendHelloMessage(ChannelHandlerContext ctx, FrameCodec frameCodec, String nodeId,
HelloMessage inboundHelloMessage); void activateEth(ChannelHandlerContext ctx, EthVersion version); void setInetSocketAddress(InetSocketAddress inetSocketAddress); NodeStatistics getNodeStatistics(); void setNode(byte[] nodeId); Node getNode(); void initMessageCodes(List<Capability> caps); boolean isProtocolsInitialized(); boolean isUsingNewProtocol(); void onDisconnect(); String getPeerId(); boolean isActive(); NodeID getNodeId(); void disconnect(ReasonCode reason); InetSocketAddress getInetSocketAddress(); PeerStatistics getPeerStats(); boolean hasEthStatusSucceeded(); BigInteger getTotalDifficulty(); SyncStatistics getSyncStats(); void dropConnection(); void sendMessage(Message message); @Override NodeID getPeerNodeID(); @Override InetAddress getAddress(); Stats getStats(); @Override boolean equals(Object o); @Override int hashCode(); @Override double score(long currentTime, MessageType type); @Override void imported(boolean best); @Override String toString(); }
|
@Test public void getNumberOfPeersToSendStatusTo() { ChannelManagerImpl channelManagerImpl = new ChannelManagerImpl(new TestSystemProperties(), null);; assertEquals(1, channelManagerImpl.getNumberOfPeersToSendStatusTo(1)); assertEquals(2, channelManagerImpl.getNumberOfPeersToSendStatusTo(2)); assertEquals(3, channelManagerImpl.getNumberOfPeersToSendStatusTo(3)); assertEquals(3, channelManagerImpl.getNumberOfPeersToSendStatusTo(5)); assertEquals(3, channelManagerImpl.getNumberOfPeersToSendStatusTo(9)); assertEquals(3, channelManagerImpl.getNumberOfPeersToSendStatusTo(12)); assertEquals(4, channelManagerImpl.getNumberOfPeersToSendStatusTo(20)); assertEquals(5, channelManagerImpl.getNumberOfPeersToSendStatusTo(25)); assertEquals(10, channelManagerImpl.getNumberOfPeersToSendStatusTo(1000)); }
|
@VisibleForTesting int getNumberOfPeersToSendStatusTo(int peerCount) { int peerCountSqrt = (int) Math.sqrt(peerCount); return Math.min(10, Math.min(Math.max(3, peerCountSqrt), peerCount)); }
|
ChannelManagerImpl implements ChannelManager { @VisibleForTesting int getNumberOfPeersToSendStatusTo(int peerCount) { int peerCountSqrt = (int) Math.sqrt(peerCount); return Math.min(10, Math.min(Math.max(3, peerCountSqrt), peerCount)); } }
|
ChannelManagerImpl implements ChannelManager { @VisibleForTesting int getNumberOfPeersToSendStatusTo(int peerCount) { int peerCountSqrt = (int) Math.sqrt(peerCount); return Math.min(10, Math.min(Math.max(3, peerCountSqrt), peerCount)); } ChannelManagerImpl(RskSystemProperties config, SyncPool syncPool); }
|
ChannelManagerImpl implements ChannelManager { @VisibleForTesting int getNumberOfPeersToSendStatusTo(int peerCount) { int peerCountSqrt = (int) Math.sqrt(peerCount); return Math.min(10, Math.min(Math.max(3, peerCountSqrt), peerCount)); } ChannelManagerImpl(RskSystemProperties config, SyncPool syncPool); @Override void start(); @Override void stop(); @VisibleForTesting void tryProcessNewPeers(); boolean isRecentlyDisconnected(InetAddress peerAddress); @Nonnull Set<NodeID> broadcastBlock(@Nonnull final Block block); @Nonnull Set<NodeID> broadcastBlockHash(@Nonnull final List<BlockIdentifier> identifiers, final Set<NodeID> targets); @Override int broadcastStatus(Status status); void add(Channel peer); void notifyDisconnect(Channel channel); Collection<Peer> getActivePeers(); boolean isAddressBlockAvailable(InetAddress inetAddress); @Nonnull Set<NodeID> broadcastTransaction(@Nonnull final Transaction transaction, @Nonnull final Set<NodeID> skip); @Override Set<NodeID> broadcastTransactions(@Nonnull final List<Transaction> transactions, @Nonnull final Set<NodeID> skip); @VisibleForTesting void setActivePeers(Map<NodeID, Channel> newActivePeers); }
|
ChannelManagerImpl implements ChannelManager { @VisibleForTesting int getNumberOfPeersToSendStatusTo(int peerCount) { int peerCountSqrt = (int) Math.sqrt(peerCount); return Math.min(10, Math.min(Math.max(3, peerCountSqrt), peerCount)); } ChannelManagerImpl(RskSystemProperties config, SyncPool syncPool); @Override void start(); @Override void stop(); @VisibleForTesting void tryProcessNewPeers(); boolean isRecentlyDisconnected(InetAddress peerAddress); @Nonnull Set<NodeID> broadcastBlock(@Nonnull final Block block); @Nonnull Set<NodeID> broadcastBlockHash(@Nonnull final List<BlockIdentifier> identifiers, final Set<NodeID> targets); @Override int broadcastStatus(Status status); void add(Channel peer); void notifyDisconnect(Channel channel); Collection<Peer> getActivePeers(); boolean isAddressBlockAvailable(InetAddress inetAddress); @Nonnull Set<NodeID> broadcastTransaction(@Nonnull final Transaction transaction, @Nonnull final Set<NodeID> skip); @Override Set<NodeID> broadcastTransactions(@Nonnull final List<Transaction> transactions, @Nonnull final Set<NodeID> skip); @VisibleForTesting void setActivePeers(Map<NodeID, Channel> newActivePeers); }
|
@Test public void blockAddressIsAvailable() throws UnknownHostException { ChannelManagerImpl channelManagerImpl = new ChannelManagerImpl(new TestSystemProperties(), null);; Assert.assertTrue(channelManagerImpl.isAddressBlockAvailable(InetAddress.getLocalHost())); }
|
public boolean isAddressBlockAvailable(InetAddress inetAddress) { synchronized (activePeersLock) { return activePeers.values().stream() .map(ch -> new InetAddressBlock(ch.getInetSocketAddress().getAddress(), networkCIDR)) .filter(block -> block.contains(inetAddress)) .count() < maxConnectionsAllowed; } }
|
ChannelManagerImpl implements ChannelManager { public boolean isAddressBlockAvailable(InetAddress inetAddress) { synchronized (activePeersLock) { return activePeers.values().stream() .map(ch -> new InetAddressBlock(ch.getInetSocketAddress().getAddress(), networkCIDR)) .filter(block -> block.contains(inetAddress)) .count() < maxConnectionsAllowed; } } }
|
ChannelManagerImpl implements ChannelManager { public boolean isAddressBlockAvailable(InetAddress inetAddress) { synchronized (activePeersLock) { return activePeers.values().stream() .map(ch -> new InetAddressBlock(ch.getInetSocketAddress().getAddress(), networkCIDR)) .filter(block -> block.contains(inetAddress)) .count() < maxConnectionsAllowed; } } ChannelManagerImpl(RskSystemProperties config, SyncPool syncPool); }
|
ChannelManagerImpl implements ChannelManager { public boolean isAddressBlockAvailable(InetAddress inetAddress) { synchronized (activePeersLock) { return activePeers.values().stream() .map(ch -> new InetAddressBlock(ch.getInetSocketAddress().getAddress(), networkCIDR)) .filter(block -> block.contains(inetAddress)) .count() < maxConnectionsAllowed; } } ChannelManagerImpl(RskSystemProperties config, SyncPool syncPool); @Override void start(); @Override void stop(); @VisibleForTesting void tryProcessNewPeers(); boolean isRecentlyDisconnected(InetAddress peerAddress); @Nonnull Set<NodeID> broadcastBlock(@Nonnull final Block block); @Nonnull Set<NodeID> broadcastBlockHash(@Nonnull final List<BlockIdentifier> identifiers, final Set<NodeID> targets); @Override int broadcastStatus(Status status); void add(Channel peer); void notifyDisconnect(Channel channel); Collection<Peer> getActivePeers(); boolean isAddressBlockAvailable(InetAddress inetAddress); @Nonnull Set<NodeID> broadcastTransaction(@Nonnull final Transaction transaction, @Nonnull final Set<NodeID> skip); @Override Set<NodeID> broadcastTransactions(@Nonnull final List<Transaction> transactions, @Nonnull final Set<NodeID> skip); @VisibleForTesting void setActivePeers(Map<NodeID, Channel> newActivePeers); }
|
ChannelManagerImpl implements ChannelManager { public boolean isAddressBlockAvailable(InetAddress inetAddress) { synchronized (activePeersLock) { return activePeers.values().stream() .map(ch -> new InetAddressBlock(ch.getInetSocketAddress().getAddress(), networkCIDR)) .filter(block -> block.contains(inetAddress)) .count() < maxConnectionsAllowed; } } ChannelManagerImpl(RskSystemProperties config, SyncPool syncPool); @Override void start(); @Override void stop(); @VisibleForTesting void tryProcessNewPeers(); boolean isRecentlyDisconnected(InetAddress peerAddress); @Nonnull Set<NodeID> broadcastBlock(@Nonnull final Block block); @Nonnull Set<NodeID> broadcastBlockHash(@Nonnull final List<BlockIdentifier> identifiers, final Set<NodeID> targets); @Override int broadcastStatus(Status status); void add(Channel peer); void notifyDisconnect(Channel channel); Collection<Peer> getActivePeers(); boolean isAddressBlockAvailable(InetAddress inetAddress); @Nonnull Set<NodeID> broadcastTransaction(@Nonnull final Transaction transaction, @Nonnull final Set<NodeID> skip); @Override Set<NodeID> broadcastTransactions(@Nonnull final List<Transaction> transactions, @Nonnull final Set<NodeID> skip); @VisibleForTesting void setActivePeers(Map<NodeID, Channel> newActivePeers); }
|
@Test public void broadcastBlock() { ChannelManager target = new ChannelManagerImpl(mock(RskSystemProperties.class), mock(SyncPool.class)); Block block = mock(Block.class); when(block.getHash()).thenReturn(new Keccak256(new byte[32])); Set<NodeID> nodeIds = target.broadcastBlock(block); assertTrue(nodeIds.isEmpty()); }
|
@Nonnull public Set<NodeID> broadcastBlock(@Nonnull final Block block) { final Set<NodeID> nodesIdsBroadcastedTo = new HashSet<>(); final BlockIdentifier bi = new BlockIdentifier(block.getHash().getBytes(), block.getNumber()); final Message newBlock = new BlockMessage(block); final Message newBlockHashes = new NewBlockHashesMessage(Arrays.asList(bi)); synchronized (activePeersLock) { activePeers.values().forEach(c -> logger.trace("RSK activePeers: {}", c)); List<Channel> peers = new ArrayList<>(activePeers.values()); Collections.shuffle(peers); int sqrt = (int) Math.floor(Math.sqrt(peers.size())); for (int i = 0; i < sqrt; i++) { Channel peer = peers.get(i); nodesIdsBroadcastedTo.add(peer.getNodeId()); logger.trace("RSK propagate: {}", peer); peer.sendMessage(newBlock); } for (int i = sqrt; i < peers.size(); i++) { Channel peer = peers.get(i); logger.trace("RSK announce: {}", peer); peer.sendMessage(newBlockHashes); } } return nodesIdsBroadcastedTo; }
|
ChannelManagerImpl implements ChannelManager { @Nonnull public Set<NodeID> broadcastBlock(@Nonnull final Block block) { final Set<NodeID> nodesIdsBroadcastedTo = new HashSet<>(); final BlockIdentifier bi = new BlockIdentifier(block.getHash().getBytes(), block.getNumber()); final Message newBlock = new BlockMessage(block); final Message newBlockHashes = new NewBlockHashesMessage(Arrays.asList(bi)); synchronized (activePeersLock) { activePeers.values().forEach(c -> logger.trace("RSK activePeers: {}", c)); List<Channel> peers = new ArrayList<>(activePeers.values()); Collections.shuffle(peers); int sqrt = (int) Math.floor(Math.sqrt(peers.size())); for (int i = 0; i < sqrt; i++) { Channel peer = peers.get(i); nodesIdsBroadcastedTo.add(peer.getNodeId()); logger.trace("RSK propagate: {}", peer); peer.sendMessage(newBlock); } for (int i = sqrt; i < peers.size(); i++) { Channel peer = peers.get(i); logger.trace("RSK announce: {}", peer); peer.sendMessage(newBlockHashes); } } return nodesIdsBroadcastedTo; } }
|
ChannelManagerImpl implements ChannelManager { @Nonnull public Set<NodeID> broadcastBlock(@Nonnull final Block block) { final Set<NodeID> nodesIdsBroadcastedTo = new HashSet<>(); final BlockIdentifier bi = new BlockIdentifier(block.getHash().getBytes(), block.getNumber()); final Message newBlock = new BlockMessage(block); final Message newBlockHashes = new NewBlockHashesMessage(Arrays.asList(bi)); synchronized (activePeersLock) { activePeers.values().forEach(c -> logger.trace("RSK activePeers: {}", c)); List<Channel> peers = new ArrayList<>(activePeers.values()); Collections.shuffle(peers); int sqrt = (int) Math.floor(Math.sqrt(peers.size())); for (int i = 0; i < sqrt; i++) { Channel peer = peers.get(i); nodesIdsBroadcastedTo.add(peer.getNodeId()); logger.trace("RSK propagate: {}", peer); peer.sendMessage(newBlock); } for (int i = sqrt; i < peers.size(); i++) { Channel peer = peers.get(i); logger.trace("RSK announce: {}", peer); peer.sendMessage(newBlockHashes); } } return nodesIdsBroadcastedTo; } ChannelManagerImpl(RskSystemProperties config, SyncPool syncPool); }
|
ChannelManagerImpl implements ChannelManager { @Nonnull public Set<NodeID> broadcastBlock(@Nonnull final Block block) { final Set<NodeID> nodesIdsBroadcastedTo = new HashSet<>(); final BlockIdentifier bi = new BlockIdentifier(block.getHash().getBytes(), block.getNumber()); final Message newBlock = new BlockMessage(block); final Message newBlockHashes = new NewBlockHashesMessage(Arrays.asList(bi)); synchronized (activePeersLock) { activePeers.values().forEach(c -> logger.trace("RSK activePeers: {}", c)); List<Channel> peers = new ArrayList<>(activePeers.values()); Collections.shuffle(peers); int sqrt = (int) Math.floor(Math.sqrt(peers.size())); for (int i = 0; i < sqrt; i++) { Channel peer = peers.get(i); nodesIdsBroadcastedTo.add(peer.getNodeId()); logger.trace("RSK propagate: {}", peer); peer.sendMessage(newBlock); } for (int i = sqrt; i < peers.size(); i++) { Channel peer = peers.get(i); logger.trace("RSK announce: {}", peer); peer.sendMessage(newBlockHashes); } } return nodesIdsBroadcastedTo; } ChannelManagerImpl(RskSystemProperties config, SyncPool syncPool); @Override void start(); @Override void stop(); @VisibleForTesting void tryProcessNewPeers(); boolean isRecentlyDisconnected(InetAddress peerAddress); @Nonnull Set<NodeID> broadcastBlock(@Nonnull final Block block); @Nonnull Set<NodeID> broadcastBlockHash(@Nonnull final List<BlockIdentifier> identifiers, final Set<NodeID> targets); @Override int broadcastStatus(Status status); void add(Channel peer); void notifyDisconnect(Channel channel); Collection<Peer> getActivePeers(); boolean isAddressBlockAvailable(InetAddress inetAddress); @Nonnull Set<NodeID> broadcastTransaction(@Nonnull final Transaction transaction, @Nonnull final Set<NodeID> skip); @Override Set<NodeID> broadcastTransactions(@Nonnull final List<Transaction> transactions, @Nonnull final Set<NodeID> skip); @VisibleForTesting void setActivePeers(Map<NodeID, Channel> newActivePeers); }
|
ChannelManagerImpl implements ChannelManager { @Nonnull public Set<NodeID> broadcastBlock(@Nonnull final Block block) { final Set<NodeID> nodesIdsBroadcastedTo = new HashSet<>(); final BlockIdentifier bi = new BlockIdentifier(block.getHash().getBytes(), block.getNumber()); final Message newBlock = new BlockMessage(block); final Message newBlockHashes = new NewBlockHashesMessage(Arrays.asList(bi)); synchronized (activePeersLock) { activePeers.values().forEach(c -> logger.trace("RSK activePeers: {}", c)); List<Channel> peers = new ArrayList<>(activePeers.values()); Collections.shuffle(peers); int sqrt = (int) Math.floor(Math.sqrt(peers.size())); for (int i = 0; i < sqrt; i++) { Channel peer = peers.get(i); nodesIdsBroadcastedTo.add(peer.getNodeId()); logger.trace("RSK propagate: {}", peer); peer.sendMessage(newBlock); } for (int i = sqrt; i < peers.size(); i++) { Channel peer = peers.get(i); logger.trace("RSK announce: {}", peer); peer.sendMessage(newBlockHashes); } } return nodesIdsBroadcastedTo; } ChannelManagerImpl(RskSystemProperties config, SyncPool syncPool); @Override void start(); @Override void stop(); @VisibleForTesting void tryProcessNewPeers(); boolean isRecentlyDisconnected(InetAddress peerAddress); @Nonnull Set<NodeID> broadcastBlock(@Nonnull final Block block); @Nonnull Set<NodeID> broadcastBlockHash(@Nonnull final List<BlockIdentifier> identifiers, final Set<NodeID> targets); @Override int broadcastStatus(Status status); void add(Channel peer); void notifyDisconnect(Channel channel); Collection<Peer> getActivePeers(); boolean isAddressBlockAvailable(InetAddress inetAddress); @Nonnull Set<NodeID> broadcastTransaction(@Nonnull final Transaction transaction, @Nonnull final Set<NodeID> skip); @Override Set<NodeID> broadcastTransactions(@Nonnull final List<Transaction> transactions, @Nonnull final Set<NodeID> skip); @VisibleForTesting void setActivePeers(Map<NodeID, Channel> newActivePeers); }
|
@Test public void getBalanceWithAccountAndBlockWithTransaction() throws Exception { World world = new World(); BlockChainImpl blockChain = world.getBlockChain(); TransactionPool transactionPool = world.getTransactionPool(); Account acc1 = new AccountBuilder(world).name("acc1").balance(Coin.valueOf(10000000)).build(); Account acc2 = new AccountBuilder(world).name("acc2").build(); Block genesis = world.getBlockByName("g00"); Transaction tx = new TransactionBuilder().sender(acc1).receiver(acc2).value(BigInteger.valueOf(10000)).build(); List<Transaction> txs = new ArrayList<>(); txs.add(tx); Block block1 = new BlockBuilder(world.getBlockChain(), world.getBridgeSupportFactory(), world.getBlockStore()).trieStore(world.getTrieStore()).parent(genesis).transactions(txs).build(); org.junit.Assert.assertEquals(ImportResult.IMPORTED_BEST, blockChain.tryToConnect(block1)); Web3Impl web3 = createWeb3(world, transactionPool, null); String accountAddress = ByteUtil.toHexString(acc2.getAddress().getBytes()); String balanceString = "0x" + ByteUtil.toHexString(BigInteger.valueOf(10000).toByteArray()); org.junit.Assert.assertEquals("0x0", web3.eth_getBalance(accountAddress, "0x0")); org.junit.Assert.assertEquals(balanceString, web3.eth_getBalance(accountAddress, "0x1")); org.junit.Assert.assertEquals(balanceString, web3.eth_getBalance(accountAddress, "pending")); }
|
@Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.asBigInteger()); }
|
Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.asBigInteger()); } }
|
Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.asBigInteger()); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); }
|
Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.asBigInteger()); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); }
|
Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.asBigInteger()); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); public Ethereum eth; }
|
@Test public void put() { byte[] randomKey = TestUtils.randomBytes(20); byte[] randomValue = TestUtils.randomBytes(20); dataSourceWithCache.put(randomKey, randomValue); assertThat(baseDataSource.get(randomKey), is(nullValue())); dataSourceWithCache.flush(); assertThat(baseDataSource.get(randomKey), is(randomValue)); }
|
@Override public byte[] put(byte[] key, byte[] value) { ByteArrayWrapper wrappedKey = ByteUtil.wrap(key); return put(wrappedKey, value); }
|
DataSourceWithCache implements KeyValueDataSource { @Override public byte[] put(byte[] key, byte[] value) { ByteArrayWrapper wrappedKey = ByteUtil.wrap(key); return put(wrappedKey, value); } }
|
DataSourceWithCache implements KeyValueDataSource { @Override public byte[] put(byte[] key, byte[] value) { ByteArrayWrapper wrappedKey = ByteUtil.wrap(key); return put(wrappedKey, value); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); }
|
DataSourceWithCache implements KeyValueDataSource { @Override public byte[] put(byte[] key, byte[] value) { ByteArrayWrapper wrappedKey = ByteUtil.wrap(key); return put(wrappedKey, value); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); @Override byte[] get(byte[] key); @Override byte[] put(byte[] key, byte[] value); @Override void delete(byte[] key); @Override Set<byte[]> keys(); @Override void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove); @Override void flush(); String getName(); void init(); boolean isAlive(); void close(); }
|
DataSourceWithCache implements KeyValueDataSource { @Override public byte[] put(byte[] key, byte[] value) { ByteArrayWrapper wrappedKey = ByteUtil.wrap(key); return put(wrappedKey, value); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); @Override byte[] get(byte[] key); @Override byte[] put(byte[] key, byte[] value); @Override void delete(byte[] key); @Override Set<byte[]> keys(); @Override void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove); @Override void flush(); String getName(); void init(); boolean isAlive(); void close(); }
|
@Test public void keys() { Map<ByteArrayWrapper, byte[]> initialEntries = generateRandomValuesToUpdate(CACHE_SIZE); Set<byte[]> initialKeys = initialEntries.keySet().stream().map(ByteArrayWrapper::getData).collect(Collectors.toSet()); baseDataSource.updateBatch(initialEntries, Collections.emptySet()); assertThat(dataSourceWithCache.keys(), is(initialKeys)); byte[] randomKey = TestUtils.randomBytes(20); dataSourceWithCache.get(randomKey); assertThat(dataSourceWithCache.keys(), not(hasItem(randomKey))); }
|
@Override public Set<byte[]> keys() { Stream<ByteArrayWrapper> baseKeys; Stream<ByteArrayWrapper> committedKeys; Stream<ByteArrayWrapper> uncommittedKeys; Set<ByteArrayWrapper> uncommittedKeysToRemove; this.lock.readLock().lock(); try { baseKeys = base.keys().stream().map(ByteArrayWrapper::new); committedKeys = committedCache.entrySet().stream() .filter(e -> e.getValue() != null) .map(Map.Entry::getKey); uncommittedKeys = uncommittedCache.entrySet().stream() .filter(e -> e.getValue() != null) .map(Map.Entry::getKey); uncommittedKeysToRemove = uncommittedCache.entrySet().stream() .filter(e -> e.getValue() == null) .map(Map.Entry::getKey) .collect(Collectors.toSet()); } finally { this.lock.readLock().unlock(); } Set<ByteArrayWrapper> knownKeys = Stream.concat(Stream.concat(baseKeys, committedKeys), uncommittedKeys) .collect(Collectors.toSet()); knownKeys.removeAll(uncommittedKeysToRemove); return knownKeys.stream() .map(ByteArrayWrapper::getData) .collect(Collectors.toSet()); }
|
DataSourceWithCache implements KeyValueDataSource { @Override public Set<byte[]> keys() { Stream<ByteArrayWrapper> baseKeys; Stream<ByteArrayWrapper> committedKeys; Stream<ByteArrayWrapper> uncommittedKeys; Set<ByteArrayWrapper> uncommittedKeysToRemove; this.lock.readLock().lock(); try { baseKeys = base.keys().stream().map(ByteArrayWrapper::new); committedKeys = committedCache.entrySet().stream() .filter(e -> e.getValue() != null) .map(Map.Entry::getKey); uncommittedKeys = uncommittedCache.entrySet().stream() .filter(e -> e.getValue() != null) .map(Map.Entry::getKey); uncommittedKeysToRemove = uncommittedCache.entrySet().stream() .filter(e -> e.getValue() == null) .map(Map.Entry::getKey) .collect(Collectors.toSet()); } finally { this.lock.readLock().unlock(); } Set<ByteArrayWrapper> knownKeys = Stream.concat(Stream.concat(baseKeys, committedKeys), uncommittedKeys) .collect(Collectors.toSet()); knownKeys.removeAll(uncommittedKeysToRemove); return knownKeys.stream() .map(ByteArrayWrapper::getData) .collect(Collectors.toSet()); } }
|
DataSourceWithCache implements KeyValueDataSource { @Override public Set<byte[]> keys() { Stream<ByteArrayWrapper> baseKeys; Stream<ByteArrayWrapper> committedKeys; Stream<ByteArrayWrapper> uncommittedKeys; Set<ByteArrayWrapper> uncommittedKeysToRemove; this.lock.readLock().lock(); try { baseKeys = base.keys().stream().map(ByteArrayWrapper::new); committedKeys = committedCache.entrySet().stream() .filter(e -> e.getValue() != null) .map(Map.Entry::getKey); uncommittedKeys = uncommittedCache.entrySet().stream() .filter(e -> e.getValue() != null) .map(Map.Entry::getKey); uncommittedKeysToRemove = uncommittedCache.entrySet().stream() .filter(e -> e.getValue() == null) .map(Map.Entry::getKey) .collect(Collectors.toSet()); } finally { this.lock.readLock().unlock(); } Set<ByteArrayWrapper> knownKeys = Stream.concat(Stream.concat(baseKeys, committedKeys), uncommittedKeys) .collect(Collectors.toSet()); knownKeys.removeAll(uncommittedKeysToRemove); return knownKeys.stream() .map(ByteArrayWrapper::getData) .collect(Collectors.toSet()); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); }
|
DataSourceWithCache implements KeyValueDataSource { @Override public Set<byte[]> keys() { Stream<ByteArrayWrapper> baseKeys; Stream<ByteArrayWrapper> committedKeys; Stream<ByteArrayWrapper> uncommittedKeys; Set<ByteArrayWrapper> uncommittedKeysToRemove; this.lock.readLock().lock(); try { baseKeys = base.keys().stream().map(ByteArrayWrapper::new); committedKeys = committedCache.entrySet().stream() .filter(e -> e.getValue() != null) .map(Map.Entry::getKey); uncommittedKeys = uncommittedCache.entrySet().stream() .filter(e -> e.getValue() != null) .map(Map.Entry::getKey); uncommittedKeysToRemove = uncommittedCache.entrySet().stream() .filter(e -> e.getValue() == null) .map(Map.Entry::getKey) .collect(Collectors.toSet()); } finally { this.lock.readLock().unlock(); } Set<ByteArrayWrapper> knownKeys = Stream.concat(Stream.concat(baseKeys, committedKeys), uncommittedKeys) .collect(Collectors.toSet()); knownKeys.removeAll(uncommittedKeysToRemove); return knownKeys.stream() .map(ByteArrayWrapper::getData) .collect(Collectors.toSet()); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); @Override byte[] get(byte[] key); @Override byte[] put(byte[] key, byte[] value); @Override void delete(byte[] key); @Override Set<byte[]> keys(); @Override void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove); @Override void flush(); String getName(); void init(); boolean isAlive(); void close(); }
|
DataSourceWithCache implements KeyValueDataSource { @Override public Set<byte[]> keys() { Stream<ByteArrayWrapper> baseKeys; Stream<ByteArrayWrapper> committedKeys; Stream<ByteArrayWrapper> uncommittedKeys; Set<ByteArrayWrapper> uncommittedKeysToRemove; this.lock.readLock().lock(); try { baseKeys = base.keys().stream().map(ByteArrayWrapper::new); committedKeys = committedCache.entrySet().stream() .filter(e -> e.getValue() != null) .map(Map.Entry::getKey); uncommittedKeys = uncommittedCache.entrySet().stream() .filter(e -> e.getValue() != null) .map(Map.Entry::getKey); uncommittedKeysToRemove = uncommittedCache.entrySet().stream() .filter(e -> e.getValue() == null) .map(Map.Entry::getKey) .collect(Collectors.toSet()); } finally { this.lock.readLock().unlock(); } Set<ByteArrayWrapper> knownKeys = Stream.concat(Stream.concat(baseKeys, committedKeys), uncommittedKeys) .collect(Collectors.toSet()); knownKeys.removeAll(uncommittedKeysToRemove); return knownKeys.stream() .map(ByteArrayWrapper::getData) .collect(Collectors.toSet()); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); @Override byte[] get(byte[] key); @Override byte[] put(byte[] key, byte[] value); @Override void delete(byte[] key); @Override Set<byte[]> keys(); @Override void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove); @Override void flush(); String getName(); void init(); boolean isAlive(); void close(); }
|
@Test public void delete() { byte[] randomKey = TestUtils.randomBytes(20); baseDataSource.put(randomKey, TestUtils.randomBytes(20)); dataSourceWithCache.delete(randomKey); dataSourceWithCache.flush(); assertThat(baseDataSource.get(randomKey), is(nullValue())); }
|
@Override public void delete(byte[] key) { delete(ByteUtil.wrap(key)); }
|
DataSourceWithCache implements KeyValueDataSource { @Override public void delete(byte[] key) { delete(ByteUtil.wrap(key)); } }
|
DataSourceWithCache implements KeyValueDataSource { @Override public void delete(byte[] key) { delete(ByteUtil.wrap(key)); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); }
|
DataSourceWithCache implements KeyValueDataSource { @Override public void delete(byte[] key) { delete(ByteUtil.wrap(key)); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); @Override byte[] get(byte[] key); @Override byte[] put(byte[] key, byte[] value); @Override void delete(byte[] key); @Override Set<byte[]> keys(); @Override void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove); @Override void flush(); String getName(); void init(); boolean isAlive(); void close(); }
|
DataSourceWithCache implements KeyValueDataSource { @Override public void delete(byte[] key) { delete(ByteUtil.wrap(key)); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); @Override byte[] get(byte[] key); @Override byte[] put(byte[] key, byte[] value); @Override void delete(byte[] key); @Override Set<byte[]> keys(); @Override void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove); @Override void flush(); String getName(); void init(); boolean isAlive(); void close(); }
|
@Test public void updateBatch() { Map<ByteArrayWrapper, byte[]> initialEntries = generateRandomValuesToUpdate(CACHE_SIZE); baseDataSource.updateBatch(initialEntries, Collections.emptySet()); Set<ByteArrayWrapper> keysToBatchRemove = initialEntries.keySet().stream().limit(CACHE_SIZE / 2).collect(Collectors.toSet()); dataSourceWithCache.updateBatch(Collections.emptyMap(), keysToBatchRemove); dataSourceWithCache.flush(); for (ByteArrayWrapper removedKey : keysToBatchRemove) { assertThat(baseDataSource.get(removedKey.getData()), is(nullValue())); } }
|
@Override public void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove) { if (rows.containsKey(null) || rows.containsValue(null)) { throw new IllegalArgumentException("Cannot update null values"); } rows.keySet().removeAll(keysToRemove); this.lock.writeLock().lock(); try { rows.forEach(this::put); keysToRemove.forEach(this::delete); } finally { this.lock.writeLock().unlock(); } }
|
DataSourceWithCache implements KeyValueDataSource { @Override public void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove) { if (rows.containsKey(null) || rows.containsValue(null)) { throw new IllegalArgumentException("Cannot update null values"); } rows.keySet().removeAll(keysToRemove); this.lock.writeLock().lock(); try { rows.forEach(this::put); keysToRemove.forEach(this::delete); } finally { this.lock.writeLock().unlock(); } } }
|
DataSourceWithCache implements KeyValueDataSource { @Override public void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove) { if (rows.containsKey(null) || rows.containsValue(null)) { throw new IllegalArgumentException("Cannot update null values"); } rows.keySet().removeAll(keysToRemove); this.lock.writeLock().lock(); try { rows.forEach(this::put); keysToRemove.forEach(this::delete); } finally { this.lock.writeLock().unlock(); } } DataSourceWithCache(KeyValueDataSource base, int cacheSize); }
|
DataSourceWithCache implements KeyValueDataSource { @Override public void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove) { if (rows.containsKey(null) || rows.containsValue(null)) { throw new IllegalArgumentException("Cannot update null values"); } rows.keySet().removeAll(keysToRemove); this.lock.writeLock().lock(); try { rows.forEach(this::put); keysToRemove.forEach(this::delete); } finally { this.lock.writeLock().unlock(); } } DataSourceWithCache(KeyValueDataSource base, int cacheSize); @Override byte[] get(byte[] key); @Override byte[] put(byte[] key, byte[] value); @Override void delete(byte[] key); @Override Set<byte[]> keys(); @Override void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove); @Override void flush(); String getName(); void init(); boolean isAlive(); void close(); }
|
DataSourceWithCache implements KeyValueDataSource { @Override public void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove) { if (rows.containsKey(null) || rows.containsValue(null)) { throw new IllegalArgumentException("Cannot update null values"); } rows.keySet().removeAll(keysToRemove); this.lock.writeLock().lock(); try { rows.forEach(this::put); keysToRemove.forEach(this::delete); } finally { this.lock.writeLock().unlock(); } } DataSourceWithCache(KeyValueDataSource base, int cacheSize); @Override byte[] get(byte[] key); @Override byte[] put(byte[] key, byte[] value); @Override void delete(byte[] key); @Override Set<byte[]> keys(); @Override void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove); @Override void flush(); String getName(); void init(); boolean isAlive(); void close(); }
|
@Test public void test_2() { assertTrue(TypeConverter.toJsonHex(EMPTY_BYTE_ARRAY).equals("0x00")); byte[] rlpSuccess = Hex.decode("f9010c808255aeb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c08255ae01"); byte[] rlpFailed = Hex.decode("f9010c808255aeb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c08255ae80"); TransactionReceipt txReceipt = new TransactionReceipt(rlpSuccess); assertTrue(Arrays.equals(txReceipt.getStatus(), new byte[]{0x01})); txReceipt = new TransactionReceipt(rlpFailed); assertTrue(Arrays.equals(txReceipt.getStatus(), EMPTY_BYTE_ARRAY)); }
|
public byte[] getStatus() { return this.status; }
|
TransactionReceipt { public byte[] getStatus() { return this.status; } }
|
TransactionReceipt { public byte[] getStatus() { return this.status; } TransactionReceipt(); TransactionReceipt(byte[] rlp); TransactionReceipt(byte[] postTxState, byte[] cumulativeGas, byte[] gasUsed,
Bloom bloomFilter, List<LogInfo> logInfoList, byte[] status); }
|
TransactionReceipt { public byte[] getStatus() { return this.status; } TransactionReceipt(); TransactionReceipt(byte[] rlp); TransactionReceipt(byte[] postTxState, byte[] cumulativeGas, byte[] gasUsed,
Bloom bloomFilter, List<LogInfo> logInfoList, byte[] status); byte[] getPostTxState(); byte[] getCumulativeGas(); byte[] getGasUsed(); long getCumulativeGasLong(); Bloom getBloomFilter(); List<LogInfo> getLogInfoList(); byte[] getEncoded(); void setStatus(byte[] status); boolean isSuccessful(); void setTxStatus(boolean success); boolean hasTxStatus(); boolean isTxStatusOK(); void setPostTxState(byte[] postTxState); void setCumulativeGas(long cumulativeGas); void setGasUsed(long gasUsed); void setCumulativeGas(byte[] cumulativeGas); void setGasUsed(byte[] gasUsed); void setLogInfoList(List<LogInfo> logInfoList); void setTransaction(Transaction transaction); Transaction getTransaction(); @Override String toString(); byte[] getStatus(); }
|
TransactionReceipt { public byte[] getStatus() { return this.status; } TransactionReceipt(); TransactionReceipt(byte[] rlp); TransactionReceipt(byte[] postTxState, byte[] cumulativeGas, byte[] gasUsed,
Bloom bloomFilter, List<LogInfo> logInfoList, byte[] status); byte[] getPostTxState(); byte[] getCumulativeGas(); byte[] getGasUsed(); long getCumulativeGasLong(); Bloom getBloomFilter(); List<LogInfo> getLogInfoList(); byte[] getEncoded(); void setStatus(byte[] status); boolean isSuccessful(); void setTxStatus(boolean success); boolean hasTxStatus(); boolean isTxStatusOK(); void setPostTxState(byte[] postTxState); void setCumulativeGas(long cumulativeGas); void setGasUsed(long gasUsed); void setCumulativeGas(byte[] cumulativeGas); void setGasUsed(byte[] gasUsed); void setLogInfoList(List<LogInfo> logInfoList); void setTransaction(Transaction transaction); Transaction getTransaction(); @Override String toString(); byte[] getStatus(); }
|
@Test public void testInitHandlesFreeTransactionsOK() { BlockTxSignatureCache blockTxSignatureCache = mock(BlockTxSignatureCache.class); Transaction transaction = mock(Transaction.class); TransactionExecutor txExecutor = new TransactionExecutor( constants, activationConfig, transaction, txIndex, rskAddress, repository, blockStore, receiptStore, blockFactory, programInvokeFactory, executionBlock, gasUsedInTheBlock, vmConfig, true, true, precompiledContracts, deletedAccounts, blockTxSignatureCache ); when(transaction.getGasLimit()).thenReturn(BigInteger.valueOf(4000000).toByteArray()); when(executionBlock.getGasLimit()).thenReturn(BigInteger.valueOf(6800000).toByteArray()); when(repository.getNonce(transaction.getSender())).thenReturn(BigInteger.valueOf(1L)); when(transaction.getNonce()).thenReturn(BigInteger.valueOf(1L).toByteArray()); RskAddress receiver = new RskAddress("0000000000000000000000000000000000000001"); when(transaction.getReceiveAddress()).thenReturn(receiver); when(transaction.acceptTransactionSignature(constants.getChainId())).thenReturn(true); when(repository.getBalance(transaction.getSender())).thenReturn(new Coin(BigInteger.valueOf(0L))); when(transaction.getValue()).thenReturn(new Coin(BigInteger.valueOf(68000))); assertEquals(0, transaction.transactionCost(constants, activationConfig.forBlock(executionBlock.getNumber()))); assertFalse(txExecutor.executeTransaction()); }
|
public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; }
|
TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } }
|
TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository track, BlockStore blockStore, ReceiptStore receiptStore, BlockFactory blockFactory,
ProgramInvokeFactory programInvokeFactory, Block executionBlock, long gasUsedInTheBlock, VmConfig vmConfig,
boolean playVm, boolean remascEnabled, PrecompiledContracts precompiledContracts, Set<DataWord> deletedAccounts,
SignatureCache signatureCache); }
|
TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository track, BlockStore blockStore, ReceiptStore receiptStore, BlockFactory blockFactory,
ProgramInvokeFactory programInvokeFactory, Block executionBlock, long gasUsedInTheBlock, VmConfig vmConfig,
boolean playVm, boolean remascEnabled, PrecompiledContracts precompiledContracts, Set<DataWord> deletedAccounts,
SignatureCache signatureCache); boolean executeTransaction(); TransactionReceipt getReceipt(); void extractTrace(ProgramTraceProcessor programTraceProcessor); TransactionExecutor setLocalCall(boolean localCall); List<LogInfo> getVMLogs(); ProgramResult getResult(); long getGasUsed(); Coin getPaidFees(); }
|
TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository track, BlockStore blockStore, ReceiptStore receiptStore, BlockFactory blockFactory,
ProgramInvokeFactory programInvokeFactory, Block executionBlock, long gasUsedInTheBlock, VmConfig vmConfig,
boolean playVm, boolean remascEnabled, PrecompiledContracts precompiledContracts, Set<DataWord> deletedAccounts,
SignatureCache signatureCache); boolean executeTransaction(); TransactionReceipt getReceipt(); void extractTrace(ProgramTraceProcessor programTraceProcessor); TransactionExecutor setLocalCall(boolean localCall); List<LogInfo> getVMLogs(); ProgramResult getResult(); long getGasUsed(); Coin getPaidFees(); }
|
@Test public void InvalidTxsIsInBlockAndShouldntBeInCache(){ ReceivedTxSignatureCache receivedTxSignatureCache = mock(ReceivedTxSignatureCache.class); BlockTxSignatureCache blockTxSignatureCache = new BlockTxSignatureCache(receivedTxSignatureCache); MutableRepository cacheTrack = mock(MutableRepository.class); when(repository.startTracking()).thenReturn(cacheTrack); RskAddress sender = new RskAddress("0000000000000000000000000000000000000001"); RskAddress receiver = new RskAddress("0000000000000000000000000000000000000002"); byte[] gasLimit = BigInteger.valueOf(4000000).toByteArray(); byte[] txNonce = BigInteger.valueOf(1L).toByteArray(); Coin gasPrice = Coin.valueOf(1); Coin value = new Coin(BigInteger.valueOf(2)); Transaction transaction = getTransaction(sender, receiver, gasLimit, txNonce, gasPrice, value); when(executionBlock.getGasLimit()).thenReturn(BigInteger.valueOf(6800000).toByteArray()); when(repository.getNonce(sender)).thenReturn(BigInteger.valueOf(1L)); when(repository.getBalance(sender)).thenReturn(new Coin(BigInteger.valueOf(0L))); TransactionExecutor txExecutor = new TransactionExecutor( constants, activationConfig, transaction, txIndex, rskAddress, repository, blockStore, receiptStore, blockFactory, programInvokeFactory, executionBlock, gasUsedInTheBlock, vmConfig, true, true, precompiledContracts, deletedAccounts, blockTxSignatureCache ); assertEquals(0, transaction.transactionCost(constants, activationConfig.forBlock(executionBlock.getNumber()))); assertFalse(txExecutor.executeTransaction()); assertFalse(blockTxSignatureCache.containsTx(transaction)); }
|
public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; }
|
TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } }
|
TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository track, BlockStore blockStore, ReceiptStore receiptStore, BlockFactory blockFactory,
ProgramInvokeFactory programInvokeFactory, Block executionBlock, long gasUsedInTheBlock, VmConfig vmConfig,
boolean playVm, boolean remascEnabled, PrecompiledContracts precompiledContracts, Set<DataWord> deletedAccounts,
SignatureCache signatureCache); }
|
TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository track, BlockStore blockStore, ReceiptStore receiptStore, BlockFactory blockFactory,
ProgramInvokeFactory programInvokeFactory, Block executionBlock, long gasUsedInTheBlock, VmConfig vmConfig,
boolean playVm, boolean remascEnabled, PrecompiledContracts precompiledContracts, Set<DataWord> deletedAccounts,
SignatureCache signatureCache); boolean executeTransaction(); TransactionReceipt getReceipt(); void extractTrace(ProgramTraceProcessor programTraceProcessor); TransactionExecutor setLocalCall(boolean localCall); List<LogInfo> getVMLogs(); ProgramResult getResult(); long getGasUsed(); Coin getPaidFees(); }
|
TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository track, BlockStore blockStore, ReceiptStore receiptStore, BlockFactory blockFactory,
ProgramInvokeFactory programInvokeFactory, Block executionBlock, long gasUsedInTheBlock, VmConfig vmConfig,
boolean playVm, boolean remascEnabled, PrecompiledContracts precompiledContracts, Set<DataWord> deletedAccounts,
SignatureCache signatureCache); boolean executeTransaction(); TransactionReceipt getReceipt(); void extractTrace(ProgramTraceProcessor programTraceProcessor); TransactionExecutor setLocalCall(boolean localCall); List<LogInfo> getVMLogs(); ProgramResult getResult(); long getGasUsed(); Coin getPaidFees(); }
|
@Test public void remascTxIsReceivedAndShouldntBeInCache(){ ReceivedTxSignatureCache receivedTxSignatureCache = mock(ReceivedTxSignatureCache.class); BlockTxSignatureCache blockTxSignatureCache = new BlockTxSignatureCache(receivedTxSignatureCache); MutableRepository cacheTrack = mock(MutableRepository.class); when(repository.startTracking()).thenReturn(cacheTrack); RskAddress sender = PrecompiledContracts.REMASC_ADDR; RskAddress receiver = new RskAddress("0000000000000000000000000000000000000002"); byte[] gasLimit = BigInteger.valueOf(4000000).toByteArray(); byte[] txNonce = BigInteger.valueOf(1L).toByteArray(); Coin gasPrice = Coin.valueOf(1); Coin value = new Coin(BigInteger.valueOf(2)); Transaction transaction = getTransaction(sender, receiver, gasLimit, txNonce, gasPrice, value); when(executionBlock.getGasLimit()).thenReturn(BigInteger.valueOf(6800000).toByteArray()); when(repository.getNonce(sender)).thenReturn(BigInteger.valueOf(1L)); when(repository.getBalance(sender)).thenReturn(new Coin(BigInteger.valueOf(0L))); TransactionExecutor txExecutor = new TransactionExecutor( constants, activationConfig, transaction, txIndex, rskAddress, repository, blockStore, receiptStore, blockFactory, programInvokeFactory, executionBlock, gasUsedInTheBlock, vmConfig, true, true, precompiledContracts, deletedAccounts, blockTxSignatureCache ); assertEquals(0, transaction.transactionCost(constants, activationConfig.forBlock(executionBlock.getNumber()))); assertFalse(txExecutor.executeTransaction()); assertFalse(blockTxSignatureCache.containsTx(transaction)); }
|
public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; }
|
TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } }
|
TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository track, BlockStore blockStore, ReceiptStore receiptStore, BlockFactory blockFactory,
ProgramInvokeFactory programInvokeFactory, Block executionBlock, long gasUsedInTheBlock, VmConfig vmConfig,
boolean playVm, boolean remascEnabled, PrecompiledContracts precompiledContracts, Set<DataWord> deletedAccounts,
SignatureCache signatureCache); }
|
TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository track, BlockStore blockStore, ReceiptStore receiptStore, BlockFactory blockFactory,
ProgramInvokeFactory programInvokeFactory, Block executionBlock, long gasUsedInTheBlock, VmConfig vmConfig,
boolean playVm, boolean remascEnabled, PrecompiledContracts precompiledContracts, Set<DataWord> deletedAccounts,
SignatureCache signatureCache); boolean executeTransaction(); TransactionReceipt getReceipt(); void extractTrace(ProgramTraceProcessor programTraceProcessor); TransactionExecutor setLocalCall(boolean localCall); List<LogInfo> getVMLogs(); ProgramResult getResult(); long getGasUsed(); Coin getPaidFees(); }
|
TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository track, BlockStore blockStore, ReceiptStore receiptStore, BlockFactory blockFactory,
ProgramInvokeFactory programInvokeFactory, Block executionBlock, long gasUsedInTheBlock, VmConfig vmConfig,
boolean playVm, boolean remascEnabled, PrecompiledContracts precompiledContracts, Set<DataWord> deletedAccounts,
SignatureCache signatureCache); boolean executeTransaction(); TransactionReceipt getReceipt(); void extractTrace(ProgramTraceProcessor programTraceProcessor); TransactionExecutor setLocalCall(boolean localCall); List<LogInfo> getVMLogs(); ProgramResult getResult(); long getGasUsed(); Coin getPaidFees(); }
|
@Test public void createsHeaderWithEmptyStateRoot() { BlockHeader header = blockHeaderBuilder.build(); assertArrayEquals(HashUtil.EMPTY_TRIE_HASH, header.getStateRoot()); }
|
public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
@Test public void createsHeaderWithEmptyTxTrieRoot() { BlockHeader header = blockHeaderBuilder.build(); assertArrayEquals(HashUtil.EMPTY_TRIE_HASH, header.getTxTrieRoot()); }
|
public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
@Test public void eth_mining() { Ethereum ethMock = Web3Mocks.getMockEthereum(); Blockchain blockchain = Web3Mocks.getMockBlockchain(); BlockStore blockStore = Web3Mocks.getMockBlockStore(); RskSystemProperties mockProperties = Web3Mocks.getMockProperties(); MinerClient minerClient = new SimpleMinerClient(); PersonalModule personalModule = new PersonalModuleWalletDisabled(); TxPoolModule txPoolModule = new TxPoolModuleImpl(Web3Mocks.getMockTransactionPool()); DebugModule debugModule = new DebugModuleImpl(null, null, Web3Mocks.getMockMessageHandler(), null); Web3 web3 = new Web3Impl( ethMock, blockchain, blockStore, null, mockProperties, minerClient, null, personalModule, null, null, txPoolModule, null, debugModule, null, null, Web3Mocks.getMockChannelManager(), null, null, null, null, null, null, null, mock(Web3InformationRetriever.class)); assertTrue("Node is not mining", !web3.eth_mining()); try { minerClient.start(); assertTrue("Node is mining", web3.eth_mining()); } finally { minerClient.stop(); } assertTrue("Node is not mining", !web3.eth_mining()); }
|
@Override public boolean eth_mining() { Boolean s = null; try { return s = minerClient.isMining(); } finally { if (logger.isDebugEnabled()) { logger.debug("eth_mining(): {}", s); } } }
|
Web3Impl implements Web3 { @Override public boolean eth_mining() { Boolean s = null; try { return s = minerClient.isMining(); } finally { if (logger.isDebugEnabled()) { logger.debug("eth_mining(): {}", s); } } } }
|
Web3Impl implements Web3 { @Override public boolean eth_mining() { Boolean s = null; try { return s = minerClient.isMining(); } finally { if (logger.isDebugEnabled()) { logger.debug("eth_mining(): {}", s); } } } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); }
|
Web3Impl implements Web3 { @Override public boolean eth_mining() { Boolean s = null; try { return s = minerClient.isMining(); } finally { if (logger.isDebugEnabled()) { logger.debug("eth_mining(): {}", s); } } } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); }
|
Web3Impl implements Web3 { @Override public boolean eth_mining() { Boolean s = null; try { return s = minerClient.isMining(); } finally { if (logger.isDebugEnabled()) { logger.debug("eth_mining(): {}", s); } } } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); public Ethereum eth; }
|
@Test public void createsHeaderWithEmptyReceiptTrieRoot() { BlockHeader header = blockHeaderBuilder.build(); assertArrayEquals(HashUtil.EMPTY_TRIE_HASH, header.getReceiptsRoot()); }
|
public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
@Test public void createsHeaderWithEmptyLogsBloom() { BlockHeader header = blockHeaderBuilder.build(); assertArrayEquals(new Bloom().getData(), header.getLogsBloom()); }
|
public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
@Test public void createsHeaderWithEmptyPaidFees() { BlockHeader header = blockHeaderBuilder.build(); assertEquals(Coin.valueOf(0), header.getPaidFees()); }
|
public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
@Test public void createsHeaderWithEmptyMinimumGasPrice() { BlockHeader header = blockHeaderBuilder.build(); assertEquals(Coin.valueOf(0), header.getMinimumGasPrice()); }
|
public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
@Test public void createsHeaderWithEmptyMergedMiningFields() { BlockHeader header = blockHeaderBuilder.build(); assertTrue(Arrays.equals(new byte[0], header.getBitcoinMergedMiningMerkleProof())); assertTrue(Arrays.equals(new byte[0], header.getBitcoinMergedMiningHeader())); assertTrue(Arrays.equals(new byte[0], header.getBitcoinMergedMiningCoinbaseTransaction())); assertTrue(Arrays.equals(new byte[0], header.getExtraData())); }
|
public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
@Test public void createsHeaderWithEmptyUmmRootAndRskipUmmOn() { BlockHeader header = blockHeaderBuilder.build(); assertArrayEquals(new byte[0], header.getUmmRoot()); }
|
public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
@Test public void createsHeaderWithEmptyUmmRootAndRskipUmmOff() { BlockHeaderBuilder builder = new BlockHeaderBuilder(ActivationConfigsForTest.allBut(ConsensusRule.RSKIPUMM)); BlockHeader header = builder.build(); assertNull(header.getUmmRoot()); }
|
public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createUmmCompliantHeader) { if (activationConfig.isActive(ConsensusRule.RSKIPUMM, number)) { if (ummRoot == null) { ummRoot = new byte[0]; } } } return new BlockHeader( parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, receiptTrieRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, paidFees, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof, bitcoinMergedMiningCoinbaseTransaction, mergedMiningForkDetectionData, minimumGasPrice, uncleCount, false, useRskip92Encoding, includeForkDetectionData, ummRoot ); } BlockHeaderBuilder(ActivationConfig activationConfig); BlockHeaderBuilder setCreateConsensusCompliantHeader(boolean createConsensusCompliantHeader); BlockHeaderBuilder setCreateUmmCompliantHeader(boolean createUmmCompliantHeader); BlockHeaderBuilder setStateRoot(byte[] stateRoot); BlockHeaderBuilder setDifficulty(BlockDifficulty difficulty); BlockHeaderBuilder setPaidFees(Coin paidFees); BlockHeaderBuilder setGasUsed(long gasUsed); BlockHeaderBuilder setLogsBloom(byte[] logsBloom); BlockHeaderBuilder setBitcoinMergedMiningHeader(byte[] bitcoinMergedMiningHeader); BlockHeaderBuilder setBitcoinMergedMiningMerkleProof(byte[] bitcoinMergedMiningMerkleProof); BlockHeaderBuilder setBitcoinMergedMiningCoinbaseTransaction(byte[] bitcoinMergedMiningCoinbaseTransaction); BlockHeaderBuilder setTxTrieRoot(byte[] txTrieRoot); BlockHeaderBuilder setEmptyTxTrieRoot(); BlockHeaderBuilder setReceiptTrieRoot(byte[] receiptTrieRoot); BlockHeaderBuilder setTimestamp(long timestamp); BlockHeaderBuilder setNumber(long number); BlockHeaderBuilder setGasLimit(byte[] gasLimit); BlockHeaderBuilder setExtraData(byte[] extraData); BlockHeaderBuilder setMergedMiningForkDetectionData(byte[] mergedMiningForkDetectionData); BlockHeaderBuilder setMinimumGasPrice(Coin minimumGasPrice); BlockHeaderBuilder setUncleCount(int uncleCount); BlockHeaderBuilder setUseRskip92Encoding(boolean useRskip92Encoding); BlockHeaderBuilder setIncludeForkDetectionData(boolean includeForkDetectionData); BlockHeaderBuilder setParentHashFromKeccak256(Keccak256 parentHash); BlockHeaderBuilder setParentHash(byte[] parentHash); BlockHeaderBuilder setEmptyUnclesHash(); BlockHeaderBuilder setUnclesHash(byte[] unclesHash); BlockHeaderBuilder setCoinbase(RskAddress coinbase); BlockHeaderBuilder setDifficultyFromBytes(@Nullable byte[] data); BlockHeaderBuilder setEmptyMergedMiningForkDetectionData(); BlockHeaderBuilder setEmptyExtraData(); BlockHeaderBuilder setEmptyLogsBloom(); BlockHeaderBuilder setEmptyStateRoot(); BlockHeaderBuilder setEmptyReceiptTrieRoot(); BlockHeaderBuilder setUmmRoot(byte[] ummRoot); BlockHeader build(); }
|
@Test public void getEmptyTransactionList() { TransactionSet txset = new TransactionSet(); List<Transaction> result = txset.getTransactions(); Assert.assertNotNull(result); Assert.assertTrue(result.isEmpty()); }
|
public List<Transaction> getTransactions() { return transactionsByHash.values().stream() .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); }
|
TransactionSet { public List<Transaction> getTransactions() { return transactionsByHash.values().stream() .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); } }
|
TransactionSet { public List<Transaction> getTransactions() { return transactionsByHash.values().stream() .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transaction> transactionsByHash, Map<RskAddress, List<Transaction>> transactionsByAddress); }
|
TransactionSet { public List<Transaction> getTransactions() { return transactionsByHash.values().stream() .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transaction> transactionsByHash, Map<RskAddress, List<Transaction>> transactionsByAddress); void addTransaction(Transaction transaction); boolean hasTransaction(Transaction transaction); void removeTransactionByHash(Keccak256 hash); List<Transaction> getTransactions(); List<Transaction> getTransactionsWithSender(RskAddress senderAddress); }
|
TransactionSet { public List<Transaction> getTransactions() { return transactionsByHash.values().stream() .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transaction> transactionsByHash, Map<RskAddress, List<Transaction>> transactionsByAddress); void addTransaction(Transaction transaction); boolean hasTransaction(Transaction transaction); void removeTransactionByHash(Keccak256 hash); List<Transaction> getTransactions(); List<Transaction> getTransactionsWithSender(RskAddress senderAddress); }
|
@Test public void hasTransaction() { TransactionSet txset = new TransactionSet(); Transaction transaction1 = createSampleTransaction(10); Transaction transaction2 = createSampleTransaction(20); Transaction transaction3 = createSampleTransaction(30); txset.addTransaction(transaction1); txset.addTransaction(transaction2); Assert.assertTrue(txset.hasTransaction(transaction1)); Assert.assertTrue(txset.hasTransaction(transaction2)); Assert.assertFalse(txset.hasTransaction(transaction3)); }
|
public boolean hasTransaction(Transaction transaction) { return this.transactionsByHash.containsKey(transaction.getHash()); }
|
TransactionSet { public boolean hasTransaction(Transaction transaction) { return this.transactionsByHash.containsKey(transaction.getHash()); } }
|
TransactionSet { public boolean hasTransaction(Transaction transaction) { return this.transactionsByHash.containsKey(transaction.getHash()); } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transaction> transactionsByHash, Map<RskAddress, List<Transaction>> transactionsByAddress); }
|
TransactionSet { public boolean hasTransaction(Transaction transaction) { return this.transactionsByHash.containsKey(transaction.getHash()); } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transaction> transactionsByHash, Map<RskAddress, List<Transaction>> transactionsByAddress); void addTransaction(Transaction transaction); boolean hasTransaction(Transaction transaction); void removeTransactionByHash(Keccak256 hash); List<Transaction> getTransactions(); List<Transaction> getTransactionsWithSender(RskAddress senderAddress); }
|
TransactionSet { public boolean hasTransaction(Transaction transaction) { return this.transactionsByHash.containsKey(transaction.getHash()); } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transaction> transactionsByHash, Map<RskAddress, List<Transaction>> transactionsByAddress); void addTransaction(Transaction transaction); boolean hasTransaction(Transaction transaction); void removeTransactionByHash(Keccak256 hash); List<Transaction> getTransactions(); List<Transaction> getTransactionsWithSender(RskAddress senderAddress); }
|
@Test public void getEmptyTransactionListByUnknownSender() { TransactionSet txset = new TransactionSet(); List<Transaction> result = txset.getTransactionsWithSender(new RskAddress(new byte[20])); Assert.assertNotNull(result); Assert.assertTrue(result.isEmpty()); }
|
public List<Transaction> getTransactionsWithSender(RskAddress senderAddress) { List<Transaction> list = this.transactionsByAddress.get(senderAddress); if (list == null) { return Collections.emptyList(); } return list; }
|
TransactionSet { public List<Transaction> getTransactionsWithSender(RskAddress senderAddress) { List<Transaction> list = this.transactionsByAddress.get(senderAddress); if (list == null) { return Collections.emptyList(); } return list; } }
|
TransactionSet { public List<Transaction> getTransactionsWithSender(RskAddress senderAddress) { List<Transaction> list = this.transactionsByAddress.get(senderAddress); if (list == null) { return Collections.emptyList(); } return list; } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transaction> transactionsByHash, Map<RskAddress, List<Transaction>> transactionsByAddress); }
|
TransactionSet { public List<Transaction> getTransactionsWithSender(RskAddress senderAddress) { List<Transaction> list = this.transactionsByAddress.get(senderAddress); if (list == null) { return Collections.emptyList(); } return list; } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transaction> transactionsByHash, Map<RskAddress, List<Transaction>> transactionsByAddress); void addTransaction(Transaction transaction); boolean hasTransaction(Transaction transaction); void removeTransactionByHash(Keccak256 hash); List<Transaction> getTransactions(); List<Transaction> getTransactionsWithSender(RskAddress senderAddress); }
|
TransactionSet { public List<Transaction> getTransactionsWithSender(RskAddress senderAddress) { List<Transaction> list = this.transactionsByAddress.get(senderAddress); if (list == null) { return Collections.emptyList(); } return list; } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transaction> transactionsByHash, Map<RskAddress, List<Transaction>> transactionsByAddress); void addTransaction(Transaction transaction); boolean hasTransaction(Transaction transaction); void removeTransactionByHash(Keccak256 hash); List<Transaction> getTransactions(); List<Transaction> getTransactionsWithSender(RskAddress senderAddress); }
|
@Test public void getGasPrice() { Web3Impl web3 = createWeb3(); web3.eth = new SimpleEthereum(); String expectedValue = ByteUtil.toHexString(new BigInteger("20000000000").toByteArray()); expectedValue = "0x" + (expectedValue.startsWith("0") ? expectedValue.substring(1) : expectedValue); org.junit.Assert.assertEquals(expectedValue, web3.eth_gasPrice()); }
|
@Override public String eth_gasPrice() { String gasPrice = null; try { gasPrice = TypeConverter.toQuantityJsonHex(eth.getGasPrice().asBigInteger().longValue()); return gasPrice; } finally { if (logger.isDebugEnabled()) { logger.debug("eth_gasPrice(): {}", gasPrice); } } }
|
Web3Impl implements Web3 { @Override public String eth_gasPrice() { String gasPrice = null; try { gasPrice = TypeConverter.toQuantityJsonHex(eth.getGasPrice().asBigInteger().longValue()); return gasPrice; } finally { if (logger.isDebugEnabled()) { logger.debug("eth_gasPrice(): {}", gasPrice); } } } }
|
Web3Impl implements Web3 { @Override public String eth_gasPrice() { String gasPrice = null; try { gasPrice = TypeConverter.toQuantityJsonHex(eth.getGasPrice().asBigInteger().longValue()); return gasPrice; } finally { if (logger.isDebugEnabled()) { logger.debug("eth_gasPrice(): {}", gasPrice); } } } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); }
|
Web3Impl implements Web3 { @Override public String eth_gasPrice() { String gasPrice = null; try { gasPrice = TypeConverter.toQuantityJsonHex(eth.getGasPrice().asBigInteger().longValue()); return gasPrice; } finally { if (logger.isDebugEnabled()) { logger.debug("eth_gasPrice(): {}", gasPrice); } } } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); }
|
Web3Impl implements Web3 { @Override public String eth_gasPrice() { String gasPrice = null; try { gasPrice = TypeConverter.toQuantityJsonHex(eth.getGasPrice().asBigInteger().longValue()); return gasPrice; } finally { if (logger.isDebugEnabled()) { logger.debug("eth_gasPrice(): {}", gasPrice); } } } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); public Ethereum eth; }
|
@Ignore @Test public void encodeReceiptTest() { String data = "f90244a0f5ff3fbd159773816a7c707a9b8cb6bb778b934a8f6466c7830ed970498f4b688301e848b902000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dbda94cd2a3d9f938e13cd947ec05abc7fe734df8dd826c083a1a1a1"; byte[] stateRoot = Hex.decode("f5ff3fbd159773816a7c707a9b8cb6bb778b934a8f6466c7830ed970498f4b68"); byte[] gasUsed = Hex.decode("01E848"); Bloom bloom = new Bloom(Hex.decode("0000000000000000800000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")); LogInfo logInfo1 = new LogInfo( Hex.decode("cd2a3d9f938e13cd947ec05abc7fe734df8dd826"), null, Hex.decode("a1a1a1") ); List<LogInfo> logs = new ArrayList<>(); logs.add(logInfo1); TransactionReceipt receipt = new TransactionReceipt(stateRoot, gasUsed, gasUsed, bloom, logs, TransactionReceipt.SUCCESS_STATUS); assertEquals(data, ByteUtil.toHexString(receipt.getEncoded())); }
|
public byte[] getEncoded() { if (this.rlpEncoding == null) { byte[] v; byte[] r; byte[] s; if (this.signature != null) { v = RLP.encodeByte((byte) (chainId == 0 ? signature.getV() : (signature.getV() - LOWER_REAL_V) + (chainId * 2 + CHAIN_ID_INC))); r = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.getR())); s = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.getS())); } else { v = chainId == 0 ? RLP.encodeElement(EMPTY_BYTE_ARRAY) : RLP.encodeByte(chainId); r = RLP.encodeElement(EMPTY_BYTE_ARRAY); s = RLP.encodeElement(EMPTY_BYTE_ARRAY); } this.rlpEncoding = encode(v, r, s); } return ByteUtil.cloneBytes(this.rlpEncoding); }
|
Transaction { public byte[] getEncoded() { if (this.rlpEncoding == null) { byte[] v; byte[] r; byte[] s; if (this.signature != null) { v = RLP.encodeByte((byte) (chainId == 0 ? signature.getV() : (signature.getV() - LOWER_REAL_V) + (chainId * 2 + CHAIN_ID_INC))); r = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.getR())); s = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.getS())); } else { v = chainId == 0 ? RLP.encodeElement(EMPTY_BYTE_ARRAY) : RLP.encodeByte(chainId); r = RLP.encodeElement(EMPTY_BYTE_ARRAY); s = RLP.encodeElement(EMPTY_BYTE_ARRAY); } this.rlpEncoding = encode(v, r, s); } return ByteUtil.cloneBytes(this.rlpEncoding); } }
|
Transaction { public byte[] getEncoded() { if (this.rlpEncoding == null) { byte[] v; byte[] r; byte[] s; if (this.signature != null) { v = RLP.encodeByte((byte) (chainId == 0 ? signature.getV() : (signature.getV() - LOWER_REAL_V) + (chainId * 2 + CHAIN_ID_INC))); r = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.getR())); s = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.getS())); } else { v = chainId == 0 ? RLP.encodeElement(EMPTY_BYTE_ARRAY) : RLP.encodeByte(chainId); r = RLP.encodeElement(EMPTY_BYTE_ARRAY); s = RLP.encodeElement(EMPTY_BYTE_ARRAY); } this.rlpEncoding = encode(v, r, s); } return ByteUtil.cloneBytes(this.rlpEncoding); } protected Transaction(byte[] rawData); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data, byte[] r, byte[] s, byte v); Transaction(long nonce, long gasPrice, long gas, String to, long value, byte[] data, byte chainId); Transaction(BigInteger nonce, BigInteger gasPrice, BigInteger gas, String to, BigInteger value, byte[] data,
byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String data, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte[] decodedData, byte chainId); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] valueRaw, byte[] data,
byte chainId); }
|
Transaction { public byte[] getEncoded() { if (this.rlpEncoding == null) { byte[] v; byte[] r; byte[] s; if (this.signature != null) { v = RLP.encodeByte((byte) (chainId == 0 ? signature.getV() : (signature.getV() - LOWER_REAL_V) + (chainId * 2 + CHAIN_ID_INC))); r = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.getR())); s = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.getS())); } else { v = chainId == 0 ? RLP.encodeElement(EMPTY_BYTE_ARRAY) : RLP.encodeByte(chainId); r = RLP.encodeElement(EMPTY_BYTE_ARRAY); s = RLP.encodeElement(EMPTY_BYTE_ARRAY); } this.rlpEncoding = encode(v, r, s); } return ByteUtil.cloneBytes(this.rlpEncoding); } protected Transaction(byte[] rawData); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data, byte[] r, byte[] s, byte v); Transaction(long nonce, long gasPrice, long gas, String to, long value, byte[] data, byte chainId); Transaction(BigInteger nonce, BigInteger gasPrice, BigInteger gas, String to, BigInteger value, byte[] data,
byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String data, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte[] decodedData, byte chainId); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] valueRaw, byte[] data,
byte chainId); Transaction toImmutableTransaction(); long transactionCost(Constants constants, ActivationConfig.ForBlock activations); void verify(); Keccak256 getHash(); Keccak256 getRawHash(); byte[] getNonce(); Coin getValue(); RskAddress getReceiveAddress(); Coin getGasPrice(); byte[] getGasLimit(); byte[] getData(); ECDSASignature getSignature(); boolean acceptTransactionSignature(byte currentChainId); void sign(byte[] privKeyBytes); void setSignature(ECDSASignature signature); void setSignature(ECKey.ECDSASignature signature); @Nullable RskAddress getContractAddress(); boolean isContractCreation(); ECKey getKey(); synchronized RskAddress getSender(); synchronized RskAddress getSender(SignatureCache signatureCache); byte getChainId(); @Override String toString(); byte[] getEncodedRaw(); byte[] getEncoded(); BigInteger getGasLimitAsInteger(); BigInteger getNonceAsInteger(); @Override int hashCode(); @Override boolean equals(Object obj); boolean isLocalCallTransaction(); void setLocalCallTransaction(boolean isLocalCall); boolean isRemascTransaction(int txPosition, int txsSize); }
|
Transaction { public byte[] getEncoded() { if (this.rlpEncoding == null) { byte[] v; byte[] r; byte[] s; if (this.signature != null) { v = RLP.encodeByte((byte) (chainId == 0 ? signature.getV() : (signature.getV() - LOWER_REAL_V) + (chainId * 2 + CHAIN_ID_INC))); r = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.getR())); s = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.getS())); } else { v = chainId == 0 ? RLP.encodeElement(EMPTY_BYTE_ARRAY) : RLP.encodeByte(chainId); r = RLP.encodeElement(EMPTY_BYTE_ARRAY); s = RLP.encodeElement(EMPTY_BYTE_ARRAY); } this.rlpEncoding = encode(v, r, s); } return ByteUtil.cloneBytes(this.rlpEncoding); } protected Transaction(byte[] rawData); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data, byte[] r, byte[] s, byte v); Transaction(long nonce, long gasPrice, long gas, String to, long value, byte[] data, byte chainId); Transaction(BigInteger nonce, BigInteger gasPrice, BigInteger gas, String to, BigInteger value, byte[] data,
byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String data, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte[] decodedData, byte chainId); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] valueRaw, byte[] data,
byte chainId); Transaction toImmutableTransaction(); long transactionCost(Constants constants, ActivationConfig.ForBlock activations); void verify(); Keccak256 getHash(); Keccak256 getRawHash(); byte[] getNonce(); Coin getValue(); RskAddress getReceiveAddress(); Coin getGasPrice(); byte[] getGasLimit(); byte[] getData(); ECDSASignature getSignature(); boolean acceptTransactionSignature(byte currentChainId); void sign(byte[] privKeyBytes); void setSignature(ECDSASignature signature); void setSignature(ECKey.ECDSASignature signature); @Nullable RskAddress getContractAddress(); boolean isContractCreation(); ECKey getKey(); synchronized RskAddress getSender(); synchronized RskAddress getSender(SignatureCache signatureCache); byte getChainId(); @Override String toString(); byte[] getEncodedRaw(); byte[] getEncoded(); BigInteger getGasLimitAsInteger(); BigInteger getNonceAsInteger(); @Override int hashCode(); @Override boolean equals(Object obj); boolean isLocalCallTransaction(); void setLocalCallTransaction(boolean isLocalCall); boolean isRemascTransaction(int txPosition, int txsSize); static final int DATAWORD_LENGTH; }
|
@Test public void verifyTx_noSignature() { BigInteger value = new BigInteger("1000000000000000000000"); byte[] privKey = HashUtil.keccak256("cat".getBytes()); ECKey ecKey = ECKey.fromPrivate(privKey); byte[] gasPrice = Hex.decode("09184e72a000"); byte[] gas = Hex.decode("4255"); Transaction tx = new Transaction(new byte[0], gasPrice, gas, ecKey.getAddress(), value.toByteArray(),null); try { tx.verify(); } catch (Exception e) { fail(e.getMessage()); } }
|
public void verify() { validate(); }
|
Transaction { public void verify() { validate(); } }
|
Transaction { public void verify() { validate(); } protected Transaction(byte[] rawData); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data, byte[] r, byte[] s, byte v); Transaction(long nonce, long gasPrice, long gas, String to, long value, byte[] data, byte chainId); Transaction(BigInteger nonce, BigInteger gasPrice, BigInteger gas, String to, BigInteger value, byte[] data,
byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String data, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte[] decodedData, byte chainId); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] valueRaw, byte[] data,
byte chainId); }
|
Transaction { public void verify() { validate(); } protected Transaction(byte[] rawData); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data, byte[] r, byte[] s, byte v); Transaction(long nonce, long gasPrice, long gas, String to, long value, byte[] data, byte chainId); Transaction(BigInteger nonce, BigInteger gasPrice, BigInteger gas, String to, BigInteger value, byte[] data,
byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String data, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte[] decodedData, byte chainId); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] valueRaw, byte[] data,
byte chainId); Transaction toImmutableTransaction(); long transactionCost(Constants constants, ActivationConfig.ForBlock activations); void verify(); Keccak256 getHash(); Keccak256 getRawHash(); byte[] getNonce(); Coin getValue(); RskAddress getReceiveAddress(); Coin getGasPrice(); byte[] getGasLimit(); byte[] getData(); ECDSASignature getSignature(); boolean acceptTransactionSignature(byte currentChainId); void sign(byte[] privKeyBytes); void setSignature(ECDSASignature signature); void setSignature(ECKey.ECDSASignature signature); @Nullable RskAddress getContractAddress(); boolean isContractCreation(); ECKey getKey(); synchronized RskAddress getSender(); synchronized RskAddress getSender(SignatureCache signatureCache); byte getChainId(); @Override String toString(); byte[] getEncodedRaw(); byte[] getEncoded(); BigInteger getGasLimitAsInteger(); BigInteger getNonceAsInteger(); @Override int hashCode(); @Override boolean equals(Object obj); boolean isLocalCallTransaction(); void setLocalCallTransaction(boolean isLocalCall); boolean isRemascTransaction(int txPosition, int txsSize); }
|
Transaction { public void verify() { validate(); } protected Transaction(byte[] rawData); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data, byte[] r, byte[] s, byte v); Transaction(long nonce, long gasPrice, long gas, String to, long value, byte[] data, byte chainId); Transaction(BigInteger nonce, BigInteger gasPrice, BigInteger gas, String to, BigInteger value, byte[] data,
byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String data, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte[] decodedData, byte chainId); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] valueRaw, byte[] data,
byte chainId); Transaction toImmutableTransaction(); long transactionCost(Constants constants, ActivationConfig.ForBlock activations); void verify(); Keccak256 getHash(); Keccak256 getRawHash(); byte[] getNonce(); Coin getValue(); RskAddress getReceiveAddress(); Coin getGasPrice(); byte[] getGasLimit(); byte[] getData(); ECDSASignature getSignature(); boolean acceptTransactionSignature(byte currentChainId); void sign(byte[] privKeyBytes); void setSignature(ECDSASignature signature); void setSignature(ECKey.ECDSASignature signature); @Nullable RskAddress getContractAddress(); boolean isContractCreation(); ECKey getKey(); synchronized RskAddress getSender(); synchronized RskAddress getSender(SignatureCache signatureCache); byte getChainId(); @Override String toString(); byte[] getEncodedRaw(); byte[] getEncoded(); BigInteger getGasLimitAsInteger(); BigInteger getNonceAsInteger(); @Override int hashCode(); @Override boolean equals(Object obj); boolean isLocalCallTransaction(); void setLocalCallTransaction(boolean isLocalCall); boolean isRemascTransaction(int txPosition, int txsSize); static final int DATAWORD_LENGTH; }
|
@Test public void toString_nullElements() { byte[] encodedNull = RLP.encodeElement(null); byte[] encodedEmptyArray = RLP.encodeElement(EMPTY_BYTE_ARRAY); byte[] rawData = RLP.encodeList(encodedNull, encodedNull, encodedNull, encodedNull, encodedNull, encodedNull, encodedEmptyArray, encodedEmptyArray, encodedEmptyArray); Transaction tx = new ImmutableTransaction(rawData); try { tx.toString(); } catch (Exception e) { fail(e.getMessage()); } }
|
@Override public String toString() { return "TransactionData [" + "hash=" + ByteUtil.toHexStringOrEmpty(getHash().getBytes()) + " nonce=" + ByteUtil.toHexStringOrEmpty(nonce) + ", gasPrice=" + gasPrice + ", gas=" + ByteUtil.toHexStringOrEmpty(gasLimit) + ", receiveAddress=" + receiveAddress + ", value=" + value + ", data=" + ByteUtil.toHexStringOrEmpty(data) + ", signatureV=" + (signature == null ? "" : signature.getV()) + ", signatureR=" + (signature == null ? "" : ByteUtil.toHexStringOrEmpty(BigIntegers.asUnsignedByteArray(signature.getR()))) + ", signatureS=" + (signature == null ? "" : ByteUtil.toHexStringOrEmpty(BigIntegers.asUnsignedByteArray(signature.getS()))) + "]"; }
|
Transaction { @Override public String toString() { return "TransactionData [" + "hash=" + ByteUtil.toHexStringOrEmpty(getHash().getBytes()) + " nonce=" + ByteUtil.toHexStringOrEmpty(nonce) + ", gasPrice=" + gasPrice + ", gas=" + ByteUtil.toHexStringOrEmpty(gasLimit) + ", receiveAddress=" + receiveAddress + ", value=" + value + ", data=" + ByteUtil.toHexStringOrEmpty(data) + ", signatureV=" + (signature == null ? "" : signature.getV()) + ", signatureR=" + (signature == null ? "" : ByteUtil.toHexStringOrEmpty(BigIntegers.asUnsignedByteArray(signature.getR()))) + ", signatureS=" + (signature == null ? "" : ByteUtil.toHexStringOrEmpty(BigIntegers.asUnsignedByteArray(signature.getS()))) + "]"; } }
|
Transaction { @Override public String toString() { return "TransactionData [" + "hash=" + ByteUtil.toHexStringOrEmpty(getHash().getBytes()) + " nonce=" + ByteUtil.toHexStringOrEmpty(nonce) + ", gasPrice=" + gasPrice + ", gas=" + ByteUtil.toHexStringOrEmpty(gasLimit) + ", receiveAddress=" + receiveAddress + ", value=" + value + ", data=" + ByteUtil.toHexStringOrEmpty(data) + ", signatureV=" + (signature == null ? "" : signature.getV()) + ", signatureR=" + (signature == null ? "" : ByteUtil.toHexStringOrEmpty(BigIntegers.asUnsignedByteArray(signature.getR()))) + ", signatureS=" + (signature == null ? "" : ByteUtil.toHexStringOrEmpty(BigIntegers.asUnsignedByteArray(signature.getS()))) + "]"; } protected Transaction(byte[] rawData); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data, byte[] r, byte[] s, byte v); Transaction(long nonce, long gasPrice, long gas, String to, long value, byte[] data, byte chainId); Transaction(BigInteger nonce, BigInteger gasPrice, BigInteger gas, String to, BigInteger value, byte[] data,
byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String data, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte[] decodedData, byte chainId); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] valueRaw, byte[] data,
byte chainId); }
|
Transaction { @Override public String toString() { return "TransactionData [" + "hash=" + ByteUtil.toHexStringOrEmpty(getHash().getBytes()) + " nonce=" + ByteUtil.toHexStringOrEmpty(nonce) + ", gasPrice=" + gasPrice + ", gas=" + ByteUtil.toHexStringOrEmpty(gasLimit) + ", receiveAddress=" + receiveAddress + ", value=" + value + ", data=" + ByteUtil.toHexStringOrEmpty(data) + ", signatureV=" + (signature == null ? "" : signature.getV()) + ", signatureR=" + (signature == null ? "" : ByteUtil.toHexStringOrEmpty(BigIntegers.asUnsignedByteArray(signature.getR()))) + ", signatureS=" + (signature == null ? "" : ByteUtil.toHexStringOrEmpty(BigIntegers.asUnsignedByteArray(signature.getS()))) + "]"; } protected Transaction(byte[] rawData); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data, byte[] r, byte[] s, byte v); Transaction(long nonce, long gasPrice, long gas, String to, long value, byte[] data, byte chainId); Transaction(BigInteger nonce, BigInteger gasPrice, BigInteger gas, String to, BigInteger value, byte[] data,
byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String data, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte[] decodedData, byte chainId); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] valueRaw, byte[] data,
byte chainId); Transaction toImmutableTransaction(); long transactionCost(Constants constants, ActivationConfig.ForBlock activations); void verify(); Keccak256 getHash(); Keccak256 getRawHash(); byte[] getNonce(); Coin getValue(); RskAddress getReceiveAddress(); Coin getGasPrice(); byte[] getGasLimit(); byte[] getData(); ECDSASignature getSignature(); boolean acceptTransactionSignature(byte currentChainId); void sign(byte[] privKeyBytes); void setSignature(ECDSASignature signature); void setSignature(ECKey.ECDSASignature signature); @Nullable RskAddress getContractAddress(); boolean isContractCreation(); ECKey getKey(); synchronized RskAddress getSender(); synchronized RskAddress getSender(SignatureCache signatureCache); byte getChainId(); @Override String toString(); byte[] getEncodedRaw(); byte[] getEncoded(); BigInteger getGasLimitAsInteger(); BigInteger getNonceAsInteger(); @Override int hashCode(); @Override boolean equals(Object obj); boolean isLocalCallTransaction(); void setLocalCallTransaction(boolean isLocalCall); boolean isRemascTransaction(int txPosition, int txsSize); }
|
Transaction { @Override public String toString() { return "TransactionData [" + "hash=" + ByteUtil.toHexStringOrEmpty(getHash().getBytes()) + " nonce=" + ByteUtil.toHexStringOrEmpty(nonce) + ", gasPrice=" + gasPrice + ", gas=" + ByteUtil.toHexStringOrEmpty(gasLimit) + ", receiveAddress=" + receiveAddress + ", value=" + value + ", data=" + ByteUtil.toHexStringOrEmpty(data) + ", signatureV=" + (signature == null ? "" : signature.getV()) + ", signatureR=" + (signature == null ? "" : ByteUtil.toHexStringOrEmpty(BigIntegers.asUnsignedByteArray(signature.getR()))) + ", signatureS=" + (signature == null ? "" : ByteUtil.toHexStringOrEmpty(BigIntegers.asUnsignedByteArray(signature.getS()))) + "]"; } protected Transaction(byte[] rawData); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data, byte[] r, byte[] s, byte v); Transaction(long nonce, long gasPrice, long gas, String to, long value, byte[] data, byte chainId); Transaction(BigInteger nonce, BigInteger gasPrice, BigInteger gas, String to, BigInteger value, byte[] data,
byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String data, byte chainId); Transaction(String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte[] decodedData, byte chainId); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] valueRaw, byte[] data,
byte chainId); Transaction toImmutableTransaction(); long transactionCost(Constants constants, ActivationConfig.ForBlock activations); void verify(); Keccak256 getHash(); Keccak256 getRawHash(); byte[] getNonce(); Coin getValue(); RskAddress getReceiveAddress(); Coin getGasPrice(); byte[] getGasLimit(); byte[] getData(); ECDSASignature getSignature(); boolean acceptTransactionSignature(byte currentChainId); void sign(byte[] privKeyBytes); void setSignature(ECDSASignature signature); void setSignature(ECKey.ECDSASignature signature); @Nullable RskAddress getContractAddress(); boolean isContractCreation(); ECKey getKey(); synchronized RskAddress getSender(); synchronized RskAddress getSender(SignatureCache signatureCache); byte getChainId(); @Override String toString(); byte[] getEncodedRaw(); byte[] getEncoded(); BigInteger getGasLimitAsInteger(); BigInteger getNonceAsInteger(); @Override int hashCode(); @Override boolean equals(Object obj); boolean isLocalCallTransaction(); void setLocalCallTransaction(boolean isLocalCall); boolean isRemascTransaction(int txPosition, int txsSize); static final int DATAWORD_LENGTH; }
|
@Test public void testGetEncoded() { String expected = "dc809a0100000000000000000000000000000000000000000000000000"; AccountState acct = new AccountState(BigInteger.ZERO, new Coin(BigInteger.valueOf(2).pow(200))); assertEquals(expected, ByteUtil.toHexString(acct.getEncoded())); }
|
public byte[] getEncoded() { if (rlpEncoded == null) { byte[] anonce = RLP.encodeBigInteger(this.nonce); byte[] abalance = RLP.encodeSignedCoinNonNullZero(this.balance); if (stateFlags != 0) { byte[] astateFlags = RLP.encodeInt(this.stateFlags); this.rlpEncoded = RLP.encodeList(anonce, abalance, astateFlags); } else { this.rlpEncoded = RLP.encodeList(anonce, abalance); } } return rlpEncoded; }
|
AccountState { public byte[] getEncoded() { if (rlpEncoded == null) { byte[] anonce = RLP.encodeBigInteger(this.nonce); byte[] abalance = RLP.encodeSignedCoinNonNullZero(this.balance); if (stateFlags != 0) { byte[] astateFlags = RLP.encodeInt(this.stateFlags); this.rlpEncoded = RLP.encodeList(anonce, abalance, astateFlags); } else { this.rlpEncoded = RLP.encodeList(anonce, abalance); } } return rlpEncoded; } }
|
AccountState { public byte[] getEncoded() { if (rlpEncoded == null) { byte[] anonce = RLP.encodeBigInteger(this.nonce); byte[] abalance = RLP.encodeSignedCoinNonNullZero(this.balance); if (stateFlags != 0) { byte[] astateFlags = RLP.encodeInt(this.stateFlags); this.rlpEncoded = RLP.encodeList(anonce, abalance, astateFlags); } else { this.rlpEncoded = RLP.encodeList(anonce, abalance); } } return rlpEncoded; } AccountState(); AccountState(BigInteger nonce, Coin balance); AccountState(byte[] rlpData); }
|
AccountState { public byte[] getEncoded() { if (rlpEncoded == null) { byte[] anonce = RLP.encodeBigInteger(this.nonce); byte[] abalance = RLP.encodeSignedCoinNonNullZero(this.balance); if (stateFlags != 0) { byte[] astateFlags = RLP.encodeInt(this.stateFlags); this.rlpEncoded = RLP.encodeList(anonce, abalance, astateFlags); } else { this.rlpEncoded = RLP.encodeList(anonce, abalance); } } return rlpEncoded; } AccountState(); AccountState(BigInteger nonce, Coin balance); AccountState(byte[] rlpData); BigInteger getNonce(); void setNonce(BigInteger nonce); void incrementNonce(); Coin getBalance(); Coin addToBalance(Coin value); byte[] getEncoded(); void setDeleted(boolean deleted); boolean isDeleted(); AccountState clone(); String toString(); int getStateFlags(); void setStateFlags(int s); Boolean isHibernated(); void hibernate(); void wakeUp(); }
|
AccountState { public byte[] getEncoded() { if (rlpEncoded == null) { byte[] anonce = RLP.encodeBigInteger(this.nonce); byte[] abalance = RLP.encodeSignedCoinNonNullZero(this.balance); if (stateFlags != 0) { byte[] astateFlags = RLP.encodeInt(this.stateFlags); this.rlpEncoded = RLP.encodeList(anonce, abalance, astateFlags); } else { this.rlpEncoded = RLP.encodeList(anonce, abalance); } } return rlpEncoded; } AccountState(); AccountState(BigInteger nonce, Coin balance); AccountState(byte[] rlpData); BigInteger getNonce(); void setNonce(BigInteger nonce); void incrementNonce(); Coin getBalance(); Coin addToBalance(Coin value); byte[] getEncoded(); void setDeleted(boolean deleted); boolean isDeleted(); AccountState clone(); String toString(); int getStateFlags(); void setStateFlags(int s); Boolean isHibernated(); void hibernate(); void wakeUp(); }
|
@Ignore @Test public void parentDifficultyLessHeaderDifficulty() { BlockHeader header = getHeader(10004); BlockHeader parent = getHeader(10000); assertTrue(rule.validate(header, parent)); }
|
@Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error("#{}: difficulty != calcDifficulty", header.getNumber()); return false; } return true; }
|
DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error("#{}: difficulty != calcDifficulty", header.getNumber()); return false; } return true; } }
|
DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error("#{}: difficulty != calcDifficulty", header.getNumber()); return false; } return true; } DifficultyRule(DifficultyCalculator difficultyCalculator); }
|
DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error("#{}: difficulty != calcDifficulty", header.getNumber()); return false; } return true; } DifficultyRule(DifficultyCalculator difficultyCalculator); @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error("#{}: difficulty != calcDifficulty", header.getNumber()); return false; } return true; } DifficultyRule(DifficultyCalculator difficultyCalculator); @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
@Test public void parentDifficultyEqualHeaderDifficulty() { BlockHeader header = getHeader(10000); BlockHeader parent = getHeader(10000); assertFalse(rule.validate(header, parent)); }
|
@Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error("#{}: difficulty != calcDifficulty", header.getNumber()); return false; } return true; }
|
DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error("#{}: difficulty != calcDifficulty", header.getNumber()); return false; } return true; } }
|
DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error("#{}: difficulty != calcDifficulty", header.getNumber()); return false; } return true; } DifficultyRule(DifficultyCalculator difficultyCalculator); }
|
DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error("#{}: difficulty != calcDifficulty", header.getNumber()); return false; } return true; } DifficultyRule(DifficultyCalculator difficultyCalculator); @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error("#{}: difficulty != calcDifficulty", header.getNumber()); return false; } return true; } DifficultyRule(DifficultyCalculator difficultyCalculator); @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
@Test public void parentNumberEqualBlockNumberMinusOne() { BlockHeader header = getHeader(10000); BlockHeader parent = getHeader(9999); assertTrue(rule.validate(header, parent)); }
|
@Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; }
|
ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } }
|
ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } }
|
ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
@Test public void parentNumberEqualBlockNumber() { BlockHeader header = getHeader(100); BlockHeader parent = getHeader(100); assertFalse(rule.validate(header, parent)); }
|
@Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; }
|
ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } }
|
ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } }
|
ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
@Test public void parentNumberGreaterThanBlockNumber() { BlockHeader header = getHeader(100); BlockHeader parent = getHeader(101); assertFalse(rule.validate(header, parent)); }
|
@Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; }
|
ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } }
|
ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } }
|
ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
@Test public void parentGasLimitLessThanGasLimit() { BlockHeader header = getHeader(10000); BlockHeader parent = getHeader(9999); assertTrue(rule.validate(header, parent)); }
|
@Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } ParentGasLimitRule(int gasLimitBoundDivisor); }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } ParentGasLimitRule(int gasLimitBoundDivisor); @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } ParentGasLimitRule(int gasLimitBoundDivisor); @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
@Test public void getUnknownTransactionReceipt() throws Exception { ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB()); World world = new World(receiptStore); Web3Impl web3 = createWeb3(world, receiptStore); Account acc1 = new AccountBuilder().name("acc1").build(); Account acc2 = new AccountBuilder().name("acc2").build(); Transaction tx = new TransactionBuilder().sender(acc1).receiver(acc2).value(BigInteger.valueOf(1000000)).build(); String hashString = tx.getHash().toHexString(); Assert.assertNull(web3.eth_getTransactionReceipt(hashString)); Assert.assertNull(web3.rsk_getRawTransactionReceiptByHash(hashString)); }
|
@Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No transaction info for {}", transactionHash); return null; } Block block = blockStore.getBlockByHash(txInfo.getBlockHash()); Transaction tx = block.getTransactionsList().get(txInfo.getIndex()); txInfo.setTransaction(tx); return new TransactionReceiptDTO(block, txInfo); }
|
Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No transaction info for {}", transactionHash); return null; } Block block = blockStore.getBlockByHash(txInfo.getBlockHash()); Transaction tx = block.getTransactionsList().get(txInfo.getIndex()); txInfo.setTransaction(tx); return new TransactionReceiptDTO(block, txInfo); } }
|
Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No transaction info for {}", transactionHash); return null; } Block block = blockStore.getBlockByHash(txInfo.getBlockHash()); Transaction tx = block.getTransactionsList().get(txInfo.getIndex()); txInfo.setTransaction(tx); return new TransactionReceiptDTO(block, txInfo); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); }
|
Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No transaction info for {}", transactionHash); return null; } Block block = blockStore.getBlockByHash(txInfo.getBlockHash()); Transaction tx = block.getTransactionsList().get(txInfo.getIndex()); txInfo.setTransaction(tx); return new TransactionReceiptDTO(block, txInfo); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); }
|
Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No transaction info for {}", transactionHash); return null; } Block block = blockStore.getBlockByHash(txInfo.getBlockHash()); Transaction tx = block.getTransactionsList().get(txInfo.getIndex()); txInfo.setTransaction(tx); return new TransactionReceiptDTO(block, txInfo); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); public Ethereum eth; }
|
@Test public void parentGasLimitTooLessThanGasLimit() { BlockHeader header = getHeader(100); BlockHeader parent = getHeader(9); assertFalse(rule.validate(header, parent)); }
|
@Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } ParentGasLimitRule(int gasLimitBoundDivisor); }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } ParentGasLimitRule(int gasLimitBoundDivisor); @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } ParentGasLimitRule(int gasLimitBoundDivisor); @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
@Test public void parentGasLimitGreaterThanGasLimit() { BlockHeader header = getHeader(10000); BlockHeader parent = getHeader(10001); assertTrue(rule.validate(header, parent)); }
|
@Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } ParentGasLimitRule(int gasLimitBoundDivisor); }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } ParentGasLimitRule(int gasLimitBoundDivisor); @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } ParentGasLimitRule(int gasLimitBoundDivisor); @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
@Test public void parentGasLimitTooGreaterThanGasLimit() { BlockHeader header = getHeader(9); BlockHeader parent = getHeader(100); assertFalse(rule.validate(header, parent)); }
|
@Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } ParentGasLimitRule(int gasLimitBoundDivisor); }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } ParentGasLimitRule(int gasLimitBoundDivisor); @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } ParentGasLimitRule(int gasLimitBoundDivisor); @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
@Test public void parentGasLimitOfBy1Tests() { BlockHeader parent = getHeader(2049); BlockHeader headerGGood = getHeader(2051); BlockHeader headerGBad = getHeader(2052); BlockHeader headerLGood = getHeader(2047); BlockHeader headerLBad = getHeader(2046); assertTrue(rule.validate(headerGGood, parent)); assertTrue(rule.validate(headerLGood, parent)); assertFalse(rule.validate(headerGBad, parent)); assertFalse(rule.validate(headerLBad, parent)); }
|
@Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } ParentGasLimitRule(int gasLimitBoundDivisor); }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } ParentGasLimitRule(int gasLimitBoundDivisor); @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGasLimit.subtract(deltaLimit)) < 0 || headerGasLimit.compareTo(parentGasLimit.add(deltaLimit)) > 0) { logger.error(String.format("#%d: gas limit exceeds parentBlock.getGasLimit() (+-) GAS_LIMIT_BOUND_DIVISOR", header.getNumber())); return false; } return true; } ParentGasLimitRule(int gasLimitBoundDivisor); @Override boolean validate(BlockHeader header, BlockHeader parent); }
|
@Test public void toGas() { Assert.assertEquals(0, GasCost.toGas(new byte[0])); Assert.assertEquals(1, GasCost.toGas(new byte[] { 0x01 })); Assert.assertEquals(255, GasCost.toGas(new byte[] { (byte)0xff })); Assert.assertEquals( Long.MAX_VALUE, GasCost.toGas(BigInteger.valueOf(Long.MAX_VALUE).toByteArray()) ); }
|
public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test public void toGasOverflowsSlightly() { byte[] bytes = new byte[32]; for (int k = 0; k < 17; k++) { bytes[k] = (byte)0x00; } bytes[17] = (byte)0x80; for (int k = 18; k < 32; k++) { bytes[k] = (byte)0x00; } Assert.assertEquals(GasCost.toGas(bytes), Long.MAX_VALUE); }
|
public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void toGasGivesNegativeValue() throws GasCost.InvalidGasException { byte[] negativeBytes = new byte[]{ (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, }; GasCost.toGas(negativeBytes); }
|
public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test public void toGasArrayTooBig() throws GasCost.InvalidGasException { byte[] bigArray = new byte[]{ (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, }; Assert.assertEquals(GasCost.toGas(bigArray), Long.MAX_VALUE); }
|
public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void toGasFromLongWithNegativeLong() { GasCost.toGas(-1L); }
|
public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void toGasFromOverflowedLong() { Assert.assertEquals(Long.MAX_VALUE, GasCost.toGas(Long.MAX_VALUE + 1)); }
|
public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test public void getTransactionReceipt() throws Exception { ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB()); World world = new World(receiptStore); Web3Impl web3 = createWeb3(world, receiptStore); Account acc1 = new AccountBuilder(world).name("acc1").balance(Coin.valueOf(2000000)).build(); Account acc2 = new AccountBuilder().name("acc2").build(); Transaction tx = new TransactionBuilder().sender(acc1).receiver(acc2).value(BigInteger.valueOf(1000000)).build(); List<Transaction> txs = new ArrayList<>(); txs.add(tx); Block genesis = world.getBlockChain().getBestBlock(); Block block1 = new BlockBuilder(world.getBlockChain(), world.getBridgeSupportFactory(), world.getBlockStore()).trieStore(world.getTrieStore()).parent(genesis).transactions(txs).build(); org.junit.Assert.assertEquals(ImportResult.IMPORTED_BEST, world.getBlockChain().tryToConnect(block1)); String hashString = tx.getHash().toHexString(); TransactionReceiptDTO tr = web3.eth_getTransactionReceipt(hashString); assertNotNull(tr); org.junit.Assert.assertEquals("0x" + hashString, tr.getTransactionHash()); String trxFrom = TypeConverter.toJsonHex(tx.getSender().getBytes()); org.junit.Assert.assertEquals(trxFrom, tr.getFrom()); String trxTo = TypeConverter.toJsonHex(tx.getReceiveAddress().getBytes()); org.junit.Assert.assertEquals(trxTo, tr.getTo()); String blockHashString = "0x" + block1.getHash(); org.junit.Assert.assertEquals(blockHashString, tr.getBlockHash()); String blockNumberAsHex = "0x" + Long.toHexString(block1.getNumber()); org.junit.Assert.assertEquals(blockNumberAsHex, tr.getBlockNumber()); String rawTransactionReceipt = web3.rsk_getRawTransactionReceiptByHash(hashString); String expectedRawTxReceipt = "0xf9010c01825208b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c082520801"; Assert.assertEquals(expectedRawTxReceipt, rawTransactionReceipt); String[] transactionReceiptNodes = web3.rsk_getTransactionReceiptNodesByHash(blockHashString, hashString); ArrayList<String> expectedRawTxReceiptNodes = new ArrayList<>(); expectedRawTxReceiptNodes.add("0x70078048ee76b19fc451dba9dbee8b3e73084f79ea540d3940b3b36b128e8024e9302500010f"); Assert.assertEquals(1, transactionReceiptNodes.length); Assert.assertEquals(expectedRawTxReceiptNodes.get(0), transactionReceiptNodes[0]); }
|
@Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No transaction info for {}", transactionHash); return null; } Block block = blockStore.getBlockByHash(txInfo.getBlockHash()); Transaction tx = block.getTransactionsList().get(txInfo.getIndex()); txInfo.setTransaction(tx); return new TransactionReceiptDTO(block, txInfo); }
|
Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No transaction info for {}", transactionHash); return null; } Block block = blockStore.getBlockByHash(txInfo.getBlockHash()); Transaction tx = block.getTransactionsList().get(txInfo.getIndex()); txInfo.setTransaction(tx); return new TransactionReceiptDTO(block, txInfo); } }
|
Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No transaction info for {}", transactionHash); return null; } Block block = blockStore.getBlockByHash(txInfo.getBlockHash()); Transaction tx = block.getTransactionsList().get(txInfo.getIndex()); txInfo.setTransaction(tx); return new TransactionReceiptDTO(block, txInfo); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); }
|
Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No transaction info for {}", transactionHash); return null; } Block block = blockStore.getBlockByHash(txInfo.getBlockHash()); Transaction tx = block.getTransactionsList().get(txInfo.getIndex()); txInfo.setTransaction(tx); return new TransactionReceiptDTO(block, txInfo); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); }
|
Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No transaction info for {}", transactionHash); return null; } Block block = blockStore.getBlockByHash(txInfo.getBlockHash()); Transaction tx = block.getTransactionsList().get(txInfo.getIndex()); txInfo.setTransaction(tx); return new TransactionReceiptDTO(block, txInfo); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); public Ethereum eth; }
|
@Test public void toGasFromLong() { Assert.assertEquals(Long.MAX_VALUE, GasCost.toGas(Long.MAX_VALUE)); Assert.assertEquals(123L, GasCost.toGas(123L)); }
|
public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test public void toGasWithBigInteger() { BigInteger bi = BigInteger.valueOf(Long.MAX_VALUE - 10); Assert.assertEquals(Long.MAX_VALUE - 10, GasCost.toGas(bi)); }
|
public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void toGasWithNegativeBigInteger() { BigInteger bi = BigInteger.valueOf(-1); GasCost.toGas(bi); }
|
public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void moreNegativeBiToGas() { Assert.assertEquals(Long.MAX_VALUE, GasCost.toGas(BigInteger.valueOf(-3512))); }
|
public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void mostNegativeBiToGas() { Assert.assertEquals(Long.MAX_VALUE, GasCost.toGas(BigInteger.valueOf(-99999999999999L))); }
|
public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test public void calculateAddGas() { Assert.assertEquals(1, GasCost.add(1, 0)); Assert.assertEquals(2, GasCost.add(1, 1)); Assert.assertEquals(1000000, GasCost.add(500000, 500000)); }
|
public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; }
|
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } }
|
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); }
|
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test public void calculateAddGasWithOverflow() { Assert.assertEquals(Long.MAX_VALUE, GasCost.add(Long.MAX_VALUE, 1)); Assert.assertEquals(Long.MAX_VALUE, GasCost.add(1, Long.MAX_VALUE)); Assert.assertEquals(Long.MAX_VALUE, GasCost.add(Long.MAX_VALUE, Long.MAX_VALUE)); }
|
public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; }
|
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } }
|
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); }
|
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void calculateAddGasCostWithSecondNegativeInputAndResult() throws GasCost.InvalidGasException { GasCost.add(0, -1); }
|
public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; }
|
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } }
|
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); }
|
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void calculateAddGasCostWithFirstNegativeInputAndResult() throws GasCost.InvalidGasException { GasCost.add(-1, 1); }
|
public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; }
|
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } }
|
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); }
|
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test public void calculateSubtractGasCost() { Assert.assertEquals(1, GasCost.subtract(1, 0)); Assert.assertEquals(0, GasCost.subtract(1, 1)); Assert.assertEquals(1000000, GasCost.subtract(1500000, 500000)); Assert.assertEquals(0, GasCost.subtract(Long.MAX_VALUE, Long.MAX_VALUE)); }
|
public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test public void getTransactionReceiptNotInMainBlockchain() throws Exception { ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB()); World world = new World(receiptStore); Web3Impl web3 = createWeb3(world, receiptStore); Account acc1 = new AccountBuilder(world).name("acc1").balance(Coin.valueOf(2000000)).build(); Account acc2 = new AccountBuilder().name("acc2").build(); Transaction tx = new TransactionBuilder().sender(acc1).receiver(acc2).value(BigInteger.valueOf(1000000)).build(); List<Transaction> txs = new ArrayList<>(); txs.add(tx); Block genesis = world.getBlockChain().getBestBlock(); Block block1 = new BlockBuilder(world.getBlockChain(), world.getBridgeSupportFactory(), world.getBlockStore()).trieStore(world.getTrieStore()).parent(genesis).difficulty(3l).transactions(txs).build(); org.junit.Assert.assertEquals(ImportResult.IMPORTED_BEST, world.getBlockChain().tryToConnect(block1)); Block block1b = new BlockBuilder(world.getBlockChain(), world.getBridgeSupportFactory(), world.getBlockStore()).trieStore(world.getTrieStore()).parent(genesis) .difficulty(block1.getDifficulty().asBigInteger().longValue()-1).build(); Block block2b = new BlockBuilder(world.getBlockChain(), world.getBridgeSupportFactory(), world.getBlockStore()).trieStore(world.getTrieStore()).difficulty(2).parent(block1b).build(); org.junit.Assert.assertEquals(ImportResult.IMPORTED_NOT_BEST, world.getBlockChain().tryToConnect(block1b)); org.junit.Assert.assertEquals(ImportResult.IMPORTED_BEST, world.getBlockChain().tryToConnect(block2b)); String hashString = tx.getHash().toHexString(); TransactionReceiptDTO tr = web3.eth_getTransactionReceipt(hashString); Assert.assertNull(tr); }
|
@Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No transaction info for {}", transactionHash); return null; } Block block = blockStore.getBlockByHash(txInfo.getBlockHash()); Transaction tx = block.getTransactionsList().get(txInfo.getIndex()); txInfo.setTransaction(tx); return new TransactionReceiptDTO(block, txInfo); }
|
Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No transaction info for {}", transactionHash); return null; } Block block = blockStore.getBlockByHash(txInfo.getBlockHash()); Transaction tx = block.getTransactionsList().get(txInfo.getIndex()); txInfo.setTransaction(tx); return new TransactionReceiptDTO(block, txInfo); } }
|
Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No transaction info for {}", transactionHash); return null; } Block block = blockStore.getBlockByHash(txInfo.getBlockHash()); Transaction tx = block.getTransactionsList().get(txInfo.getIndex()); txInfo.setTransaction(tx); return new TransactionReceiptDTO(block, txInfo); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); }
|
Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No transaction info for {}", transactionHash); return null; } Block block = blockStore.getBlockByHash(txInfo.getBlockHash()); Transaction tx = block.getTransactionsList().get(txInfo.getIndex()); txInfo.setTransaction(tx); return new TransactionReceiptDTO(block, txInfo); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); }
|
Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No transaction info for {}", transactionHash); return null; } Block block = blockStore.getBlockByHash(txInfo.getBlockHash()); Transaction tx = block.getTransactionsList().get(txInfo.getIndex()); txInfo.setTransaction(tx); return new TransactionReceiptDTO(block, txInfo); } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); public Ethereum eth; }
|
@Test(expected = GasCost.InvalidGasException.class) public void calculateSubtractWithNegativeInput() throws GasCost.InvalidGasException { GasCost.subtract(1, -1); }
|
public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void calculateSubtractWithExtremelyNegativeResult() throws GasCost.InvalidGasException { GasCost.subtract(0, Long.MAX_VALUE); }
|
public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void calculateSubtractGasToInvalidSubtle() throws GasCost.InvalidGasException { GasCost.subtract(1, 2); }
|
public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void calculateSubtractGasToInvalidObvious() throws GasCost.InvalidGasException { GasCost.subtract(1, 159); }
|
public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void multiplyWithNegativeValues() throws GasCost.InvalidGasException { GasCost.multiply(-1, -2); }
|
public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void multiplyWithXNegative() throws GasCost.InvalidGasException { GasCost.multiply(-1, 123); }
|
public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void multiplyWithYNegative() throws GasCost.InvalidGasException { GasCost.multiply(1, -9123); }
|
public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test public void multiply() { long x = (long) Math.pow(2, 62); long y = (long) Math.pow(2, 12); long overflowed = GasCost.multiply(x, y); Assert.assertEquals("overflowed is coverted to max gas", Long.MAX_VALUE, overflowed); }
|
public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test public void multiplyOverflowing() throws GasCost.InvalidGasException { Assert.assertEquals(Long.MAX_VALUE, GasCost.multiply(4611686018427387903L, 4096L)); }
|
public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void multiplyWithNegativeInput() throws GasCost.InvalidGasException { GasCost.multiply(1, -9123); }
|
public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test public void getTransactionByHash() throws Exception { ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB()); World world = new World(receiptStore); Web3Impl web3 = createWeb3(world, receiptStore); Account acc1 = new AccountBuilder(world).name("acc1").balance(Coin.valueOf(2000000)).build(); Account acc2 = new AccountBuilder().name("acc2").build(); Transaction tx = new TransactionBuilder().sender(acc1).receiver(acc2).value(BigInteger.valueOf(1000000)).build(); List<Transaction> txs = new ArrayList<>(); txs.add(tx); Block genesis = world.getBlockChain().getBestBlock(); Block block1 = new BlockBuilder(world.getBlockChain(), world.getBridgeSupportFactory(), world.getBlockStore()).trieStore(world.getTrieStore()).parent(genesis).transactions(txs).build(); org.junit.Assert.assertEquals(ImportResult.IMPORTED_BEST, world.getBlockChain().tryToConnect(block1)); String hashString = tx.getHash().toHexString(); TransactionResultDTO tr = web3.eth_getTransactionByHash(hashString); assertNotNull(tr); org.junit.Assert.assertEquals("0x" + hashString, tr.hash); String blockHashString = "0x" + block1.getHash(); org.junit.Assert.assertEquals(blockHashString, tr.blockHash); org.junit.Assert.assertEquals("0x", tr.input); org.junit.Assert.assertEquals("0x" + ByteUtil.toHexString(tx.getReceiveAddress().getBytes()), tr.to); Assert.assertArrayEquals(new byte[] {tx.getSignature().getV()}, TypeConverter.stringHexToByteArray(tr.v)); Assert.assertThat(TypeConverter.stringHexToBigInteger(tr.s), is(tx.getSignature().getS())); Assert.assertThat(TypeConverter.stringHexToBigInteger(tr.r), is(tx.getSignature().getR())); }
|
@Override public TransactionResultDTO eth_getTransactionByHash(String transactionHash) { TransactionResultDTO s = null; try { Keccak256 txHash = new Keccak256(stringHexToByteArray(transactionHash)); Block block = null; TransactionInfo txInfo = this.receiptStore.getInMainChain(txHash.getBytes(), blockStore); if (txInfo == null) { List<Transaction> txs = web3InformationRetriever.getTransactions("pending"); for (Transaction tx : txs) { if (tx.getHash().equals(txHash)) { return s = new TransactionResultDTO(null, null, tx); } } } else { block = blockchain.getBlockByHash(txInfo.getBlockHash()); Block mainBlock = blockchain.getBlockByNumber(block.getNumber()); if (!block.getHash().equals(mainBlock.getHash())) { return null; } txInfo.setTransaction(block.getTransactionsList().get(txInfo.getIndex())); } if (txInfo == null) { return null; } return s = new TransactionResultDTO(block, txInfo.getIndex(), txInfo.getReceipt().getTransaction()); } finally { logger.debug("eth_getTransactionByHash({}): {}", transactionHash, s); } }
|
Web3Impl implements Web3 { @Override public TransactionResultDTO eth_getTransactionByHash(String transactionHash) { TransactionResultDTO s = null; try { Keccak256 txHash = new Keccak256(stringHexToByteArray(transactionHash)); Block block = null; TransactionInfo txInfo = this.receiptStore.getInMainChain(txHash.getBytes(), blockStore); if (txInfo == null) { List<Transaction> txs = web3InformationRetriever.getTransactions("pending"); for (Transaction tx : txs) { if (tx.getHash().equals(txHash)) { return s = new TransactionResultDTO(null, null, tx); } } } else { block = blockchain.getBlockByHash(txInfo.getBlockHash()); Block mainBlock = blockchain.getBlockByNumber(block.getNumber()); if (!block.getHash().equals(mainBlock.getHash())) { return null; } txInfo.setTransaction(block.getTransactionsList().get(txInfo.getIndex())); } if (txInfo == null) { return null; } return s = new TransactionResultDTO(block, txInfo.getIndex(), txInfo.getReceipt().getTransaction()); } finally { logger.debug("eth_getTransactionByHash({}): {}", transactionHash, s); } } }
|
Web3Impl implements Web3 { @Override public TransactionResultDTO eth_getTransactionByHash(String transactionHash) { TransactionResultDTO s = null; try { Keccak256 txHash = new Keccak256(stringHexToByteArray(transactionHash)); Block block = null; TransactionInfo txInfo = this.receiptStore.getInMainChain(txHash.getBytes(), blockStore); if (txInfo == null) { List<Transaction> txs = web3InformationRetriever.getTransactions("pending"); for (Transaction tx : txs) { if (tx.getHash().equals(txHash)) { return s = new TransactionResultDTO(null, null, tx); } } } else { block = blockchain.getBlockByHash(txInfo.getBlockHash()); Block mainBlock = blockchain.getBlockByNumber(block.getNumber()); if (!block.getHash().equals(mainBlock.getHash())) { return null; } txInfo.setTransaction(block.getTransactionsList().get(txInfo.getIndex())); } if (txInfo == null) { return null; } return s = new TransactionResultDTO(block, txInfo.getIndex(), txInfo.getReceipt().getTransaction()); } finally { logger.debug("eth_getTransactionByHash({}): {}", transactionHash, s); } } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); }
|
Web3Impl implements Web3 { @Override public TransactionResultDTO eth_getTransactionByHash(String transactionHash) { TransactionResultDTO s = null; try { Keccak256 txHash = new Keccak256(stringHexToByteArray(transactionHash)); Block block = null; TransactionInfo txInfo = this.receiptStore.getInMainChain(txHash.getBytes(), blockStore); if (txInfo == null) { List<Transaction> txs = web3InformationRetriever.getTransactions("pending"); for (Transaction tx : txs) { if (tx.getHash().equals(txHash)) { return s = new TransactionResultDTO(null, null, tx); } } } else { block = blockchain.getBlockByHash(txInfo.getBlockHash()); Block mainBlock = blockchain.getBlockByNumber(block.getNumber()); if (!block.getHash().equals(mainBlock.getHash())) { return null; } txInfo.setTransaction(block.getTransactionsList().get(txInfo.getIndex())); } if (txInfo == null) { return null; } return s = new TransactionResultDTO(block, txInfo.getIndex(), txInfo.getReceipt().getTransaction()); } finally { logger.debug("eth_getTransactionByHash({}): {}", transactionHash, s); } } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); }
|
Web3Impl implements Web3 { @Override public TransactionResultDTO eth_getTransactionByHash(String transactionHash) { TransactionResultDTO s = null; try { Keccak256 txHash = new Keccak256(stringHexToByteArray(transactionHash)); Block block = null; TransactionInfo txInfo = this.receiptStore.getInMainChain(txHash.getBytes(), blockStore); if (txInfo == null) { List<Transaction> txs = web3InformationRetriever.getTransactions("pending"); for (Transaction tx : txs) { if (tx.getHash().equals(txHash)) { return s = new TransactionResultDTO(null, null, tx); } } } else { block = blockchain.getBlockByHash(txInfo.getBlockHash()); Block mainBlock = blockchain.getBlockByNumber(block.getNumber()); if (!block.getHash().equals(mainBlock.getHash())) { return null; } txInfo.setTransaction(block.getTransactionsList().get(txInfo.getIndex())); } if (txInfo == null) { return null; } return s = new TransactionResultDTO(block, txInfo.getIndex(), txInfo.getReceipt().getTransaction()); } finally { logger.debug("eth_getTransactionByHash({}): {}", transactionHash, s); } } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blockStore,
ReceiptStore receiptStore,
RskSystemProperties config,
MinerClient minerClient,
MinerServer minerServer,
PersonalModule personalModule,
EthModule ethModule,
EvmModule evmModule,
TxPoolModule txPoolModule,
MnrModule mnrModule,
DebugModule debugModule,
TraceModule traceModule,
RskModule rskModule,
ChannelManager channelManager,
PeerScoringManager peerScoringManager,
PeerServer peerServer,
BlockProcessor nodeBlockProcessor,
HashRateCalculator hashRateCalculator,
ConfigCapabilities configCapabilities,
BuildInfo buildInfo,
BlocksBloomStore blocksBloomStore,
Web3InformationRetriever web3InformationRetriever); @Override void start(); @Override void stop(); @Override String web3_clientVersion(); @Override String web3_sha3(String data); @Override String net_version(); @Override String net_peerCount(); @Override boolean net_listening(); @Override String rsk_protocolVersion(); @Override String eth_protocolVersion(); @Override Object eth_syncing(); @Override String eth_coinbase(); @Override boolean eth_mining(); @Override BigInteger eth_hashrate(); @Override BigInteger eth_netHashrate(); @Override String[] net_peerList(); @Override String eth_gasPrice(); @Override String eth_blockNumber(); @Override String eth_getBalance(String address, String block); @Override String eth_getBalance(String address); @Override String eth_getStorageAt(String address, String storageIdx, String blockId); @Override String eth_getTransactionCount(String address, String blockId); Block getBlockByJSonHash(String blockHash); @Override String eth_getBlockTransactionCountByHash(String blockHash); static Block getBlockByNumberOrStr(String bnOrId, Blockchain blockchain); @Override String eth_getBlockTransactionCountByNumber(String bnOrId); @Override String eth_getUncleCountByBlockHash(String blockHash); @Override String eth_getUncleCountByBlockNumber(String bnOrId); BlockInformationResult getBlockInformationResult(BlockInformation blockInformation); BlockResultDTO getBlockResult(Block b, boolean fullTx); BlockInformationResult[] eth_getBlocksByNumber(String number); @Override BlockResultDTO eth_getBlockByHash(String blockHash, Boolean fullTransactionObjects); @Override BlockResultDTO eth_getBlockByNumber(String bnOrId, Boolean fullTransactionObjects); @Override TransactionResultDTO eth_getTransactionByHash(String transactionHash); @Override TransactionResultDTO eth_getTransactionByBlockHashAndIndex(String blockHash, String index); @Override TransactionResultDTO eth_getTransactionByBlockNumberAndIndex(String bnOrId, String index); @Override TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash); @Override BlockResultDTO eth_getUncleByBlockHashAndIndex(String blockHash, String uncleIdx); @Override BlockResultDTO eth_getUncleByBlockNumberAndIndex(String blockId, String uncleIdx); @Override String[] eth_getCompilers(); @Override Map<String, CompilationResultDTO> eth_compileLLL(String contract); @Override Map<String, CompilationResultDTO> eth_compileSerpent(String contract); @Override Map<String, CompilationResultDTO> eth_compileSolidity(String contract); @Override String eth_newFilter(FilterRequest fr); @Override String eth_newBlockFilter(); @Override String eth_newPendingTransactionFilter(); @Override boolean eth_uninstallFilter(String id); @Override Object[] eth_getFilterChanges(String id); @Override Object[] eth_getFilterLogs(String id); @Override Object[] eth_getLogs(FilterRequest fr); @Override Map<String, String> rpc_modules(); @Override void db_putString(); @Override void db_getString(); @Override boolean eth_submitWork(String nonce, String header, String mince); @Override boolean eth_submitHashrate(String hashrate, String id); @Override void db_putHex(); @Override void db_getHex(); @Override String personal_newAccountWithSeed(String seed); @Override String personal_newAccount(String passphrase); @Override String personal_importRawKey(String key, String passphrase); @Override String personal_dumpRawKey(String address); @Override String[] personal_listAccounts(); @Override String personal_sendTransaction(CallArguments args, String passphrase); @Override boolean personal_unlockAccount(String address, String passphrase, String duration); @Override boolean personal_lockAccount(String address); @Override EthModule getEthModule(); @Override EvmModule getEvmModule(); @Override TxPoolModule getTxPoolModule(); @Override MnrModule getMnrModule(); @Override DebugModule getDebugModule(); @Override TraceModule getTraceModule(); @Override RskModule getRskModule(); @Override void sco_banAddress(String address); @Override void sco_unbanAddress(String address); @Override PeerScoringInformation[] sco_peerList(); @Override String[] sco_bannedAddresses(); public Ethereum eth; }
|
@Test public void calculateGasCost() throws GasCost.InvalidGasException { Assert.assertEquals(1, GasCost.calculateTotal(1, 0, 0)); Assert.assertEquals(2, GasCost.calculateTotal(0, 2, 1)); Assert.assertEquals(7, GasCost.calculateTotal(1, 2, 3)); Assert.assertEquals(10, GasCost.calculateTotal(4, 3, 2)); Assert.assertEquals(GasCost.CREATE + 100 * GasCost.CREATE_DATA, GasCost.calculateTotal(GasCost.CREATE, GasCost.CREATE_DATA, 100)); Assert.assertEquals(Long.MAX_VALUE, GasCost.calculateTotal(1, Long.MAX_VALUE, 1)); Assert.assertEquals(Long.MAX_VALUE, GasCost.calculateTotal(Long.MAX_VALUE, Long.MAX_VALUE, 1)); Assert.assertEquals(Long.MAX_VALUE, GasCost.calculateTotal(0, Long.MAX_VALUE, 2)); }
|
public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void calculateGasCostWithNegativeSecondInputs() throws GasCost.InvalidGasException { GasCost.calculateTotal(1, -1, 1); }
|
public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void calculateGasCostWithNegativeFirstInput() throws GasCost.InvalidGasException { GasCost.calculateTotal(-1, 1, 1); }
|
public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test(expected = GasCost.InvalidGasException.class) public void calculateGasCostWithNegativeThirdInput() throws GasCost.InvalidGasException { GasCost.calculateTotal(1, 1, -1); }
|
public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test public void calculateGasCostBeyondMaxGas() throws GasCost.InvalidGasException { Assert.assertEquals(Long.MAX_VALUE, GasCost.calculateTotal(1, Long.MAX_VALUE, 1)); Assert.assertEquals(Long.MAX_VALUE, GasCost.calculateTotal(1, Long.MAX_VALUE, 1)); Assert.assertEquals(Long.MAX_VALUE, GasCost.calculateTotal(Long.MAX_VALUE, 1, 1)); }
|
public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); }
|
GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units, mult)) { return Long.MAX_VALUE; } long result = baseCost + mult; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long add(long x, long y); static long multiply(long x, long y); static long subtract(long x, long y); static long calculateTotal(long baseCost, long unitCost, long units); static final long STEP; static final long SSTORE; static final long ZEROSTEP; static final long QUICKSTEP; static final long FASTESTSTEP; static final long FASTSTEP; static final long MIDSTEP; static final long SLOWSTEP; static final long EXTSTEP; static final long GENESISGASLIMIT; static final long MINGASLIMIT; static final long BALANCE; static final long SHA3; static final long SHA3_WORD; static final long SLOAD; static final long STOP; static final long SUICIDE; static final long CLEAR_SSTORE; static final long SET_SSTORE; static final long RESET_SSTORE; static final long REFUND_SSTORE; static final long CREATE; static final long JUMPDEST; static final long CREATE_DATA_BYTE; static final long CALL; static final long STIPEND_CALL; static final long VT_CALL; static final long NEW_ACCT_CALL; static final long MEMORY; static final long MEMORY_V1; static final long SUICIDE_REFUND; static final long QUAD_COEFF_DIV; static final long CREATE_DATA; static final long REPLACE_DATA; static final long TX_NO_ZERO_DATA; static final long TX_ZERO_DATA; static final long TRANSACTION; static final long TRANSACTION_DEFAULT; static final long TRANSACTION_CREATE_CONTRACT; static final long LOG_GAS; static final long LOG_DATA_GAS; static final long LOG_TOPIC_GAS; static final long COPY_GAS; static final long EXP_GAS; static final long EXP_BYTE_GAS; static final long IDENTITY; static final long IDENTITY_WORD; static final long RIPEMD160; static final long RIPEMD160_WORD; static final long SHA256; static final long SHA256_WORD; static final long EC_RECOVER; static final long EXT_CODE_SIZE; static final long EXT_CODE_COPY; static final long EXT_CODE_HASH; static final long CODEREPLACE; static final long NEW_ACCT_SUICIDE; static final long RETURN; static final long MAX_GAS; }
|
@Test public void testAdd() { byte[] three = new byte[32]; for (int i = 0; i < three.length; i++) { three[i] = (byte) 0xff; } DataWord x = DataWord.valueOf(three); byte[] xdata = x.getData(); DataWord result = x.add(DataWord.valueOf(three)); assertArrayEquals(xdata, x.getData()); assertEquals(32, result.getData().length); }
|
public DataWord add(DataWord word) { byte[] newdata = new byte[BYTES]; for (int i = 31, overflow = 0; i >= 0; i--) { int v = (this.data[i] & 0xff) + (word.data[i] & 0xff) + overflow; newdata[i] = (byte) v; overflow = v >>> 8; } return new DataWord(newdata); }
|
DataWord implements Comparable<DataWord> { public DataWord add(DataWord word) { byte[] newdata = new byte[BYTES]; for (int i = 31, overflow = 0; i >= 0; i--) { int v = (this.data[i] & 0xff) + (word.data[i] & 0xff) + overflow; newdata[i] = (byte) v; overflow = v >>> 8; } return new DataWord(newdata); } }
|
DataWord implements Comparable<DataWord> { public DataWord add(DataWord word) { byte[] newdata = new byte[BYTES]; for (int i = 31, overflow = 0; i >= 0; i--) { int v = (this.data[i] & 0xff) + (word.data[i] & 0xff) + overflow; newdata[i] = (byte) v; overflow = v >>> 8; } return new DataWord(newdata); } private DataWord(byte[] data); }
|
DataWord implements Comparable<DataWord> { public DataWord add(DataWord word) { byte[] newdata = new byte[BYTES]; for (int i = 31, overflow = 0; i >= 0; i--) { int v = (this.data[i] & 0xff) + (word.data[i] & 0xff) + overflow; newdata[i] = (byte) v; overflow = v >>> 8; } return new DataWord(newdata); } private DataWord(byte[] data); byte[] getData(); byte[] getNoLeadZeroesData(); byte[] getByteArrayForStorage(); byte[] getLast20Bytes(); BigInteger value(); int intValue(); int intValueCheck(); int intValueSafe(); long longValue(); long longValueSafe(); BigInteger sValue(); String bigIntValue(); boolean isZero(); boolean isNegative(); DataWord and(DataWord w2); DataWord or(DataWord w2); DataWord xor(DataWord w2); DataWord bnot(); DataWord add(DataWord word); DataWord mul(DataWord word); DataWord div(DataWord word); DataWord sDiv(DataWord word); DataWord sub(DataWord word); DataWord exp(DataWord word); DataWord mod(DataWord word); DataWord sMod(DataWord word); DataWord addmod(DataWord word1, DataWord word2); DataWord mulmod(DataWord word1, DataWord word2); DataWord shiftLeft(DataWord arg); DataWord shiftRight(DataWord arg); DataWord shiftRightSigned(DataWord arg); @JsonValue @Override String toString(); String toPrefixString(); String shortHex(); @Override boolean equals(Object o); boolean equalValue(DataWord o); @Override int hashCode(); @Override int compareTo(DataWord o); DataWord signExtend(byte k); boolean occupyMoreThan(int n); int bytesOccupied(); static int numberOfLeadingZeros(byte i); static int numberOfTrailingNonZeros(byte i); int bitsOccupied(); boolean isHex(String hex); static DataWord fromString(String value); static DataWord fromLongString(String value); @JsonCreator static DataWord valueFromHex(String data); static DataWord valueOf(int num); static DataWord valueOf(long num); static DataWord valueOf(byte[] data); static DataWord valueOf(byte[] data, int offset, int length); }
|
DataWord implements Comparable<DataWord> { public DataWord add(DataWord word) { byte[] newdata = new byte[BYTES]; for (int i = 31, overflow = 0; i >= 0; i--) { int v = (this.data[i] & 0xff) + (word.data[i] & 0xff) + overflow; newdata[i] = (byte) v; overflow = v >>> 8; } return new DataWord(newdata); } private DataWord(byte[] data); byte[] getData(); byte[] getNoLeadZeroesData(); byte[] getByteArrayForStorage(); byte[] getLast20Bytes(); BigInteger value(); int intValue(); int intValueCheck(); int intValueSafe(); long longValue(); long longValueSafe(); BigInteger sValue(); String bigIntValue(); boolean isZero(); boolean isNegative(); DataWord and(DataWord w2); DataWord or(DataWord w2); DataWord xor(DataWord w2); DataWord bnot(); DataWord add(DataWord word); DataWord mul(DataWord word); DataWord div(DataWord word); DataWord sDiv(DataWord word); DataWord sub(DataWord word); DataWord exp(DataWord word); DataWord mod(DataWord word); DataWord sMod(DataWord word); DataWord addmod(DataWord word1, DataWord word2); DataWord mulmod(DataWord word1, DataWord word2); DataWord shiftLeft(DataWord arg); DataWord shiftRight(DataWord arg); DataWord shiftRightSigned(DataWord arg); @JsonValue @Override String toString(); String toPrefixString(); String shortHex(); @Override boolean equals(Object o); boolean equalValue(DataWord o); @Override int hashCode(); @Override int compareTo(DataWord o); DataWord signExtend(byte k); boolean occupyMoreThan(int n); int bytesOccupied(); static int numberOfLeadingZeros(byte i); static int numberOfTrailingNonZeros(byte i); int bitsOccupied(); boolean isHex(String hex); static DataWord fromString(String value); static DataWord fromLongString(String value); @JsonCreator static DataWord valueFromHex(String data); static DataWord valueOf(int num); static DataWord valueOf(long num); static DataWord valueOf(byte[] data); static DataWord valueOf(byte[] data, int offset, int length); static final int BYTES; static final BigInteger _2_256; static final BigInteger MAX_VALUE; static final DataWord ZERO; static final DataWord ONE; static final int MAX_POW; }
|
@Test public void testMod() { String expected = "000000000000000000000000000000000000000000000000000000000000001a"; byte[] one = new byte[32]; one[31] = 0x1e; byte[] two = new byte[32]; for (int i = 0; i < two.length; i++) { two[i] = (byte) 0xff; } two[31] = 0x56; DataWord x = DataWord.valueOf(one); byte[] xdata = x.getData(); DataWord y = DataWord.valueOf(two); byte[] ydata = y.getData(); DataWord result = y.mod(x); assertArrayEquals(xdata, x.getData()); assertArrayEquals(ydata, y.getData()); assertEquals(32, result.getData().length); assertEquals(expected, ByteUtil.toHexString(result.getData())); }
|
public DataWord mod(DataWord word) { if (word.isZero()) { return DataWord.ZERO; } BigInteger result = value().mod(word.value()); return valueOf(result.and(MAX_VALUE)); }
|
DataWord implements Comparable<DataWord> { public DataWord mod(DataWord word) { if (word.isZero()) { return DataWord.ZERO; } BigInteger result = value().mod(word.value()); return valueOf(result.and(MAX_VALUE)); } }
|
DataWord implements Comparable<DataWord> { public DataWord mod(DataWord word) { if (word.isZero()) { return DataWord.ZERO; } BigInteger result = value().mod(word.value()); return valueOf(result.and(MAX_VALUE)); } private DataWord(byte[] data); }
|
DataWord implements Comparable<DataWord> { public DataWord mod(DataWord word) { if (word.isZero()) { return DataWord.ZERO; } BigInteger result = value().mod(word.value()); return valueOf(result.and(MAX_VALUE)); } private DataWord(byte[] data); byte[] getData(); byte[] getNoLeadZeroesData(); byte[] getByteArrayForStorage(); byte[] getLast20Bytes(); BigInteger value(); int intValue(); int intValueCheck(); int intValueSafe(); long longValue(); long longValueSafe(); BigInteger sValue(); String bigIntValue(); boolean isZero(); boolean isNegative(); DataWord and(DataWord w2); DataWord or(DataWord w2); DataWord xor(DataWord w2); DataWord bnot(); DataWord add(DataWord word); DataWord mul(DataWord word); DataWord div(DataWord word); DataWord sDiv(DataWord word); DataWord sub(DataWord word); DataWord exp(DataWord word); DataWord mod(DataWord word); DataWord sMod(DataWord word); DataWord addmod(DataWord word1, DataWord word2); DataWord mulmod(DataWord word1, DataWord word2); DataWord shiftLeft(DataWord arg); DataWord shiftRight(DataWord arg); DataWord shiftRightSigned(DataWord arg); @JsonValue @Override String toString(); String toPrefixString(); String shortHex(); @Override boolean equals(Object o); boolean equalValue(DataWord o); @Override int hashCode(); @Override int compareTo(DataWord o); DataWord signExtend(byte k); boolean occupyMoreThan(int n); int bytesOccupied(); static int numberOfLeadingZeros(byte i); static int numberOfTrailingNonZeros(byte i); int bitsOccupied(); boolean isHex(String hex); static DataWord fromString(String value); static DataWord fromLongString(String value); @JsonCreator static DataWord valueFromHex(String data); static DataWord valueOf(int num); static DataWord valueOf(long num); static DataWord valueOf(byte[] data); static DataWord valueOf(byte[] data, int offset, int length); }
|
DataWord implements Comparable<DataWord> { public DataWord mod(DataWord word) { if (word.isZero()) { return DataWord.ZERO; } BigInteger result = value().mod(word.value()); return valueOf(result.and(MAX_VALUE)); } private DataWord(byte[] data); byte[] getData(); byte[] getNoLeadZeroesData(); byte[] getByteArrayForStorage(); byte[] getLast20Bytes(); BigInteger value(); int intValue(); int intValueCheck(); int intValueSafe(); long longValue(); long longValueSafe(); BigInteger sValue(); String bigIntValue(); boolean isZero(); boolean isNegative(); DataWord and(DataWord w2); DataWord or(DataWord w2); DataWord xor(DataWord w2); DataWord bnot(); DataWord add(DataWord word); DataWord mul(DataWord word); DataWord div(DataWord word); DataWord sDiv(DataWord word); DataWord sub(DataWord word); DataWord exp(DataWord word); DataWord mod(DataWord word); DataWord sMod(DataWord word); DataWord addmod(DataWord word1, DataWord word2); DataWord mulmod(DataWord word1, DataWord word2); DataWord shiftLeft(DataWord arg); DataWord shiftRight(DataWord arg); DataWord shiftRightSigned(DataWord arg); @JsonValue @Override String toString(); String toPrefixString(); String shortHex(); @Override boolean equals(Object o); boolean equalValue(DataWord o); @Override int hashCode(); @Override int compareTo(DataWord o); DataWord signExtend(byte k); boolean occupyMoreThan(int n); int bytesOccupied(); static int numberOfLeadingZeros(byte i); static int numberOfTrailingNonZeros(byte i); int bitsOccupied(); boolean isHex(String hex); static DataWord fromString(String value); static DataWord fromLongString(String value); @JsonCreator static DataWord valueFromHex(String data); static DataWord valueOf(int num); static DataWord valueOf(long num); static DataWord valueOf(byte[] data); static DataWord valueOf(byte[] data, int offset, int length); static final int BYTES; static final BigInteger _2_256; static final BigInteger MAX_VALUE; static final DataWord ZERO; static final DataWord ONE; static final int MAX_POW; }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.