diff --git a/common/src/main/kotlin/fund/cyber/search/model/ethereum/Block.kt b/common/src/main/kotlin/fund/cyber/search/model/ethereum/Block.kt index f2584f86..fd1c1f45 100644 --- a/common/src/main/kotlin/fund/cyber/search/model/ethereum/Block.kt +++ b/common/src/main/kotlin/fund/cyber/search/model/ethereum/Block.kt @@ -1,14 +1,10 @@ package fund.cyber.search.model.ethereum import fund.cyber.search.model.chains.BlockEntity -import fund.cyber.search.model.chains.ChainInfo import java.math.BigDecimal import java.math.BigInteger import java.time.Instant -const val ETHEREUM_CLASSIC_REWARD_CHANGED_BLOCK_NUMBER = 5000000 -const val ETHEREUM_REWARD_CHANGED_BLOCK_NUMBER = 4370000 - data class EthereumBlock( override val number: Long, //parsed from hex val hash: String, @@ -33,13 +29,3 @@ data class EthereumBlock( val unclesReward: BigDecimal, //including uncles reward, todo rename val txFees: BigDecimal ) : BlockEntity - -//todo change to use block trace rewards operations -//todo: 1) add properly support of new classic fork. 2) add support of custom reward functions in forks -fun getBlockReward(chainInfo: ChainInfo, number: Long): BigDecimal { - return if (chainInfo.name == "ETHEREUM_CLASSIC") { - if (number < ETHEREUM_CLASSIC_REWARD_CHANGED_BLOCK_NUMBER) BigDecimal("5") else BigDecimal("4") - } else { - if (number < ETHEREUM_REWARD_CHANGED_BLOCK_NUMBER) BigDecimal("5") else BigDecimal("3") - } -} diff --git a/common/src/main/kotlin/fund/cyber/search/model/ethereum/Uncle.kt b/common/src/main/kotlin/fund/cyber/search/model/ethereum/Uncle.kt index 29d27227..5e14ed60 100644 --- a/common/src/main/kotlin/fund/cyber/search/model/ethereum/Uncle.kt +++ b/common/src/main/kotlin/fund/cyber/search/model/ethereum/Uncle.kt @@ -1,14 +1,9 @@ package fund.cyber.search.model.ethereum -import fund.cyber.common.decimal32 -import fund.cyber.common.decimal8 import fund.cyber.search.model.chains.ChainEntity -import fund.cyber.search.model.chains.ChainInfo import java.math.BigDecimal -import java.math.RoundingMode import java.time.Instant -const val DIVIDE_SCALE = 18 data class EthereumUncle( val hash: String, @@ -21,15 +16,3 @@ data class EthereumUncle( val miner: String, val uncleReward: BigDecimal ) : ChainEntity - -//todo: add support of custom reward functions in forks -fun getUncleReward(chainInfo: ChainInfo, uncleNumber: Long, blockNumber: Long): BigDecimal { - - val blockReward = getBlockReward(chainInfo, blockNumber) - return if (chainInfo.name == "ETHEREUM_CLASSIC") { - getBlockReward(chainInfo, blockNumber).divide(decimal32, DIVIDE_SCALE, RoundingMode.FLOOR).stripTrailingZeros() - } else { - ((uncleNumber.toBigDecimal() + decimal8 - blockNumber.toBigDecimal()) * blockReward) - .divide(decimal8, DIVIDE_SCALE, RoundingMode.FLOOR).stripTrailingZeros() - } -} diff --git a/gradle/coverage-subprojects.gradle b/gradle/coverage-subprojects.gradle index 5da7afcd..714c1d1f 100644 --- a/gradle/coverage-subprojects.gradle +++ b/gradle/coverage-subprojects.gradle @@ -1,7 +1,7 @@ apply plugin: "jacoco" jacoco { - toolVersion = "0.8.2-SNAPSHOT" + toolVersion = "0.8.2" } test { diff --git a/gradle/coverage.gradle b/gradle/coverage.gradle index d86205c5..f257418f 100644 --- a/gradle/coverage.gradle +++ b/gradle/coverage.gradle @@ -16,7 +16,7 @@ repositories { } jacoco { - toolVersion = "0.8.2-SNAPSHOT" + toolVersion = "0.8.2" } def allTestCoverageFile = "$buildDir/jacoco/rootTestsCoverage.exec" diff --git a/pumps/ethereum/src/main/kotlin/fund/cyber/pump/ethereum/client/ParityToEthereumBundleConverter.kt b/pumps/ethereum/src/main/kotlin/fund/cyber/pump/ethereum/client/ParityToEthereumBundleConverter.kt index 4e3b319d..8301a4f8 100644 --- a/pumps/ethereum/src/main/kotlin/fund/cyber/pump/ethereum/client/ParityToEthereumBundleConverter.kt +++ b/pumps/ethereum/src/main/kotlin/fund/cyber/pump/ethereum/client/ParityToEthereumBundleConverter.kt @@ -1,6 +1,5 @@ package fund.cyber.pump.ethereum.client -import fund.cyber.common.DECIMAL_SCALE import fund.cyber.common.decimal32 import fund.cyber.common.hexToLong import fund.cyber.common.sum @@ -11,15 +10,13 @@ import fund.cyber.search.model.ethereum.EthereumBlock import fund.cyber.search.model.ethereum.EthereumTx import fund.cyber.search.model.ethereum.EthereumUncle import fund.cyber.search.model.ethereum.TxTrace -import fund.cyber.search.model.ethereum.getBlockReward -import fund.cyber.search.model.ethereum.getUncleReward import fund.cyber.search.model.ethereum.weiToEthRate import org.springframework.stereotype.Component import org.web3j.protocol.core.methods.response.EthBlock import org.web3j.protocol.core.methods.response.Transaction import org.web3j.protocol.core.methods.response.TransactionReceipt +import org.web3j.protocol.parity.methods.response.Trace import java.math.BigDecimal -import java.math.RoundingMode import java.time.Instant @Component @@ -31,8 +28,8 @@ class ParityToEthereumBundleConverter( fun convert(rawData: BundleRawData): EthereumBlockBundle { val transactions = parityTransactionsToDao(rawData) - val block = parityBlockToDao(rawData.block, transactions) - val blockUncles = parityUnclesToDao(block, rawData.uncles) + val block = parityBlockToDao(rawData.block, transactions, rawData.calls) + val blockUncles = parityUnclesToDao(block, rawData.uncles, rawData.calls) //todo parent hash test, reorganisation return EthereumBlockBundle( @@ -57,7 +54,9 @@ class ParityToEthereumBundleConverter( ) } - private fun parityUnclesToDao(block: EthereumBlock, uncles: List): List { + private fun parityUnclesToDao(block: EthereumBlock, uncles: List, traces: List) + : List + { return uncles.mapIndexed { index, uncle -> val uncleNumber = uncle.number.toLong() EthereumUncle( @@ -66,7 +65,7 @@ class ParityToEthereumBundleConverter( timestamp = Instant.ofEpochSecond(uncle.timestampRaw.hexToLong()), blockNumber = block.number, blockTime = block.timestamp, blockHash = block.hash.toSearchHashFormat(), - uncleReward = getUncleReward(chainInfo, uncleNumber, block.number) + uncleReward = getUncleReward(traces, uncle.miner.toSearchHashFormat(), index) ) } } @@ -109,14 +108,16 @@ class ParityToEthereumBundleConverter( } - private fun parityBlockToDao(parityBlock: EthBlock.Block, transactions: List): EthereumBlock { - + private fun parityBlockToDao(parityBlock: EthBlock.Block, transactions: List, traces: List) + : EthereumBlock + { val blockTxesFees = transactions.map { tx -> tx.fee } val number = parityBlock.numberRaw.hexToLong() - val blockReward = getBlockReward(chainInfo, number) - val uncleReward = (blockReward * parityBlock.uncles.size.toBigDecimal()) - .divide(decimal32, DECIMAL_SCALE, RoundingMode.FLOOR).stripTrailingZeros() + val blockReward = getBlockReward(traces) + val uncleInclusionReward = blockReward.multiply(parityBlock.uncles.size.toBigDecimal()) + .divide(decimal32.plus(parityBlock.uncles.size.toBigDecimal())).stripTrailingZeros() + val staticBlockReward = blockReward.minus(uncleInclusionReward).stripTrailingZeros() return EthereumBlock( hash = parityBlock.hash.toSearchHashFormat(), parentHash = parityBlock.parentHash.toSearchHashFormat(), @@ -131,7 +132,28 @@ class ParityToEthereumBundleConverter( stateRoot = parityBlock.stateRoot.toSearchHashFormat(), sha3Uncles = parityBlock.sha3Uncles.toSearchHashFormat(), uncles = parityBlock.uncles, txNumber = parityBlock.transactions.size, nonce = parityBlock.nonce.toLong(), - txFees = blockTxesFees.sum(), blockReward = blockReward, unclesReward = uncleReward + txFees = blockTxesFees.sum(), blockReward = staticBlockReward, + unclesReward = uncleInclusionReward ) } + + fun getRewardTraces(traces: List): List { + return traces + .map { trace -> trace.action } + .filterIsInstance() + } + + fun getBlockReward(traces: List): BigDecimal { + return getRewardTraces(traces) + .filter { rewardAction -> rewardAction.rewardType == "block" }[0].value.toBigDecimal() * weiToEthRate + } + + fun getUncleReward(traces: List, miner: String, unclePosition: Int): BigDecimal { + val uncleRewardTracesByMiner = getRewardTraces(traces) + .filter { rewardAction -> + rewardAction.rewardType == "uncle" && rewardAction.author.toSearchHashFormat() == miner} + if (uncleRewardTracesByMiner.size == 1) + return uncleRewardTracesByMiner.get(0).value.toBigDecimal() * weiToEthRate + return uncleRewardTracesByMiner[unclePosition].value.toBigDecimal() * weiToEthRate + } } diff --git a/pumps/ethereum/src/test/kotlin/fund/cyber/pump/ethereum/client/EthereumBlockchainInterfaceTest.kt b/pumps/ethereum/src/test/kotlin/fund/cyber/pump/ethereum/client/EthereumBlockchainInterfaceTest.kt index 24a89b7f..6075dfa3 100644 --- a/pumps/ethereum/src/test/kotlin/fund/cyber/pump/ethereum/client/EthereumBlockchainInterfaceTest.kt +++ b/pumps/ethereum/src/test/kotlin/fund/cyber/pump/ethereum/client/EthereumBlockchainInterfaceTest.kt @@ -33,7 +33,7 @@ class EthereumBlockchainInterfaceTest { @Test fun blockBundleByNumberTest() { - val blockNumber = 1L + val blockNumber = 6149845L val ethBlock = testData.getBlock(blockNumber) val uncle = testData.getUncle(ethBlock.block.hash, 0) val receipt = testData.getReceipt("0xd7b10b163b1de8f8967d824ea73d996c476588a91a4c714ad897b135cf7fa4c5") @@ -57,15 +57,15 @@ class EthereumBlockchainInterfaceTest { val blockchainInterface = EthereumBlockchainInterface(jsonRpcParity, converter, genesisMock, SimpleMeterRegistry()) val bundle = blockchainInterface.blockBundleByNumber(1) - Assertions.assertThat(bundle.number).isEqualTo(1) - Assertions.assertThat(bundle.hash).isEqualTo("B") + Assertions.assertThat(bundle.number).isEqualTo(6149845) + Assertions.assertThat(bundle.hash).isEqualTo("02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7") Assertions.assertThat(bundle.parentHash).isEqualTo("A") Assertions.assertThat(bundle.txes).hasSize(1) - Assertions.assertThat(bundle.uncles).hasSize(1) + Assertions.assertThat(bundle.uncles).hasSize(2) Assertions.assertThat(bundle.block).isNotNull() - Assertions.assertThat(bundle.block.hash).isEqualTo("B") + Assertions.assertThat(bundle.block.hash).isEqualTo("02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7") Assertions.assertThat(bundle.txes[0].hash).isEqualTo("d7b10b163b1de8f8967d824ea73d996c476588a91a4c714ad897b135cf7fa4c5") - Assertions.assertThat(bundle.uncles[0].hash).isEqualTo("UB") + Assertions.assertThat(bundle.uncles[0].hash).isEqualTo("772205e8de3b9d52bc6c410c7adf1348abb32c97adbee6aebdd9a2bb33f7fbf8") } @Test diff --git a/pumps/ethereum/src/test/kotlin/fund/cyber/pump/ethereum/client/ParityToEthereumBundleConverterTest.kt b/pumps/ethereum/src/test/kotlin/fund/cyber/pump/ethereum/client/ParityToEthereumBundleConverterTest.kt index 7f72afe2..88d46d73 100644 --- a/pumps/ethereum/src/test/kotlin/fund/cyber/pump/ethereum/client/ParityToEthereumBundleConverterTest.kt +++ b/pumps/ethereum/src/test/kotlin/fund/cyber/pump/ethereum/client/ParityToEthereumBundleConverterTest.kt @@ -1,5 +1,7 @@ package fund.cyber.pump.ethereum.client +import fund.cyber.common.DECIMAL_SCALE +import fund.cyber.common.decimal32 import fund.cyber.search.model.chains.ChainFamily import fund.cyber.search.model.chains.ChainInfo import fund.cyber.search.model.ethereum.CallOperation @@ -8,6 +10,7 @@ import fund.cyber.search.model.ethereum.OperationTrace import org.assertj.core.api.Assertions import org.junit.jupiter.api.Test import java.math.BigDecimal +import java.math.RoundingMode import java.time.Instant @Suppress("LongMethod") @@ -17,27 +20,26 @@ class ParityToEthereumBundleConverterTest { private val testData = ParityTestData() private val converter = ParityToEthereumBundleConverter(chainInfo) - @Test - fun convertTest() { - val ethBlock = testData.getBlock(1) - val uncle = testData.getUncle("0xB", 0) + fun convertTwoUnclesDifferentMinerTest() { + val ethBlock = testData.getBlock(6149845) + val uncle0 = testData.getUncle("0x02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7", 0) + val uncle1 = testData.getUncle("0x02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7", 1) val receipt = testData.getReceipt("0xd7b10b163b1de8f8967d824ea73d996c476588a91a4c714ad897b135cf7fa4c5") - val tracesResponse = testData.getTraces(1) - + val tracesResponse = testData.getTraces(6149845) - val rawData = BundleRawData(ethBlock.block, listOf(uncle.block), listOf(receipt.result), tracesResponse.traces) + val rawData = BundleRawData(ethBlock.block, listOf(uncle0.block, uncle1.block), listOf(receipt.result), tracesResponse.traces) val bundle = converter.convert(rawData) - Assertions.assertThat(bundle.hash).isEqualTo("B") + Assertions.assertThat(bundle.hash).isEqualTo("02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7") Assertions.assertThat(bundle.parentHash).isEqualTo("A") - Assertions.assertThat(bundle.number).isEqualTo(1) + Assertions.assertThat(bundle.number).isEqualTo(6149845) Assertions.assertThat(bundle.blockSize).isEqualTo(101) Assertions.assertThat(bundle.block).isNotNull() - Assertions.assertThat(bundle.block.hash).isEqualTo("B") - Assertions.assertThat(bundle.block.number).isEqualTo(1) + Assertions.assertThat(bundle.block.hash).isEqualTo("02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7") + Assertions.assertThat(bundle.block.number).isEqualTo(6149845) Assertions.assertThat(bundle.block.parentHash).isEqualTo("A") Assertions.assertThat(bundle.block.timestamp).isEqualTo(Instant.ofEpochSecond(111111111)) Assertions.assertThat(bundle.block.sha3Uncles).isEqualTo("") @@ -53,29 +55,39 @@ class ParityToEthereumBundleConverterTest { Assertions.assertThat(bundle.block.gasLimit).isEqualTo(200) Assertions.assertThat(bundle.block.gasUsed).isEqualTo(150) Assertions.assertThat(bundle.block.txNumber).isEqualTo(1) - Assertions.assertThat(bundle.block.uncles.size).isEqualTo(1) - Assertions.assertThat(bundle.block.blockReward).isEqualTo(BigDecimal("5")) - Assertions.assertThat(bundle.block.unclesReward).isEqualTo(BigDecimal("0.15625")) + Assertions.assertThat(bundle.block.uncles.size).isEqualTo(2) + val expectedIncludingUnclesReward = ((3 * 2).toBigDecimal()).divide(decimal32, DECIMAL_SCALE, RoundingMode.FLOOR).stripTrailingZeros() + Assertions.assertThat(bundle.block.unclesReward.stripTrailingZeros()).isEqualTo(expectedIncludingUnclesReward) + Assertions.assertThat(bundle.block.blockReward.stripTrailingZeros()).isEqualTo(BigDecimal(3)) Assertions.assertThat(bundle.block.txFees).isEqualTo(BigDecimal("0.000084000000000000")) - Assertions.assertThat(bundle.uncles.size).isEqualTo(1) - Assertions.assertThat(bundle.uncles[0].hash).isEqualTo("UB") + Assertions.assertThat(bundle.uncles.size).isEqualTo(2) + Assertions.assertThat(bundle.uncles[0].hash).isEqualTo("772205e8de3b9d52bc6c410c7adf1348abb32c97adbee6aebdd9a2bb33f7fbf8") Assertions.assertThat(bundle.uncles[0].position).isEqualTo(0) - Assertions.assertThat(bundle.uncles[0].number).isEqualTo(1) + Assertions.assertThat(bundle.uncles[0].number).isEqualTo(6149845) Assertions.assertThat(bundle.uncles[0].timestamp).isEqualTo(Instant.ofEpochSecond(111111111)) - Assertions.assertThat(bundle.uncles[0].blockNumber).isEqualTo(1) + Assertions.assertThat(bundle.uncles[0].blockNumber).isEqualTo(6149845) Assertions.assertThat(bundle.uncles[0].blockTime).isEqualTo(Instant.ofEpochSecond(111111111)) - Assertions.assertThat(bundle.uncles[0].blockHash).isEqualTo("B") - Assertions.assertThat(bundle.uncles[0].miner).isEqualTo("UMINER") - Assertions.assertThat(bundle.uncles[0].uncleReward).isEqualTo(BigDecimal("5")) + Assertions.assertThat(bundle.uncles[0].blockHash).isEqualTo("02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7") + Assertions.assertThat(bundle.uncles[0].miner).isEqualTo("c8ebccc5f5689fa8659d83713341e5ad19349448") + Assertions.assertThat(bundle.uncles[0].uncleReward.stripTrailingZeros()).isEqualTo(BigDecimal(2.625)) + Assertions.assertThat(bundle.uncles[1].hash).isEqualTo("a435f091388391e8edec523a26c127776c6d469dee9f8812aaade52f0f31f402") + Assertions.assertThat(bundle.uncles[1].position).isEqualTo(1) + Assertions.assertThat(bundle.uncles[1].number).isEqualTo(6149845) + Assertions.assertThat(bundle.uncles[1].timestamp).isEqualTo(Instant.ofEpochSecond(111111111)) + Assertions.assertThat(bundle.uncles[1].blockNumber).isEqualTo(6149845) + Assertions.assertThat(bundle.uncles[1].blockTime).isEqualTo(Instant.ofEpochSecond(111111111)) + Assertions.assertThat(bundle.uncles[1].blockHash).isEqualTo("02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7") + Assertions.assertThat(bundle.uncles[1].miner).isEqualTo("c8ebccc5f5689fa8659d83713341e5ad19349441") + Assertions.assertThat(bundle.uncles[1].uncleReward.stripTrailingZeros()).isEqualTo(BigDecimal(2.25)) Assertions.assertThat(bundle.txes.size).isEqualTo(1) Assertions.assertThat(bundle.txes[0].hash).isEqualTo("d7b10b163b1de8f8967d824ea73d996c476588a91a4c714ad897b135cf7fa4c5") Assertions.assertThat(bundle.txes[0].error).isNull() Assertions.assertThat(bundle.txes[0].nonce).isEqualTo(0) - Assertions.assertThat(bundle.txes[0].blockHash).isEqualTo("B") - Assertions.assertThat(bundle.txes[0].blockNumber).isEqualTo(1) + Assertions.assertThat(bundle.txes[0].blockHash).isEqualTo("02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7") + Assertions.assertThat(bundle.txes[0].blockNumber).isEqualTo(6149845) Assertions.assertThat(bundle.txes[0].firstSeenTime).isEqualTo(Instant.ofEpochSecond(111111111)) Assertions.assertThat(bundle.txes[0].blockTime).isEqualTo(Instant.ofEpochSecond(111111111)) Assertions.assertThat(bundle.txes[0].positionInBlock).isEqualTo(0) @@ -103,10 +115,54 @@ class ParityToEthereumBundleConverterTest { Assertions.assertThat(bundle.txes[0].trace!!.rootOperationTrace).isEqualTo(expectedRootOperationTrace) } + @Test + fun convertTwoUnclesSameMinerTest() { + val ethBlock = testData.getBlock(6154914) + val uncle0 = testData.getUncle("0x12e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7", 0) + val uncle1 = testData.getUncle("0x12e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7", 1) + val tracesResponse = testData.getTraces(6154914) + + val rawData = BundleRawData(ethBlock.block, listOf(uncle0.block, uncle1.block), listOf(), tracesResponse.traces) + + val bundle = converter.convert(rawData) + + Assertions.assertThat(bundle.hash).isEqualTo("12e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7") + Assertions.assertThat(bundle.parentHash).isEqualTo("A") + Assertions.assertThat(bundle.number).isEqualTo(6154914) + Assertions.assertThat(bundle.blockSize).isEqualTo(101) + + Assertions.assertThat(bundle.block).isNotNull() + Assertions.assertThat(bundle.block.hash).isEqualTo("12e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7") + Assertions.assertThat(bundle.block.number).isEqualTo(6154914) + Assertions.assertThat(bundle.block.uncles.size).isEqualTo(2) + val expectedUncleInclusionReward = ((3 * 2).toBigDecimal()).divide(decimal32, DECIMAL_SCALE, RoundingMode.FLOOR).stripTrailingZeros() + Assertions.assertThat(bundle.block.unclesReward.stripTrailingZeros()).isEqualTo(expectedUncleInclusionReward) + Assertions.assertThat(bundle.block.blockReward.stripTrailingZeros()).isEqualTo(BigDecimal(3)) + Assertions.assertThat(bundle.block.txFees).isEqualTo(BigDecimal("0")) + + Assertions.assertThat(bundle.uncles.size).isEqualTo(2) + Assertions.assertThat(bundle.uncles[0].hash).isEqualTo("96aea1634772681458dafeedc968e05df41cf1da0f0ef38e548044ed1841e730") + Assertions.assertThat(bundle.uncles[0].position).isEqualTo(0) + Assertions.assertThat(bundle.uncles[0].number).isEqualTo(6154914) + Assertions.assertThat(bundle.uncles[0].timestamp).isEqualTo(Instant.ofEpochSecond(111111111)) + Assertions.assertThat(bundle.uncles[0].blockNumber).isEqualTo(6154914) + Assertions.assertThat(bundle.uncles[0].blockTime).isEqualTo(Instant.ofEpochSecond(111111111)) + Assertions.assertThat(bundle.uncles[0].blockHash).isEqualTo("12e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7") + Assertions.assertThat(bundle.uncles[0].miner).isEqualTo("123") + Assertions.assertThat(bundle.uncles[0].uncleReward.stripTrailingZeros()).isEqualTo(BigDecimal(2.625)) + Assertions.assertThat(bundle.uncles[1].hash).isEqualTo("527fa10104dc069db366e6e054251fd986c7ea3a49afebb539aa6f0b991baedc") + Assertions.assertThat(bundle.uncles[1].position).isEqualTo(1) + Assertions.assertThat(bundle.uncles[1].number).isEqualTo(6154914) + Assertions.assertThat(bundle.uncles[1].timestamp).isEqualTo(Instant.ofEpochSecond(111111111)) + Assertions.assertThat(bundle.uncles[1].blockNumber).isEqualTo(6154914) + Assertions.assertThat(bundle.uncles[1].blockTime).isEqualTo(Instant.ofEpochSecond(111111111)) + Assertions.assertThat(bundle.uncles[1].blockHash).isEqualTo("12e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7") + Assertions.assertThat(bundle.uncles[1].miner).isEqualTo("123") + Assertions.assertThat(bundle.uncles[1].uncleReward.stripTrailingZeros()).isEqualTo(BigDecimal(1.875)) + } @Test fun convertMempoolTxTest() { - val mempoolTx = testData.getTx("0xc713064951e38f55b167c483a882bd1550b12d58c552800e1e25a764e70a6894") val convertedTx = converter.parityMempoolTxToDao(mempoolTx) @@ -129,5 +185,4 @@ class ParityToEthereumBundleConverterTest { Assertions.assertThat(convertedTx.createdSmartContract).isNull() Assertions.assertThat(convertedTx.trace).isNull() } - } diff --git a/pumps/ethereum/src/test/resources/client/parity-data/block/1.json b/pumps/ethereum/src/test/resources/client/parity-data/block/6149845.json similarity index 72% rename from pumps/ethereum/src/test/resources/client/parity-data/block/1.json rename to pumps/ethereum/src/test/resources/client/parity-data/block/6149845.json index 468e6bb0..e28d0793 100644 --- a/pumps/ethereum/src/test/resources/client/parity-data/block/1.json +++ b/pumps/ethereum/src/test/resources/client/parity-data/block/6149845.json @@ -1,7 +1,7 @@ { "result": { - "number": "0x1", - "hash": "0xB", + "number": "0x5DD6D5", + "hash": "0x02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7", "parentHash": "0xA", "nonce": "0x0", "sha3Uncles": "", @@ -23,8 +23,8 @@ { "hash": "0xd7b10b163b1de8f8967d824ea73d996c476588a91a4c714ad897b135cf7fa4c5", "nonce": "0x0", - "blockHash": "0xB", - "blockNumber": "0x1", + "blockHash": "0x02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7", + "blockNumber": "0x5DD6D5", "transactionIndex": "0x0", "from": "0x52bc44d5378309ee2abf1539bf71de1b7d7be3b5", "to": "0x00b654761a1b4372a77f6a327893572f55a483c7", @@ -40,7 +40,8 @@ } ], "uncles": [ - "0xUB" + "0x772205e8de3b9d52bc6c410c7adf1348abb32c97adbee6aebdd9a2bb33f7fbf8", + "0xa435f091388391e8edec523a26c127776c6d469dee9f8812aaade52f0f31f402" ], "sealFields": [] } diff --git a/pumps/ethereum/src/test/resources/client/parity-data/block/6154914.json b/pumps/ethereum/src/test/resources/client/parity-data/block/6154914.json new file mode 100644 index 00000000..b4ed8e86 --- /dev/null +++ b/pumps/ethereum/src/test/resources/client/parity-data/block/6154914.json @@ -0,0 +1,29 @@ +{ + "result": { + "number": "0x5DEAA2", + "hash": "0x12e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7", + "parentHash": "0xA", + "nonce": "0x0", + "sha3Uncles": "", + "logsBloom": "", + "transactionsRoot": "0xTXROOT", + "stateRoot": "", + "receiptsRoot": "", + "author": "0xAUTHOR", + "miner": "0xMINER", + "mixHash": "", + "difficulty": "0x64", + "totalDifficulty": "0x64", + "extraData": "", + "size": "0x65", + "gasLimit": "0xC8", + "gasUsed": "0x96", + "timestamp": "111111111", + "transactions": [], + "uncles": [ + "0x96aea1634772681458dafeedc968e05df41cf1da0f0ef38e548044ed1841e730", + "0x527fa10104dc069db366e6e054251fd986c7ea3a49afebb539aa6f0b991baedc" + ], + "sealFields": [] + } +} \ No newline at end of file diff --git a/pumps/ethereum/src/test/resources/client/parity-data/traces/1.json b/pumps/ethereum/src/test/resources/client/parity-data/traces/1.json deleted file mode 100644 index c6703ddf..00000000 --- a/pumps/ethereum/src/test/resources/client/parity-data/traces/1.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "result": [ - { - "action": { - "callType": "call", - "from": "0x52bc44d5378309ee2abf1539bf71de1b7d7be3b5", - "gas": "0xC350", - "input": "0x", - "to": "0x00b654761a1b4372a77f6a327893572f55a483c7", - "value": "0x6d25aa60a635a00" - }, - "blockHash": "0xB", - "blockNumber": 1, - "result": { - "gasUsed": "0x5208", - "output": "0x" - }, - "subtraces": 0, - "traceAddress": [], - "transactionHash": "0xd7b10b163b1de8f8967d824ea73d996c476588a91a4c714ad897b135cf7fa4c5", - "transactionPosition": 0, - "type": "call" - } - ] -} diff --git a/pumps/ethereum/src/test/resources/client/parity-data/traces/6149845.json b/pumps/ethereum/src/test/resources/client/parity-data/traces/6149845.json new file mode 100644 index 00000000..65d2e3c3 --- /dev/null +++ b/pumps/ethereum/src/test/resources/client/parity-data/traces/6149845.json @@ -0,0 +1,67 @@ +{ + "result": [ + { + "action": { + "callType": "call", + "from": "0x52bc44d5378309ee2abf1539bf71de1b7d7be3b5", + "gas": "0xC350", + "input": "0x", + "to": "0x00b654761a1b4372a77f6a327893572f55a483c7", + "value": "0x6d25aa60a635a00" + }, + "blockHash": "0x02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7", + "blockNumber": 6149845, + "result": { + "gasUsed": "0x5208", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0xd7b10b163b1de8f8967d824ea73d996c476588a91a4c714ad897b135cf7fa4c5", + "transactionPosition": 0, + "type": "call" + }, { + "action": { + "author": "0x5088d623ba0fcf0131e0897a91734a4d83596aa0", + "rewardType": "block", + "value": "0x2C3C465CA58EC000" + }, + "blockHash": "0x02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7", + "blockNumber": 6149845, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + }, { + "action": { + "author": "0xc8ebccc5f5689fa8659d83713341e5ad19349448", + "rewardType": "uncle", + "value": "0x246DDF9797668000" + }, + "blockHash": "0x772205e8de3b9d52bc6c410c7adf1348abb32c97adbee6aebdd9a2bb33f7fbf8", + "blockNumber": 6149844, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type":"reward" + }, { + "action": { + "author": "0xc8ebccc5f5689fa8659d83713341e5ad19349441", + "rewardType": "uncle", + "value": "0x1F399B1438A10000" + }, + "blockHash": "0xa435f091388391e8edec523a26c127776c6d469dee9f8812aaade52f0f31f402", + "blockNumber": 6149843, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type":"reward" + } + ] +} diff --git a/pumps/ethereum/src/test/resources/client/parity-data/traces/6154914.json b/pumps/ethereum/src/test/resources/client/parity-data/traces/6154914.json new file mode 100644 index 00000000..b6a77508 --- /dev/null +++ b/pumps/ethereum/src/test/resources/client/parity-data/traces/6154914.json @@ -0,0 +1,47 @@ +{ + "result": [ + { + "action": { + "author": "0x5088d623ba0fcf0131e0897a91734a4d83596aa0", + "rewardType": "block", + "value": "0x2C3C465CA58EC000" + }, + "blockHash": "0x12e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7", + "blockNumber": 6154914, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + }, { + "action": { + "author": "0x123", + "rewardType": "uncle", + "value": "0x246DDF9797668000" + }, + "blockHash": "0x96aea1634772681458dafeedc968e05df41cf1da0f0ef38e548044ed1841e730", + "blockNumber": 6154914, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type":"reward" + }, { + "action": { + "author": "0x123", + "rewardType": "uncle", + "value": "0x1A055690D9DB8000" + }, + "blockHash": "0x527fa10104dc069db366e6e054251fd986c7ea3a49afebb539aa6f0b991baedc", + "blockNumber": 6154914, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type":"reward" + } + ] +} diff --git a/pumps/ethereum/src/test/resources/client/parity-data/uncles/0xB_0.json b/pumps/ethereum/src/test/resources/client/parity-data/uncles/0x02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7_0.json similarity index 81% rename from pumps/ethereum/src/test/resources/client/parity-data/uncles/0xB_0.json rename to pumps/ethereum/src/test/resources/client/parity-data/uncles/0x02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7_0.json index adec77b1..9b58467b 100644 --- a/pumps/ethereum/src/test/resources/client/parity-data/uncles/0xB_0.json +++ b/pumps/ethereum/src/test/resources/client/parity-data/uncles/0x02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7_0.json @@ -1,7 +1,7 @@ { "result": { - "number": "0x1", - "hash": "0xUB", + "number": "0x5DD6D5", + "hash": "0x772205e8de3b9d52bc6c410c7adf1348abb32c97adbee6aebdd9a2bb33f7fbf8", "parentHash": "0xA", "nonce": "0x0", "sha3Uncles": "", @@ -9,8 +9,8 @@ "transactionsRoot": "0xTXROOT", "stateRoot": "", "receiptsRoot": "", - "author": "0xUAUTHOR", - "miner": "0xUMINER", + "author": "0xc8ebccc5f5689fa8659d83713341e5ad19349448", + "miner": "0xc8ebccc5f5689fa8659d83713341e5ad19349448", "mixHash": "", "difficulty": "0x64", "totalDifficulty": "0x64", diff --git a/pumps/ethereum/src/test/resources/client/parity-data/uncles/0x02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7_1.json b/pumps/ethereum/src/test/resources/client/parity-data/uncles/0x02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7_1.json new file mode 100644 index 00000000..4613739f --- /dev/null +++ b/pumps/ethereum/src/test/resources/client/parity-data/uncles/0x02e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7_1.json @@ -0,0 +1,45 @@ +{ + "result": { + "number": "0x5DD6D5", + "hash": "0xa435f091388391e8edec523a26c127776c6d469dee9f8812aaade52f0f31f402", + "parentHash": "0xA", + "nonce": "0x0", + "sha3Uncles": "", + "logsBloom": "", + "transactionsRoot": "0xTXROOT", + "stateRoot": "", + "receiptsRoot": "", + "author": "0xc8ebccc5f5689fa8659d83713341e5ad19349441", + "miner": "0xc8ebccc5f5689fa8659d83713341e5ad19349441", + "mixHash": "", + "difficulty": "0x64", + "totalDifficulty": "0x64", + "extraData": "", + "size": "101", + "gasLimit": "200", + "gasUsed": "150", + "timestamp": "111111111", + "transactions": [ + { + "hash": "0xd7b10b163b1de8f8967d824ea73d996c476588a91a4c714ad897b135cf7fa4c5", + "nonce": "0x0", + "blockHash": "0xB", + "blockNumber": "1", + "transactionIndex": "1", + "from": "0x52bc44d5378309ee2abf1539bf71de1b7d7be3b5", + "to": "0x00b654761a1b4372a77f6a327893572f55a483c7", + "value": "0x6d25aa60a635a00", + "gasPrice": "0x38D7EA4C68000", + "gas": "0x7148", + "input": "0x", + "publicKey": "", + "raw": "", + "r": "", + "s": "", + "v": 1 + } + ], + "uncles": [], + "sealFields": [] + } +} \ No newline at end of file diff --git a/pumps/ethereum/src/test/resources/client/parity-data/uncles/0x12e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7_0.json b/pumps/ethereum/src/test/resources/client/parity-data/uncles/0x12e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7_0.json new file mode 100644 index 00000000..346a7310 --- /dev/null +++ b/pumps/ethereum/src/test/resources/client/parity-data/uncles/0x12e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7_0.json @@ -0,0 +1,26 @@ +{ + "result": { + "number": "0x5DEAA2", + "hash": "0x96aea1634772681458dafeedc968e05df41cf1da0f0ef38e548044ed1841e730", + "parentHash": "0xA", + "nonce": "0x0", + "sha3Uncles": "", + "logsBloom": "", + "transactionsRoot": "0xTXROOT", + "stateRoot": "", + "receiptsRoot": "", + "author": "0x123", + "miner": "0x123", + "mixHash": "", + "difficulty": "0x64", + "totalDifficulty": "0x64", + "extraData": "", + "size": "101", + "gasLimit": "200", + "gasUsed": "150", + "timestamp": "111111111", + "transactions": [], + "uncles": [], + "sealFields": [] + } +} \ No newline at end of file diff --git a/pumps/ethereum/src/test/resources/client/parity-data/uncles/0x12e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7_1.json b/pumps/ethereum/src/test/resources/client/parity-data/uncles/0x12e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7_1.json new file mode 100644 index 00000000..164db3e0 --- /dev/null +++ b/pumps/ethereum/src/test/resources/client/parity-data/uncles/0x12e2ee54556a80710af3f80691781bf4eae37ae869d40bcf46b4186aeb6ce4d7_1.json @@ -0,0 +1,26 @@ +{ + "result": { + "number": "0x5DEAA2", + "hash": "0x527fa10104dc069db366e6e054251fd986c7ea3a49afebb539aa6f0b991baedc", + "parentHash": "0xA", + "nonce": "0x0", + "sha3Uncles": "", + "logsBloom": "", + "transactionsRoot": "0xTXROOT", + "stateRoot": "", + "receiptsRoot": "", + "author": "0x123", + "miner": "0x123", + "mixHash": "", + "difficulty": "0x64", + "totalDifficulty": "0x64", + "extraData": "", + "size": "101", + "gasLimit": "200", + "gasUsed": "150", + "timestamp": "111111111", + "transactions": [], + "uncles": [], + "sealFields": [] + } +} \ No newline at end of file