You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuweni.apache.org by to...@apache.org on 2023/01/29 02:08:07 UTC
[incubator-tuweni] branch main updated: spotless upgrade - trim all lines to 120 max
This is an automated email from the ASF dual-hosted git repository.
toulmean pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git
The following commit(s) were added to refs/heads/main by this push:
new 18e1684c2 spotless upgrade - trim all lines to 120 max
new abdcd7816 Merge pull request #493 from atoulme/spotless_upgrade
18e1684c2 is described below
commit 18e1684c2e0f66fb4aac0c6419aa9667115b64d2
Author: Antoine Toulme <an...@lunar-ocean.com>
AuthorDate: Tue Jan 17 00:29:26 2023 -0800
spotless upgrade - trim all lines to 120 max
---
build.gradle | 2 +-
.../org/apache/tuweni/devp2p/eth/EthClient.kt | 8 +++--
.../org/apache/tuweni/devp2p/eth/EthHandler.kt | 7 +++-
.../org/apache/tuweni/devp2p/eth/EthHandler66.kt | 33 ++++++++++++++---
.../org/apache/tuweni/devp2p/DiscoveryService.kt | 7 +++-
.../apache/tuweni/blockprocessor/BlockProcessor.kt | 3 +-
.../tuweni/blockprocessor/TransactionProcessor.kt | 13 +++++--
.../tuweni/blockprocessor/BlockProcessorTest.kt | 22 ++++++++++--
.../blockprocessor/TransactionProcessorTest.kt | 2 +-
.../apache/tuweni/ethclientui/UIIntegrationTest.kt | 4 ++-
.../org/apache/tuweni/ethclient/EthereumClient.kt | 25 +++++++++----
.../tuweni/ethclient/EthereumClientConfig.kt | 14 ++++++--
.../WireConnectionPeerRepositoryAdapter.kt | 6 +++-
.../tuweni/ethclient/EthereumClientConfigTest.kt | 4 ++-
.../org/apache/tuweni/eth/crawler/CrawlerConfig.kt | 17 ++++++---
.../tuweni/eth/crawler/CrawlerRESTService.kt | 8 +++--
.../tuweni/eth/crawler/EthstatsDataRepository.kt | 32 +++++++++++++----
.../tuweni/eth/crawler/RelationalPeerRepository.kt | 37 +++++++++++++------
.../org/apache/tuweni/eth/crawler/rest/Metadata.kt | 6 +++-
.../tuweni/eth/crawler/rest/ClientIdInfoTest.kt | 4 ++-
.../org/apache/tuweni/eth/precompiles/Contracts.kt | 7 +++-
.../tuweni/eth/repository/BlockchainRepository.kt | 14 ++++++--
.../eth/repository/TransientStateRepository.kt | 14 ++++++--
.../kotlin/org/apache/tuweni/eth/JSONRPCRequest.kt | 4 ++-
.../org/apache/tuweni/eth/JSONRPCResponse.kt | 14 ++++++--
.../apache/tuweni/ethstats/EthStatsReporterTest.kt | 9 +++--
.../org/apache/tuweni/ethstats/EthStatsServer.kt | 6 +++-
.../org/apache/tuweni/ethstats/AuthMessageTest.kt | 4 ++-
.../org/apache/tuweni/ethstats/NodeStatsTest.kt | 3 +-
.../org/apache/tuweni/evmdsl/Instructions.kt | 6 +++-
.../org/apache/tuweni/evmdsl/DeploymentTest.kt | 9 +++--
.../apache/tuweni/evm/EthereumVirtualMachine.kt | 42 ++++++++++++++++++----
.../tuweni/evm/TransactionalEVMHostContext.kt | 17 +++++++--
.../kotlin/org/apache/tuweni/evm/impl/EvmVmImpl.kt | 15 ++++++--
.../org/apache/tuweni/evm/EVMReferenceTest.kt | 8 ++++-
.../kotlin/org/apache/tuweni/evm/EcroverTest.kt | 26 ++++++++++++--
.../tuweni/evm/EthereumVirtualMachineTest.kt | 6 +++-
.../org/apache/tuweni/evm/EvmCertificationTest.kt | 18 ++++++++--
.../kotlin/org/apache/tuweni/evm/OpcodeTest.kt | 18 ++++++++--
.../kotlin/org/apache/tuweni/evm/impl/StackTest.kt | 5 ++-
.../kotlin/org/apache/tuweni/genesis/Quorum.kt | 3 +-
.../org/apache/tuweni/genesis/GenesisTest.kt | 4 ++-
.../org/apache/tuweni/jsonrpc/app/JSONRPCApp.kt | 17 ++++++---
.../org/apache/tuweni/jsonrpc/app/JSONRPCConfig.kt | 21 +++++++++--
.../org/apache/tuweni/jsonrpc/JSONRPCClient.kt | 6 +++-
.../org/apache/tuweni/jsonrpc/JSONRPCServer.kt | 9 ++---
.../org/apache/tuweni/jsonrpc/JSONRPCClientTest.kt | 5 ++-
.../org/apache/tuweni/kv/PersistenceMarshaller.kt | 4 ++-
.../org/apache/tuweni/trie/MerklePatriciaTrie.kt | 5 ++-
.../trie/StoredMerklePatriciaTrieKotlinTest.kt | 10 ++++--
.../org/apache/tuweni/metrics/MetricsService.kt | 5 ++-
.../tuweni/scuttlebutt/lib/model/FeedValue.kt | 9 ++++-
.../vertx/SecureScuttlebuttVertxClient.kt | 6 +++-
.../SecureScuttlebuttHandshakeClientTest.kt | 6 ++--
.../apache/tuweni/scuttlebutt/rpc/RPCMessage.kt | 4 ++-
.../org/apache/tuweni/scuttlebutt/InviteTest.kt | 13 +++++--
.../apache/tuweni/stratum/server/StratumServer.kt | 7 +++-
57 files changed, 515 insertions(+), 118 deletions(-)
diff --git a/build.gradle b/build.gradle
index 95f977af6..b320dca14 100644
--- a/build.gradle
+++ b/build.gradle
@@ -26,7 +26,7 @@ buildscript {
}
plugins {
- id 'com.diffplug.spotless' version '6.12.1'
+ id 'com.diffplug.spotless' version '6.13.0'
id 'net.ltgt.errorprone' version '3.0.1'
id 'org.springframework.boot' version '2.7.7'
id 'io.spring.dependency-management' version '1.1.0'
diff --git a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthClient.kt b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthClient.kt
index c67374bbb..a33108887 100644
--- a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthClient.kt
+++ b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthClient.kt
@@ -84,7 +84,10 @@ open class EthClient(
reverse: Boolean,
connection: WireConnection
): AsyncResult<List<BlockHeader>> {
- logger.info("Requesting headers hash: $blockHash maxHeaders: $maxHeaders skip: $skip reverse: $reverse with uri ${connection.uri()}")
+ logger.info(
+ "Requesting headers hash: $blockHash maxHeaders: $maxHeaders skip: $skip reverse: " +
+ "$reverse with uri ${connection.uri()}"
+ )
val conn = connectionSelectionStrategy.selectConnection()
val completion = AsyncResult.incomplete<List<BlockHeader>>()
headerRequests.computeIfAbsent(connection.uri() + blockHash.toHexString()) {
@@ -193,7 +196,8 @@ open class EthClient(
fun nodeDataWasRequested(connection: WireConnection): Request<List<Bytes?>>? =
nodeDataRequests[connection.uri()]
- fun transactionReceiptsRequested(connection: WireConnection): Request<List<List<TransactionReceipt>>>? = transactionReceiptRequests[connection.uri()]
+ fun transactionReceiptsRequested(connection: WireConnection): Request<List<List<TransactionReceipt>>>? =
+ transactionReceiptRequests[connection.uri()]
override suspend fun submitPooledTransaction(vararg tx: Transaction) {
for (t in tx) {
diff --git a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler.kt b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler.kt
index adafb389d..e9199f169 100644
--- a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler.kt
+++ b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler.kt
@@ -220,7 +220,12 @@ internal class EthHandler(
blockHeaderRequest.skip,
blockHeaderRequest.reverse
)
- service.send(connection.agreedSubprotocolVersion(ETH62.name()), MessageType.BlockHeaders.code, connection, BlockHeaders(headers).toBytes())
+ service.send(
+ connection.agreedSubprotocolVersion(ETH62.name()),
+ MessageType.BlockHeaders.code,
+ connection,
+ BlockHeaders(headers).toBytes()
+ )
}
private suspend fun handleNewBlockHashes(message: NewBlockHashes) {
diff --git a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler66.kt b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler66.kt
index 5d8e12c22..b78c4de5a 100644
--- a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler66.kt
+++ b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler66.kt
@@ -72,12 +72,14 @@ internal class EthHandler66(
requestIdentifier,
GetBlockHeaders.read(payload)
)
+
MessageType.BlockHeaders.code -> handleHeaders(connection, requestIdentifier, BlockHeaders.read(payload))
MessageType.GetBlockBodies.code -> handleGetBlockBodies(
connection,
requestIdentifier,
GetBlockBodies.read(payload)
)
+
MessageType.BlockBodies.code -> handleBlockBodies(connection, requestIdentifier, BlockBodies.read(payload))
MessageType.NewBlock.code -> handleNewBlock(NewBlock.read(message))
MessageType.GetNodeData.code -> handleGetNodeData(connection, requestIdentifier, GetNodeData.read(payload))
@@ -88,11 +90,13 @@ internal class EthHandler66(
connection,
NewPooledTransactionHashes.read(message)
)
+
MessageType.GetPooledTransactions.code -> handleGetPooledTransactions(
connection,
requestIdentifier,
GetPooledTransactions.read(payload)
)
+
MessageType.PooledTransactions.code -> handlePooledTransactions(PooledTransactions.read(payload))
else -> {
logger.warn("Unknown message type {} with request identifier {}", messageType, requestIdentifier)
@@ -106,7 +110,11 @@ internal class EthHandler66(
controller.addNewPooledTransactions(read.transactions)
}
- private suspend fun handleGetPooledTransactions(connection: WireConnection, requestIdentifier: Bytes, read: GetPooledTransactions) {
+ private suspend fun handleGetPooledTransactions(
+ connection: WireConnection,
+ requestIdentifier: Bytes,
+ read: GetPooledTransactions
+ ) {
val tx = controller.findPooledTransactions(read.hashes)
logger.debug("Responding to GetPooledTransactions with {} transactions", tx.size)
service.send(
@@ -144,7 +152,10 @@ internal class EthHandler66(
disconnect = true
}
if (!status.genesisHash.equals(blockchainInfo.genesisHash())) {
- EthHandler.logger.info("Peer with different genesisHash ${status.genesisHash} (expected ${blockchainInfo.genesisHash()})")
+ EthHandler.logger.info(
+ "Peer with different genesisHash ${status.genesisHash} " +
+ "(expected ${blockchainInfo.genesisHash()})"
+ )
disconnect = true
}
@@ -200,7 +211,11 @@ internal class EthHandler66(
controller.addNewTransactionReceipts(connection, requestIdentifier, receipts.transactionReceipts)
}
- private suspend fun handleGetReceipts(connection: WireConnection, requestIdentifier: Bytes, getReceipts: GetReceipts) {
+ private suspend fun handleGetReceipts(
+ connection: WireConnection,
+ requestIdentifier: Bytes,
+ getReceipts: GetReceipts
+ ) {
val receipts = controller.findTransactionReceipts(getReceipts.hashes)
service.send(
EthSubprotocol.ETH66,
@@ -234,7 +249,11 @@ internal class EthHandler66(
controller.addNewBlockBodies(connection, requestIdentifier, message.bodies)
}
- private suspend fun handleGetBlockBodies(connection: WireConnection, requestIdentifier: Bytes, message: GetBlockBodies) {
+ private suspend fun handleGetBlockBodies(
+ connection: WireConnection,
+ requestIdentifier: Bytes,
+ message: GetBlockBodies
+ ) {
if (message.hashes.isEmpty()) {
service.disconnect(connection, DisconnectReason.SUBPROTOCOL_REASON)
return
@@ -255,7 +274,11 @@ internal class EthHandler66(
controller.addNewBlockHeaders(connection, requestIdentifier, headers.headers)
}
- private suspend fun handleGetBlockHeaders(connection: WireConnection, requestIdentifier: Bytes, blockHeaderRequest: GetBlockHeaders) {
+ private suspend fun handleGetBlockHeaders(
+ connection: WireConnection,
+ requestIdentifier: Bytes,
+ blockHeaderRequest: GetBlockHeaders
+ ) {
val headers = controller.findHeaders(
blockHeaderRequest.block,
blockHeaderRequest.maxHeaders,
diff --git a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/DiscoveryService.kt b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/DiscoveryService.kt
index 0be60401d..7a68fd0dd 100644
--- a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/DiscoveryService.kt
+++ b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/DiscoveryService.kt
@@ -474,7 +474,12 @@ internal class CoroutineDiscoveryService constructor(
for (node in ArrayList(nodes)) {
val peer = peerRepository.get(selfEndpoint!!.address, selfEndpoint!!.udpPort, node.nodeId)
if (!results.contains(peer)) {
- results.orderedInsert(peer) { a, _ -> targetId.xorDistCmp(a.nodeId.bytesArray(), node.nodeId.bytesArray()) }
+ results.orderedInsert(peer) { a, _ ->
+ targetId.xorDistCmp(
+ a.nodeId.bytesArray(),
+ node.nodeId.bytesArray()
+ )
+ }
results.removeAt(results.lastIndex)
}
}
diff --git a/eth-blockprocessor/src/main/kotlin/org/apache/tuweni/blockprocessor/BlockProcessor.kt b/eth-blockprocessor/src/main/kotlin/org/apache/tuweni/blockprocessor/BlockProcessor.kt
index 23b18afe8..dd687aa4e 100644
--- a/eth-blockprocessor/src/main/kotlin/org/apache/tuweni/blockprocessor/BlockProcessor.kt
+++ b/eth-blockprocessor/src/main/kotlin/org/apache/tuweni/blockprocessor/BlockProcessor.kt
@@ -89,7 +89,8 @@ class BlockProcessor(val chainId: UInt256) {
val txProcessor = TransactionProcessor(vm, hardFork, repository, stateChanges)
val indexKey = RLP.encodeValue(UInt256.valueOf(counter).trimLeadingZeros())
transactionsTrie.put(indexKey, tx.toBytes())
- val txResult = txProcessor.execute(tx, timestamp, chainId, parentBlock, gasLimit, gasUsed, allGasUsed, coinbase, bloomFilter)
+ val txResult =
+ txProcessor.execute(tx, timestamp, chainId, parentBlock, gasLimit, gasUsed, allGasUsed, coinbase, bloomFilter)
if (txResult.success) {
val receipt = txResult.receipt!!
receiptsTrie.put(indexKey, receipt.toBytes())
diff --git a/eth-blockprocessor/src/main/kotlin/org/apache/tuweni/blockprocessor/TransactionProcessor.kt b/eth-blockprocessor/src/main/kotlin/org/apache/tuweni/blockprocessor/TransactionProcessor.kt
index 07886e88f..2a04c7a35 100644
--- a/eth-blockprocessor/src/main/kotlin/org/apache/tuweni/blockprocessor/TransactionProcessor.kt
+++ b/eth-blockprocessor/src/main/kotlin/org/apache/tuweni/blockprocessor/TransactionProcessor.kt
@@ -35,9 +35,18 @@ import org.apache.tuweni.units.bigints.UInt256
import org.apache.tuweni.units.ethereum.Gas
import org.apache.tuweni.units.ethereum.Wei
-data class TransactionProcessorResult(val receipt: TransactionReceipt? = null, val success: Boolean = false, val gasUsed: Gas = Gas.ZERO)
+data class TransactionProcessorResult(
+ val receipt: TransactionReceipt? = null,
+ val success: Boolean = false,
+ val gasUsed: Gas = Gas.ZERO
+)
-class TransactionProcessor(val vm: EthereumVirtualMachine, val hardFork: HardFork, val repository: BlockchainRepository, val stateChanges: TransientStateRepository) {
+class TransactionProcessor(
+ val vm: EthereumVirtualMachine,
+ val hardFork: HardFork,
+ val repository: BlockchainRepository,
+ val stateChanges: TransientStateRepository
+) {
fun calculateTransactionCost(payload: Bytes, hardFork: HardFork): Gas {
var zeros = 0
diff --git a/eth-blockprocessor/src/test/kotlin/org/apache/tuweni/blockprocessor/BlockProcessorTest.kt b/eth-blockprocessor/src/test/kotlin/org/apache/tuweni/blockprocessor/BlockProcessorTest.kt
index fa9d3d04f..1538f6307 100644
--- a/eth-blockprocessor/src/test/kotlin/org/apache/tuweni/blockprocessor/BlockProcessorTest.kt
+++ b/eth-blockprocessor/src/test/kotlin/org/apache/tuweni/blockprocessor/BlockProcessorTest.kt
@@ -42,8 +42,26 @@ class BlockProcessorTest {
fun testValidBlockNoTransactions() = runBlocking {
val processor = BlockProcessor(UInt256.ONE)
val repository = BlockchainRepository.inMemory(Genesis.dev())
- val result = processor.execute(Genesis.dev().header, Address.ZERO, Gas.valueOf(100), Gas.ZERO, UInt256.ZERO, listOf(), repository, Registry.istanbul, HardFork.HOMESTEAD)
- val block = result.block.toBlock(listOf(), Address.ZERO, UInt256.ONE, Instant.now(), Bytes.EMPTY, Genesis.emptyHash, UInt64.random())
+ val result = processor.execute(
+ Genesis.dev().header,
+ Address.ZERO,
+ Gas.valueOf(100),
+ Gas.ZERO,
+ UInt256.ZERO,
+ listOf(),
+ repository,
+ Registry.istanbul,
+ HardFork.HOMESTEAD
+ )
+ val block = result.block.toBlock(
+ listOf(),
+ Address.ZERO,
+ UInt256.ONE,
+ Instant.now(),
+ Bytes.EMPTY,
+ Genesis.emptyHash,
+ UInt64.random()
+ )
assertEquals(0, block.body.transactions.size)
}
}
diff --git a/eth-blockprocessor/src/test/kotlin/org/apache/tuweni/blockprocessor/TransactionProcessorTest.kt b/eth-blockprocessor/src/test/kotlin/org/apache/tuweni/blockprocessor/TransactionProcessorTest.kt
index 1810b7d1c..1ac899101 100644
--- a/eth-blockprocessor/src/test/kotlin/org/apache/tuweni/blockprocessor/TransactionProcessorTest.kt
+++ b/eth-blockprocessor/src/test/kotlin/org/apache/tuweni/blockprocessor/TransactionProcessorTest.kt
@@ -82,7 +82,7 @@ class BlockProcessorReferenceTest {
private fun findGeneralStateTests(): Stream<Arguments> {
return findTests("/GeneralStateTests/**/*.json").filter {
val testName = it.get()[1] as String
- (testName == "randomStatetest553") // || !(testName).contains("loop") || (testName).equals("OverflowGasMakeMoney")
+ (testName == "randomStatetest553")
}
}
diff --git a/eth-client-ui/src/integrationTest/kotlin/org/apache/tuweni/ethclientui/UIIntegrationTest.kt b/eth-client-ui/src/integrationTest/kotlin/org/apache/tuweni/ethclientui/UIIntegrationTest.kt
index a23777299..c39597395 100644
--- a/eth-client-ui/src/integrationTest/kotlin/org/apache/tuweni/ethclientui/UIIntegrationTest.kt
+++ b/eth-client-ui/src/integrationTest/kotlin/org/apache/tuweni/ethclientui/UIIntegrationTest.kt
@@ -71,7 +71,9 @@ type="memory""""
val response3 = con3.inputStream.readAllBytes()
assertTrue(response3.isNotEmpty())
assertEquals(
- """{"peerCounts":{"default":0},"bestBlocks":{"default":{"hash":"0xa08d1edb37ba1c62db764ef7c2566cbe368b850f5b3762c6c24114a3fd97b87f","number":"0x0000000000000000000000000000000000000000000000000000000000000000"}}}""",
+ """{"peerCounts":{"default":0},""" +
+ """"bestBlocks":{"default":{"hash":"0xa08d1edb37ba1c62db764ef7c2566cbe368b850f5b3762c6c24114a3fd97b87f",""" +
+ """"number":"0x0000000000000000000000000000000000000000000000000000000000000000"}}}""",
String(response3)
)
ui.stop()
diff --git a/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/EthereumClient.kt b/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/EthereumClient.kt
index 6267e9ebb..18b81ae0f 100644
--- a/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/EthereumClient.kt
+++ b/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/EthereumClient.kt
@@ -309,10 +309,18 @@ class EthereumClient(
}
).thenRun {
for (sync in config.synchronizers()) {
- val syncRepository = storageRepositories[sync.getRepository()] ?: throw IllegalArgumentException("Repository ${sync.getRepository()} missing for synchronizer ${sync.getName()}")
- val syncService = rlpxServices[sync.getRlpxService()] ?: throw IllegalArgumentException("Service ${sync.getRlpxService()} missing for synchronizer ${sync.getName()}")
- val syncPeerRepository = peerRepositories[sync.getPeerRepository()] ?: throw IllegalArgumentException("Peer repository ${sync.getPeerRepository()} missing for synchronizer ${sync.getName()}")
- val adapter = adapters[sync.getRlpxService()] ?: throw IllegalArgumentException("Service ${sync.getRlpxService()} missing for synchronizer ${sync.getName()}")
+ val syncRepository = storageRepositories[sync.getRepository()] ?: throw IllegalArgumentException(
+ "Repository ${sync.getRepository()} missing for synchronizer ${sync.getName()}"
+ )
+ val syncService = rlpxServices[sync.getRlpxService()] ?: throw IllegalArgumentException(
+ "Service ${sync.getRlpxService()} missing for synchronizer ${sync.getName()}"
+ )
+ val syncPeerRepository = peerRepositories[sync.getPeerRepository()] ?: throw IllegalArgumentException(
+ "Peer repository ${sync.getPeerRepository()} missing for synchronizer ${sync.getName()}"
+ )
+ val adapter = adapters[sync.getRlpxService()] ?: throw IllegalArgumentException(
+ "Service ${sync.getRlpxService()} missing for synchronizer ${sync.getName()}"
+ )
when (sync.getType()) {
SynchronizerType.BEST -> {
@@ -351,7 +359,9 @@ class EthereumClient(
}
SynchronizerType.CANONICAL -> {
val fromRepository = storageRepositories.get(sync.getFromRepository())
- ?: throw IllegalArgumentException("Missing repository for canonical repository ${sync.getFromRepository()}")
+ ?: throw IllegalArgumentException(
+ "Missing repository for canonical repository ${sync.getFromRepository()}"
+ )
val canonicalSynchronizer = CanonicalSynchronizer(
repository = syncRepository,
client = syncService.getClient(ETH66) as EthRequestsManager,
@@ -379,7 +389,10 @@ class EthereumClient(
validators[validator.getName()] = chainIdValidator
}
ValidatorType.TRANSACTIONHASH -> {
- val transactionsHashValidator = TransactionsHashValidator(from = validator.getFrom(), to = validator.getTo())
+ val transactionsHashValidator = TransactionsHashValidator(
+ from = validator.getFrom(),
+ to = validator.getTo()
+ )
validators[validator.getName()] = transactionsHashValidator
}
}
diff --git a/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/EthereumClientConfig.kt b/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/EthereumClientConfig.kt
index aead7ad2d..f169f1f2b 100644
--- a/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/EthereumClientConfig.kt
+++ b/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/EthereumClientConfig.kt
@@ -358,8 +358,18 @@ class EthereumClientConfig(private var config: Configuration = Configuration.emp
synchronizersSection.addLong("from", 0L, "Start block to sync from", PropertyValidator.isGreaterOrEqual(0L))
synchronizersSection.addLong("to", 0L, "End block to sync to", PropertyValidator.isGreaterOrEqual(0L))
synchronizersSection.addString("repository", "default", "Blockchain repository to use", null)
- synchronizersSection.addString("rlpxService", "default", "RLPx service to use for requests with this synchronizer", null)
- synchronizersSection.addString("peerRepository", "default", "Peer repository to use for requests with this synchronizer", null)
+ synchronizersSection.addString(
+ "rlpxService",
+ "default",
+ "RLPx service to use for requests with this synchronizer",
+ null
+ )
+ synchronizersSection.addString(
+ "peerRepository",
+ "default",
+ "Peer repository to use for requests with this synchronizer",
+ null
+ )
synchronizersSection.addString("fromRepository", null, "(only for canonical) Repository to sync from", null)
val validatorsSection = SchemaBuilder.create()
diff --git a/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/WireConnectionPeerRepositoryAdapter.kt b/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/WireConnectionPeerRepositoryAdapter.kt
index 442ba7769..b86edc3ab 100644
--- a/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/WireConnectionPeerRepositoryAdapter.kt
+++ b/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/WireConnectionPeerRepositoryAdapter.kt
@@ -86,7 +86,11 @@ class WireConnectionPeerRepositoryAdapter(val peerRepository: EthereumPeerReposi
fun get(ethereumConnection: EthereumConnection): WireConnection {
val conn = connections[ethereumConnection.identity().id()]
if (conn == null) {
- logger.info("Connection ${ethereumConnection.identity().id()} not found, present are: ${connections.keys.joinToString(",")}}")
+ logger.info(
+ "Connection ${
+ ethereumConnection.identity().id()
+ } not found, present are: ${connections.keys.joinToString(",")}}"
+ )
throw NoSuchElementException("No connection available")
}
return conn
diff --git a/eth-client/src/test/kotlin/org/apache/tuweni/ethclient/EthereumClientConfigTest.kt b/eth-client/src/test/kotlin/org/apache/tuweni/ethclient/EthereumClientConfigTest.kt
index 5084dadee..c748a4417 100644
--- a/eth-client/src/test/kotlin/org/apache/tuweni/ethclient/EthereumClientConfigTest.kt
+++ b/eth-client/src/test/kotlin/org/apache/tuweni/ethclient/EthereumClientConfigTest.kt
@@ -108,7 +108,9 @@ class EthereumClientConfigTest {
@Test
fun testDNSClientWithDNSServer() {
- val config = EthereumClientConfig.fromString("[dns.mine]\nenrLink=\"example.com\"\npollingPeriod=1000\ndnsServer=\"4.4.5.5\"")
+ val config = EthereumClientConfig.fromString(
+ "[dns.mine]\nenrLink=\"example.com\"\npollingPeriod=1000\ndnsServer=\"4.4.5.5\""
+ )
assertEquals(1, config.dnsClients().size)
assertEquals("example.com", config.dnsClients()[0].enrLink())
assertEquals(1000, config.dnsClients()[0].pollingPeriod())
diff --git a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/CrawlerConfig.kt b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/CrawlerConfig.kt
index ce5946e75..ae791d8bb 100644
--- a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/CrawlerConfig.kt
+++ b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/CrawlerConfig.kt
@@ -24,7 +24,7 @@ import java.net.URI
import java.nio.file.Path
class CrawlerConfig(val filePath: Path) {
-
+ @Suppress("ktlint:max-line-length")
companion object {
val mainnetEthereumBootnodes = listOf(
"enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303", // Singapore AWS
@@ -46,7 +46,6 @@ class CrawlerConfig(val filePath: Path) {
// Ethereum Foundation Aleth Bootnodes
"enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303" // DE
)
-
val mainnetDiscoveryDNS = "enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@all.mainnet.ethdisco.net"
fun schema(): Schema {
@@ -73,7 +72,12 @@ class CrawlerConfig(val filePath: Path) {
.addInteger("ethstatsPort", 1338, "Ethstats port", null)
.addString("ethstatsSecret", "changeme", "Ethstats shared secret", null)
.addLong("peerCacheExpiration", 5 * 60 * 1000L, "Peer data cache expiration", null)
- .addLong("clientIdsInterval", 24 * 60 * 60 * 1000 * 2L, "Client IDs Interval - number of milliseconds to go back in time", null)
+ .addLong(
+ "clientIdsInterval",
+ 24 * 60 * 60 * 1000 * 2L,
+ "Client IDs Interval - number of milliseconds to go back in time",
+ null
+ )
.addLong("clientsStatsDelay", 30 * 1000L, "Delay between client stats calculations", null)
.addLong("rlpxDisconnectionDelay", 10 * 1000L, "RLPx connections disconnection delay", null)
.addInteger("maxRequestsPerSec", 30, "Number of requests per second over HTTP", null)
@@ -81,7 +85,12 @@ class CrawlerConfig(val filePath: Path) {
.addInteger("metricsPort", 9090, "Metric service port", PropertyValidator.isValidPort())
.addString("metricsNetworkInterface", "localhost", "Metric service network interface", null)
.addBoolean("metricsGrpcPushEnabled", false, "Enable pushing metrics to gRPC service", null)
- .addBoolean("metricsPrometheusEnabled", false, "Enable exposing metrics on the Prometheus endpoint", null)
+ .addBoolean(
+ "metricsPrometheusEnabled",
+ false,
+ "Enable exposing metrics on the Prometheus endpoint",
+ null
+ )
.addString("corsAllowedOrigins", "*", "CORS allowed domains filter for REST service", null)
val upgradesSection = SchemaBuilder.create()
diff --git a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/CrawlerRESTService.kt b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/CrawlerRESTService.kt
index ab0e23f02..799e68128 100644
--- a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/CrawlerRESTService.kt
+++ b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/CrawlerRESTService.kt
@@ -75,7 +75,10 @@ class CrawlerRESTService(
)
val apiServlet = ctx.addServlet(OpenApiServlet::class.java.name, "/api/*")
- apiServlet.setInitParameter("openApi.configuration.resourcePackages", "org.apache.tuweni.eth.crawler.rest")
+ apiServlet.setInitParameter(
+ "openApi.configuration.resourcePackages",
+ "org.apache.tuweni.eth.crawler.rest"
+ )
apiServlet.initOrder = 2
ctx.setBaseResource(Resource.newResource(CrawlerRESTService::class.java.getResource("/webapp")))
@@ -86,7 +89,8 @@ class CrawlerRESTService(
val swagger = ServletHolder("swagger-ui", DefaultServlet::class.java)
swagger.setInitParameter(
"resourceBase",
- CrawlerRESTService::class.java.getClassLoader().getResource("META-INF/resources/webjars/swagger-ui/4.15.5/").toString()
+ CrawlerRESTService::class.java.getClassLoader().getResource("META-INF/resources/webjars/swagger-ui/4.15.5/")
+ .toString()
)
swagger.setInitParameter("pathInfoOnly", "true")
ctx.addServlet(swagger, "/swagger-ui/*")
diff --git a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/EthstatsDataRepository.kt b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/EthstatsDataRepository.kt
index 2a8d85b5f..1dac55ae8 100644
--- a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/EthstatsDataRepository.kt
+++ b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/EthstatsDataRepository.kt
@@ -39,7 +39,8 @@ class EthstatsDataRepository(
ds.connection.use { conn ->
val stmt =
conn.prepareStatement(
- "insert into ethstats_peer(address, id, name, client, net, api, protocol, os, osVer, node, port) values(?,?,?,?,?,?,?,?,?,?,?)"
+ "insert into ethstats_peer(address, id, name, client, net, api, protocol, os, osVer, node, port) " +
+ "values(?,?,?,?,?,?,?,?,?,?,?)"
)
stmt.use {
it.setString(1, remoteAddress)
@@ -62,7 +63,10 @@ class EthstatsDataRepository(
ds.connection.use { conn ->
val stmt =
conn.prepareStatement(
- "insert into ethstats_block(address, id, number, hash, parentHash, timestamp, miner, gasUsed, gasLimit, difficulty, totalDifficulty, transactions, transactionsRoot, stateRoot, uncles) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
+ """insert into ethstats_block(address, id, number, hash, parentHash, timestamp, miner, gasUsed,
+ |gasLimit, difficulty, totalDifficulty, transactions, transactionsRoot, stateRoot, uncles)
+ |values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
+ """.trimMargin()
)
stmt.use {
val txArray = conn.createArrayOf("bytea", block.transactions.map { it.hash.toArrayUnsafe() }.toTypedArray())
@@ -107,7 +111,9 @@ class EthstatsDataRepository(
ds.connection.use { conn ->
val stmt =
conn.prepareStatement(
- "insert into ethstats_nodestats(address, id, gasPrice, hashrate, mining, syncing, active, uptime, peers) values(?,?,?,?,?,?,?,?,?)"
+ """insert into ethstats_nodestats(address, id, gasPrice, hashrate, mining, syncing, active,
+ |uptime, peers) values(?,?,?,?,?,?,?,?,?)
+ """.trimMargin()
)
stmt.use {
it.setString(1, remoteAddress)
@@ -157,7 +163,10 @@ class EthstatsDataRepository(
return@async ds.connection.use { conn ->
val stmt =
conn.prepareStatement(
- "select number, hash, parentHash, timestamp, miner, gasUsed, gasLimit, difficulty, totalDifficulty, transactions, transactionsRoot, stateRoot, uncles from ethstats_block where id=? order by createdAt desc limit 1"
+ """select number, hash, parentHash, timestamp, miner, gasUsed, gasLimit, difficulty, totalDifficulty,
+ |transactions, transactionsRoot, stateRoot, uncles from ethstats_block where id=? order by createdAt
+ |desc limit 1
+ """.trimMargin()
)
stmt.use {
it.setString(1, id)
@@ -173,7 +182,9 @@ class EthstatsDataRepository(
rs.getLong(7),
UInt256.fromBytes(Bytes.wrap(rs.getBytes(8))),
UInt256.fromBytes(Bytes.wrap(rs.getBytes(9))),
- (rs.getArray(10).array as Array<*>).map { TxStats(Hash.fromBytes(Bytes.wrap(it as ByteArray))) },
+ (rs.getArray(10).array as Array<*>).map {
+ TxStats(Hash.fromBytes(Bytes.wrap(it as ByteArray)))
+ },
Hash.fromBytes(Bytes.wrap(rs.getBytes(11))),
Hash.fromBytes(Bytes.wrap(rs.getBytes(12))),
(rs.getArray(13).array as Array<*>).map { Hash.fromBytes(Bytes.wrap(it as ByteArray)) }
@@ -213,7 +224,12 @@ class EthstatsDataRepository(
null
}
}
- val nodeInfoStmt = conn.prepareStatement("select name, node, port, net, protocol, api, os, osVer, client from ethstats_peer where id=? order by createdAt desc limit 1")
+ val nodeInfoStmt =
+ conn.prepareStatement(
+ """select name, node, port, net, protocol, api, os, osVer, client from
+ |ethstats_peer where id=? order by createdAt desc limit 1
+ """.trimMargin()
+ )
val nodeInfo = nodeInfoStmt.use {
it.setString(1, id)
val rs = it.executeQuery()
@@ -235,7 +251,9 @@ class EthstatsDataRepository(
}
val nodeStatsStmt = conn.prepareStatement(
- "select active, syncing, mining, hashrate, peers, gasPrice, uptime from ethstats_nodestats where id=? order by createdAt desc limit 1"
+ """select active, syncing, mining, hashrate, peers, gasPrice, uptime from ethstats_nodestats
+ |where id=? order by createdAt desc limit 1
+ """.trimMargin()
)
val nodeStats = nodeStatsStmt.use {
it.setString(1, id)
diff --git a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/RelationalPeerRepository.kt b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/RelationalPeerRepository.kt
index 821e8ac27..4ad2ef07c 100644
--- a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/RelationalPeerRepository.kt
+++ b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/RelationalPeerRepository.kt
@@ -107,7 +107,10 @@ open class RelationalPeerRepository(
) as RepositoryPeer
val stmt =
conn.prepareStatement(
- "insert into nodeInfo(id, createdAt, host, port, publickey, p2pVersion, clientId, capabilities, genesisHash, bestHash, totalDifficulty, identity, disconnectReason) values(?,?,?,?,?,?,?,?,?,?,?,?,?)"
+ """insert into nodeInfo(id, createdAt, host, port, publickey, p2pVersion, clientId, capabilities,
+ | genesisHash, bestHash, totalDifficulty, identity, disconnectReason)
+ | values(?,?,?,?,?,?,?,?,?,?,?,?,?)
+ """.trimMargin()
)
stmt.use {
val peerHello = wireConnection.peerHello
@@ -163,9 +166,12 @@ open class RelationalPeerRepository(
): List<PeerConnectionInfoDetails> {
dataSource.connection.use { conn ->
var query =
- "select distinct nodeinfo.createdAt, nodeinfo.publickey, nodeinfo.p2pversion, nodeinfo.clientId, nodeinfo.capabilities, nodeinfo.genesisHash, nodeinfo.besthash, nodeinfo.totalDifficulty from nodeinfo " +
- " inner join (select identity, max(createdAt) as maxCreatedAt from nodeinfo group by identity) maxSeen " +
- " on nodeinfo.identity = maxSeen.identity and nodeinfo.createdAt = maxSeen.maxCreatedAt where createdAt < ? order by nodeInfo.createdAt desc"
+ """select distinct nodeinfo.createdAt, nodeinfo.publickey, nodeinfo.p2pversion, nodeinfo.clientId,
+ |nodeinfo.capabilities, nodeinfo.genesisHash, nodeinfo.besthash, nodeinfo.totalDifficulty from nodeinfo
+ |inner join (select identity, max(createdAt) as maxCreatedAt from nodeinfo group by identity) maxSeen
+ |on nodeinfo.identity = maxSeen.identity and nodeinfo.createdAt = maxSeen.maxCreatedAt
+ |where createdAt < ? order by nodeInfo.createdAt desc
+ """.trimMargin()
if (from != null && limit != null) {
query += " limit $limit offset $from"
}
@@ -207,8 +213,10 @@ open class RelationalPeerRepository(
dataSource.connection.use { conn ->
val stmt =
conn.prepareStatement(
- "select endpoint.host, endpoint.port, identity.publickey from endpoint inner " +
- "join identity on (endpoint.identity = identity.id) where endpoint.identity NOT IN (select identity from nodeinfo) order by endpoint.lastSeen desc limit $limit offset $from"
+ """select endpoint.host, endpoint.port, identity.publickey from endpoint inner join identity on
+ |(endpoint.identity = identity.id) where endpoint.identity NOT IN (select identity from nodeinfo)
+ |order by endpoint.lastSeen desc limit $limit offset $from
+ """.trimMargin()
)
stmt.use {
// map results.
@@ -228,7 +236,11 @@ open class RelationalPeerRepository(
internal fun getClientIdsInternal(): List<ClientInfo> {
dataSource.connection.use { conn ->
val sql =
- "select clients.clientId, count(clients.clientId) from (select nodeinfo.clientId, nodeInfo.createdAt from nodeinfo inner join (select identity, max(createdAt) as maxCreatedAt from nodeinfo group by identity) maxSeen on nodeinfo.identity = maxSeen.identity and nodeinfo.createdAt = maxSeen.maxCreatedAt) as clients where clients.createdAt > ? group by clients.clientId"
+ """select clients.clientId, count(clients.clientId) from (select nodeinfo.clientId, nodeInfo.createdAt
+ |from nodeinfo inner join (select identity, max(createdAt) as maxCreatedAt from nodeinfo group by identity)
+ |maxSeen on nodeinfo.identity = maxSeen.identity and nodeinfo.createdAt = maxSeen.maxCreatedAt) as clients
+ |where clients.createdAt > ? group by clients.clientId
+ """.trimMargin()
val stmt =
conn.prepareStatement(sql)
stmt.use {
@@ -250,10 +262,13 @@ open class RelationalPeerRepository(
internal fun getPeerWithInfo(infoCollected: Long, publicKey: String): PeerConnectionInfoDetails? {
dataSource.connection.use { conn ->
- var query =
- "select distinct nodeinfo.createdAt, nodeinfo.publickey, nodeinfo.p2pversion, nodeinfo.clientId, nodeinfo.capabilities, nodeinfo.genesisHash, nodeinfo.besthash, nodeinfo.totalDifficulty from nodeinfo " +
- " inner join (select identity, max(createdAt) as maxCreatedAt from nodeinfo group by identity) maxSeen " +
- " on nodeinfo.identity = maxSeen.identity and nodeinfo.createdAt = maxSeen.maxCreatedAt where createdAt < ? and nodeinfo.publickey = ? order by nodeInfo.createdAt desc"
+ val query =
+ """select distinct nodeinfo.createdAt, nodeinfo.publickey, nodeinfo.p2pversion, nodeinfo.clientId,
+ |nodeinfo.capabilities, nodeinfo.genesisHash, nodeinfo.besthash, nodeinfo.totalDifficulty from nodeinfo
+ |inner join (select identity, max(createdAt) as maxCreatedAt from nodeinfo group by identity) maxSeen
+ |on nodeinfo.identity = maxSeen.identity and nodeinfo.createdAt = maxSeen.maxCreatedAt
+ |where createdAt < ? and nodeinfo.publickey = ? order by nodeInfo.createdAt desc
+ """.trimMargin()
val stmt =
conn.prepareStatement(query)
stmt.use {
diff --git a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/rest/Metadata.kt b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/rest/Metadata.kt
index 611087701..c26f63e59 100644
--- a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/rest/Metadata.kt
+++ b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/rest/Metadata.kt
@@ -21,7 +21,11 @@ import io.swagger.v3.oas.annotations.info.Info
import io.swagger.v3.oas.annotations.servers.Server
@OpenAPIDefinition(
- info = Info(title = "Apache Tuweni Network Crawler", version = "1.0.0", description = "REST API for the Ethereum network crawler"),
+ info = Info(
+ title = "Apache Tuweni Network Crawler",
+ version = "1.0.0",
+ description = "REST API for the Ethereum network crawler"
+ ),
servers = arrayOf(Server(url = "/api"))
)
class Metadata
diff --git a/eth-crawler/src/test/kotlin/org/apache/tuweni/eth/crawler/rest/ClientIdInfoTest.kt b/eth-crawler/src/test/kotlin/org/apache/tuweni/eth/crawler/rest/ClientIdInfoTest.kt
index a4e940e64..b3d4589fa 100644
--- a/eth-crawler/src/test/kotlin/org/apache/tuweni/eth/crawler/rest/ClientIdInfoTest.kt
+++ b/eth-crawler/src/test/kotlin/org/apache/tuweni/eth/crawler/rest/ClientIdInfoTest.kt
@@ -34,7 +34,9 @@ class ClientIdInfoTest {
@Test
fun testWithLabel() {
- val clientInfo = ClientIdInfo("OpenEthereum/Bob Ross/v3.0.1-stable-8ca8089-20200601/x86_64-unknown-linux-gnu/rustc1.43.1")
+ val clientInfo = ClientIdInfo(
+ "OpenEthereum/Bob Ross/v3.0.1-stable-8ca8089-20200601/x86_64-unknown-linux-gnu/rustc1.43.1"
+ )
assertEquals("OpenEthereum", clientInfo.name)
assertEquals("Bob Ross", clientInfo.label)
assertEquals("v3.0.1-stable-8ca8089-20200601", clientInfo.version)
diff --git a/eth-precompiles/src/main/kotlin/org/apache/tuweni/eth/precompiles/Contracts.kt b/eth-precompiles/src/main/kotlin/org/apache/tuweni/eth/precompiles/Contracts.kt
index 1864339d8..7f195d259 100644
--- a/eth-precompiles/src/main/kotlin/org/apache/tuweni/eth/precompiles/Contracts.kt
+++ b/eth-precompiles/src/main/kotlin/org/apache/tuweni/eth/precompiles/Contracts.kt
@@ -130,7 +130,12 @@ class ModExpPrecompileContract : PrecompileContract {
}
}
-class AltBN128PrecompiledContract(private val operation: Byte, val inputLen: Int, val baseCost: Long, val pairingGasCost: Long) : PrecompileContract {
+class AltBN128PrecompiledContract(
+ private val operation: Byte,
+ val inputLen: Int,
+ val baseCost: Long,
+ val pairingGasCost: Long
+) : PrecompileContract {
override fun run(input: Bytes): Result {
val parameters = input.size() / 192
diff --git a/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/BlockchainRepository.kt b/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/BlockchainRepository.kt
index 9738985aa..f7e2035bf 100644
--- a/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/BlockchainRepository.kt
+++ b/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/BlockchainRepository.kt
@@ -550,7 +550,12 @@ class BlockchainRepository(
accountState.storageRoot
)
tree.put(key, value)
- val newAccountState = AccountState(accountState.nonce, accountState.balance, Hash.fromBytes(tree.rootHash()), accountState.codeHash)
+ val newAccountState = AccountState(
+ accountState.nonce,
+ accountState.balance,
+ Hash.fromBytes(tree.rootHash()),
+ accountState.codeHash
+ )
worldState!!.put(addrHash, newAccountState.toBytes())
}
@@ -571,7 +576,12 @@ class BlockchainRepository(
accountState.storageRoot
)
tree.remove(key)
- val newAccountState = AccountState(accountState.nonce, accountState.balance, Hash.fromBytes(tree.rootHash()), accountState.codeHash)
+ val newAccountState = AccountState(
+ accountState.nonce,
+ accountState.balance,
+ Hash.fromBytes(tree.rootHash()),
+ accountState.codeHash
+ )
worldState!!.put(addrHash, newAccountState.toBytes())
}
diff --git a/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/TransientStateRepository.kt b/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/TransientStateRepository.kt
index b1f4a71ba..22f34c6bc 100644
--- a/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/TransientStateRepository.kt
+++ b/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/TransientStateRepository.kt
@@ -92,7 +92,12 @@ class TransientStateRepository(val repository: BlockchainRepository) : StateRepo
accountState.storageRoot
)
tree.put(key, value)
- val newAccountState = AccountState(accountState.nonce, accountState.balance, Hash.fromBytes(tree.rootHash()), accountState.codeHash)
+ val newAccountState = AccountState(
+ accountState.nonce,
+ accountState.balance,
+ Hash.fromBytes(tree.rootHash()),
+ accountState.codeHash
+ )
transientWorldState.put(addrHash, newAccountState.toBytes())
}
@@ -112,7 +117,12 @@ class TransientStateRepository(val repository: BlockchainRepository) : StateRepo
accountState.storageRoot
)
tree.remove(key)
- val newAccountState = AccountState(accountState.nonce, accountState.balance, Hash.fromBytes(tree.rootHash()), accountState.codeHash)
+ val newAccountState = AccountState(
+ accountState.nonce,
+ accountState.balance,
+ Hash.fromBytes(tree.rootHash()),
+ accountState.codeHash
+ )
transientWorldState.put(addrHash, newAccountState.toBytes())
}
diff --git a/eth/src/main/kotlin/org/apache/tuweni/eth/JSONRPCRequest.kt b/eth/src/main/kotlin/org/apache/tuweni/eth/JSONRPCRequest.kt
index 206949074..919cab548 100644
--- a/eth/src/main/kotlin/org/apache/tuweni/eth/JSONRPCRequest.kt
+++ b/eth/src/main/kotlin/org/apache/tuweni/eth/JSONRPCRequest.kt
@@ -49,7 +49,9 @@ data class JSONRPCRequest constructor(
}
}
- override fun equals(other: Any?) = other is JSONRPCRequest && this.method == other.method && params.contentEquals(other.params)
+ override fun equals(other: Any?) = other is JSONRPCRequest && this.method == other.method && params.contentEquals(
+ other.params
+ )
override fun hashCode() = 31 * method.hashCode() + params.contentHashCode()
fun serializeRequest(): String {
diff --git a/eth/src/main/kotlin/org/apache/tuweni/eth/JSONRPCResponse.kt b/eth/src/main/kotlin/org/apache/tuweni/eth/JSONRPCResponse.kt
index b94ba9227..e5274eb8f 100644
--- a/eth/src/main/kotlin/org/apache/tuweni/eth/JSONRPCResponse.kt
+++ b/eth/src/main/kotlin/org/apache/tuweni/eth/JSONRPCResponse.kt
@@ -20,7 +20,14 @@ import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.annotation.JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
-data class JSONRPCResponse(@JsonProperty("id") val id: StringOrLong, @JsonProperty("result") val result: Any? = null, @JsonProperty("error") val error: JSONRPCError? = null, @JsonProperty("jsonrpc") val jsonrpc: String = "2.0")
+data class JSONRPCResponse(
+ @JsonProperty("id") val id: StringOrLong,
+ @JsonProperty("result") val result: Any? = null,
+ @JsonProperty(
+ "error"
+ ) val error: JSONRPCError? = null,
+ @JsonProperty("jsonrpc") val jsonrpc: String = "2.0"
+)
data class JSONRPCError(@JsonProperty("code") val code: Long, @JsonProperty("message") val message: String)
@@ -29,5 +36,8 @@ val invalidRequest = JSONRPCResponse(id = StringOrLong(0), error = JSONRPCError(
val methodNotFound = JSONRPCResponse(id = StringOrLong(0), error = JSONRPCError(-32601, "Method not found"))
val invalidParams = JSONRPCResponse(id = StringOrLong(0), error = JSONRPCError(-32602, "Invalid params"))
val internalError = JSONRPCResponse(id = StringOrLong(0), error = JSONRPCError(-32603, "Internal error"))
-val tooManyRequests = JSONRPCResponse(id = StringOrLong(0), error = JSONRPCError(code = -32000, message = "Too many requests"))
+val tooManyRequests = JSONRPCResponse(
+ id = StringOrLong(0),
+ error = JSONRPCError(code = -32000, message = "Too many requests")
+)
val methodNotEnabled = JSONRPCResponse(id = StringOrLong(0), error = JSONRPCError(-32604, "Method not enabled"))
diff --git a/ethstats/src/integrationTest/kotlin/org/apache/tuweni/ethstats/EthStatsReporterTest.kt b/ethstats/src/integrationTest/kotlin/org/apache/tuweni/ethstats/EthStatsReporterTest.kt
index 4159b10cf..08f574e1d 100644
--- a/ethstats/src/integrationTest/kotlin/org/apache/tuweni/ethstats/EthStatsReporterTest.kt
+++ b/ethstats/src/integrationTest/kotlin/org/apache/tuweni/ethstats/EthStatsReporterTest.kt
@@ -94,13 +94,18 @@ public class EthStatsReporterTest {
assertTrue(
server
.messagesContain(
- "{\"emit\":[\"hello\",{\"id\":\"foo\",\"info\":{\"api\":\"No\",\"canUpdateHistory\":true,\"client\":\"Apache Tuweni Ethstats\",\"name\":\"name\",\"net\":\"10\",\"node\":\"node\",\"os\":\"Windoz\",\"os_v\":\"64\",\"port\":33030,\"protocol\":\"eth/63\"},\"secret\":\"wat\"}]}"
+ "{\"emit\":[\"hello\",{\"id\":\"foo\",\"info\":{\"api\":\"No\",\"canUpdateHistory\":true,\"client\":" +
+ "\"Apache Tuweni Ethstats\",\"name\":\"name\",\"net\":\"10\",\"node\":\"node\",\"os\":\"Windoz\"," +
+ "\"os_v\":\"64\",\"port\":33030,\"protocol\":\"eth/63\"},\"secret\":\"wat\"}]}"
)
)
assertTrue(server.messagesContain("{\"emit\":[\"node-ping\",{\"id\":\"foo\""))
assertTrue(server.messagesContain("{\"emit\":[\"block\","), server.getResults().joinToString("\n"))
assertTrue(server.messagesContain("\"stats\":{\"pending\":42}"), server.getResults().joinToString("\n"))
- assertTrue(server.messagesContain("{\"emit\":[\"stats\",{\"id\":\"foo\",\"stats\":"), server.getResults().joinToString("\n"))
+ assertTrue(
+ server.messagesContain("{\"emit\":[\"stats\",{\"id\":\"foo\",\"stats\":"),
+ server.getResults().joinToString("\n")
+ )
reporter.stop()
}
diff --git a/ethstats/src/main/kotlin/org/apache/tuweni/ethstats/EthStatsServer.kt b/ethstats/src/main/kotlin/org/apache/tuweni/ethstats/EthStatsServer.kt
index 7443340ba..367e259f4 100644
--- a/ethstats/src/main/kotlin/org/apache/tuweni/ethstats/EthStatsServer.kt
+++ b/ethstats/src/main/kotlin/org/apache/tuweni/ethstats/EthStatsServer.kt
@@ -93,7 +93,11 @@ class EthStatsServer(
("hello") -> {
val clientSecret = event.get(1).get("secret").textValue()
if (clientSecret != secret) {
- logger.info("Client {} connected with wrong secret {}, disconnecting", websocket.remoteAddress(), clientSecret)
+ logger.info(
+ "Client {} connected with wrong secret {}, disconnecting",
+ websocket.remoteAddress(),
+ clientSecret
+ )
websocket.close()
return
}
diff --git a/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/AuthMessageTest.kt b/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/AuthMessageTest.kt
index 0ef91ff35..2ee5caeaf 100644
--- a/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/AuthMessageTest.kt
+++ b/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/AuthMessageTest.kt
@@ -28,7 +28,9 @@ class AuthMessageTest {
val message = AuthMessage(nodeInfo, "foo", "secret")
val mapper = ObjectMapper()
assertEquals(
- "{\"id\":\"foo\",\"info\":{\"api\":\"No\",\"canUpdateHistory\":true,\"client\":\"Apache Tuweni Ethstats\",\"name\":\"foo\",\"net\":\"eth\",\"node\":\"node\",\"os\":\"os\",\"os_v\":\"123\",\"port\":123,\"protocol\":\"protocol\"},\"secret\":\"secret\"}",
+ "{\"id\":\"foo\",\"info\":{\"api\":\"No\",\"canUpdateHistory\":true," +
+ "\"client\":\"Apache Tuweni Ethstats\",\"name\":\"foo\",\"net\":\"eth\",\"node\":\"node\"," +
+ "\"os\":\"os\",\"os_v\":\"123\",\"port\":123,\"protocol\":\"protocol\"},\"secret\":\"secret\"}",
mapper.writeValueAsString(message)
)
}
diff --git a/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/NodeStatsTest.kt b/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/NodeStatsTest.kt
index b06fced6d..a4810105a 100644
--- a/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/NodeStatsTest.kt
+++ b/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/NodeStatsTest.kt
@@ -29,7 +29,8 @@ class NodeStatsTest {
mapper.registerModule(EthJsonModule())
val stats = NodeStats(true, true, true, 42, 23, 5000, 1234567)
assertEquals(
- "{\"active\":true,\"gasPrice\":5000,\"hashrate\":42,\"mining\":true,\"peers\":23,\"syncing\":true,\"uptime\":1234567}",
+ "{\"active\":true,\"gasPrice\":5000,\"hashrate\":42," +
+ "\"mining\":true,\"peers\":23,\"syncing\":true,\"uptime\":1234567}",
mapper.writeValueAsString(stats)
)
}
diff --git a/evm-dsl/src/main/kotlin/org/apache/tuweni/evmdsl/Instructions.kt b/evm-dsl/src/main/kotlin/org/apache/tuweni/evmdsl/Instructions.kt
index 47c3ea5d0..6f42c833d 100644
--- a/evm-dsl/src/main/kotlin/org/apache/tuweni/evmdsl/Instructions.kt
+++ b/evm-dsl/src/main/kotlin/org/apache/tuweni/evmdsl/Instructions.kt
@@ -35,7 +35,11 @@ interface Instruction {
fun end(): Boolean = false
}
-data class InstructionModel(val opcode: Byte, val additionalBytesToRead: Int = 0, val creator: (code: Bytes, index: Int) -> Instruction)
+data class InstructionModel(
+ val opcode: Byte,
+ val additionalBytesToRead: Int = 0,
+ val creator: (code: Bytes, index: Int) -> Instruction
+)
/**
* A registry of instructions that can be used to read code back into the DSL.
diff --git a/evm-dsl/src/test/kotlin/org/apache/tuweni/evmdsl/DeploymentTest.kt b/evm-dsl/src/test/kotlin/org/apache/tuweni/evmdsl/DeploymentTest.kt
index 6839e66ab..47c34a7e4 100644
--- a/evm-dsl/src/test/kotlin/org/apache/tuweni/evmdsl/DeploymentTest.kt
+++ b/evm-dsl/src/test/kotlin/org/apache/tuweni/evmdsl/DeploymentTest.kt
@@ -24,7 +24,12 @@ class DeploymentTest {
@Test
fun testDeploymentCreation() {
- val deployment = Deployment(Code.read(Bytes.fromHexString("0x600035f660115760006000526001601ff35b60016000526001601ff3")))
- assertEquals(Bytes.fromHexString("0x7f600035f660115760006000526001601ff35b60016000526001601ff300000000600052601c6000f3"), deployment.toBytes())
+ val deployment = Deployment(
+ Code.read(Bytes.fromHexString("0x600035f660115760006000526001601ff35b60016000526001601ff3"))
+ )
+ assertEquals(
+ Bytes.fromHexString("0x7f600035f660115760006000526001601ff35b60016000526001601ff300000000600052601c6000f3"),
+ deployment.toBytes()
+ )
}
}
diff --git a/evm/src/main/kotlin/org/apache/tuweni/evm/EthereumVirtualMachine.kt b/evm/src/main/kotlin/org/apache/tuweni/evm/EthereumVirtualMachine.kt
index 8552406f2..2b6b3966c 100644
--- a/evm/src/main/kotlin/org/apache/tuweni/evm/EthereumVirtualMachine.kt
+++ b/evm/src/main/kotlin/org/apache/tuweni/evm/EthereumVirtualMachine.kt
@@ -304,18 +304,33 @@ class EthereumVirtualMachine(
var gasAvailable = gas
if (depth > 1024) {
val gasManager = GasManager(gas)
- return EVMResult(EVMExecutionStatusCode.CALL_DEPTH_EXCEEDED, hostContext, NoOpExecutionChanges, EVMState(gasManager, listOf(), Stack(), Memory(), null))
+ return EVMResult(
+ EVMExecutionStatusCode.CALL_DEPTH_EXCEEDED,
+ hostContext,
+ NoOpExecutionChanges,
+ EVMState(gasManager, listOf(), Stack(), Memory(), null)
+ )
}
val senderNonce = hostContext.getNonce(sender)
if (senderNonce >= MAX_NONCE) {
- return EVMResult(EVMExecutionStatusCode.REJECTED, hostContext, NoOpExecutionChanges, EVMState(GasManager(gas), listOf(), Stack(), Memory(), null))
+ return EVMResult(
+ EVMExecutionStatusCode.REJECTED,
+ hostContext,
+ NoOpExecutionChanges,
+ EVMState(GasManager(gas), listOf(), Stack(), Memory(), null)
+ )
}
if (callKind == CallKind.CREATE || callKind == CallKind.CREATE2) {
val codeDepositGasFee = UInt256.valueOf(code.size() * 200L)
if (gas < codeDepositGasFee) {
- return EVMResult(EVMExecutionStatusCode.REJECTED, hostContext, NoOpExecutionChanges, EVMState(GasManager(gas), listOf(), Stack(), Memory(), null))
+ return EVMResult(
+ EVMExecutionStatusCode.REJECTED,
+ hostContext,
+ NoOpExecutionChanges,
+ EVMState(GasManager(gas), listOf(), Stack(), Memory(), null)
+ )
}
gasAvailable = gasAvailable.subtract(codeDepositGasFee)
}
@@ -327,7 +342,12 @@ class EthereumVirtualMachine(
val senderBalance = hostContext.getBalance(sender)
val amount = Wei.valueOf(UInt256.fromBytes(value))
if (senderBalance.toUInt256() < amount.toUInt256()) {
- return EVMResult(EVMExecutionStatusCode.REJECTED, hostContext, NoOpExecutionChanges, EVMState(GasManager(gas), listOf(), Stack(), Memory(), null))
+ return EVMResult(
+ EVMExecutionStatusCode.REJECTED,
+ hostContext,
+ NoOpExecutionChanges,
+ EVMState(GasManager(gas), listOf(), Stack(), Memory(), null)
+ )
}
hostContext.setBalance(sender, senderBalance.subtract(amount))
hostContext.setBalance(destination, destinationBalance.add(amount))
@@ -335,13 +355,23 @@ class EthereumVirtualMachine(
if (precompile != null) {
if (callKind == CallKind.CREATE || callKind == CallKind.CREATE2) {
- return EVMResult(EVMExecutionStatusCode.REJECTED, hostContext, NoOpExecutionChanges, EVMState(GasManager(gas), listOf(), Stack(), Memory(), null))
+ return EVMResult(
+ EVMExecutionStatusCode.REJECTED,
+ hostContext,
+ NoOpExecutionChanges,
+ EVMState(GasManager(gas), listOf(), Stack(), Memory(), null)
+ )
}
logger.trace("Executing precompile $contractAddress")
val result = precompile.run(inputData)
val gasManager = GasManager(gasAvailable)
gasManager.add(result.gas)
- return EVMResult(if (result.output == null) EVMExecutionStatusCode.PRECOMPILE_FAILURE else EVMExecutionStatusCode.SUCCESS, hostContext, NoOpExecutionChanges, EVMState(gasManager, listOf(), Stack(), Memory(), result.output))
+ return EVMResult(
+ if (result.output == null) EVMExecutionStatusCode.PRECOMPILE_FAILURE else EVMExecutionStatusCode.SUCCESS,
+ hostContext,
+ NoOpExecutionChanges,
+ EVMState(gasManager, listOf(), Stack(), Memory(), result.output)
+ )
} else {
val msg =
EVMMessage(
diff --git a/evm/src/main/kotlin/org/apache/tuweni/evm/TransactionalEVMHostContext.kt b/evm/src/main/kotlin/org/apache/tuweni/evm/TransactionalEVMHostContext.kt
index 479209c6e..39176ccc4 100644
--- a/evm/src/main/kotlin/org/apache/tuweni/evm/TransactionalEVMHostContext.kt
+++ b/evm/src/main/kotlin/org/apache/tuweni/evm/TransactionalEVMHostContext.kt
@@ -97,7 +97,11 @@ class TransactionalEVMHostContext(
override suspend fun isEmptyAccount(address: Address): Boolean {
logger.trace("Entering isEmptyAccount")
val accountState = transientRepository.getAccount(address)
- return null == accountState || (accountState.balance.isZero && accountState.nonce.isZero && EMPTY_CODE_HASH.equals(accountState.codeHash) && EMPTY_STORAGE_HASH.equals(accountState.storageRoot))
+ return null == accountState || (
+ accountState.balance.isZero && accountState.nonce.isZero && EMPTY_CODE_HASH.equals(
+ accountState.codeHash
+ ) && EMPTY_STORAGE_HASH.equals(accountState.storageRoot)
+ )
}
/**
@@ -112,7 +116,11 @@ class TransactionalEVMHostContext(
*/
override suspend fun getStorage(address: Address, key: Bytes): Bytes32? {
logger.trace("Entering getStorage")
- val value = transientRepository.getAccountStoreValue(address, Hash.hash(key))?.let { UInt256.fromBytes(RLP.decodeValue(it)) }
+ val value = transientRepository.getAccountStoreValue(address, Hash.hash(key))?.let {
+ UInt256.fromBytes(
+ RLP.decodeValue(it)
+ )
+ }
logger.trace("key $key value $value")
return value
}
@@ -123,7 +131,10 @@ class TransactionalEVMHostContext(
override suspend fun incrementNonce(address: Address): UInt256 {
val account = transientRepository.getAccount(address) ?: transientRepository.newAccountState()
val newNonce = account.nonce.add(1)
- transientRepository.storeAccount(address, AccountState(newNonce, account.balance, account.storageRoot, account.codeHash))
+ transientRepository.storeAccount(
+ address,
+ AccountState(newNonce, account.balance, account.storageRoot, account.codeHash)
+ )
return newNonce
}
diff --git a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/EvmVmImpl.kt b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/EvmVmImpl.kt
index 38ba4d16d..ae3512bac 100644
--- a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/EvmVmImpl.kt
+++ b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/EvmVmImpl.kt
@@ -90,7 +90,12 @@ class EvmVmImpl(val stepListener: StepListener? = null) : EvmVm {
val opcode = registry.get(fork, code.get(current))
if (opcode == null) {
logger.error("Could not find opcode for ${code.slice(current, 1)} at position $current")
- return EVMResult(EVMExecutionStatusCode.INVALID_INSTRUCTION, hostContext, hostContext as TransactionalEVMHostContext, EVMState(gasManager, hostContext.getLogs(), stack, memory))
+ return EVMResult(
+ EVMExecutionStatusCode.INVALID_INSTRUCTION,
+ hostContext,
+ hostContext as TransactionalEVMHostContext,
+ EVMState(gasManager, hostContext.getLogs(), stack, memory)
+ )
}
val currentOpcodeByte = code.get(current)
current++
@@ -103,7 +108,13 @@ class EvmVmImpl(val stepListener: StepListener? = null) : EvmVm {
"gas: ${gasManager.gasLeft()} cost: ${gasManager.lastGasCost()}"
)
}
- val state = EVMState(gasManager, (hostContext as TransactionalEVMHostContext).getLogs(), stack, memory, result?.output)
+ val state = EVMState(
+ gasManager,
+ (hostContext as TransactionalEVMHostContext).getLogs(),
+ stack,
+ memory,
+ result?.output
+ )
if (result?.status != null) {
traceExecution(executionPath)
diff --git a/evm/src/test/kotlin/org/apache/tuweni/evm/EVMReferenceTest.kt b/evm/src/test/kotlin/org/apache/tuweni/evm/EVMReferenceTest.kt
index e2e802fce..fb84cee32 100644
--- a/evm/src/test/kotlin/org/apache/tuweni/evm/EVMReferenceTest.kt
+++ b/evm/src/test/kotlin/org/apache/tuweni/evm/EVMReferenceTest.kt
@@ -152,7 +152,13 @@ class EVMReferenceTest {
}
}
}
- val vm = EthereumVirtualMachine(repository, repository, Registry.istanbul, EvmVmImpl::create, mapOf(Pair("DISABLE_TRANSFER_VALUE", "true")))
+ val vm = EthereumVirtualMachine(
+ repository,
+ repository,
+ Registry.istanbul,
+ EvmVmImpl::create,
+ mapOf(Pair("DISABLE_TRANSFER_VALUE", "true"))
+ )
vm.start()
try {
val result = vm.execute(
diff --git a/evm/src/test/kotlin/org/apache/tuweni/evm/EcroverTest.kt b/evm/src/test/kotlin/org/apache/tuweni/evm/EcroverTest.kt
index ac2922934..674a5019b 100644
--- a/evm/src/test/kotlin/org/apache/tuweni/evm/EcroverTest.kt
+++ b/evm/src/test/kotlin/org/apache/tuweni/evm/EcroverTest.kt
@@ -66,7 +66,13 @@ class EcroverTest {
@JvmStatic
@Throws(IOException::class)
private fun findFrontierTests(): Stream<Arguments> {
- return Stream.of(EcroverTest::class.java.getResource("/ecrecover.yaml").openConnection().getInputStream().use { input -> prepareTest(input) })
+ return Stream.of(
+ EcroverTest::class.java.getResource("/ecrecover.yaml").openConnection().getInputStream().use { input ->
+ prepareTest(
+ input
+ )
+ }
+ )
}
@Throws(IOException::class)
@@ -161,11 +167,25 @@ class EcroverTest {
assertTrue(changesRepository.accountsExists(address), address.toHexString())
val accountState = changesRepository.getAccount(address)
val balance = accountState?.balance ?: Wei.valueOf(0)
- assertEquals(info.balance, balance, "balance doesn't match: " + address.toHexString() + ":" + if (balance > info.balance) balance.subtract(info.balance).toString() else info.balance.subtract(balance).toString())
+ assertEquals(
+ info.balance,
+ balance,
+ "balance doesn't match: " + address.toHexString() + ":" + if (balance > info.balance) {
+ balance.subtract(
+ info.balance
+ ).toString()
+ } else {
+ info.balance.subtract(balance).toString()
+ }
+ )
assertEquals(info.nonce, accountState!!.nonce)
for (stored in info.storage) {
- val changed = changesRepository.getAccountStoreValue(address, Hash.hash(stored.key))?.let { RLP.decodeValue(it) } ?: UInt256.ZERO
+ val changed = changesRepository.getAccountStoreValue(address, Hash.hash(stored.key))?.let {
+ RLP.decodeValue(
+ it
+ )
+ } ?: UInt256.ZERO
assertEquals(stored.value, Bytes32.leftPad(changed)) {
runBlocking {
val account = changesRepository.getAccount(address) ?: changesRepository.newAccountState()
diff --git a/evm/src/test/kotlin/org/apache/tuweni/evm/EthereumVirtualMachineTest.kt b/evm/src/test/kotlin/org/apache/tuweni/evm/EthereumVirtualMachineTest.kt
index 1280870c0..a69417767 100644
--- a/evm/src/test/kotlin/org/apache/tuweni/evm/EthereumVirtualMachineTest.kt
+++ b/evm/src/test/kotlin/org/apache/tuweni/evm/EthereumVirtualMachineTest.kt
@@ -203,7 +203,11 @@ class EthereumVirtualMachineTest {
val result = runCode(Bytes.fromHexString("0x30600052596000f3"), { EvmVmImpl.create(listener) })
assertEquals(EVMExecutionStatusCode.HALTED, result.statusCode)
assertEquals(
- Bytes.fromHexString("0xf88183676173a00000000000000000000000000000000000000000000000000000000000030d40866d656d6f7279a0000000000000000000000000353363663737323034654565663935326532350085737461636ba00000000000000000000000000000000000000000000000000000000000000020866f757470757480846c6f6773"),
+ Bytes.fromHexString(
+ "0xf88183676173a000000000000000000000000000000000000000000000000000000000000" +
+ "30d40866d656d6f7279a0000000000000000000000000353363663737323034654565663935326532350085737461636ba" +
+ "00000000000000000000000000000000000000000000000000000000000000020866f757470757480846c6f6773"
+ ),
result.state.toBytes()
)
}
diff --git a/evm/src/test/kotlin/org/apache/tuweni/evm/EvmCertificationTest.kt b/evm/src/test/kotlin/org/apache/tuweni/evm/EvmCertificationTest.kt
index d4bd5364b..0ac346a48 100644
--- a/evm/src/test/kotlin/org/apache/tuweni/evm/EvmCertificationTest.kt
+++ b/evm/src/test/kotlin/org/apache/tuweni/evm/EvmCertificationTest.kt
@@ -239,11 +239,25 @@ class EvmCertificationTest {
assertTrue(changesRepository.accountsExists(address))
val accountState = changesRepository.getAccount(address)
val balance = accountState?.balance ?: Wei.valueOf(0)
- assertEquals(info.balance, balance, "balance doesn't match: " + address.toHexString() + ":" + if (balance > info.balance) balance.subtract(info.balance).toString() else info.balance.subtract(balance).toString())
+ assertEquals(
+ info.balance,
+ balance,
+ "balance doesn't match: " + address.toHexString() + ":" + if (balance > info.balance) {
+ balance.subtract(
+ info.balance
+ ).toString()
+ } else {
+ info.balance.subtract(balance).toString()
+ }
+ )
assertEquals(info.nonce, accountState!!.nonce)
for (stored in info.storage) {
- val changed = changesRepository.getAccountStoreValue(address, Hash.hash(stored.key))?.let { RLP.decodeValue(it) } ?: UInt256.ZERO
+ val changed = changesRepository.getAccountStoreValue(address, Hash.hash(stored.key))?.let {
+ RLP.decodeValue(
+ it
+ )
+ } ?: UInt256.ZERO
assertEquals(stored.value, Bytes32.leftPad(changed)) {
runBlocking {
val account = changesRepository.getAccount(address) ?: changesRepository.newAccountState()
diff --git a/evm/src/test/kotlin/org/apache/tuweni/evm/OpcodeTest.kt b/evm/src/test/kotlin/org/apache/tuweni/evm/OpcodeTest.kt
index dc5ee3a4b..52a19667c 100644
--- a/evm/src/test/kotlin/org/apache/tuweni/evm/OpcodeTest.kt
+++ b/evm/src/test/kotlin/org/apache/tuweni/evm/OpcodeTest.kt
@@ -236,11 +236,25 @@ class OpcodeTest {
assertTrue(changesRepository.accountsExists(address))
val accountState = changesRepository.getAccount(address)
val balance = accountState?.balance ?: Wei.valueOf(0)
- assertEquals(info.balance, balance, "balance doesn't match: " + address.toHexString() + ":" + if (balance > info.balance) balance.subtract(info.balance).toString() else info.balance.subtract(balance).toString())
+ assertEquals(
+ info.balance,
+ balance,
+ "balance doesn't match: " + address.toHexString() + ":" + if (balance > info.balance) {
+ balance.subtract(
+ info.balance
+ ).toString()
+ } else {
+ info.balance.subtract(balance).toString()
+ }
+ )
assertEquals(info.nonce, accountState!!.nonce)
for (stored in info.storage) {
- val changed = changesRepository.getAccountStoreValue(address, Hash.hash(stored.key))?.let { RLP.decodeValue(it) } ?: UInt256.ZERO
+ val changed = changesRepository.getAccountStoreValue(address, Hash.hash(stored.key))?.let {
+ RLP.decodeValue(
+ it
+ )
+ } ?: UInt256.ZERO
assertEquals(stored.value, Bytes32.leftPad(changed)) {
runBlocking {
val account = changesRepository.getAccount(address) ?: changesRepository.newAccountState()
diff --git a/evm/src/test/kotlin/org/apache/tuweni/evm/impl/StackTest.kt b/evm/src/test/kotlin/org/apache/tuweni/evm/impl/StackTest.kt
index 5f6c52bf7..bd72e4d20 100644
--- a/evm/src/test/kotlin/org/apache/tuweni/evm/impl/StackTest.kt
+++ b/evm/src/test/kotlin/org/apache/tuweni/evm/impl/StackTest.kt
@@ -115,7 +115,10 @@ class StackTest {
stack.pop()
stack.pop()
assertEquals(Bytes.fromHexString("0x040506"), stack.popBytes())
- assertEquals(Bytes.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000201"), stack.get(0))
+ assertEquals(
+ Bytes.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000201"),
+ stack.get(0)
+ )
assertEquals(Bytes.fromHexString("0x0201"), stack.getBytes(0))
assertEquals(Bytes.fromHexString("0x0201"), stack.popBytes())
assertEquals(Bytes.fromHexString("0x03"), stack.popBytes())
diff --git a/genesis/src/main/kotlin/org/apache/tuweni/genesis/Quorum.kt b/genesis/src/main/kotlin/org/apache/tuweni/genesis/Quorum.kt
index a1a3db07e..f14c4addc 100644
--- a/genesis/src/main/kotlin/org/apache/tuweni/genesis/Quorum.kt
+++ b/genesis/src/main/kotlin/org/apache/tuweni/genesis/Quorum.kt
@@ -102,7 +102,8 @@ class QuorumConfig(val genesis: Genesis, val validators: List<SECP256K1.KeyPair>
fun validatorsToCsv(): String {
return validatorHeader + validators.map {
- Address.fromPublicKey(it.publicKey()).toHexString() + "," + it.publicKey().toHexString() + "," + it.secretKey().bytes().toHexString()
+ Address.fromPublicKey(it.publicKey()).toHexString() + "," + it.publicKey().toHexString() + "," + it.secretKey()
+ .bytes().toHexString()
}.joinToString("\n")
}
diff --git a/genesis/src/test/kotlin/org/apache/tuweni/genesis/GenesisTest.kt b/genesis/src/test/kotlin/org/apache/tuweni/genesis/GenesisTest.kt
index 5a072e85d..3920eebb8 100644
--- a/genesis/src/test/kotlin/org/apache/tuweni/genesis/GenesisTest.kt
+++ b/genesis/src/test/kotlin/org/apache/tuweni/genesis/GenesisTest.kt
@@ -43,7 +43,9 @@ class GenesisTest {
extraData = Bytes.EMPTY,
gasLimit = 0L,
parentHash = Bytes32.leftPad(Bytes.fromHexString("0x00ff")),
- alloc = mapOf(Pair(Address.fromHexString("0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"), mapOf(Pair("balance", UInt256.ONE)))),
+ alloc = mapOf(
+ Pair(Address.fromHexString("0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"), mapOf(Pair("balance", UInt256.ONE)))
+ ),
config = GenesisConfig(chainId = 1337)
)
val mapper = JsonMapper()
diff --git a/jsonrpc-app/src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCApp.kt b/jsonrpc-app/src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCApp.kt
index 1bc3f6ba6..e1e7e2409 100644
--- a/jsonrpc-app/src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCApp.kt
+++ b/jsonrpc-app/src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCApp.kt
@@ -109,7 +109,13 @@ class JSONRPCApplication(
fun run() {
logger.info("JSON-RPC proxy starting")
- val client = JSONRPCClient(vertx, config.endpointUrl(), basicAuthenticationEnabled = config.endpointBasicAuthEnabled(), basicAuthenticationUsername = config.endpointBasicAuthUsername(), basicAuthenticationPassword = config.endpointBasicAuthPassword())
+ val client = JSONRPCClient(
+ vertx,
+ config.endpointUrl(),
+ basicAuthenticationEnabled = config.endpointBasicAuthEnabled(),
+ basicAuthenticationUsername = config.endpointBasicAuthUsername(),
+ basicAuthenticationPassword = config.endpointBasicAuthPassword()
+ )
val allowListHandler = MethodAllowListHandler(config.allowedMethods()) { req ->
try {
@@ -131,7 +137,8 @@ class JSONRPCApplication(
"responses",
ConfigurationBuilder().persistence().addStore(RocksDBStoreConfigurationBuilder::class.java)
.location(Paths.get(config.cacheStoragePath(), "storage").toAbsolutePath().toString())
- .expiredLocation(Paths.get(config.cacheStoragePath(), "expired").toAbsolutePath().toString()).expiration().lifespan(config.cacheLifespan()).maxIdle(config.cacheMaxIdle()).build()
+ .expiredLocation(Paths.get(config.cacheStoragePath(), "expired").toAbsolutePath().toString()).expiration()
+ .lifespan(config.cacheLifespan()).maxIdle(config.cacheMaxIdle()).build()
)
val cachingHandler =
@@ -205,9 +212,11 @@ class PersistenceMarshaller : AbstractMarshaller() {
val mapper = ObjectMapper()
}
- override fun objectFromByteBuffer(buf: ByteArray?, offset: Int, length: Int) = mapper.readValue(Bytes.wrap(buf!!, offset, length).toArrayUnsafe(), JSONRPCResponse::class.java)
+ override fun objectFromByteBuffer(buf: ByteArray?, offset: Int, length: Int) =
+ mapper.readValue(Bytes.wrap(buf!!, offset, length).toArrayUnsafe(), JSONRPCResponse::class.java)
- override fun objectToBuffer(o: Any?, estimatedSize: Int): ByteBuffer = ByteBufferImpl.create(mapper.writeValueAsBytes(o))
+ override fun objectToBuffer(o: Any?, estimatedSize: Int): ByteBuffer =
+ ByteBufferImpl.create(mapper.writeValueAsBytes(o))
override fun isMarshallable(o: Any?): Boolean = o is JSONRPCResponse
diff --git a/jsonrpc-app/src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCConfig.kt b/jsonrpc-app/src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCConfig.kt
index 58f0e96c5..a33e3b2fa 100644
--- a/jsonrpc-app/src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCConfig.kt
+++ b/jsonrpc-app/src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCConfig.kt
@@ -41,7 +41,12 @@ class JSONRPCConfig(val filePath: Path? = null) {
.addString("clientFingerprintsFile", "fingerprints.txt", "File recording client connection fingerprints", null)
.addString("serverSecurity", "record", "Server security mode: record, allowlist, ca, tofu", null)
.addBoolean("ssl", false, "Whether the JSON-RPC server should serve data over SSL", null)
- .addBoolean("basicAuth", false, "Whether the JSON-RPC server should authenticate incoming requests with HTTP Basic Authentication", null)
+ .addBoolean(
+ "basicAuth",
+ false,
+ "Whether the JSON-RPC server should authenticate incoming requests with HTTP Basic Authentication",
+ null
+ )
.addString("basicAuthUsername", "", "HTTP Basic Auth username", null)
.addString("basicAuthPassword", "", "HTTP Basic Auth password", null)
.addString("basicAuthRealm", "Apache Tuweni JSON-RPC proxy", "HTTP Basic Auth realm", null)
@@ -52,7 +57,19 @@ class JSONRPCConfig(val filePath: Path? = null) {
.addBoolean("endpointBasicAuthEnabled", false, "Enable basic authentication for the endpoint", null)
.addString("endpointBasicAuthUsername", "", "Basic authentication username for the endpoint", null)
.addString("endpointBasicAuthPassword", "", "Basic authentication password for the endpoint", null)
- .addListOfString("cachedMethods", listOf("eth_blockNumber", "eth_getBlockByNumber", "eth_getBlockByHash", "eth_getTransactionReceipt", "eth_getTransactionByHash", "eth_getLogs"), "Cached JSON-RPC methods", null)
+ .addListOfString(
+ "cachedMethods",
+ listOf(
+ "eth_blockNumber",
+ "eth_getBlockByNumber",
+ "eth_getBlockByHash",
+ "eth_getTransactionReceipt",
+ "eth_getTransactionByHash",
+ "eth_getLogs"
+ ),
+ "Cached JSON-RPC methods",
+ null
+ )
.addBoolean("cacheEnabled", true, "Enable caching", null)
.addString("cacheStoragePath", "", "Location of cache storage", null)
.addInteger("maxConcurrentRequests", 30, "Maximum concurrent requests", null)
diff --git a/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/JSONRPCClient.kt b/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/JSONRPCClient.kt
index c91629476..7c9e20581 100644
--- a/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/JSONRPCClient.kt
+++ b/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/JSONRPCClient.kt
@@ -136,7 +136,11 @@ class JSONRPCClient(
* @throws ConnectException if it cannot dial the remote client
*/
suspend fun getTransactionCount_latest(address: Address): UInt256 {
- val body = JSONRPCRequest(StringOrLong(nextId()), "eth_getTransactionCount", arrayOf(address.toHexString(), "latest"))
+ val body = JSONRPCRequest(
+ StringOrLong(nextId()),
+ "eth_getTransactionCount",
+ arrayOf(address.toHexString(), "latest")
+ )
val jsonResponse = sendRequest(body).await()
val err = jsonResponse.error
if (err != null) {
diff --git a/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/JSONRPCServer.kt b/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/JSONRPCServer.kt
index ecb088a61..2dff1f6d9 100644
--- a/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/JSONRPCServer.kt
+++ b/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/JSONRPCServer.kt
@@ -100,7 +100,8 @@ class JSONRPCServer(
}
suspend fun start() {
- val serverOptions = HttpServerOptions().setPort(port).setHost(networkInterface).setSsl(ssl).setTracingPolicy(TracingPolicy.ALWAYS)
+ val serverOptions =
+ HttpServerOptions().setPort(port).setHost(networkInterface).setSsl(ssl).setTracingPolicy(TracingPolicy.ALWAYS)
trustOptions?.let {
serverOptions.setTrustOptions(it)
}
@@ -120,9 +121,8 @@ class JSONRPCServer(
router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)))
val basicAuthHandler = BasicAuthHandler.create(
{ authInfo, resultHandler ->
- if (basicAuthenticationUsername == authInfo.getString("username") && basicAuthenticationPassword == authInfo.getString(
- "password"
- )
+ if (basicAuthenticationUsername == authInfo.getString("username") &&
+ basicAuthenticationPassword == authInfo.getString("password")
) {
resultHandler.handle(Future.succeededFuture(JSONRPCUser(authInfo)))
} else {
@@ -212,6 +212,7 @@ private class JSONRPCUser(val principal: JsonObject) : User {
override fun setAuthProvider(authProvider: AuthProvider?) {
}
+
override fun merge(other: User?): User {
if (other is JSONRPCUser) {
other.principal.map.forEach {
diff --git a/jsonrpc/src/test/kotlin/org/apache/tuweni/jsonrpc/JSONRPCClientTest.kt b/jsonrpc/src/test/kotlin/org/apache/tuweni/jsonrpc/JSONRPCClientTest.kt
index b1d8025cd..8c54b1e45 100644
--- a/jsonrpc/src/test/kotlin/org/apache/tuweni/jsonrpc/JSONRPCClientTest.kt
+++ b/jsonrpc/src/test/kotlin/org/apache/tuweni/jsonrpc/JSONRPCClientTest.kt
@@ -56,7 +56,10 @@ class JSONRPCClientTest {
@JvmStatic
@BeforeAll
fun runServer(@VertxInstance vertx: Vertx): Unit = runBlocking {
- Assumptions.assumeTrue(!System.getProperty("os.name").lowercase().contains("win"), "Server ports cannot bind on Windows")
+ Assumptions.assumeTrue(
+ !System.getProperty("os.name").lowercase().contains("win"),
+ "Server ports cannot bind on Windows"
+ )
server = JSONRPCServer(
vertx,
port = 0,
diff --git a/kv/src/main/kotlin/org/apache/tuweni/kv/PersistenceMarshaller.kt b/kv/src/main/kotlin/org/apache/tuweni/kv/PersistenceMarshaller.kt
index e0508ab29..55f726630 100644
--- a/kv/src/main/kotlin/org/apache/tuweni/kv/PersistenceMarshaller.kt
+++ b/kv/src/main/kotlin/org/apache/tuweni/kv/PersistenceMarshaller.kt
@@ -29,7 +29,9 @@ class PersistenceMarshaller : AbstractMarshaller() {
override fun objectFromByteBuffer(buf: ByteArray?, offset: Int, length: Int) = Bytes.wrap(buf!!, offset, length)
- override fun objectToBuffer(o: Any?, estimatedSize: Int): ByteBuffer = ByteBufferImpl.create((o as Bytes).toArrayUnsafe())
+ override fun objectToBuffer(o: Any?, estimatedSize: Int): ByteBuffer = ByteBufferImpl.create(
+ (o as Bytes).toArrayUnsafe()
+ )
override fun isMarshallable(o: Any?): Boolean = o is Bytes
diff --git a/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/MerklePatriciaTrie.kt b/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/MerklePatriciaTrie.kt
index c39f8d66a..d2cb88fcf 100644
--- a/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/MerklePatriciaTrie.kt
+++ b/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/MerklePatriciaTrie.kt
@@ -40,7 +40,10 @@ internal fun stringDeserializer(b: Bytes): String = String(b.toArrayUnsafe(), UT
* @constructor Creates an empty trie.
*/
-class MerklePatriciaTrie<V> @JvmOverloads constructor(valueSerializer: (V) -> Bytes, override val coroutineContext: CoroutineContext = Dispatchers.Default) : MerkleTrie<Bytes, V> {
+class MerklePatriciaTrie<V> @JvmOverloads constructor(
+ valueSerializer: (V) -> Bytes,
+ override val coroutineContext: CoroutineContext = Dispatchers.Default
+) : MerkleTrie<Bytes, V> {
companion object {
/**
diff --git a/merkle-trie/src/test/kotlin/org/apache/tuweni/trie/StoredMerklePatriciaTrieKotlinTest.kt b/merkle-trie/src/test/kotlin/org/apache/tuweni/trie/StoredMerklePatriciaTrieKotlinTest.kt
index 835f73bd5..1fc18c0a4 100644
--- a/merkle-trie/src/test/kotlin/org/apache/tuweni/trie/StoredMerklePatriciaTrieKotlinTest.kt
+++ b/merkle-trie/src/test/kotlin/org/apache/tuweni/trie/StoredMerklePatriciaTrieKotlinTest.kt
@@ -347,7 +347,10 @@ internal class StoredMerklePatriciaTrieKotlinTest {
Hash.keccak256(Bytes32.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")),
Bytes.fromHexString("0x32")
)
- assertEquals(Bytes32.fromHexString("0x9ff0b4b6f084c8432d75c0549758a165ec9d80e5f01440d8753d57a9c95f529e"), tree.rootHash())
+ assertEquals(
+ Bytes32.fromHexString("0x9ff0b4b6f084c8432d75c0549758a165ec9d80e5f01440d8753d57a9c95f529e"),
+ tree.rootHash()
+ )
}
@Test
@@ -370,6 +373,9 @@ internal class StoredMerklePatriciaTrieKotlinTest {
Hash.keccak256(Bytes32.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")),
Bytes.fromHexString("0x81c8")
)
- assertEquals(Bytes32.fromHexString("0x4e05e0192d92867cde657332e4d893cf4d1fbbfca597067a7a385b876efe0a21"), tree.rootHash())
+ assertEquals(
+ Bytes32.fromHexString("0x4e05e0192d92867cde657332e4d893cf4d1fbbfca597067a7a385b876efe0a21"),
+ tree.rootHash()
+ )
}
}
diff --git a/metrics/src/main/kotlin/org/apache/tuweni/metrics/MetricsService.kt b/metrics/src/main/kotlin/org/apache/tuweni/metrics/MetricsService.kt
index 84c40d8bd..441f52780 100644
--- a/metrics/src/main/kotlin/org/apache/tuweni/metrics/MetricsService.kt
+++ b/metrics/src/main/kotlin/org/apache/tuweni/metrics/MetricsService.kt
@@ -52,7 +52,10 @@ class MetricsService(
private val periodicReader: PeriodicMetricReader?
init {
- val exporter = OtlpGrpcMetricExporter.builder().setEndpoint(grpcEndpoint).setTimeout(grpcTimeout, TimeUnit.MILLISECONDS).build()
+ val exporter = OtlpGrpcMetricExporter.builder().setEndpoint(grpcEndpoint).setTimeout(
+ grpcTimeout,
+ TimeUnit.MILLISECONDS
+ ).build()
logger.info("Starting metrics service")
val resource = Resource.getDefault()
.merge(
diff --git a/scuttlebutt-client-lib/src/main/kotlin/org/apache/tuweni/scuttlebutt/lib/model/FeedValue.kt b/scuttlebutt-client-lib/src/main/kotlin/org/apache/tuweni/scuttlebutt/lib/model/FeedValue.kt
index 73cb9f70e..b112c5fee 100644
--- a/scuttlebutt-client-lib/src/main/kotlin/org/apache/tuweni/scuttlebutt/lib/model/FeedValue.kt
+++ b/scuttlebutt-client-lib/src/main/kotlin/org/apache/tuweni/scuttlebutt/lib/model/FeedValue.kt
@@ -31,7 +31,14 @@ import java.io.IOException
* @param hash the hash type of the message
* @param content the content of the message
*/
-class FeedValue(val previous: String, val author: Author, val sequence: Long, val timestamp: Long, val hash: String, private val content: JsonNode) {
+class FeedValue(
+ val previous: String,
+ val author: Author,
+ val sequence: Long,
+ val timestamp: Long,
+ val hash: String,
+ private val content: JsonNode
+) {
companion object {
private val mapper = ObjectMapper()
diff --git a/scuttlebutt-handshake/src/main/kotlin/org/apache/tuweni/scuttlebutt/handshake/vertx/SecureScuttlebuttVertxClient.kt b/scuttlebutt-handshake/src/main/kotlin/org/apache/tuweni/scuttlebutt/handshake/vertx/SecureScuttlebuttVertxClient.kt
index fae4491d8..cacf5de9b 100644
--- a/scuttlebutt-handshake/src/main/kotlin/org/apache/tuweni/scuttlebutt/handshake/vertx/SecureScuttlebuttVertxClient.kt
+++ b/scuttlebutt-handshake/src/main/kotlin/org/apache/tuweni/scuttlebutt/handshake/vertx/SecureScuttlebuttVertxClient.kt
@@ -45,7 +45,11 @@ import org.slf4j.LoggerFactory
* @param keyPair the identity of the server according to the Secure Scuttlebutt protocol
* @param networkIdentifier the network identifier of the server according to the Secure Scuttlebutt protocol
*/
-class SecureScuttlebuttVertxClient(private val vertx: Vertx, private val keyPair: Signature.KeyPair, private val networkIdentifier: Bytes32) {
+class SecureScuttlebuttVertxClient(
+ private val vertx: Vertx,
+ private val keyPair: Signature.KeyPair,
+ private val networkIdentifier: Bytes32
+) {
private inner class NetSocketClientHandler(
private val socket: NetSocket,
remotePublicKey: Signature.PublicKey?,
diff --git a/scuttlebutt-handshake/src/test/kotlin/org/apache/tuweni/scuttlebutt/handshake/SecureScuttlebuttHandshakeClientTest.kt b/scuttlebutt-handshake/src/test/kotlin/org/apache/tuweni/scuttlebutt/handshake/SecureScuttlebuttHandshakeClientTest.kt
index 50029fe4d..3c911c953 100644
--- a/scuttlebutt-handshake/src/test/kotlin/org/apache/tuweni/scuttlebutt/handshake/SecureScuttlebuttHandshakeClientTest.kt
+++ b/scuttlebutt-handshake/src/test/kotlin/org/apache/tuweni/scuttlebutt/handshake/SecureScuttlebuttHandshakeClientTest.kt
@@ -69,7 +69,8 @@ internal class SecureScuttlebuttHandshakeClientTest {
.fromBytes(
Bytes
.fromHexString(
- "0x4936543930b3d7de00ecb78952b9f6579b40b73b89512c108b35815e7b35856e9464f3d5d26fa22b3f6604cac7e41c24855fd756a326d7a22995c92bbbad1049"
+ "0x4936543930b3d7de00ecb78952b9f6579b40b73b89512c108b35815e7b35856e9464f" +
+ "3d5d26fa22b3f6604cac7e41c24855fd756a326d7a22995c92bbbad1049"
)
)
)
@@ -79,7 +80,8 @@ internal class SecureScuttlebuttHandshakeClientTest {
.fromBytes(
Bytes
.fromHexString(
- "0x05b578a14b4fef8386ffd509d6241a4a3a0a1d560603dacb6f13df01ed8a63221db3ee42b856345dde400e2f32014aed1a83c7d77ac573cce9bd32412631d607"
+ "0x05b578a14b4fef8386ffd509d6241a4a3a0a1d560603dacb6f13df01ed8a63221db3e" +
+ "e42b856345dde400e2f32014aed1a83c7d77ac573cce9bd32412631d607"
)
)
)
diff --git a/scuttlebutt-rpc/src/main/kotlin/org/apache/tuweni/scuttlebutt/rpc/RPCMessage.kt b/scuttlebutt-rpc/src/main/kotlin/org/apache/tuweni/scuttlebutt/rpc/RPCMessage.kt
index e96df43c7..929b8991a 100644
--- a/scuttlebutt-rpc/src/main/kotlin/org/apache/tuweni/scuttlebutt/rpc/RPCMessage.kt
+++ b/scuttlebutt-rpc/src/main/kotlin/org/apache/tuweni/scuttlebutt/rpc/RPCMessage.kt
@@ -50,7 +50,9 @@ class RPCMessage(messageBytes: Bytes) {
}
val bodySize = messageBytes.slice(1, 4).toInt()
requestNumber = messageBytes.slice(5, 4).toInt()
- require(messageBytes.size() >= bodySize + 9) { "Message body " + (messageBytes.size() - 9) + " is less than body size " + bodySize }
+ require(messageBytes.size() >= bodySize + 9) {
+ "Message body " + (messageBytes.size() - 9) + " is less than body size " + bodySize
+ }
body = messageBytes.slice(9, bodySize)
}
diff --git a/scuttlebutt/src/test/kotlin/org/apache/tuweni/scuttlebutt/InviteTest.kt b/scuttlebutt/src/test/kotlin/org/apache/tuweni/scuttlebutt/InviteTest.kt
index a07cbe7d5..c48dc09f6 100644
--- a/scuttlebutt/src/test/kotlin/org/apache/tuweni/scuttlebutt/InviteTest.kt
+++ b/scuttlebutt/src/test/kotlin/org/apache/tuweni/scuttlebutt/InviteTest.kt
@@ -69,13 +69,20 @@ internal class InviteTest() {
@Test
fun testParseFromCanonicalValid() {
val testInvite =
- "fake.address.com:8009:@MS/HpeAess0EGruiZjfnc+x+FkPq7qoMqSD4SdvTCtM=.ed25519~IJubWEcZM6usWncF/Lu26CyI3ZiovcHjh9+kBI1hiKI="
+ "fake.address.com:8009:@MS/HpeAess0EGruiZjfnc+x+FkPq7qoMqSD4SdvTCtM=" +
+ ".ed25519~IJubWEcZM6usWncF/Lu26CyI3ZiovcHjh9+kBI1hiKI="
try {
val invite = fromCanonicalForm(testInvite)
Assertions.assertEquals(invite.host, "fake.address.com")
Assertions.assertEquals(invite.port, 8009)
- Assertions.assertEquals(invite.identity.publicKeyAsBase64String(), "MS/HpeAess0EGruiZjfnc+x+FkPq7qoMqSD4SdvTCtM=")
- Assertions.assertEquals(invite.seedKey.bytes().toBase64String(), "IJubWEcZM6usWncF/Lu26CyI3ZiovcHjh9+kBI1hiKI=")
+ Assertions.assertEquals(
+ invite.identity.publicKeyAsBase64String(),
+ "MS/HpeAess0EGruiZjfnc+x+FkPq7qoMqSD4SdvTCtM="
+ )
+ Assertions.assertEquals(
+ invite.seedKey.bytes().toBase64String(),
+ "IJubWEcZM6usWncF/Lu26CyI3ZiovcHjh9+kBI1hiKI="
+ )
Assertions.assertEquals(invite.toCanonicalForm(), testInvite)
} catch (malformedInviteCodeException: MalformedInviteCodeException) {
Assertions.fail<Any>("Exception while parsing into canonical form: " + malformedInviteCodeException.message)
diff --git a/stratum/server/src/main/kotlin/org/apache/tuweni/stratum/server/StratumServer.kt b/stratum/server/src/main/kotlin/org/apache/tuweni/stratum/server/StratumServer.kt
index 39008bb57..944ae700b 100644
--- a/stratum/server/src/main/kotlin/org/apache/tuweni/stratum/server/StratumServer.kt
+++ b/stratum/server/src/main/kotlin/org/apache/tuweni/stratum/server/StratumServer.kt
@@ -79,7 +79,12 @@ class StratumServer(
}
private val protocols: Array<StratumProtocol> = arrayOf(
- Stratum1Protocol(extranonce, submitCallback = submitCallback, seedSupplier = seedSupplier, coroutineContext = this.coroutineContext),
+ Stratum1Protocol(
+ extranonce,
+ submitCallback = submitCallback,
+ seedSupplier = seedSupplier,
+ coroutineContext = this.coroutineContext
+ ),
Stratum1EthProxyProtocol(submitCallback, seedSupplier, this.coroutineContext)
)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tuweni.apache.org
For additional commands, e-mail: commits-help@tuweni.apache.org