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 2022/10/16 23:11:45 UTC
[incubator-tuweni] branch main updated: upgrade errorprone and spotless, specifically ktlint
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 45113bb4 upgrade errorprone and spotless, specifically ktlint
new 34cf6ce2 Merge pull request #443 from atoulme/upgrade_spotless_errorprone
45113bb4 is described below
commit 45113bb4d986a563ee4ecd634b4c417446b80fb7
Author: Antoine Toulme <an...@lunar-ocean.com>
AuthorDate: Sun Oct 16 15:47:01 2022 -0700
upgrade errorprone and spotless, specifically ktlint
---
build.gradle | 4 +-
.../concurrent/coroutines/AsyncCompletion.kt | 3 +-
.../tuweni/concurrent/coroutines/AsyncResult.kt | 3 +-
.../tuweni/devp2p/eth/ConnectToAnotherNodeTest.kt | 14 ++--
.../devp2p/eth/SendPendingTransactionsTest.kt | 8 ++-
.../tuweni/devp2p/eth/BlockchainInformation.kt | 2 +-
.../org/apache/tuweni/devp2p/eth/EthClient.kt | 3 +-
.../org/apache/tuweni/devp2p/eth/EthClient66.kt | 14 ++--
.../org/apache/tuweni/devp2p/eth/EthController.kt | 4 +-
.../org/apache/tuweni/devp2p/eth/EthHandler.kt | 14 ++--
.../org/apache/tuweni/devp2p/eth/EthHandler66.kt | 23 ++++--
.../apache/tuweni/devp2p/eth/EthHelloHandler.kt | 11 ++-
.../org/apache/tuweni/devp2p/eth/Messages.kt | 9 ++-
.../tuweni/devp2p/eth/BlockchainInformationTest.kt | 24 +++++--
.../apache/tuweni/devp2p/eth/EthControllerTest.kt | 7 +-
.../org/apache/tuweni/devp2p/eth/EthHandlerTest.kt | 22 ++++--
.../apache/tuweni/devp2p/eth/EthSubprotocolTest.kt | 3 +-
.../org/apache/tuweni/devp2p/proxy/ProxyTest.kt | 2 +-
.../org/apache/tuweni/devp2p/v5/MedallaTest.kt | 1 -
.../org/apache/tuweni/devp2p/DiscoveryService.kt | 51 ++++++++-----
.../kotlin/org/apache/tuweni/devp2p/Endpoint.kt | 1 +
.../devp2p/{EnodeUri.kt => EnodeUriComponents.kt} | 0
.../org/apache/tuweni/devp2p/EthereumNodeRecord.kt | 6 +-
.../kotlin/org/apache/tuweni/devp2p/PacketType.kt | 5 ++
.../org/apache/tuweni/devp2p/PeerRepository.kt | 2 +-
.../kotlin/org/apache/tuweni/devp2p/Scraper.kt | 6 +-
.../apache/tuweni/devp2p/v5/HandshakeSession.kt | 8 ++-
.../kotlin/org/apache/tuweni/devp2p/v5/Scraper.kt | 3 +-
.../kotlin/org/apache/tuweni/devp2p/v5/Session.kt | 4 +-
.../apache/tuweni/devp2p/v5/encrypt/AES128GCM.kt | 1 -
.../apache/tuweni/devp2p/ENRResponsePacketTest.kt | 8 ++-
.../apache/tuweni/devp2p/EthereumNodeRecordTest.kt | 3 +-
.../tuweni/devp2p/v5/HandshakeSessionTest.kt | 6 +-
.../tuweni/devp2p/v5/packet/RandomMessageTest.kt | 2 +-
.../org/apache/tuweni/discovery/DNSDaemon.kt | 2 +-
.../org/apache/tuweni/discovery/DNSEntryTest.kt | 3 +-
.../apache/tuweni/blockprocessor/BlockProcessor.kt | 4 +-
.../org/apache/tuweni/blockprocessor/ProtoBlock.kt | 6 +-
.../tuweni/blockprocessor/TransactionProcessor.kt | 4 +-
.../blockprocessor/TransactionProcessorTest.kt | 25 ++++---
.../tuweni/ethclientui/ConfigurationService.kt | 2 +-
.../org/apache/tuweni/ethclientui/StateService.kt | 2 +-
.../kotlin/org/apache/tuweni/ethclientui/UI.kt | 2 +-
.../apache/tuweni/ethclient/DNSClientRunTest.kt | 6 +-
.../tuweni/ethclient/EthereumClientRunTest.kt | 3 +-
.../tuweni/ethclient/ProxyEthereumClientTest.kt | 3 +-
.../org/apache/tuweni/ethclient/EthereumClient.kt | 84 ++++++++++++++--------
.../tuweni/ethclient/EthereumClientConfig.kt | 43 ++++++-----
.../tuweni/ethclient/EthereumPeerRepository.kt | 1 +
.../sync/FromBestBlockHeaderSynchronizer.kt | 3 +-
.../org/apache/tuweni/eth/crawler/CrawlerApp.kt | 11 +--
.../org/apache/tuweni/eth/crawler/CrawlerConfig.kt | 6 +-
.../tuweni/eth/crawler/CrawlerRESTService.kt | 2 +-
.../tuweni/eth/crawler/EthstatsDataRepository.kt | 8 +--
.../tuweni/eth/crawler/RelationalPeerRepository.kt | 8 +--
.../tuweni/eth/crawler/rest/ClientsService.kt | 1 +
.../org/apache/tuweni/eth/precompiles/Contracts.kt | 10 +--
.../org/apache/tuweni/eth/precompiles/Registry.kt | 8 ++-
.../tuweni/eth/repository/BlockHeaderFields.kt | 10 +++
.../tuweni/eth/repository/BlockchainIndex.kt | 15 ++--
.../tuweni/eth/repository/BlockchainRepository.kt | 10 +--
.../eth/repository/TransactionReceiptFields.kt | 8 +++
.../tuweni/eth/repository/BlockchainIndexTest.kt | 33 +++++----
.../eth/repository/BlockchainRepositoryTest.kt | 10 +--
.../apache/tuweni/ethstats/EthStatsReporterTest.kt | 23 +++---
.../org/apache/tuweni/ethstats/BlockStats.kt | 5 +-
.../org/apache/tuweni/ethstats/EthStatsReporter.kt | 2 +-
.../org/apache/tuweni/ethstats/EthStatsServer.kt | 2 +-
.../org/apache/tuweni/ethstats/BlockStatsTest.kt | 9 +--
.../org/apache/tuweni/ethstats/NodeStatsTest.kt | 6 +-
.../org/apache/tuweni/ethstats/TxStatsTest.kt | 6 +-
.../org/apache/tuweni/evmdsl/Instructions.kt | 2 +-
.../apache/tuweni/evm/EthereumVirtualMachine.kt | 19 +++--
.../tuweni/evm/TransactionalEVMHostContext.kt | 12 ++--
.../kotlin/org/apache/tuweni/evm/impl/EvmVmImpl.kt | 2 +-
.../org/apache/tuweni/evm/impl/OpcodeRegistry.kt | 3 +-
.../org/apache/tuweni/evm/impl/berlin/OpCodes.kt | 8 ++-
.../apache/tuweni/evm/impl/bizantium/OpCodes.kt | 4 +-
.../tuweni/evm/impl/constantinople/OpCodes.kt | 8 ++-
.../org/apache/tuweni/evm/impl/frontier/OpCodes.kt | 4 +-
.../apache/tuweni/evm/impl/homestead/OpCodes.kt | 4 +-
.../org/apache/tuweni/evm/impl/istanbul/OpCodes.kt | 8 ++-
.../apache/tuweni/evm/impl/petersburg/OpCodes.kt | 8 ++-
.../tuweni/evm/impl/spuriousDragon/OpCodes.kt | 4 +-
.../tuweni/evm/impl/tangerineWhistle/OpCodes.kt | 4 +-
.../org/apache/tuweni/evm/EVMBrokenMetreAttack.kt | 2 +-
.../org/apache/tuweni/evm/EVMReferenceTest.kt | 9 ++-
.../org/apache/tuweni/evm/EvmCertificationTest.kt | 8 ++-
.../kotlin/org/apache/tuweni/evm/OpcodeTest.kt | 8 ++-
.../org/apache/tuweni/evm/OpcodeTestModel.kt | 14 ++--
.../kotlin/org/apache/tuweni/genesis/Genesis.kt | 6 +-
.../main/kotlin/org/apache/tuweni/genesis/Main.kt | 3 +-
.../kotlin/org/apache/tuweni/genesis/Quorum.kt | 8 +--
.../kotlin/org/apache/tuweni/genesis/QuorumTest.kt | 2 +-
.../relayer/RelayerAppCommandlineArguments.kt | 11 ++-
.../org/apache/tuweni/hobbits/InteractionTest.kt | 21 ++++--
.../org/apache/tuweni/hobbits/HobbitsTransport.kt | 7 +-
.../kotlin/org/apache/tuweni/hobbits/Message.kt | 3 +
.../kotlin/org/apache/tuweni/hobbits/Relayer.kt | 12 ++--
.../apache/tuweni/hobbits/HobbitsTransportTest.kt | 4 +-
.../org/apache/tuweni/hobbits/MessageTest.kt | 15 ++--
.../org/apache/tuweni/jsonrpc/app/JSONRPCApp.kt | 10 +--
.../org/apache/tuweni/jsonrpc/JSONRPCClient.kt | 2 +-
.../org/apache/tuweni/jsonrpc/JSONRPCServer.kt | 2 +-
.../tuweni/jsonrpc/methods/MethodsHandler.kt | 12 ++--
.../org/apache/tuweni/jsonrpc/methods/Net.kt | 2 +-
.../org/apache/tuweni/jsonrpc/JSONRPCClientTest.kt | 3 +-
.../org/apache/tuweni/jsonrpc/JSONRPCServerTest.kt | 6 +-
.../org/apache/tuweni/kv/CascadingKeyValueStore.kt | 2 +-
.../apache/tuweni/kv/EntityManagerKeyValueStore.kt | 1 -
.../org/apache/tuweni/kv/ProxyKeyValueStore.kt | 2 +-
.../org/apache/tuweni/kv/SQLKeyValueStore.kt | 6 +-
.../apache/tuweni/les/GetBlockHeadersMessage.kt | 5 +-
.../org/apache/tuweni/les/LESSubProtocolHandler.kt | 1 -
.../org/apache/tuweni/les/ReceiptsMessage.kt | 4 +-
.../apache/tuweni/les/LESSubProtocolHandlerTest.kt | 3 +-
.../org/apache/tuweni/les/LESSubprotocolTest.kt | 5 +-
.../kotlin/org/apache/tuweni/les/MessagesTest.kt | 3 +-
.../kotlin/org/apache/tuweni/trie/BranchNode.kt | 3 +-
.../kotlin/org/apache/tuweni/trie/ExtensionNode.kt | 3 +-
.../main/kotlin/org/apache/tuweni/trie/LeafNode.kt | 2 +-
.../apache/tuweni/trie/StoredMerklePatriciaTrie.kt | 2 +-
.../kotlin/org/apache/tuweni/trie/StoredNode.kt | 1 +
.../org/apache/tuweni/metrics/MetricsService.kt | 2 +-
.../apache/tuweni/scuttlebutt/lib/FeedService.kt | 1 +
.../scuttlebutt/lib/ScuttlebuttClientFactory.kt | 12 ++--
.../tuweni/scuttlebutt/lib/model/FeedValue.kt | 1 +
.../ScuttlebuttLocalDiscoveryServiceTest.kt | 3 +-
.../tuweni/scuttlebutt/discovery/LocalIdentity.kt | 12 ++--
.../discovery/ScuttlebuttLocalDiscoveryService.kt | 9 ++-
.../org/apache/tuweni/stratum/StratumServerApp.kt | 7 +-
.../tuweni/stratum/server/StratumConnection.kt | 2 +-
.../tuweni/stratum/server/StratumProtocol.kt | 6 +-
.../apache/tuweni/stratum/server/StratumServer.kt | 18 +++--
.../tuweni/stratum/server/StratumProtocolTest.kt | 42 ++++++-----
135 files changed, 668 insertions(+), 413 deletions(-)
diff --git a/build.gradle b/build.gradle
index f2d594f0..9d1fae9d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -26,7 +26,7 @@ buildscript {
}
plugins {
- id 'com.diffplug.spotless' version '6.6.1'
+ id 'com.diffplug.spotless' version '6.11.0'
id 'net.ltgt.errorprone' version '2.0.2'
id 'org.springframework.boot' version '2.4.3'
id 'io.spring.dependency-management' version '1.0.6.RELEASE'
@@ -179,7 +179,7 @@ subprojects {
}
kotlin {
licenseHeaderFile rootProject.file('gradle/spotless.license.txt')
- ktlint("0.43.0").userData(['indent_size': '2', 'continuation_indent_size' : '2', 'disabled_rules': 'import-ordering'])
+ ktlint("0.47.1").editorConfigOverride(['indent_size': '2', 'continuation_indent_size' : '2'])
endWithNewline()
}
}
diff --git a/concurrent-coroutines/src/main/kotlin/org/apache/tuweni/concurrent/coroutines/AsyncCompletion.kt b/concurrent-coroutines/src/main/kotlin/org/apache/tuweni/concurrent/coroutines/AsyncCompletion.kt
index a78be160..dcea5ebb 100644
--- a/concurrent-coroutines/src/main/kotlin/org/apache/tuweni/concurrent/coroutines/AsyncCompletion.kt
+++ b/concurrent-coroutines/src/main/kotlin/org/apache/tuweni/concurrent/coroutines/AsyncCompletion.kt
@@ -169,7 +169,8 @@ suspend fun AsyncCompletion.await() {
}
private class ContinuationConsumer(
- @Volatile @JvmField var cont: Continuation<Unit>?
+ @Volatile @JvmField
+ var cont: Continuation<Unit>?
) : Consumer<Throwable?> {
override fun accept(exception: Throwable?) {
val cont = this.cont ?: return // atomically read current value unless null
diff --git a/concurrent-coroutines/src/main/kotlin/org/apache/tuweni/concurrent/coroutines/AsyncResult.kt b/concurrent-coroutines/src/main/kotlin/org/apache/tuweni/concurrent/coroutines/AsyncResult.kt
index 5d248eb8..2e2a5c2d 100644
--- a/concurrent-coroutines/src/main/kotlin/org/apache/tuweni/concurrent/coroutines/AsyncResult.kt
+++ b/concurrent-coroutines/src/main/kotlin/org/apache/tuweni/concurrent/coroutines/AsyncResult.kt
@@ -154,7 +154,8 @@ suspend fun <T> AsyncResult<T>.await(): T {
}
private class ContinuationBiConsumer<T>(
- @Volatile @JvmField var cont: Continuation<T>?
+ @Volatile @JvmField
+ var cont: Continuation<T>?
) : BiConsumer<T?, Throwable?> {
@Suppress("UNCHECKED_CAST")
override fun accept(result: T?, exception: Throwable?) {
diff --git a/devp2p-eth/src/integrationTest/kotlin/org/apache/tuweni/devp2p/eth/ConnectToAnotherNodeTest.kt b/devp2p-eth/src/integrationTest/kotlin/org/apache/tuweni/devp2p/eth/ConnectToAnotherNodeTest.kt
index 05787807..68065939 100644
--- a/devp2p-eth/src/integrationTest/kotlin/org/apache/tuweni/devp2p/eth/ConnectToAnotherNodeTest.kt
+++ b/devp2p-eth/src/integrationTest/kotlin/org/apache/tuweni/devp2p/eth/ConnectToAnotherNodeTest.kt
@@ -77,8 +77,12 @@ class ConnectToAnotherNodeTest {
EthSubprotocol(
repository = repository,
blockchainInfo = SimpleBlockchainInformation(
- UInt256.valueOf(genesisFile.chainId.toLong()), genesisBlock.header.difficulty,
- genesisBlock.header.hash, UInt256.valueOf(42L), genesisBlock.header.hash, genesisFile.forks
+ UInt256.valueOf(genesisFile.chainId.toLong()),
+ genesisBlock.header.difficulty,
+ genesisBlock.header.hash,
+ UInt256.valueOf(42L),
+ genesisBlock.header.hash,
+ genesisFile.forks
),
pendingTransactionsPool = MemoryTransactionPool()
)
@@ -137,7 +141,8 @@ class ConnectToAnotherNodeTest {
blockchainInfo = SimpleBlockchainInformation(
UInt256.ZERO,
genesisBlock.header.difficulty,
- genesisBlock.header.hash, UInt256.valueOf(42L),
+ genesisBlock.header.hash,
+ UInt256.valueOf(42L),
genesisBlock.header.hash,
emptyList()
),
@@ -171,7 +176,8 @@ class ConnectToAnotherNodeTest {
blockchainInfo = SimpleBlockchainInformation(
UInt256.ZERO,
genesisBlock.header.difficulty,
- genesisBlock.header.hash, UInt256.valueOf(42L),
+ genesisBlock.header.hash,
+ UInt256.valueOf(42L),
genesisBlock.header.hash,
emptyList()
),
diff --git a/devp2p-eth/src/integrationTest/kotlin/org/apache/tuweni/devp2p/eth/SendPendingTransactionsTest.kt b/devp2p-eth/src/integrationTest/kotlin/org/apache/tuweni/devp2p/eth/SendPendingTransactionsTest.kt
index 0ef4bcf9..452ba4bc 100644
--- a/devp2p-eth/src/integrationTest/kotlin/org/apache/tuweni/devp2p/eth/SendPendingTransactionsTest.kt
+++ b/devp2p-eth/src/integrationTest/kotlin/org/apache/tuweni/devp2p/eth/SendPendingTransactionsTest.kt
@@ -86,8 +86,12 @@ class SendPendingTransactionsTest {
EthSubprotocol(
repository = repository,
blockchainInfo = SimpleBlockchainInformation(
- UInt256.valueOf(genesisFile.chainId.toLong()), genesisBlock.header.difficulty,
- genesisBlock.header.hash, UInt256.valueOf(42L), genesisBlock.header.hash, genesisFile.forks
+ UInt256.valueOf(genesisFile.chainId.toLong()),
+ genesisBlock.header.difficulty,
+ genesisBlock.header.hash,
+ UInt256.valueOf(42L),
+ genesisBlock.header.hash,
+ genesisFile.forks
),
pendingTransactionsPool = MemoryTransactionPool()
)
diff --git a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/BlockchainInformation.kt b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/BlockchainInformation.kt
index 618448c0..2a0f1303 100644
--- a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/BlockchainInformation.kt
+++ b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/BlockchainInformation.kt
@@ -103,7 +103,7 @@ class SimpleBlockchainInformation(
val bestHash: Hash,
val bestNumber: UInt256,
val genesisHash: Hash,
- possibleForks: List<Long>,
+ possibleForks: List<Long>
) : BlockchainInformation {
private val forkIds: List<ForkInfo>
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 fb56e3e3..c67374bb 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
@@ -33,6 +33,7 @@ import org.apache.tuweni.units.bigints.UInt256
import org.slf4j.LoggerFactory
val logger = LoggerFactory.getLogger(EthClient::class.java)
+
/**
* Client of the ETH subprotocol, allowing to request block and node data
*/
@@ -182,7 +183,7 @@ open class EthClient(
@Suppress("TYPE_INFERENCE_ONLY_INPUT_TYPES_WARNING")
fun headersRequested(
connection: WireConnection,
- blockHeader: BlockHeader,
+ blockHeader: BlockHeader
): Request<List<BlockHeader>>? = headerRequests.remove(connection.uri() + blockHeader.hash.toHexString())
?: headerRequests.remove(connection.uri() + blockHeader.number.toHexString())
diff --git a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthClient66.kt b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthClient66.kt
index 9bc614ef..55c99bb1 100644
--- a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthClient66.kt
+++ b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthClient66.kt
@@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory
open class EthClient66(
private val service: RLPxService,
private val pendingTransactionsPool: TransactionPool,
- private val connectionSelectionStrategy: ConnectionSelectionStrategy,
+ private val connectionSelectionStrategy: ConnectionSelectionStrategy
) : EthClient(service, pendingTransactionsPool, connectionSelectionStrategy) {
companion object {
@@ -55,7 +55,7 @@ open class EthClient66(
override fun requestTransactionReceipts(
blockHashes: List<Hash>,
- connection: WireConnection,
+ connection: WireConnection
): AsyncResult<List<List<TransactionReceipt>>> {
val handle = AsyncResult.incomplete<List<List<TransactionReceipt>>>()
transactionReceiptRequests.computeIfAbsent(UInt64.random().toBytes()) { key ->
@@ -78,7 +78,7 @@ open class EthClient66(
maxHeaders: Long,
skip: Long,
reverse: Boolean,
- connection: WireConnection,
+ connection: WireConnection
): AsyncResult<List<BlockHeader>> {
logger.info("Requesting headers hash: $blockHash maxHeaders: $maxHeaders skip: $skip reverse: $reverse")
if (connection.agreedSubprotocolVersion(EthSubprotocol.ETH66.name()) != EthSubprotocol.ETH66) {
@@ -105,7 +105,7 @@ open class EthClient66(
maxHeaders: Long,
skip: Long,
reverse: Boolean,
- connection: WireConnection,
+ connection: WireConnection
): AsyncResult<List<BlockHeader>> {
if (connection.agreedSubprotocolVersion(EthSubprotocol.ETH66.name()) != EthSubprotocol.ETH66) {
return super.requestBlockHeaders(blockNumber, maxHeaders, skip, reverse, connection)
@@ -130,7 +130,7 @@ open class EthClient66(
override fun requestBlockHeaders(
blockHashes: List<Hash>,
- connection: WireConnection,
+ connection: WireConnection
): AsyncResult<List<BlockHeader>> {
if (connection.agreedSubprotocolVersion(EthSubprotocol.ETH66.name()) != EthSubprotocol.ETH66) {
return super.requestBlockHeaders(blockHashes, connection)
@@ -198,7 +198,7 @@ open class EthClient66(
}
fun headersRequested(
- requestIdentifier: Bytes,
+ requestIdentifier: Bytes
): Request<List<BlockHeader>>? {
val request = headerRequests.remove(requestIdentifier) ?: return null
return request
@@ -211,7 +211,7 @@ open class EthClient66(
nodeDataRequests[requestIdentifier]
fun transactionReceiptsRequested(
- requestIdentifier: Bytes,
+ requestIdentifier: Bytes
): Request<List<List<TransactionReceipt>>>? = transactionReceiptRequests[requestIdentifier]
override suspend fun submitPooledTransaction(vararg tx: Transaction) {
diff --git a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthController.kt b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthController.kt
index 545740e5..e1db98ea 100644
--- a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthController.kt
+++ b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthController.kt
@@ -34,7 +34,7 @@ class EthController(
val repository: BlockchainRepository,
val pendingTransactionsPool: TransactionPool,
val requestsManager: EthRequestsManager,
- val connectionsListener: (WireConnection, Status) -> Unit = { _, _ -> },
+ val connectionsListener: (WireConnection, Status) -> Unit = { _, _ -> }
) {
suspend fun findTransactionReceipts(hashes: List<Hash>): List<List<TransactionReceipt>> {
@@ -166,7 +166,7 @@ class EthController(
suspend fun addNewTransactionReceipts(
connection: WireConnection,
requestIdentifier: Bytes?,
- transactionReceipts: List<List<TransactionReceipt>>,
+ transactionReceipts: List<List<TransactionReceipt>>
) {
val request = if (requestIdentifier == null) {
(requestsManager as EthClient).transactionReceiptsRequested(connection)
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 cfc328eb..adafb389 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
@@ -39,7 +39,7 @@ internal class EthHandler(
override val coroutineContext: CoroutineContext = Dispatchers.Default,
private val blockchainInfo: BlockchainInformation,
private val service: RLPxService,
- private val controller: EthController,
+ private val controller: EthController
) : SubProtocolHandler, CoroutineScope {
private val pendingStatus = ExpiringMap<String, PeerInfo>(60000)
@@ -171,7 +171,6 @@ internal class EthHandler(
}
private suspend fun handleGetReceipts(connection: WireConnection, getReceipts: GetReceipts) {
-
service.send(
connection.agreedSubprotocolVersion(ETH62.name()),
MessageType.Receipts.code,
@@ -240,11 +239,16 @@ internal class EthHandler(
val forkId =
blockchainInfo.getLastestApplicableFork(controller.repository.retrieveChainHeadHeader().number.toLong())
service.send(
- ethSubProtocol, MessageType.Status.code, connection,
+ ethSubProtocol,
+ MessageType.Status.code,
+ connection,
StatusMessage(
ethSubProtocol.version(),
- blockchainInfo.networkID(), blockchainInfo.totalDifficulty(),
- blockchainInfo.bestHash(), blockchainInfo.genesisHash(), forkId.hash,
+ blockchainInfo.networkID(),
+ blockchainInfo.totalDifficulty(),
+ blockchainInfo.bestHash(),
+ blockchainInfo.genesisHash(),
+ forkId.hash,
forkId.next
).toBytes()
)
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 d6553cff..5d8e12c2 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
@@ -39,7 +39,7 @@ internal class EthHandler66(
override val coroutineContext: CoroutineContext = Dispatchers.Default,
private val blockchainInfo: BlockchainInformation,
private val service: RLPxService,
- private val controller: EthController,
+ private val controller: EthController
) : SubProtocolHandler, CoroutineScope {
private val ethHandler = EthHandler(coroutineContext, blockchainInfo, service, controller)
@@ -85,10 +85,12 @@ internal class EthHandler66(
MessageType.GetReceipts.code -> handleGetReceipts(connection, requestIdentifier, GetReceipts.read(payload))
MessageType.Receipts.code -> handleReceipts(connection, requestIdentifier, Receipts.read(payload))
MessageType.NewPooledTransactionHashes.code -> handleNewPooledTransactionHashes(
- connection, NewPooledTransactionHashes.read(message)
+ connection,
+ NewPooledTransactionHashes.read(message)
)
MessageType.GetPooledTransactions.code -> handleGetPooledTransactions(
- connection, requestIdentifier,
+ connection,
+ requestIdentifier,
GetPooledTransactions.read(payload)
)
MessageType.PooledTransactions.code -> handlePooledTransactions(PooledTransactions.read(payload))
@@ -261,7 +263,9 @@ internal class EthHandler66(
blockHeaderRequest.reverse
)
service.send(
- EthSubprotocol.ETH66, MessageType.BlockHeaders.code, connection,
+ EthSubprotocol.ETH66,
+ MessageType.BlockHeaders.code,
+ connection,
RLP.encodeList {
it.writeValue(requestIdentifier)
it.writeRLP(BlockHeaders(headers).toBytes())
@@ -290,11 +294,16 @@ internal class EthHandler66(
val forkId =
blockchainInfo.getLastestApplicableFork(controller.repository.retrieveChainHeadHeader().number.toLong())
service.send(
- ethSubProtocol, MessageType.Status.code, connection,
+ ethSubProtocol,
+ MessageType.Status.code,
+ connection,
StatusMessage(
ethSubProtocol.version(),
- blockchainInfo.networkID(), blockchainInfo.totalDifficulty(),
- blockchainInfo.bestHash(), blockchainInfo.genesisHash(), forkId.hash,
+ blockchainInfo.networkID(),
+ blockchainInfo.totalDifficulty(),
+ blockchainInfo.bestHash(),
+ blockchainInfo.genesisHash(),
+ forkId.hash,
forkId.next
).toBytes()
)
diff --git a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHelloHandler.kt b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHelloHandler.kt
index 480937c9..37f5183d 100644
--- a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHelloHandler.kt
+++ b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHelloHandler.kt
@@ -76,11 +76,16 @@ internal class EthHelloHandler(
val forkId =
blockchainInfo.getLastestApplicableFork(0L)
service.send(
- ethSubProtocol, MessageType.Status.code, connection,
+ ethSubProtocol,
+ MessageType.Status.code,
+ connection,
StatusMessage(
ethSubProtocol.version(),
- blockchainInfo.networkID(), blockchainInfo.totalDifficulty(),
- blockchainInfo.bestHash(), blockchainInfo.genesisHash(), forkId.hash,
+ blockchainInfo.networkID(),
+ blockchainInfo.totalDifficulty(),
+ blockchainInfo.bestHash(),
+ blockchainInfo.genesisHash(),
+ forkId.hash,
forkId.next
).toBytes()
)
diff --git a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/Messages.kt b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/Messages.kt
index db5c1578..93e906c5 100644
--- a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/Messages.kt
+++ b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/Messages.kt
@@ -74,8 +74,13 @@ internal data class StatusMessage(
}
StatusMessage(
- protocolVersion, networkID, totalDifficulty, bestHash,
- genesisHash, forkInfo?.first, forkInfo?.second?.toLong()
+ protocolVersion,
+ networkID,
+ totalDifficulty,
+ bestHash,
+ genesisHash,
+ forkInfo?.first,
+ forkInfo?.second?.toLong()
)
}
}
diff --git a/devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/BlockchainInformationTest.kt b/devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/BlockchainInformationTest.kt
index af8a5329..229122b8 100644
--- a/devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/BlockchainInformationTest.kt
+++ b/devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/BlockchainInformationTest.kt
@@ -32,8 +32,12 @@ class BlockchainInformationTest {
val genesisFile = GenesisFile.read(contents)
val genesisBlock = genesisFile.toBlock()
val info = SimpleBlockchainInformation(
- UInt256.valueOf(genesisFile.chainId.toLong()), genesisBlock.header.difficulty,
- genesisBlock.header.hash, UInt256.valueOf(42L), genesisBlock.header.hash, genesisFile.forks
+ UInt256.valueOf(genesisFile.chainId.toLong()),
+ genesisBlock.header.difficulty,
+ genesisBlock.header.hash,
+ UInt256.valueOf(42L),
+ genesisBlock.header.hash,
+ genesisFile.forks
)
assertEquals(Bytes.fromHexString("0xfc64ec04"), info.getForkHashes()[0])
assertEquals(Bytes.fromHexString("0x97c2c34c"), info.getForkHashes()[1])
@@ -51,8 +55,12 @@ class BlockchainInformationTest {
val genesisFile = GenesisFile.read(contents)
val genesisBlock = genesisFile.toBlock()
val info = SimpleBlockchainInformation(
- UInt256.valueOf(genesisFile.chainId.toLong()), genesisBlock.header.difficulty,
- genesisBlock.header.hash, UInt256.valueOf(42L), genesisBlock.header.hash, genesisFile.forks
+ UInt256.valueOf(genesisFile.chainId.toLong()),
+ genesisBlock.header.difficulty,
+ genesisBlock.header.hash,
+ UInt256.valueOf(42L),
+ genesisBlock.header.hash,
+ genesisFile.forks
)
assertEquals(1150000L, info.getLastestApplicableFork(0L).next)
}
@@ -63,8 +71,12 @@ class BlockchainInformationTest {
val genesisFile = GenesisFile.read(contents)
val genesisBlock = genesisFile.toBlock()
val info = SimpleBlockchainInformation(
- UInt256.valueOf(genesisFile.chainId.toLong()), genesisBlock.header.difficulty,
- genesisBlock.header.hash, UInt256.valueOf(42L), genesisBlock.header.hash, genesisFile.forks
+ UInt256.valueOf(genesisFile.chainId.toLong()),
+ genesisBlock.header.difficulty,
+ genesisBlock.header.hash,
+ UInt256.valueOf(42L),
+ genesisBlock.header.hash,
+ genesisFile.forks
)
assertEquals(Bytes.fromHexString("0x30c7ddbc"), info.getLastestApplicableFork(0L).hash)
assertEquals(10L, info.getLastestApplicableFork(0L).next)
diff --git a/devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/EthControllerTest.kt b/devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/EthControllerTest.kt
index 0be3bca4..4acb40fa 100644
--- a/devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/EthControllerTest.kt
+++ b/devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/EthControllerTest.kt
@@ -16,16 +16,16 @@
*/
package org.apache.tuweni.devp2p.eth
+import com.nhaarman.mockitokotlin2.mock
import kotlinx.coroutines.runBlocking
import org.apache.tuweni.bytes.Bytes
import org.apache.tuweni.eth.BlockBody
import org.apache.tuweni.eth.repository.BlockchainRepository
import org.apache.tuweni.eth.repository.MemoryTransactionPool
import org.apache.tuweni.genesis.Genesis
+import org.apache.tuweni.junit.BouncyCastleExtension
import org.apache.tuweni.rlpx.wire.WireConnection
import org.junit.jupiter.api.Test
-import com.nhaarman.mockitokotlin2.mock
-import org.apache.tuweni.junit.BouncyCastleExtension
import org.junit.jupiter.api.extension.ExtendWith
@ExtendWith(BouncyCastleExtension::class)
@@ -33,12 +33,11 @@ class EthControllerTest {
@Test
fun testMismatchHeaders() = runBlocking {
-
val requestsManager = EthClient66(mock {}, mock {}, mock {})
val controller = EthController(
BlockchainRepository.inMemory(Genesis.dev()),
MemoryTransactionPool(),
- requestsManager,
+ requestsManager
) { _, _ -> }
val conn = mock<WireConnection> {}
diff --git a/devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/EthHandlerTest.kt b/devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/EthHandlerTest.kt
index adfac502..ef8134fe 100644
--- a/devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/EthHandlerTest.kt
+++ b/devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/EthHandlerTest.kt
@@ -54,9 +54,9 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.ArgumentCaptor
import org.mockito.ArgumentMatchers.eq
-import org.mockito.Mockito.`when`
import org.mockito.Mockito.mock
import org.mockito.Mockito.verify
+import org.mockito.Mockito.`when`
import java.time.Instant
import java.time.temporal.ChronoUnit
@@ -121,7 +121,8 @@ class EthHandlerTest {
blockchainInfo = SimpleBlockchainInformation(
UInt256.valueOf(42L),
UInt256.ONE,
- genesisBlock.header.hash, UInt256.valueOf(42L),
+ genesisBlock.header.hash,
+ UInt256.valueOf(42L),
genesisBlock.header.hash,
emptyList()
),
@@ -137,9 +138,13 @@ class EthHandlerTest {
repository.storeTransactionReceipt(
TransactionReceipt(
Bytes32.random(),
- 32L, LogsBloomFilter(), emptyList()
+ 32L,
+ LogsBloomFilter(),
+ emptyList()
),
- txIndex, tx.hash, newBlock.header.hash
+ txIndex,
+ tx.hash,
+ newBlock.header.hash
)
txIndex++
}
@@ -172,8 +177,13 @@ class EthHandlerTest {
BlockBody(
listOf(
Transaction(
- UInt256.ONE, Wei.valueOf(20L), Gas.valueOf(3000),
- Address.fromBytes(Bytes.random(20)), Wei.valueOf(1000), Bytes.EMPTY, SECP256K1.KeyPair.random()
+ UInt256.ONE,
+ Wei.valueOf(20L),
+ Gas.valueOf(3000),
+ Address.fromBytes(Bytes.random(20)),
+ Wei.valueOf(1000),
+ Bytes.EMPTY,
+ SECP256K1.KeyPair.random()
)
),
emptyList()
diff --git a/devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/EthSubprotocolTest.kt b/devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/EthSubprotocolTest.kt
index 0ffdce1f..07c3a84d 100644
--- a/devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/EthSubprotocolTest.kt
+++ b/devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/EthSubprotocolTest.kt
@@ -43,7 +43,8 @@ class EthSubprotocolTest {
val blockchainInfo = SimpleBlockchainInformation(
UInt256.ONE,
UInt256.ONE,
- Hash.fromBytes(Bytes32.random()), UInt256.valueOf(42L),
+ Hash.fromBytes(Bytes32.random()),
+ UInt256.valueOf(42L),
Hash.fromBytes(Bytes32.random()),
emptyList()
)
diff --git a/devp2p-proxy/src/test/kotlin/org/apache/tuweni/devp2p/proxy/ProxyTest.kt b/devp2p-proxy/src/test/kotlin/org/apache/tuweni/devp2p/proxy/ProxyTest.kt
index 27bbac06..61375d58 100644
--- a/devp2p-proxy/src/test/kotlin/org/apache/tuweni/devp2p/proxy/ProxyTest.kt
+++ b/devp2p-proxy/src/test/kotlin/org/apache/tuweni/devp2p/proxy/ProxyTest.kt
@@ -27,8 +27,8 @@ import org.apache.tuweni.rlpx.wire.SubProtocolIdentifier
import org.apache.tuweni.rlpx.wire.WireConnection
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
-import org.mockito.Mockito.`when`
import org.mockito.Mockito.mock
+import org.mockito.Mockito.`when`
internal class SubProtocolServiceImpl() : SubprotocolService {
diff --git a/devp2p/src/integrationTest/kotlin/org/apache/tuweni/devp2p/v5/MedallaTest.kt b/devp2p/src/integrationTest/kotlin/org/apache/tuweni/devp2p/v5/MedallaTest.kt
index 9bb30d3f..d5f1e38b 100644
--- a/devp2p/src/integrationTest/kotlin/org/apache/tuweni/devp2p/v5/MedallaTest.kt
+++ b/devp2p/src/integrationTest/kotlin/org/apache/tuweni/devp2p/v5/MedallaTest.kt
@@ -38,7 +38,6 @@ class MedallaTest {
@Test
fun testConnect(@VertxInstance vertx: Vertx) = runBlocking {
-
val enrRec =
"enr:-LK4QC3FCb7-JTNRiWAezECk_QUJc9c2IkJA1-EAmqAA5wmdbPWsAeRpnMXKRJqOYG0TE99ycB1nOb9y26mjb" +
"_UoHS4Bh2F0dG5ldHOIAAAAAAAAAACEZXRoMpDnp11aAAAAAf__________gmlkgnY0gmlwhDMPYfCJc2VjcDI1N" +
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 dc6475f9..0be60401 100644
--- a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/DiscoveryService.kt
+++ b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/DiscoveryService.kt
@@ -122,13 +122,17 @@ interface DiscoveryService {
advertiseTcpPort: Int? = null,
routingTable: PeerRoutingTable = DevP2PPeerRoutingTable(keyPair.publicKey()),
packetFilter: ((SECP256K1.PublicKey, SocketAddress) -> Boolean)? = null,
- timeSupplier: () -> Long = CURRENT_TIME_SUPPLIER,
+ timeSupplier: () -> Long = CURRENT_TIME_SUPPLIER
): DiscoveryService {
val bindAddress =
- if (host == null) SocketAddress.inetSocketAddress(port, "127.0.0.1") else SocketAddress.inetSocketAddress(
- port,
- host
- )
+ if (host == null) {
+ SocketAddress.inetSocketAddress(port, "127.0.0.1")
+ } else {
+ SocketAddress.inetSocketAddress(
+ port,
+ host
+ )
+ }
return open(
vertx,
keyPair,
@@ -177,7 +181,7 @@ interface DiscoveryService {
advertiseTcpPort: Int? = null,
routingTable: PeerRoutingTable = DevP2PPeerRoutingTable(keyPair.publicKey()),
packetFilter: ((SECP256K1.PublicKey, SocketAddress) -> Boolean)? = null,
- timeSupplier: () -> Long = CURRENT_TIME_SUPPLIER,
+ timeSupplier: () -> Long = CURRENT_TIME_SUPPLIER
): DiscoveryService {
return CoroutineDiscoveryService(
vertx,
@@ -295,7 +299,7 @@ internal class CoroutineDiscoveryService constructor(
private val routingTable: PeerRoutingTable = DevP2PPeerRoutingTable(keyPair.publicKey()),
private val packetFilter: ((SECP256K1.PublicKey, SocketAddress) -> Boolean)? = null,
private val timeSupplier: () -> Long = DiscoveryService.CURRENT_TIME_SUPPLIER,
- override val coroutineContext: CoroutineContext = vertx.dispatcher() + CoroutineExceptionHandler { _, _ -> },
+ override val coroutineContext: CoroutineContext = vertx.dispatcher() + CoroutineExceptionHandler { _, _ -> }
) : DiscoveryService, CoroutineScope {
companion object {
@@ -352,7 +356,12 @@ internal class CoroutineDiscoveryService constructor(
advertiseTcpPort
)
enr = EthereumNodeRecord.toRLP(
- keyPair, seq, enrData, null, InetAddress.getByName(endpoint.address), endpoint.tcpPort,
+ keyPair,
+ seq,
+ enrData,
+ null,
+ InetAddress.getByName(endpoint.address),
+ endpoint.tcpPort,
endpoint.udpPort
)
selfEndpoint = endpoint
@@ -386,7 +395,8 @@ internal class CoroutineDiscoveryService constructor(
if (result.peer != peer) {
logger.warn(
"{}: ignoring bootstrap peer {} - responding node used a different node-id",
- serviceDescriptor, uri
+ serviceDescriptor,
+ uri
)
return false
}
@@ -483,7 +493,6 @@ internal class CoroutineDiscoveryService constructor(
}
private suspend fun receivePacket(datagram: Buffer, address: SocketAddress, arrivalTime: Long) {
-
val packet: Packet
try {
packet = Packet.decodeFrom(Bytes.wrap(datagram.bytes))
@@ -572,8 +581,11 @@ internal class CoroutineDiscoveryService constructor(
logger.debug("{}: verified peer endpoint {} (node-id: {})", serviceDescriptor, endpoint.address, peer.nodeId)
} else {
logger.debug(
- "{}: verified peer endpoint {} (node-id: {} - changed from {})", serviceDescriptor,
- endpoint.address, peer.nodeId, sender.nodeId
+ "{}: verified peer endpoint {} (node-id: {} - changed from {})",
+ serviceDescriptor,
+ endpoint.address,
+ peer.nodeId,
+ sender.nodeId
)
}
@@ -619,8 +631,10 @@ internal class CoroutineDiscoveryService constructor(
endpointVerification(node.endpoint, neighbor).verify(now)
}?.let { result ->
logger.debug(
- "{}: adding {} to the routing table (node-id: {})", serviceDescriptor,
- result.endpoint.address, result.peer.nodeId
+ "{}: adding {} to the routing table (node-id: {})",
+ serviceDescriptor,
+ result.endpoint.address,
+ result.peer.nodeId
)
addToRoutingTable(result.peer)
}
@@ -688,7 +702,7 @@ internal class CoroutineDiscoveryService constructor(
private suspend fun ensurePeerIsValid(
peer: Peer,
address: SocketAddress,
- arrivalTime: Long,
+ arrivalTime: Long
): VerificationResult? {
val now = timeSupplier()
peer.getEndpoint(now - ENDPOINT_PROOF_LONGEVITY_MS)?.let { endpoint ->
@@ -698,7 +712,8 @@ internal class CoroutineDiscoveryService constructor(
val endpoint = peer.updateEndpoint(
Endpoint(address, peer.endpoint.tcpPort),
- arrivalTime, now - ENDPOINT_PROOF_LONGEVITY_MS
+ arrivalTime,
+ now - ENDPOINT_PROOF_LONGEVITY_MS
)
return withTimeoutOrNull(PEER_VERIFICATION_TIMEOUT_MS) { endpointVerification(endpoint, peer).verify(now) }
}
@@ -784,7 +799,7 @@ internal class CoroutineDiscoveryService constructor(
*
* This will typically be the same as peer.endpoint, but may not be due to concurrent updates.
*/
- val endpoint: Endpoint,
+ val endpoint: Endpoint
)
private fun enrRequest(endpoint: Endpoint, peer: Peer) =
@@ -839,7 +854,7 @@ internal class CoroutineDiscoveryService constructor(
private data class ENRResult(
val peer: Peer,
- val enr: EthereumNodeRecord,
+ val enr: EthereumNodeRecord
)
private suspend fun findNodes(peer: Peer, target: SECP256K1.PublicKey): AsyncResult<List<Node>> {
diff --git a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/Endpoint.kt b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/Endpoint.kt
index 1cf82b58..dd6b0bc3 100644
--- a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/Endpoint.kt
+++ b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/Endpoint.kt
@@ -104,6 +104,7 @@ data class Endpoint(
* UDP socket address of the endpoint
*/
val udpSocketAddress: SocketAddress = SocketAddress.inetSocketAddress(udpPort, address)
+
/**
* TCP socket address of the endpoint, if set
*/
diff --git a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/EnodeUri.kt b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/EnodeUriComponents.kt
similarity index 100%
rename from devp2p/src/main/kotlin/org/apache/tuweni/devp2p/EnodeUri.kt
rename to devp2p/src/main/kotlin/org/apache/tuweni/devp2p/EnodeUriComponents.kt
diff --git a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/EthereumNodeRecord.kt b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/EthereumNodeRecord.kt
index 067b5fb1..a2685454 100644
--- a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/EthereumNodeRecord.kt
+++ b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/EthereumNodeRecord.kt
@@ -245,7 +245,8 @@ class EthereumNodeRecord(
}
val sig = SECP256K1.Signature.create(
- 1, signature.slice(0, 32).toUnsignedBigInteger(),
+ 1,
+ signature.slice(0, 32).toUnsignedBigInteger(),
signature.slice(32).toUnsignedBigInteger()
)
@@ -254,7 +255,8 @@ class EthereumNodeRecord(
if (pubKey != recovered) {
val sig0 = SECP256K1.Signature.create(
- 0, signature.slice(0, 32).toUnsignedBigInteger(),
+ 0,
+ signature.slice(0, 32).toUnsignedBigInteger(),
signature.slice(32).toUnsignedBigInteger()
)
val recovered0 = SECP256K1.PublicKey.recoverFromSignature(encoded, sig0)
diff --git a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/PacketType.kt b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/PacketType.kt
index 99ce0e6d..b09603ae 100644
--- a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/PacketType.kt
+++ b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/PacketType.kt
@@ -38,6 +38,7 @@ internal enum class PacketType(
signature: SECP256K1.Signature
) = PingPacket.decode(payload, hash, publicKey, signature) as Packet
},
+
/**
* Pong packet as response to pings
*/
@@ -49,6 +50,7 @@ internal enum class PacketType(
signature: SECP256K1.Signature
) = PongPacket.decode(payload, hash, publicKey, signature) as Packet
},
+
/**
* FindNode packet
*/
@@ -60,6 +62,7 @@ internal enum class PacketType(
signature: SECP256K1.Signature
) = FindNodePacket.decode(payload, hash, publicKey, signature) as Packet
},
+
/**
* Neighbors packet response
*/
@@ -71,6 +74,7 @@ internal enum class PacketType(
signature: SECP256K1.Signature
) = NeighborsPacket.decode(payload, hash, publicKey, signature) as Packet
},
+
/**
* ENR request packet
*/
@@ -82,6 +86,7 @@ internal enum class PacketType(
signature: SECP256K1.Signature
) = ENRRequestPacket.decode(payload, hash, publicKey, signature) as Packet
},
+
/**
* ENR response packet
*/
diff --git a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/PeerRepository.kt b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/PeerRepository.kt
index f279abc5..7ad9b5f4 100644
--- a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/PeerRepository.kt
+++ b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/PeerRepository.kt
@@ -153,7 +153,7 @@ class EphemeralPeerRepository(
private inner class EphemeralPeer(
override val nodeId: SECP256K1.PublicKey,
- knownEndpoint: Endpoint,
+ knownEndpoint: Endpoint
) : Peer {
@Volatile
override var endpoint: Endpoint = knownEndpoint
diff --git a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/Scraper.kt b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/Scraper.kt
index 5b3e989b..14e01919 100644
--- a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/Scraper.kt
+++ b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/Scraper.kt
@@ -48,7 +48,9 @@ object ScraperApp {
val uris = args.map { URI.create(it) }
val addr = SocketAddress.inetSocketAddress(11000, "0.0.0.0")
val scraper = Scraper(
- initialURIs = uris, bindAddress = addr, repository = EphemeralPeerRepository(),
+ initialURIs = uris,
+ bindAddress = addr,
+ repository = EphemeralPeerRepository(),
listeners = listOf {
println(it.uri())
}
@@ -78,7 +80,7 @@ class Scraper(
val bindAddress: SocketAddress,
val repository: PeerRepository,
val listeners: List<(Peer) -> Unit>? = null,
- val waitSecondsBetweenScrapes: Long = 30,
+ val waitSecondsBetweenScrapes: Long = 30
) : CoroutineScope {
private var service: DiscoveryService? = null
diff --git a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/v5/HandshakeSession.kt b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/v5/HandshakeSession.kt
index fd426e05..0212ff5f 100644
--- a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/v5/HandshakeSession.kt
+++ b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/v5/HandshakeSession.kt
@@ -25,8 +25,8 @@ import org.apache.tuweni.crypto.Hash
import org.apache.tuweni.crypto.SECP256K1
import org.apache.tuweni.devp2p.EthereumNodeRecord
import org.apache.tuweni.devp2p.v5.encrypt.AES128GCM
-import org.apache.tuweni.devp2p.v5.encrypt.SessionKeyGenerator
import org.apache.tuweni.devp2p.v5.encrypt.SessionKey
+import org.apache.tuweni.devp2p.v5.encrypt.SessionKeyGenerator
import org.apache.tuweni.rlp.RLP
import org.apache.tuweni.rlp.RLPReader
import org.apache.tuweni.units.bigints.UInt256
@@ -190,7 +190,8 @@ internal class HandshakeSession(
publicKey: SECP256K1.PublicKey
): Boolean {
val signature = SECP256K1.Signature.create(
- 1, signatureBytes.slice(0, 32).toUnsignedBigInteger(),
+ 1,
+ signatureBytes.slice(0, 32).toUnsignedBigInteger(),
signatureBytes.slice(32).toUnsignedBigInteger()
)
@@ -198,7 +199,8 @@ internal class HandshakeSession(
val hashedSignValue = Hash.sha2_256(signValue)
if (!SECP256K1.verifyHashed(hashedSignValue, signature, publicKey)) {
val signature0 = SECP256K1.Signature.create(
- 0, signatureBytes.slice(0, 32).toUnsignedBigInteger(),
+ 0,
+ signatureBytes.slice(0, 32).toUnsignedBigInteger(),
signatureBytes.slice(32).toUnsignedBigInteger()
)
return SECP256K1.verifyHashed(hashedSignValue, signature0, publicKey)
diff --git a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/v5/Scraper.kt b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/v5/Scraper.kt
index 120a15a6..09b5aabc 100644
--- a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/v5/Scraper.kt
+++ b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/v5/Scraper.kt
@@ -52,7 +52,8 @@ object ScraperApp {
val addr = InetSocketAddress("0.0.0.0", 10000)
val seen = ConcurrentHashMap.newKeySet<EthereumNodeRecord>()
val scraper = Scraper(
- initialENRs = enrs, bindAddress = addr,
+ initialENRs = enrs,
+ bindAddress = addr,
listeners = listOf { _, nodes ->
for (node in nodes) {
if (seen.add(node)) {
diff --git a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/v5/Session.kt b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/v5/Session.kt
index 7af1d00a..15297a08 100644
--- a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/v5/Session.kt
+++ b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/v5/Session.kt
@@ -219,7 +219,9 @@ internal class Session(
val ticket = Ticket.decrypt(message.ticket, sessionKey.initiatorKey)
ticket.validate(nodeId, address.host(), now(), message.topic)
ticket
- } else null
+ } else {
+ null
+ }
// Create new ticket
val waitTime = topicTable.put(topic, message.nodeRecord)
diff --git a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/v5/encrypt/AES128GCM.kt b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/v5/encrypt/AES128GCM.kt
index d1133ecd..1a856bc5 100644
--- a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/v5/encrypt/AES128GCM.kt
+++ b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/v5/encrypt/AES128GCM.kt
@@ -39,7 +39,6 @@ object AES128GCM {
* @param data encryption metadata
*/
fun encrypt(privateKey: Bytes, nonce: Bytes, message: Bytes, additionalAuthenticatedData: Bytes): Bytes {
-
val cipher = Cipher.getInstance("AES/GCM/NoPadding")
cipher.init(
Cipher.ENCRYPT_MODE,
diff --git a/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/ENRResponsePacketTest.kt b/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/ENRResponsePacketTest.kt
index ed710869..fa6e0ef5 100644
--- a/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/ENRResponsePacketTest.kt
+++ b/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/ENRResponsePacketTest.kt
@@ -34,9 +34,13 @@ internal class ENRResponsePacketTest {
val requestHash = Bytes32.random()
val enr = EthereumNodeRecord.toRLP(
- SECP256K1.KeyPair.random(), 2, emptyMap(),
+ SECP256K1.KeyPair.random(),
+ 2,
emptyMap(),
- InetAddress.getByName("localhost"), 3000, 12000
+ emptyMap(),
+ InetAddress.getByName("localhost"),
+ 3000,
+ 12000
)
val now = System.currentTimeMillis()
val pong = ENRResponsePacket.create(keyPair, now, requestHash, enr)
diff --git a/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/EthereumNodeRecordTest.kt b/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/EthereumNodeRecordTest.kt
index 67a198f0..7ad629eb 100644
--- a/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/EthereumNodeRecordTest.kt
+++ b/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/EthereumNodeRecordTest.kt
@@ -44,7 +44,8 @@ class EthereumNodeRecordTest {
keyPair,
1,
emptyMap(),
- emptyMap(), InetAddress.getLoopbackAddress(),
+ emptyMap(),
+ InetAddress.getLoopbackAddress(),
null,
10000
)
diff --git a/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/v5/HandshakeSessionTest.kt b/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/v5/HandshakeSessionTest.kt
index 604e67ee..6d2773de 100644
--- a/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/v5/HandshakeSessionTest.kt
+++ b/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/v5/HandshakeSessionTest.kt
@@ -51,7 +51,8 @@ class HandshakeSessionTest {
peerAddress,
peerKeyPair.publicKey(),
{ _, message -> runBlocking { peerSession!!.processMessage(message) } },
- { enr }, Dispatchers.Default
+ { enr },
+ Dispatchers.Default
)
peerSession =
HandshakeSession(
@@ -59,7 +60,8 @@ class HandshakeSessionTest {
address,
keyPair.publicKey(),
{ _, message -> runBlocking { session.processMessage(message) } },
- { peerEnr }, Dispatchers.Default
+ { peerEnr },
+ Dispatchers.Default
)
val key = session.connect().await()
diff --git a/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/v5/packet/RandomMessageTest.kt b/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/v5/packet/RandomMessageTest.kt
index f9758034..d03c47f1 100644
--- a/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/v5/packet/RandomMessageTest.kt
+++ b/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/v5/packet/RandomMessageTest.kt
@@ -17,8 +17,8 @@
package org.apache.tuweni.devp2p.v5.packet
import org.apache.tuweni.bytes.Bytes
-import org.apache.tuweni.devp2p.v5.RandomMessage
import org.apache.tuweni.devp2p.v5.Message
+import org.apache.tuweni.devp2p.v5.RandomMessage
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotEquals
import org.junit.jupiter.api.Test
diff --git a/dns-discovery/src/main/kotlin/org/apache/tuweni/discovery/DNSDaemon.kt b/dns-discovery/src/main/kotlin/org/apache/tuweni/discovery/DNSDaemon.kt
index 6c02228e..b340d40e 100644
--- a/dns-discovery/src/main/kotlin/org/apache/tuweni/discovery/DNSDaemon.kt
+++ b/dns-discovery/src/main/kotlin/org/apache/tuweni/discovery/DNSDaemon.kt
@@ -37,7 +37,7 @@ class DNSDaemon @JvmOverloads constructor(
private val seq: Long = 0,
private val period: Long = 60000L,
private val dnsServer: String? = null,
- private val vertx: Vertx,
+ private val vertx: Vertx
) {
companion object {
val logger = LoggerFactory.getLogger(DNSDaemon::class.java)
diff --git a/dns-discovery/src/test/kotlin/org/apache/tuweni/discovery/DNSEntryTest.kt b/dns-discovery/src/test/kotlin/org/apache/tuweni/discovery/DNSEntryTest.kt
index 4730720a..45728f16 100644
--- a/dns-discovery/src/test/kotlin/org/apache/tuweni/discovery/DNSEntryTest.kt
+++ b/dns-discovery/src/test/kotlin/org/apache/tuweni/discovery/DNSEntryTest.kt
@@ -123,7 +123,8 @@ class DNSEntryTest {
fun testRootToString() {
val root = ENRTreeRoot(
mapOf(
- Pair("enrtree-root", "v1"), Pair("l", "TO4Q75OQ2N7DX4EOOR7X66A6OM"),
+ Pair("enrtree-root", "v1"),
+ Pair("l", "TO4Q75OQ2N7DX4EOOR7X66A6OM"),
Pair("e", "TO4Q75OQ2N7DX4EOOR7X66A6OM"),
Pair("seq", "3"),
Pair("sig", "N-YY6UB9xD0hFx1Gmnt7v0RfSxch5tKyry2SRDoLx7B4GfPXagwLxQqyf7gAMvApFn_ORwZQekMWa_pXrcGCtwE=")
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 590d7d3e..23b18afe 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
@@ -70,7 +70,7 @@ class BlockProcessor(val chainId: UInt256) {
repository: BlockchainRepository,
precompiles: Map<Address, PrecompileContract>,
hardFork: HardFork,
- stepListener: StepListener? = null,
+ stepListener: StepListener? = null
): BlockProcessorResult {
val stateChanges = TransientStateRepository(repository)
val vm = EthereumVirtualMachine(stateChanges, repository, precompiles, { EvmVmImpl.create(stepListener) })
@@ -110,7 +110,7 @@ class BlockProcessor(val chainId: UInt256) {
bloomFilter.toBytes(),
parentBlock.number.add(1),
parentBlock.gasLimit,
- allGasUsed,
+ allGasUsed
),
ProtoBlockBody(transactions),
allReceipts,
diff --git a/eth-blockprocessor/src/main/kotlin/org/apache/tuweni/blockprocessor/ProtoBlock.kt b/eth-blockprocessor/src/main/kotlin/org/apache/tuweni/blockprocessor/ProtoBlock.kt
index 39984ab3..bf1334ce 100644
--- a/eth-blockprocessor/src/main/kotlin/org/apache/tuweni/blockprocessor/ProtoBlock.kt
+++ b/eth-blockprocessor/src/main/kotlin/org/apache/tuweni/blockprocessor/ProtoBlock.kt
@@ -42,7 +42,7 @@ data class SealableHeader(
val logsBloom: Bytes,
val number: UInt256,
val gasLimit: Gas,
- val gasUsed: Gas,
+ val gasUsed: Gas
) {
/**
@@ -55,7 +55,7 @@ data class SealableHeader(
timestamp: Instant,
extraData: Bytes,
mixHash: Hash,
- nonce: UInt64,
+ nonce: UInt64
): BlockHeader {
return BlockHeader(
parentHash,
@@ -109,7 +109,7 @@ class ProtoBlock(
timestamp: Instant,
extraData: Bytes,
mixHash: Hash,
- nonce: UInt64,
+ nonce: UInt64
): Block {
val ommersHash = Hash.hash(RLP.encodeList { writer -> ommers.forEach { writer.writeValue(it.hash) } })
return Block(
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 8de686a8..07886e88 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
@@ -69,7 +69,7 @@ class TransactionProcessor(val vm: EthereumVirtualMachine, val hardFork: HardFor
gasUsed: Gas,
allGasUsed: Gas,
coinbase: Address,
- blockBloomFilter: LogsBloomFilter,
+ blockBloomFilter: LogsBloomFilter
): TransactionProcessorResult {
val sender = tx.sender
if (sender === null) {
@@ -121,7 +121,7 @@ class TransactionProcessor(val vm: EthereumVirtualMachine, val hardFork: HardFor
parentBlock.difficulty,
chainId,
CallKind.CALL,
- hardFork,
+ hardFork
)
result.state.gasManager.add(gasCost)
if (result.statusCode != EVMExecutionStatusCode.SUCCESS) {
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 793a259d..1810b7d1 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
@@ -99,7 +99,6 @@ class BlockProcessorReferenceTest {
@Throws(IOException::class)
private fun prepareTests(path: URL, input: InputStream): Stream<Arguments> {
-
val typeRef = object : TypeReference<HashMap<String, JsonReferenceTest>>() {}
val allTests: Map<String, JsonReferenceTest> = mapper.readValue(input, typeRef)
return allTests
@@ -134,7 +133,7 @@ class BlockProcessorReferenceTest {
testName: String,
test: JsonReferenceTest,
hardFork: HardFork,
- path: URL,
+ path: URL
): List<Arguments> {
var index = 0
return test.post?.get(hardForkMappping[hardFork])?.map { exec ->
@@ -143,7 +142,6 @@ class BlockProcessorReferenceTest {
if (value.size() > 32) {
null
} else {
-
Transaction(
test.transaction!!.nonce!!,
test.transaction!!.gasPrice!!,
@@ -178,7 +176,7 @@ class BlockProcessorReferenceTest {
testIndex: Int,
test: JsonReferenceTest,
tx: () -> Transaction,
- exec: TransactionExecution,
+ exec: TransactionExecution
) {
runReferenceTests(path, testName, hardFork, testIndex, test, tx, exec)
}
@@ -190,7 +188,7 @@ class BlockProcessorReferenceTest {
testIndex: Int,
test: JsonReferenceTest,
tx: () -> Transaction?,
- exec: TransactionExecution,
+ exec: TransactionExecution
) = runBlocking {
assertNotNull(testName)
assertNotNull(hardFork)
@@ -237,7 +235,7 @@ class BlockProcessorReferenceTest {
Instant.ofEpochSecond(test.env!!.currentTimestamp!!.toLong()),
Bytes.EMPTY,
Hash.hash(RLP.encodeList {}),
- UInt64.random(),
+ UInt64.random()
)
val result =
processor.execute(
@@ -260,7 +258,8 @@ class BlockProcessorReferenceTest {
}
val logsHash = Hash.hash(rlp)
assertEquals(
- exec.logs, logsHash
+ exec.logs,
+ logsHash
) {
val logs = result.block.transactionReceipts.map { it.logs }.flatten()
logs.map {
@@ -307,14 +306,14 @@ data class JsonAccountState(
var balance: Wei? = null,
var code: Bytes? = null,
var nonce: UInt256? = null,
- var storage: Map<UInt256, UInt256>? = null,
+ var storage: Map<UInt256, UInt256>? = null
)
@JsonIgnoreProperties(ignoreUnknown = true)
data class TransactionExecutionIndex(
var data: Int? = null,
var gas: Int? = null,
- var value: Int? = null,
+ var value: Int? = null
)
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -323,7 +322,7 @@ data class TransactionExecution(
var hash: Hash? = null,
var indexes: TransactionExecutionIndex? = null,
var logs: Bytes? = null,
- var txbytes: Bytes? = null,
+ var txbytes: Bytes? = null
)
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -331,7 +330,7 @@ data class JsonReferenceTest(
var env: Env? = null,
var post: Map<String, List<TransactionExecution>>? = null,
var pre: Map<Address, JsonAccountState>? = null,
- var transaction: TransactionStep? = null,
+ var transaction: TransactionStep? = null
)
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -343,7 +342,7 @@ data class TransactionStep(
var secretKey: Bytes32? = null,
var sender: Address? = null,
var to: Address? = null,
- val value: List<Bytes>? = null,
+ val value: List<Bytes>? = null
) {
fun combinedData(): Bytes? =
data?.let {
@@ -359,5 +358,5 @@ data class Env(
var currentGasLimit: Gas? = null,
var currentNumber: UInt256? = null,
var currentTimestamp: UInt256? = null,
- var previousHash: Hash? = null,
+ var previousHash: Hash? = null
)
diff --git a/eth-client-ui/src/main/kotlin/org/apache/tuweni/ethclientui/ConfigurationService.kt b/eth-client-ui/src/main/kotlin/org/apache/tuweni/ethclientui/ConfigurationService.kt
index f7a35e2c..900005f7 100644
--- a/eth-client-ui/src/main/kotlin/org/apache/tuweni/ethclientui/ConfigurationService.kt
+++ b/eth-client-ui/src/main/kotlin/org/apache/tuweni/ethclientui/ConfigurationService.kt
@@ -16,13 +16,13 @@
*/
package org.apache.tuweni.ethclientui
-import org.apache.tuweni.ethclient.EthereumClient
import jakarta.servlet.ServletContext
import jakarta.ws.rs.GET
import jakarta.ws.rs.Path
import jakarta.ws.rs.Produces
import jakarta.ws.rs.core.Context
import jakarta.ws.rs.core.MediaType
+import org.apache.tuweni.ethclient.EthereumClient
@Path("config")
class ConfigurationService {
diff --git a/eth-client-ui/src/main/kotlin/org/apache/tuweni/ethclientui/StateService.kt b/eth-client-ui/src/main/kotlin/org/apache/tuweni/ethclientui/StateService.kt
index 9eee076f..e53157f6 100644
--- a/eth-client-ui/src/main/kotlin/org/apache/tuweni/ethclientui/StateService.kt
+++ b/eth-client-ui/src/main/kotlin/org/apache/tuweni/ethclientui/StateService.kt
@@ -16,7 +16,6 @@
*/
package org.apache.tuweni.ethclientui
-import org.apache.tuweni.ethclient.EthereumClient
import jakarta.servlet.ServletContext
import jakarta.ws.rs.GET
import jakarta.ws.rs.Path
@@ -25,6 +24,7 @@ import jakarta.ws.rs.core.Context
import jakarta.ws.rs.core.MediaType
import kotlinx.coroutines.runBlocking
import org.apache.tuweni.bytes.Bytes32
+import org.apache.tuweni.ethclient.EthereumClient
import org.apache.tuweni.units.bigints.UInt256
data class BlockHashAndNumber(val hash: Bytes32, val number: UInt256)
diff --git a/eth-client-ui/src/main/kotlin/org/apache/tuweni/ethclientui/UI.kt b/eth-client-ui/src/main/kotlin/org/apache/tuweni/ethclientui/UI.kt
index fad640c8..7f7e7716 100644
--- a/eth-client-ui/src/main/kotlin/org/apache/tuweni/ethclientui/UI.kt
+++ b/eth-client-ui/src/main/kotlin/org/apache/tuweni/ethclientui/UI.kt
@@ -30,7 +30,7 @@ class UI(
val port: Int = 0,
val networkInterface: String = "127.0.0.1",
val path: String = "/",
- val client: EthereumClient,
+ val client: EthereumClient
) {
private var server: Server? = null
diff --git a/eth-client/src/integrationTest/kotlin/org/apache/tuweni/ethclient/DNSClientRunTest.kt b/eth-client/src/integrationTest/kotlin/org/apache/tuweni/ethclient/DNSClientRunTest.kt
index 5b67cc0b..fc3a9e47 100644
--- a/eth-client/src/integrationTest/kotlin/org/apache/tuweni/ethclient/DNSClientRunTest.kt
+++ b/eth-client/src/integrationTest/kotlin/org/apache/tuweni/ethclient/DNSClientRunTest.kt
@@ -33,7 +33,8 @@ class DNSClientRunTest {
val client = DNSClient(
vertx,
DNSConfigurationImpl("default", "foo", "example.com", 1000, null),
- MapKeyValueStore.open(), MemoryPeerRepository()
+ MapKeyValueStore.open(),
+ MemoryPeerRepository()
)
runBlocking {
client.start()
@@ -46,7 +47,8 @@ class DNSClientRunTest {
val client = DNSClient(
vertx,
DNSConfigurationImpl("default", "foo", "example.com", 1000, null),
- MapKeyValueStore.open(), MemoryPeerRepository()
+ MapKeyValueStore.open(),
+ MemoryPeerRepository()
)
runBlocking {
client.seq(42L)
diff --git a/eth-client/src/integrationTest/kotlin/org/apache/tuweni/ethclient/EthereumClientRunTest.kt b/eth-client/src/integrationTest/kotlin/org/apache/tuweni/ethclient/EthereumClientRunTest.kt
index 1147e3c0..d9235ac6 100644
--- a/eth-client/src/integrationTest/kotlin/org/apache/tuweni/ethclient/EthereumClientRunTest.kt
+++ b/eth-client/src/integrationTest/kotlin/org/apache/tuweni/ethclient/EthereumClientRunTest.kt
@@ -131,7 +131,8 @@ class EthereumClientRunTest {
[genesis.default]
path=classpath:/mainnet.json
[dns.default]
- enrLink="enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@all.mainnet.ethdisco.net"""".trimMargin()
+ enrLink="enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@all.mainnet.ethdisco.net"
+ """.trimMargin()
)
val client = EthereumClient(vertx, config)
client.start()
diff --git a/eth-client/src/integrationTest/kotlin/org/apache/tuweni/ethclient/ProxyEthereumClientTest.kt b/eth-client/src/integrationTest/kotlin/org/apache/tuweni/ethclient/ProxyEthereumClientTest.kt
index d2da1eb3..04d97af5 100644
--- a/eth-client/src/integrationTest/kotlin/org/apache/tuweni/ethclient/ProxyEthereumClientTest.kt
+++ b/eth-client/src/integrationTest/kotlin/org/apache/tuweni/ethclient/ProxyEthereumClientTest.kt
@@ -26,10 +26,9 @@ import org.apache.tuweni.crypto.SECP256K1
import org.apache.tuweni.junit.BouncyCastleExtension
import org.apache.tuweni.junit.VertxExtension
import org.apache.tuweni.junit.VertxInstance
+import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
-import org.junit.jupiter.api.Assertions.assertEquals
-
import java.lang.Thread.sleep
@ExtendWith(VertxExtension::class, BouncyCastleExtension::class)
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 8829da02..a4d5dd94 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
@@ -74,7 +74,7 @@ import kotlin.coroutines.CoroutineContext
class EthereumClient(
val vertx: Vertx,
val config: EthereumClientConfig,
- override val coroutineContext: CoroutineContext = Dispatchers.Unconfined,
+ override val coroutineContext: CoroutineContext = Dispatchers.Unconfined
) : CoroutineScope {
companion object {
@@ -106,7 +106,6 @@ class EthereumClient(
suspend fun start() {
logger.info("Starting Ethereum client...")
if (config.metricsEnabled()) {
-
val metricsService = MetricsService(
"tuweni",
port = config.metricsPort(),
@@ -162,9 +161,13 @@ class EthereumClient(
val peerRepository = peerRepositories[it.peerRepository()]
if (peerRepository == null) {
val message = (
- if (peerRepositories.isEmpty()) "none" else peerRepositories.keys.joinToString(
- ","
- )
+ if (peerRepositories.isEmpty()) {
+ "none"
+ } else {
+ peerRepositories.keys.joinToString(
+ ","
+ )
+ }
) + " defined"
throw IllegalArgumentException(
"Repository $peerRepository not found, $message"
@@ -180,9 +183,13 @@ class EthereumClient(
val peerRepository = peerRepositories[it.getPeerRepository()]
if (peerRepository == null) {
val message = (
- if (peerRepositories.isEmpty()) "none" else peerRepositories.keys.joinToString(
- ","
- )
+ if (peerRepositories.isEmpty()) {
+ "none"
+ } else {
+ peerRepositories.keys.joinToString(
+ ","
+ )
+ }
) + " defined"
throw IllegalArgumentException(
"Repository $peerRepository not found, $message"
@@ -206,9 +213,13 @@ class EthereumClient(
val peerRepository = peerRepositories[rlpxConfig.peerRepository()]
if (peerRepository == null) {
val message = (
- if (peerRepositories.isEmpty()) "none" else peerRepositories.keys.joinToString(
- ","
- )
+ if (peerRepositories.isEmpty()) {
+ "none"
+ } else {
+ peerRepositories.keys.joinToString(
+ ","
+ )
+ }
) + " defined"
throw IllegalArgumentException(
"Repository ${rlpxConfig.peerRepository()} not found, $message"
@@ -217,9 +228,13 @@ class EthereumClient(
val repository = storageRepositories[rlpxConfig.repository()]
if (repository == null) {
val message = (
- if (storageRepositories.isEmpty()) "none" else storageRepositories.keys.joinToString(
- ","
- )
+ if (storageRepositories.isEmpty()) {
+ "none"
+ } else {
+ storageRepositories.keys.joinToString(
+ ","
+ )
+ }
) + " defined"
throw IllegalArgumentException(
"Repository ${rlpxConfig.repository()} not found, $message"
@@ -229,8 +244,12 @@ class EthereumClient(
val genesisBlock = repository.retrieveGenesisBlock()
val adapter = WireConnectionPeerRepositoryAdapter(peerRepository)
val blockchainInfo = SimpleBlockchainInformation(
- UInt256.valueOf(genesisFile!!.chainId.toLong()), genesisBlock.header.difficulty,
- genesisBlock.header.hash, genesisBlock.header.number, genesisBlock.header.hash, genesisFile.forks
+ UInt256.valueOf(genesisFile!!.chainId.toLong()),
+ genesisBlock.header.difficulty,
+ genesisBlock.header.hash,
+ genesisBlock.header.number,
+ genesisBlock.header.hash,
+ genesisFile.forks
)
logger.info("Initializing with blockchain information $blockchainInfo")
val ethSubprotocol = EthSubprotocol(
@@ -286,7 +305,6 @@ 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()}")
@@ -294,41 +312,41 @@ class EthereumClient(
val adapter = adapters[sync.getRlpxService()] ?: throw IllegalArgumentException("Service ${sync.getRlpxService()} missing for synchronizer ${sync.getName()}")
when (sync.getType()) {
- SynchronizerType.best -> {
+ SynchronizerType.BEST -> {
val bestSynchronizer = FromBestBlockHeaderSynchronizer(
repository = syncRepository,
client = syncService.getClient(ETH66) as EthRequestsManager,
peerRepository = syncPeerRepository,
from = sync.getFrom(),
- to = sync.getTo(),
+ to = sync.getTo()
)
bestSynchronizer.start()
synchronizers[sync.getName()] = bestSynchronizer
}
- SynchronizerType.status -> {
+ SynchronizerType.STATUS -> {
val synchronizer = PeerStatusEthSynchronizer(
repository = syncRepository,
client = syncService.getClient(ETH66) as EthRequestsManager,
peerRepository = syncPeerRepository,
adapter = adapter,
from = sync.getFrom(),
- to = sync.getTo(),
+ to = sync.getTo()
)
synchronizer.start()
synchronizers[sync.getName()] = synchronizer
}
- SynchronizerType.parent -> {
+ SynchronizerType.PARENT -> {
val parentSynchronizer = FromUnknownParentSynchronizer(
repository = syncRepository,
client = syncService.getClient(ETH66) as EthRequestsManager,
peerRepository = syncPeerRepository,
from = sync.getFrom(),
- to = sync.getTo(),
+ to = sync.getTo()
)
parentSynchronizer.start()
synchronizers[sync.getName()] = parentSynchronizer
}
- SynchronizerType.canonical -> {
+ SynchronizerType.CANONICAL -> {
val fromRepository = storageRepositories.get(sync.getFromRepository())
?: throw IllegalArgumentException("Missing repository for canonical repository ${sync.getFromRepository()}")
val canonicalSynchronizer = CanonicalSynchronizer(
@@ -337,7 +355,7 @@ class EthereumClient(
peerRepository = syncPeerRepository,
from = sync.getFrom(),
to = sync.getTo(),
- fromRepository = fromRepository,
+ fromRepository = fromRepository
)
canonicalSynchronizer.start()
synchronizers[sync.getName()] = canonicalSynchronizer
@@ -347,17 +365,17 @@ class EthereumClient(
for (validator in config.validators()) {
when (validator.getType()) {
- ValidatorType.chainId -> {
+ ValidatorType.CHAINID -> {
val chainId = validator.getChainId()
?: throw IllegalArgumentException("chainId required for validator ${validator.getName()}")
val chainIdValidator = ChainIdValidator(
from = validator.getFrom(),
to = validator.getTo(),
- chainId = chainId,
+ chainId = chainId
)
validators[validator.getName()] = chainIdValidator
}
- ValidatorType.transactionsHash -> {
+ ValidatorType.TRANSACTIONHASH -> {
val transactionsHashValidator = TransactionsHashValidator(from = validator.getFrom(), to = validator.getTo())
validators[validator.getName()] = transactionsHashValidator
}
@@ -369,9 +387,13 @@ class EthereumClient(
val peerRepository = peerRepositories[staticPeers.peerRepository()]
if (peerRepository == null) {
val message = (
- if (peerRepositories.isEmpty()) "none" else peerRepositories.keys.joinToString(
- ","
- )
+ if (peerRepositories.isEmpty()) {
+ "none"
+ } else {
+ peerRepositories.keys.joinToString(
+ ","
+ )
+ }
) + " defined"
throw IllegalArgumentException(
"Repository ${staticPeers.peerRepository()} not found, $message"
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 cb0ff8b9..4602e6bb 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
@@ -71,7 +71,7 @@ class EthereumClientConfig(private var config: Configuration = Configuration.emp
sectionConfig.getInteger("advertisedPort"),
sectionConfig.getString("repository"),
sectionConfig.getString("peerRepository"),
- sectionConfig.getString("key"),
+ sectionConfig.getString("key")
)
}
}
@@ -85,7 +85,7 @@ class EthereumClientConfig(private var config: Configuration = Configuration.emp
val sectionConfig = config.getConfigurationSection("genesis.$section")
GenesisFileConfigurationImpl(
section,
- URI.create(sectionConfig.getString("path")),
+ URI.create(sectionConfig.getString("path"))
)
}
}
@@ -99,7 +99,7 @@ class EthereumClientConfig(private var config: Configuration = Configuration.emp
val sectionConfig = config.getConfigurationSection("peerRepository.$section")
PeerRepositoryConfigurationImpl(
section,
- sectionConfig.getString("type"),
+ sectionConfig.getString("type")
)
}
}
@@ -128,7 +128,7 @@ class EthereumClientConfig(private var config: Configuration = Configuration.emp
sectionConfig.getString("peerRepository"),
sectionConfig.getString("enrLink"),
sectionConfig.getLong("pollingPeriod"),
- if (sectionConfig.contains("dnsServer")) sectionConfig.getString("dnsServer") else null,
+ if (sectionConfig.contains("dnsServer")) sectionConfig.getString("dnsServer") else null
)
}
}
@@ -168,7 +168,7 @@ class EthereumClientConfig(private var config: Configuration = Configuration.emp
val sectionConfig = config.getConfigurationSection("static.$section")
StaticPeersConfigurationImpl(
sectionConfig.getListOfString("enodes"),
- sectionConfig.getString("peerRepository"),
+ sectionConfig.getString("peerRepository")
)
}
}
@@ -203,7 +203,7 @@ class EthereumClientConfig(private var config: Configuration = Configuration.emp
sectionConfig.getString("rlpxService"),
UInt256.valueOf(sectionConfig.getLong("from")),
UInt256.valueOf(sectionConfig.getLong("to")),
- sectionConfig.getString("fromRepository"),
+ sectionConfig.getString("fromRepository")
)
}
}
@@ -216,10 +216,11 @@ class EthereumClientConfig(private var config: Configuration = Configuration.emp
return validators.map { section ->
val sectionConfig = config.getConfigurationSection("validator.$section")
ValidatorConfigurationImpl(
- section, ValidatorType.valueOf(sectionConfig.getString("type")),
+ section,
+ ValidatorType.valueOf(sectionConfig.getString("type")),
UInt256.valueOf(sectionConfig.getLong("from")),
UInt256.valueOf(sectionConfig.getLong("to")),
- sectionConfig.getInteger("chainId"),
+ sectionConfig.getInteger("chainId")
)
}
}
@@ -275,7 +276,9 @@ class EthereumClientConfig(private var config: Configuration = Configuration.emp
val staticPeers = SchemaBuilder.create()
staticPeers.addListOfString(
- "enodes", Collections.emptyList(), "Static enodes to connect to in enode://publickey@host:port format"
+ "enodes",
+ Collections.emptyList(),
+ "Static enodes to connect to in enode://publickey@host:port format"
) { _, position, value ->
val errors = mutableListOf<ConfigurationError>()
for (enode in value!!) {
@@ -306,12 +309,14 @@ class EthereumClientConfig(private var config: Configuration = Configuration.emp
val rlpx = SchemaBuilder.create()
rlpx.addString("networkInterface", "127.0.0.1", "Network interface to bind", null)
rlpx.addString(
- "key", null, "Hex string representation of the private key used to represent the node",
+ "key",
+ null,
+ "Hex string representation of the private key used to represent the node",
object : PropertyValidator<String> {
override fun validate(
key: String,
position: DocumentPosition?,
- value: String?,
+ value: String?
): MutableList<ConfigurationError> {
try {
SECP256K1.SecretKey.fromBytes(Bytes32.fromHexString(value ?: ""))
@@ -458,7 +463,7 @@ interface PeerRepositoryConfiguration {
}
enum class SynchronizerType {
- best, status, parent, canonical
+ BEST, STATUS, PARENT, CANONICAL
}
interface SynchronizerConfiguration {
@@ -473,7 +478,7 @@ interface SynchronizerConfiguration {
}
enum class ValidatorType {
- chainId, transactionsHash
+ CHAINID, TRANSACTIONHASH
}
interface ValidatorConfiguration {
@@ -498,7 +503,7 @@ internal data class RLPxServiceConfigurationImpl(
val advertisedPort: Int,
val repository: String,
val peerRepository: String,
- val key: String,
+ val key: String
) : RLPxServiceConfiguration {
private val keyPair = SECP256K1.KeyPair.fromSecretKey(SECP256K1.SecretKey.fromBytes(Bytes32.fromHexString(key)))
@@ -539,7 +544,7 @@ internal data class GenesisFileConfigurationImpl(private val name: String, priva
internal data class DataStoreConfigurationImpl(
private val name: String,
private val storagePath: Path,
- private val genesisFile: String,
+ private val genesisFile: String
) : DataStoreConfiguration {
override fun getName(): String = name
@@ -572,7 +577,7 @@ data class DiscoveryConfigurationImpl(
private val peerRepository: String,
private val port: Int,
private val networkInterface: String,
- private val identity: SECP256K1.KeyPair,
+ private val identity: SECP256K1.KeyPair
) :
DiscoveryConfiguration {
override fun getName() = name
@@ -593,7 +598,7 @@ data class StaticPeersConfigurationImpl(private val enodes: List<String>, privat
data class ProxyConfigurationImpl(
private val name: String,
private val upstream: String,
- private val downstream: String,
+ private val downstream: String
) : ProxyConfiguration {
override fun name() = name
@@ -609,7 +614,7 @@ data class SynchronizerConfigurationImpl(
private val rlpxService: String,
private val from: UInt256?,
private val to: UInt256?,
- private val fromRepository: String?,
+ private val fromRepository: String?
) : SynchronizerConfiguration {
override fun getName() = name
override fun getRepository() = repository
@@ -626,7 +631,7 @@ data class ValidatorConfigurationImpl(
private val type: ValidatorType,
private val from: UInt256?,
private val to: UInt256?,
- private val chainId: Int?,
+ private val chainId: Int?
) : ValidatorConfiguration {
override fun getName() = name
override fun getType() = type
diff --git a/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/EthereumPeerRepository.kt b/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/EthereumPeerRepository.kt
index f680ec80..e1f064f1 100644
--- a/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/EthereumPeerRepository.kt
+++ b/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/EthereumPeerRepository.kt
@@ -64,6 +64,7 @@ interface EthereumPeerRepository : PeerRepository {
* @return a listener ID
*/
fun addIdentityListener(identityListener: (Identity) -> Unit): String
+
/**
* Removes an identity listener
* @param id the listener identifier
diff --git a/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/sync/FromBestBlockHeaderSynchronizer.kt b/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/sync/FromBestBlockHeaderSynchronizer.kt
index 05949c8a..ad8f6213 100644
--- a/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/sync/FromBestBlockHeaderSynchronizer.kt
+++ b/eth-client/src/main/kotlin/org/apache/tuweni/ethclient/sync/FromBestBlockHeaderSynchronizer.kt
@@ -42,7 +42,7 @@ class FromBestBlockHeaderSynchronizer(
client: EthRequestsManager,
peerRepository: EthereumPeerRepository,
from: UInt256?,
- to: UInt256?,
+ to: UInt256?
) : Synchronizer(executor, coroutineContext, repository, client, peerRepository, from, to) {
override fun start() {
@@ -54,7 +54,6 @@ class FromBestBlockHeaderSynchronizer(
}
override fun stop() {
-
executor.shutdown()
}
diff --git a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/CrawlerApp.kt b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/CrawlerApp.kt
index fd836ee4..33e30029 100644
--- a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/CrawlerApp.kt
+++ b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/CrawlerApp.kt
@@ -88,7 +88,7 @@ class CrawlerApplication(
val thread = Thread("crawler")
thread.isDaemon = true
thread
- }.asCoroutineDispatcher(),
+ }.asCoroutineDispatcher()
) : CoroutineScope {
private val metricsService = MetricsService(
@@ -108,7 +108,6 @@ class CrawlerApplication(
}.asCoroutineDispatcher()
fun run() {
-
val dbConfig = HikariConfig()
dbConfig.maximumPoolSize = config.jdbcConnections()
dbConfig.jdbcUrl = config.jdbcUrl()
@@ -156,8 +155,12 @@ class CrawlerApplication(
val genesisFile = GenesisFile.read(contents)
val genesisBlock = genesisFile.toBlock()
val blockchainInformation = SimpleBlockchainInformation(
- UInt256.valueOf(genesisFile.chainId.toLong()), genesisBlock.header.difficulty,
- genesisBlock.header.hash, UInt256.ZERO, genesisBlock.header.hash, genesisFile.forks
+ UInt256.valueOf(genesisFile.chainId.toLong()),
+ genesisBlock.header.difficulty,
+ genesisBlock.header.hash,
+ UInt256.ZERO,
+ genesisBlock.header.hash,
+ genesisFile.forks
)
val expiringConnectionIds = ExpiringSet<String>()
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 b315e508..ce5946e7 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
@@ -59,8 +59,10 @@ class CrawlerConfig(val filePath: Path) {
.addString("discoveryDNS", mainnetDiscoveryDNS, "DNS discovery crawler", null)
.addLong("discoveryDNSPollingPeriod", 60 * 1000L, "DNS Discovery Polling Period in milliseconds", null)
.addString(
- "jdbcUrl", System.getProperty("DATABASE_URL", System.getenv("DATABASE_URL")),
- "JDBC URL of the form jdbc:posgresql://localhost:5432", PropertyValidator.isPresent()
+ "jdbcUrl",
+ System.getProperty("DATABASE_URL", System.getenv("DATABASE_URL")),
+ "JDBC URL of the form jdbc:posgresql://localhost:5432",
+ PropertyValidator.isPresent()
)
.addInteger("jdbcConnections", 25, "Number of JDBC connections for the connections pool", null)
.addString("network", "mainnet", "Network to use instead of providing a genesis file.", null)
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 a81c576e..fb25601c 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
@@ -48,7 +48,7 @@ class CrawlerRESTService(
val repository: RelationalPeerRepository,
val stats: StatsJob,
val meter: Meter,
- override val coroutineContext: CoroutineContext = Dispatchers.Default,
+ override val coroutineContext: CoroutineContext = Dispatchers.Default
) : CoroutineScope {
companion object {
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 6a334df1..2a8d85b5 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
@@ -23,9 +23,9 @@ import kotlinx.coroutines.async
import org.apache.tuweni.bytes.Bytes
import org.apache.tuweni.eth.Address
import org.apache.tuweni.eth.Hash
-import org.apache.tuweni.ethstats.NodeStats
-import org.apache.tuweni.ethstats.NodeInfo
import org.apache.tuweni.ethstats.BlockStats
+import org.apache.tuweni.ethstats.NodeInfo
+import org.apache.tuweni.ethstats.NodeStats
import org.apache.tuweni.ethstats.TxStats
import org.apache.tuweni.units.bigints.UInt256
import javax.sql.DataSource
@@ -176,7 +176,7 @@ class EthstatsDataRepository(
(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)) },
+ (rs.getArray(13).array as Array<*>).map { Hash.fromBytes(Bytes.wrap(it as ByteArray)) }
)
} else {
null
@@ -227,7 +227,7 @@ class EthstatsDataRepository(
rs.getString(6),
rs.getString(7),
rs.getString(8),
- client = rs.getString(9),
+ client = rs.getString(9)
)
} else {
null
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 088842ff..821e8ac2 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
@@ -41,7 +41,7 @@ open class RelationalPeerRepository(
private val dataSource: DataSource,
private val expiration: Long = 5 * 60 * 1000L,
private val clientIdsInterval: Long = 24 * 60 * 60 * 1000 * 2L,
- override val coroutineContext: CoroutineContext = Dispatchers.Default,
+ override val coroutineContext: CoroutineContext = Dispatchers.Default
) : CoroutineScope, PeerRepository {
companion object {
@@ -159,7 +159,7 @@ open class RelationalPeerRepository(
internal fun getPeersWithInfo(
infoCollected: Long,
from: Int? = null,
- limit: Int? = null,
+ limit: Int? = null
): List<PeerConnectionInfoDetails> {
dataSource.connection.use { conn ->
var query =
@@ -299,14 +299,14 @@ internal data class PeerConnectionInfoDetails(
val capabilities: String,
val genesisHash: String,
val bestHash: String,
- val totalDifficulty: String,
+ val totalDifficulty: String
)
internal class RepositoryPeer(
override val nodeId: SECP256K1.PublicKey,
val id: String,
knownEndpoint: Endpoint,
- private val dataSource: DataSource,
+ private val dataSource: DataSource
) : Peer {
init {
diff --git a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/rest/ClientsService.kt b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/rest/ClientsService.kt
index f1f10d22..f5563e65 100644
--- a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/rest/ClientsService.kt
+++ b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/rest/ClientsService.kt
@@ -37,6 +37,7 @@ class ClientsService {
mapper.registerModule(EthJsonModule())
}
}
+
@javax.ws.rs.core.Context
var context: ServletContext? = null
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 84bf6a12..1864339d 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
@@ -38,10 +38,11 @@ class IDPrecompiledContract : PrecompileContract {
*/
class ECRECPrecompiledContract : PrecompileContract {
override fun run(input: Bytes): Result {
- val padded = if (input.size() < 128)
+ val padded = if (input.size() < 128) {
Bytes.wrap(Bytes.repeat(0, 128 - input.size()), input)
- else
+ } else {
input
+ }
val h = Bytes32.wrap(padded.slice(0, 32))
val v = padded.slice(32, 32)
val r = padded.slice(64, 32)
@@ -97,10 +98,11 @@ class ModExpPrecompileContract : PrecompileContract {
}
override fun run(input: Bytes): Result {
- val padded = if (input.size() < 96)
+ val padded = if (input.size() < 96) {
Bytes.wrap(Bytes.repeat(0, 96 - input.size()), input)
- else
+ } else {
input
+ }
val baseLength = padded.slice(0, 32).toUnsignedBigInteger()
val exponentLength = padded.slice(32, 32).toUnsignedBigInteger()
val modulusLength = padded.slice(64, 32).toUnsignedBigInteger()
diff --git a/eth-precompiles/src/main/kotlin/org/apache/tuweni/eth/precompiles/Registry.kt b/eth-precompiles/src/main/kotlin/org/apache/tuweni/eth/precompiles/Registry.kt
index 52e021d5..5da642ca 100644
--- a/eth-precompiles/src/main/kotlin/org/apache/tuweni/eth/precompiles/Registry.kt
+++ b/eth-precompiles/src/main/kotlin/org/apache/tuweni/eth/precompiles/Registry.kt
@@ -59,7 +59,9 @@ object Registry {
val bizantiumAltBN128PairingPrecompiledContract =
AltBN128PrecompiledContract(
LibEthPairings.EIP196_PAIR_OPERATION_RAW_VALUE,
- Int.MAX_VALUE / 192 * 192, 100000, 80000
+ Int.MAX_VALUE / 192 * 192,
+ 100000,
+ 80000
)
bizantium = buildMap {
@@ -77,7 +79,9 @@ object Registry {
val istanbulAltBN128PairingPrecompiledContract =
AltBN128PrecompiledContract(
LibEthPairings.EIP196_PAIR_OPERATION_RAW_VALUE,
- Int.MAX_VALUE / 192 * 192, 45000, 34000
+ Int.MAX_VALUE / 192 * 192,
+ 45000,
+ 34000
)
val blake2bf = Address.fromBytes(Bytes.wrap(emptyArray, Bytes.of(9)))
val blake2BFPrecompileContract = Blake2BFPrecompileContract()
diff --git a/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/BlockHeaderFields.kt b/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/BlockHeaderFields.kt
index 62061b1a..076a839b 100644
--- a/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/BlockHeaderFields.kt
+++ b/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/BlockHeaderFields.kt
@@ -25,42 +25,52 @@ enum class BlockHeaderFields(val fieldName: String) {
* Parent hash
*/
PARENT_HASH("parentHash"),
+
/**
* Ommers hash
*/
OMMERS_HASH("ommersHash"),
+
/**
* Coinbase address
*/
COINBASE("coinbase"),
+
/**
* State root
*/
STATE_ROOT("stateRoot"),
+
/**
* Difficulty
*/
DIFFICULTY("difficulty"),
+
/**
* Block number
*/
NUMBER("number"),
+
/**
* Gas limit
*/
GAS_LIMIT("gasLimit"),
+
/**
* Gas used
*/
GAS_USED("gasUsed"),
+
/**
* Extra data
*/
EXTRA_DATA("extraData"),
+
/**
* Timestamp of the block
*/
TIMESTAMP("timestamp"),
+
/**
* Total difficulty
*/
diff --git a/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/BlockchainIndex.kt b/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/BlockchainIndex.kt
index 9690fa16..fb1cb6da 100644
--- a/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/BlockchainIndex.kt
+++ b/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/BlockchainIndex.kt
@@ -466,7 +466,8 @@ class BlockchainIndex(private val indexWriter: IndexWriter) : BlockchainIndexWri
document += NumericDocValuesField(TransactionReceiptFields.INDEX.fieldName, txIndex.toLong())
document += StringField(TransactionReceiptFields.TRANSACTION_HASH.fieldName, id, Field.Store.NO)
document += StringField(
- TransactionReceiptFields.BLOCK_HASH.fieldName, toBytesRef(blockHash),
+ TransactionReceiptFields.BLOCK_HASH.fieldName,
+ toBytesRef(blockHash),
Field.Store.NO
)
for (log in txReceipt.getLogs()) {
@@ -480,7 +481,8 @@ class BlockchainIndex(private val indexWriter: IndexWriter) : BlockchainIndexWri
}
document += StringField(
TransactionReceiptFields.BLOOM_FILTER.fieldName,
- toBytesRef(txReceipt.getBloomFilter().toBytes()), Field.Store.NO
+ toBytesRef(txReceipt.getBloomFilter().toBytes()),
+ Field.Store.NO
)
document += NumericDocValuesField(
TransactionReceiptFields.CUMULATIVE_GAS_USED.fieldName,
@@ -503,7 +505,8 @@ class BlockchainIndex(private val indexWriter: IndexWriter) : BlockchainIndexWri
private fun queryTxReceiptDocs(query: Query, fields: List<BlockHeaderFields>): List<Document> {
val txQuery = BooleanQuery.Builder().add(
- query, BooleanClause.Occur.MUST
+ query,
+ BooleanClause.Occur.MUST
)
.add(TermQuery(Term("_type", "txReceipt")), BooleanClause.Occur.MUST).build()
@@ -533,7 +536,8 @@ class BlockchainIndex(private val indexWriter: IndexWriter) : BlockchainIndexWri
private fun queryBlockDocs(query: Query, fields: List<BlockHeaderFields>): List<Document> {
val blockQuery = BooleanQuery.Builder().add(
- query, BooleanClause.Occur.MUST
+ query,
+ BooleanClause.Occur.MUST
)
.add(TermQuery(Term("_type", "block")), BooleanClause.Occur.MUST).build()
@@ -542,7 +546,8 @@ class BlockchainIndex(private val indexWriter: IndexWriter) : BlockchainIndexWri
private fun queryDiffDocs(query: Query, fields: List<BlockHeaderFields>): List<Document> {
val blockQuery = BooleanQuery.Builder().add(
- query, BooleanClause.Occur.MUST
+ query,
+ BooleanClause.Occur.MUST
)
.add(TermQuery(Term("_type", "difficulty")), BooleanClause.Occur.MUST).build()
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 9a304ea8..b9a76e8c 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
@@ -70,7 +70,7 @@ class BlockchainRepository(
internal val stateStore: KeyValueStore<Bytes, Bytes>,
private val blockchainIndex: BlockchainIndex,
private val meter: Meter? = null,
- override val coroutineContext: CoroutineContext = Dispatchers.Default,
+ override val coroutineContext: CoroutineContext = Dispatchers.Default
) : CoroutineScope, StateRepository {
companion object {
@@ -94,7 +94,7 @@ class BlockchainRepository(
MapKeyValueStore(),
MapKeyValueStore(),
MapKeyValueStore(),
- BlockchainIndex(writer),
+ BlockchainIndex(writer)
)
repo.setGenesisBlock(genesisBlock)
repo.storeBlock(genesisBlock)
@@ -116,7 +116,7 @@ class BlockchainRepository(
stateStore: KeyValueStore<Bytes, Bytes>,
blockchainIndex: BlockchainIndex,
genesisBlock: Block,
- meter: Meter? = null,
+ meter: Meter? = null
): BlockchainRepository {
val repo = BlockchainRepository(
chainMetadata,
@@ -215,7 +215,7 @@ class BlockchainRepository(
transactionReceipt: TransactionReceipt,
txIndex: Int,
txHash: Bytes,
- blockHash: Bytes,
+ blockHash: Bytes
) {
transactionReceiptStore.put(txHash, transactionReceipt.toBytes())
indexTransactionReceipt(transactionReceipt, txIndex, txHash, blockHash)
@@ -282,7 +282,7 @@ class BlockchainRepository(
txReceipt: TransactionReceipt,
txIndex: Int,
txHash: Bytes,
- blockHash: Bytes,
+ blockHash: Bytes
) {
blockchainIndex.index {
it.indexTransactionReceipt(txReceipt, txIndex, txHash, blockHash)
diff --git a/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/TransactionReceiptFields.kt b/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/TransactionReceiptFields.kt
index 327190ab..94af6513 100644
--- a/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/TransactionReceiptFields.kt
+++ b/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/TransactionReceiptFields.kt
@@ -25,34 +25,42 @@ enum class TransactionReceiptFields(val fieldName: String) {
* Index of a transaction in a block
*/
INDEX("index"),
+
/**
* Hash of a transaction
*/
TRANSACTION_HASH("txHash"),
+
/**
* Block hash
*/
BLOCK_HASH("blockHash"),
+
/**
* Logger address
*/
LOGGER("logger"),
+
/**
* Log topic
*/
LOG_TOPIC("logTopic"),
+
/**
* Bloom filter value
*/
BLOOM_FILTER("bloomFilter"),
+
/**
* State root
*/
STATE_ROOT("stateRoot"),
+
/**
* Cumulative gas used
*/
CUMULATIVE_GAS_USED("cumulativeGasUsed"),
+
/**
* Status of the transaction
*/
diff --git a/eth-repository/src/test/kotlin/org/apache/tuweni/eth/repository/BlockchainIndexTest.kt b/eth-repository/src/test/kotlin/org/apache/tuweni/eth/repository/BlockchainIndexTest.kt
index 09bd0726..3e7479ba 100644
--- a/eth-repository/src/test/kotlin/org/apache/tuweni/eth/repository/BlockchainIndexTest.kt
+++ b/eth-repository/src/test/kotlin/org/apache/tuweni/eth/repository/BlockchainIndexTest.kt
@@ -16,6 +16,17 @@
*/
package org.apache.tuweni.eth.repository
+import org.apache.lucene.index.DirectoryReader
+import org.apache.lucene.index.IndexWriter
+import org.apache.lucene.index.Term
+import org.apache.lucene.search.BooleanClause
+import org.apache.lucene.search.BooleanQuery
+import org.apache.lucene.search.IndexSearcher
+import org.apache.lucene.search.ScoreDoc
+import org.apache.lucene.search.TermQuery
+import org.apache.lucene.search.TopScoreDocCollector
+import org.apache.lucene.store.Directory
+import org.apache.lucene.util.BytesRef
import org.apache.tuweni.bytes.Bytes
import org.apache.tuweni.bytes.Bytes32
import org.apache.tuweni.eth.Address
@@ -29,19 +40,8 @@ import org.apache.tuweni.junit.LuceneIndex
import org.apache.tuweni.junit.LuceneIndexWriter
import org.apache.tuweni.junit.LuceneIndexWriterExtension
import org.apache.tuweni.units.bigints.UInt256
-import org.apache.tuweni.units.ethereum.Gas
-import org.apache.lucene.index.DirectoryReader
-import org.apache.lucene.index.IndexWriter
-import org.apache.lucene.index.Term
-import org.apache.lucene.search.BooleanClause
-import org.apache.lucene.search.BooleanQuery
-import org.apache.lucene.search.IndexSearcher
-import org.apache.lucene.search.ScoreDoc
-import org.apache.lucene.search.TermQuery
-import org.apache.lucene.search.TopScoreDocCollector
-import org.apache.lucene.store.Directory
-import org.apache.lucene.util.BytesRef
import org.apache.tuweni.units.bigints.UInt64
+import org.apache.tuweni.units.ethereum.Gas
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
@@ -199,7 +199,8 @@ internal class BlockchainIndexTest {
run {
val entries = reader.findInRange(
- BlockHeaderFields.NUMBER, header.number.subtract(5),
+ BlockHeaderFields.NUMBER,
+ header.number.subtract(5),
header.number.add(5)
)
assertEquals(1, entries.size)
@@ -278,7 +279,8 @@ internal class BlockchainIndexTest {
val blockchainIndex = BlockchainIndex(writer)
val txReceipt = TransactionReceipt(
- Bytes32.random(), 3,
+ Bytes32.random(),
+ 3,
LogsBloomFilter(Bytes.random(256)),
listOf(
Log(
@@ -295,7 +297,8 @@ internal class BlockchainIndexTest {
blockchainIndex.index { it.indexTransactionReceipt(txReceipt, 43, txHash, blockHash) }
val txReceiptWithStatus = TransactionReceipt(
- 42, 322,
+ 42,
+ 322,
LogsBloomFilter(Bytes.random(256)),
listOf(
Log(
diff --git a/eth-repository/src/test/kotlin/org/apache/tuweni/eth/repository/BlockchainRepositoryTest.kt b/eth-repository/src/test/kotlin/org/apache/tuweni/eth/repository/BlockchainRepositoryTest.kt
index 3260fffb..f9937d4b 100644
--- a/eth-repository/src/test/kotlin/org/apache/tuweni/eth/repository/BlockchainRepositoryTest.kt
+++ b/eth-repository/src/test/kotlin/org/apache/tuweni/eth/repository/BlockchainRepositoryTest.kt
@@ -18,6 +18,8 @@ package org.apache.tuweni.eth.repository
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
+import org.apache.lucene.index.IndexWriter
+import org.apache.lucene.util.BytesRef
import org.apache.tuweni.bytes.Bytes
import org.apache.tuweni.bytes.Bytes32
import org.apache.tuweni.crypto.SECP256K1
@@ -35,11 +37,9 @@ import org.apache.tuweni.junit.LuceneIndexWriter
import org.apache.tuweni.junit.LuceneIndexWriterExtension
import org.apache.tuweni.kv.MapKeyValueStore
import org.apache.tuweni.units.bigints.UInt256
+import org.apache.tuweni.units.bigints.UInt64
import org.apache.tuweni.units.ethereum.Gas
import org.apache.tuweni.units.ethereum.Wei
-import org.apache.lucene.index.IndexWriter
-import org.apache.lucene.util.BytesRef
-import org.apache.tuweni.units.bigints.UInt64
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotEquals
import org.junit.jupiter.api.Assertions.assertTrue
@@ -505,7 +505,9 @@ internal class BlockchainRepositoryTest {
)
val txReceipt = TransactionReceipt(
- Bytes32.random(), 3, LogsBloomFilter(Bytes.random(256)),
+ Bytes32.random(),
+ 3,
+ LogsBloomFilter(Bytes.random(256)),
listOf(
Log(
Address.fromBytes(
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 296c48e9..4159b10c 100644
--- a/ethstats/src/integrationTest/kotlin/org/apache/tuweni/ethstats/EthStatsReporterTest.kt
+++ b/ethstats/src/integrationTest/kotlin/org/apache/tuweni/ethstats/EthStatsReporterTest.kt
@@ -16,9 +16,9 @@
*/
package org.apache.tuweni.ethstats
+import io.vertx.core.Vertx
+import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
-import org.junit.jupiter.api.Assertions.assertTrue
-
import org.apache.tuweni.bytes.Bytes
import org.apache.tuweni.bytes.Bytes32
import org.apache.tuweni.eth.Address
@@ -26,17 +26,14 @@ import org.apache.tuweni.eth.Hash
import org.apache.tuweni.junit.VertxExtension
import org.apache.tuweni.junit.VertxInstance
import org.apache.tuweni.units.bigints.UInt256
-
-import java.net.URI
-import java.time.Instant
-import java.util.Collections
-
-import io.vertx.core.Vertx
-import kotlinx.coroutines.delay
import org.junit.jupiter.api.Assertions.assertNotNull
+import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
+import java.net.URI
+import java.time.Instant
+import java.util.Collections
import java.util.concurrent.atomic.AtomicReference
@Disabled("flaky")
@@ -45,7 +42,6 @@ public class EthStatsReporterTest {
@Test
fun testConnectToLocalEthStats(@VertxInstance vertx: Vertx) = runBlocking {
-
val now = Instant.EPOCH
val server = FakeEthStatsServer(vertx, "127.0.0.1", 0)
val reporter = EthStatsReporter(
@@ -111,7 +107,6 @@ public class EthStatsReporterTest {
@Test
fun testServer(@VertxInstance vertx: Vertx) = runBlocking {
-
val now = Instant.EPOCH
val nodeInfoReference = AtomicReference<NodeInfo>()
val controller = object : EthStatsServerController {
@@ -120,7 +115,11 @@ public class EthStatsReporterTest {
}
}
val server = EthStatsServer(
- vertx, "127.0.0.1", 33030, "wat", { now },
+ vertx,
+ "127.0.0.1",
+ 33030,
+ "wat",
+ { now },
controller
)
server.start()
diff --git a/ethstats/src/main/kotlin/org/apache/tuweni/ethstats/BlockStats.kt b/ethstats/src/main/kotlin/org/apache/tuweni/ethstats/BlockStats.kt
index 90eae3f1..e1ce31bc 100644
--- a/ethstats/src/main/kotlin/org/apache/tuweni/ethstats/BlockStats.kt
+++ b/ethstats/src/main/kotlin/org/apache/tuweni/ethstats/BlockStats.kt
@@ -16,13 +16,12 @@
*/
package org.apache.tuweni.ethstats
+import com.fasterxml.jackson.annotation.JsonGetter
+import com.fasterxml.jackson.annotation.JsonPropertyOrder
import org.apache.tuweni.eth.Address
import org.apache.tuweni.eth.Hash
import org.apache.tuweni.units.bigints.UInt256
-import com.fasterxml.jackson.annotation.JsonGetter
-import com.fasterxml.jackson.annotation.JsonPropertyOrder
-
/**
* Block statistics reported to ethnetstats.
*
diff --git a/ethstats/src/main/kotlin/org/apache/tuweni/ethstats/EthStatsReporter.kt b/ethstats/src/main/kotlin/org/apache/tuweni/ethstats/EthStatsReporter.kt
index 24658fee..26035288 100644
--- a/ethstats/src/main/kotlin/org/apache/tuweni/ethstats/EthStatsReporter.kt
+++ b/ethstats/src/main/kotlin/org/apache/tuweni/ethstats/EthStatsReporter.kt
@@ -84,7 +84,7 @@ class EthStatsReporter(
private val osVer: String,
private val historyRequester: (List<UInt256>) -> Unit,
private val timeSupplier: () -> Instant,
- override val coroutineContext: CoroutineContext = Dispatchers.Default,
+ override val coroutineContext: CoroutineContext = Dispatchers.Default
) : CoroutineScope {
companion object {
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 055f2c8a..7443340b 100644
--- a/ethstats/src/main/kotlin/org/apache/tuweni/ethstats/EthStatsServer.kt
+++ b/ethstats/src/main/kotlin/org/apache/tuweni/ethstats/EthStatsServer.kt
@@ -38,7 +38,7 @@ class EthStatsServer(
val secret: String,
private val timeSupplier: () -> Instant = Instant::now,
private val controller: EthStatsServerController,
- override val coroutineContext: CoroutineContext = Dispatchers.Default,
+ override val coroutineContext: CoroutineContext = Dispatchers.Default
) : CoroutineScope {
companion object {
diff --git a/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/BlockStatsTest.kt b/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/BlockStatsTest.kt
index 090fef69..2b9ad27d 100644
--- a/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/BlockStatsTest.kt
+++ b/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/BlockStatsTest.kt
@@ -16,19 +16,16 @@
*/
package org.apache.tuweni.ethstats
-import org.junit.jupiter.api.Assertions.assertEquals
-
+import com.fasterxml.jackson.databind.ObjectMapper
import org.apache.tuweni.bytes.Bytes
import org.apache.tuweni.bytes.Bytes32
import org.apache.tuweni.eth.Address
import org.apache.tuweni.eth.EthJsonModule
import org.apache.tuweni.eth.Hash
import org.apache.tuweni.units.bigints.UInt256
-
-import java.util.Collections
-
-import com.fasterxml.jackson.databind.ObjectMapper
+import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
+import java.util.Collections
class BlockStatsTest {
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 0c1a704e..b06fced6 100644
--- a/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/NodeStatsTest.kt
+++ b/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/NodeStatsTest.kt
@@ -16,11 +16,9 @@
*/
package org.apache.tuweni.ethstats
-import org.junit.jupiter.api.Assertions.assertEquals
-
-import org.apache.tuweni.eth.EthJsonModule
-
import com.fasterxml.jackson.databind.ObjectMapper
+import org.apache.tuweni.eth.EthJsonModule
+import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class NodeStatsTest {
diff --git a/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/TxStatsTest.kt b/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/TxStatsTest.kt
index 002694a3..5124e18f 100644
--- a/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/TxStatsTest.kt
+++ b/ethstats/src/test/kotlin/org/apache/tuweni/ethstats/TxStatsTest.kt
@@ -16,13 +16,11 @@
*/
package org.apache.tuweni.ethstats
-import org.junit.jupiter.api.Assertions.assertEquals
-
+import com.fasterxml.jackson.databind.ObjectMapper
import org.apache.tuweni.bytes.Bytes32
import org.apache.tuweni.eth.EthJsonModule
import org.apache.tuweni.eth.Hash
-
-import com.fasterxml.jackson.databind.ObjectMapper
+import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class TxStatsTest {
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 0275ff76..47c3ea5d 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
@@ -16,8 +16,8 @@
*/
package org.apache.tuweni.evmdsl
-import kotlin.Byte
import org.apache.tuweni.bytes.Bytes
+import kotlin.Byte
/**
* An EVM instruction. It is made of an opcode, optionally followed by bytes to be consumed by the opcode execution.
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 00adae38..8552406f 100644
--- a/evm/src/main/kotlin/org/apache/tuweni/evm/EthereumVirtualMachine.kt
+++ b/evm/src/main/kotlin/org/apache/tuweni/evm/EthereumVirtualMachine.kt
@@ -92,7 +92,7 @@ enum class HardFork(val number: Int) {
CONSTANTINOPLE(5),
PETERSBURG(6),
ISTANBUL(7),
- BERLIN(8),
+ BERLIN(8)
}
val latestHardFork = HardFork.BERLIN
@@ -111,7 +111,7 @@ data class EVMState(
val logs: List<Log>,
val stack: Stack,
val memory: Memory,
- val output: Bytes? = null,
+ val output: Bytes? = null
) {
/**
@@ -146,7 +146,7 @@ data class EVMResult(
val statusCode: EVMExecutionStatusCode,
val hostContext: HostContext,
val changes: ExecutionChanges,
- val state: EVMState,
+ val state: EVMState
)
/**
@@ -163,7 +163,7 @@ data class EVMMessage(
val origin: Address,
val inputData: Bytes,
val value: Bytes,
- val createSalt: Bytes32 = Bytes32.ZERO,
+ val createSalt: Bytes32 = Bytes32.ZERO
)
/**
@@ -178,7 +178,7 @@ class EthereumVirtualMachine(
private val repository: BlockchainRepository,
val precompiles: Map<Address, PrecompileContract>,
private val evmVmFactory: () -> EvmVm,
- private val options: Map<String, String> = mapOf(),
+ private val options: Map<String, String> = mapOf()
) {
companion object {
@@ -249,7 +249,7 @@ class EthereumVirtualMachine(
chainId: UInt256,
callKind: CallKind,
revision: HardFork = latestHardFork,
- depth: Int = 0,
+ depth: Int = 0
): EVMResult {
val hostContext = TransactionalEVMHostContext(
repository,
@@ -266,7 +266,7 @@ class EthereumVirtualMachine(
currentTimestamp,
currentGasLimit,
currentDifficulty,
- chainId,
+ chainId
)
val result =
executeInternal(
@@ -299,7 +299,7 @@ class EthereumVirtualMachine(
callKind: CallKind,
revision: HardFork = latestHardFork,
depth: Int = 0,
- hostContext: HostContext,
+ hostContext: HostContext
): EVMResult {
var gasAvailable = gas
if (depth > 1024) {
@@ -313,7 +313,6 @@ class EthereumVirtualMachine(
}
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))
@@ -738,7 +737,7 @@ val opcodes = mapOf<Byte, String>(
Pair(0xfb.toByte(), "unused"),
Pair(0xfd.toByte(), "revert"),
Pair(0xfe.toByte(), "invalid"),
- Pair(0xff.toByte(), "selfdestruct"),
+ Pair(0xff.toByte(), "selfdestruct")
)
/**
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 b6a39fd0..479209c6 100644
--- a/evm/src/main/kotlin/org/apache/tuweni/evm/TransactionalEVMHostContext.kt
+++ b/evm/src/main/kotlin/org/apache/tuweni/evm/TransactionalEVMHostContext.kt
@@ -51,7 +51,7 @@ class TransactionalEVMHostContext(
val currentTimestamp: UInt256,
val currentGasLimit: Long,
val currentDifficulty: UInt256,
- val chainId: UInt256,
+ val chainId: UInt256
) : HostContext, ExecutionChanges {
companion object {
@@ -296,7 +296,8 @@ class TransactionalEVMHostContext(
transientRepository.storeAccount(
beneficiary,
AccountState(
- beneficiaryAccountState.nonce, beneficiaryAccountState.balance.add(account.balance),
+ beneficiaryAccountState.nonce,
+ beneficiaryAccountState.balance.add(account.balance),
beneficiaryAccountState.storageRoot,
beneficiaryAccountState.codeHash
)
@@ -347,10 +348,11 @@ class TransactionalEVMHostContext(
evmMessage.gas,
evmMessage.kind,
depth = evmMessage.depth,
- hostContext = this,
+ hostContext = this
)
return result
}
+
/**
* Get transaction context function.
*
@@ -363,7 +365,9 @@ class TransactionalEVMHostContext(
logger.trace("Entering getTxContext")
return Bytes.concatenate(
gasPrice.toBytes(),
- sender, currentCoinbase, currentNumber,
+ sender,
+ currentCoinbase,
+ currentNumber,
currentTimestamp,
Bytes.ofUnsignedLong(currentGasLimit),
currentDifficulty.toBytes(),
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 e84d55e4..38ba4d16 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
@@ -32,7 +32,7 @@ data class Result(
val status: EVMExecutionStatusCode? = null,
val newCodePosition: Int? = null,
val output: Bytes? = null,
- val validationStatus: EVMExecutionStatusCode? = null,
+ val validationStatus: EVMExecutionStatusCode? = null
)
/**
diff --git a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/OpcodeRegistry.kt b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/OpcodeRegistry.kt
index aa0e0439..55bb6869 100644
--- a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/OpcodeRegistry.kt
+++ b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/OpcodeRegistry.kt
@@ -30,7 +30,7 @@ fun interface Opcode {
code: Bytes,
currentIndex: Int,
memory: Memory,
- callResult: Result?,
+ callResult: Result?
): Result?
}
@@ -41,7 +41,6 @@ class OpcodeRegistry(val opcodes: Map<HardFork, Map<Byte, Opcode>>) {
companion object {
fun create(): OpcodeRegistry {
-
val forks = mapOf(
Pair(HardFork.FRONTIER, org.apache.tuweni.evm.impl.frontier.frontierOpcodes),
Pair(HardFork.HOMESTEAD, org.apache.tuweni.evm.impl.homestead.homesteadOpcodes),
diff --git a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/berlin/OpCodes.kt b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/berlin/OpCodes.kt
index 64036532..fcdf26f5 100644
--- a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/berlin/OpCodes.kt
+++ b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/berlin/OpCodes.kt
@@ -361,7 +361,9 @@ private val sstore = Opcode { gasManager, hostContext, stack, msg, _, _, _, _ ->
if (currentValue.equals(originalValue)) {
if (originalValue.isZero) {
Gas.valueOf(20000)
- } else Gas.valueOf(5000 - 2100)
+ } else {
+ Gas.valueOf(5000 - 2100)
+ }
} else {
Gas.valueOf(100)
}
@@ -761,7 +763,9 @@ private val sha3 = Opcode { gasManager, _, stack, _, _, _, memory, _ ->
val numWords: UInt256 = length.divideCeil(32L)
val copyCost = Gas.valueOf(6).multiply(Gas.valueOf(numWords)).add(Gas.valueOf(30))
- val memoryCost = if (length.isZero) Gas.ZERO else {
+ val memoryCost = if (length.isZero) {
+ Gas.ZERO
+ } else {
val pre = org.apache.tuweni.evm.impl.frontier.memoryCost(memory.size())
val post: Gas = org.apache.tuweni.evm.impl.frontier.memoryCost(memory.newSize(from, length))
post.subtract(pre)
diff --git a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/bizantium/OpCodes.kt b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/bizantium/OpCodes.kt
index 0a329ccb..e8035960 100644
--- a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/bizantium/OpCodes.kt
+++ b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/bizantium/OpCodes.kt
@@ -676,7 +676,9 @@ private val sha3 = Opcode { gasManager, _, stack, _, _, _, memory, _ ->
val numWords: UInt256 = length.divideCeil(32L)
val copyCost = Gas.valueOf(6).multiply(Gas.valueOf(numWords)).add(Gas.valueOf(30))
- val memoryCost = if (length.isZero) Gas.ZERO else {
+ val memoryCost = if (length.isZero) {
+ Gas.ZERO
+ } else {
val pre = memoryCost(memory.size())
val post: Gas = memoryCost(memory.newSize(from, length))
post.subtract(pre)
diff --git a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/constantinople/OpCodes.kt b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/constantinople/OpCodes.kt
index 7d7762b0..780ac700 100644
--- a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/constantinople/OpCodes.kt
+++ b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/constantinople/OpCodes.kt
@@ -357,7 +357,9 @@ private val sstore = Opcode { gasManager, hostContext, stack, msg, _, _, _, _ ->
if (currentValue.equals(originalValue)) {
if (originalValue.isZero) {
Gas.valueOf(20000)
- } else Gas.valueOf(5000)
+ } else {
+ Gas.valueOf(5000)
+ }
} else {
Gas.valueOf(200)
}
@@ -724,7 +726,9 @@ private val sha3 = Opcode { gasManager, _, stack, _, _, _, memory, _ ->
val numWords: UInt256 = length.divideCeil(32L)
val copyCost = Gas.valueOf(6).multiply(Gas.valueOf(numWords)).add(Gas.valueOf(30))
- val memoryCost = if (length.isZero) Gas.ZERO else {
+ val memoryCost = if (length.isZero) {
+ Gas.ZERO
+ } else {
val pre = org.apache.tuweni.evm.impl.frontier.memoryCost(memory.size())
val post: Gas = org.apache.tuweni.evm.impl.frontier.memoryCost(memory.newSize(from, length))
post.subtract(pre)
diff --git a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/frontier/OpCodes.kt b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/frontier/OpCodes.kt
index aa4cd731..681cac26 100644
--- a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/frontier/OpCodes.kt
+++ b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/frontier/OpCodes.kt
@@ -682,7 +682,9 @@ private val sha3 = Opcode { gasManager, _, stack, _, _, _, memory, _ ->
val numWords: UInt256 = length.divideCeil(32L)
val copyCost = Gas.valueOf(6).multiply(Gas.valueOf(numWords)).add(Gas.valueOf(30))
- val memoryCost = if (length.isZero) Gas.ZERO else {
+ val memoryCost = if (length.isZero) {
+ Gas.ZERO
+ } else {
memoryCost(memory.newSize(from, length).subtract(memory.size()))
}
gasManager.add(copyCost.addSafe(memoryCost))
diff --git a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/homestead/OpCodes.kt b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/homestead/OpCodes.kt
index 0e917621..ce48320c 100644
--- a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/homestead/OpCodes.kt
+++ b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/homestead/OpCodes.kt
@@ -682,7 +682,9 @@ private val sha3 = Opcode { gasManager, _, stack, _, _, _, memory, _ ->
val numWords: UInt256 = length.divideCeil(32L)
val copyCost = Gas.valueOf(6).multiply(Gas.valueOf(numWords)).add(Gas.valueOf(30))
- val memoryCost = if (length.isZero) Gas.ZERO else {
+ val memoryCost = if (length.isZero) {
+ Gas.ZERO
+ } else {
memoryCost(memory.newSize(from, length).subtract(memory.size()))
}
gasManager.add(copyCost.addSafe(memoryCost))
diff --git a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/istanbul/OpCodes.kt b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/istanbul/OpCodes.kt
index 9df11fa8..ad4da178 100644
--- a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/istanbul/OpCodes.kt
+++ b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/istanbul/OpCodes.kt
@@ -353,7 +353,9 @@ private val sstore = Opcode { gasManager, hostContext, stack, msg, _, _, _, _ ->
if (currentValue.equals(originalValue)) {
if (originalValue.isZero) {
Gas.valueOf(20000)
- } else Gas.valueOf(5000)
+ } else {
+ Gas.valueOf(5000)
+ }
} else {
Gas.valueOf(800)
}
@@ -693,7 +695,9 @@ private val sha3 = Opcode { gasManager, _, stack, _, _, _, memory, _ ->
val numWords: UInt256 = length.divideCeil(32L)
val copyCost = Gas.valueOf(6).multiply(Gas.valueOf(numWords)).add(Gas.valueOf(30))
- val memoryCost = if (length.isZero) Gas.ZERO else {
+ val memoryCost = if (length.isZero) {
+ Gas.ZERO
+ } else {
val pre = org.apache.tuweni.evm.impl.frontier.memoryCost(memory.size())
val post: Gas = org.apache.tuweni.evm.impl.frontier.memoryCost(memory.newSize(from, length))
post.subtract(pre)
diff --git a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/petersburg/OpCodes.kt b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/petersburg/OpCodes.kt
index 8c6af29d..8fefba14 100644
--- a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/petersburg/OpCodes.kt
+++ b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/petersburg/OpCodes.kt
@@ -357,7 +357,9 @@ private val sstore = Opcode { gasManager, hostContext, stack, msg, _, _, _, _ ->
if (currentValue.equals(originalValue)) {
if (originalValue.isZero) {
Gas.valueOf(20000)
- } else Gas.valueOf(5000)
+ } else {
+ Gas.valueOf(5000)
+ }
} else {
Gas.valueOf(200)
}
@@ -719,7 +721,9 @@ private val sha3 = Opcode { gasManager, _, stack, _, _, _, memory, _ ->
val numWords: UInt256 = length.divideCeil(32L)
val copyCost = Gas.valueOf(6).multiply(Gas.valueOf(numWords)).add(Gas.valueOf(30))
- val memoryCost = if (length.isZero) Gas.ZERO else {
+ val memoryCost = if (length.isZero) {
+ Gas.ZERO
+ } else {
val pre = org.apache.tuweni.evm.impl.frontier.memoryCost(memory.size())
val post: Gas = org.apache.tuweni.evm.impl.frontier.memoryCost(memory.newSize(from, length))
post.subtract(pre)
diff --git a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/spuriousDragon/OpCodes.kt b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/spuriousDragon/OpCodes.kt
index 82defed1..83be8e47 100644
--- a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/spuriousDragon/OpCodes.kt
+++ b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/spuriousDragon/OpCodes.kt
@@ -676,7 +676,9 @@ private val sha3 = Opcode { gasManager, _, stack, _, _, _, memory, _ ->
val numWords: UInt256 = length.divideCeil(32L)
val copyCost = Gas.valueOf(6).multiply(Gas.valueOf(numWords)).add(Gas.valueOf(30))
- val memoryCost = if (length.isZero) Gas.ZERO else {
+ val memoryCost = if (length.isZero) {
+ Gas.ZERO
+ } else {
val pre = memoryCost(memory.size())
val post: Gas = memoryCost(memory.newSize(from, length))
post.subtract(pre)
diff --git a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/tangerineWhistle/OpCodes.kt b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/tangerineWhistle/OpCodes.kt
index 2993081a..f85eb43e 100644
--- a/evm/src/main/kotlin/org/apache/tuweni/evm/impl/tangerineWhistle/OpCodes.kt
+++ b/evm/src/main/kotlin/org/apache/tuweni/evm/impl/tangerineWhistle/OpCodes.kt
@@ -677,7 +677,9 @@ private val sha3 = Opcode { gasManager, _, stack, _, _, _, memory, _ ->
val numWords: UInt256 = length.divideCeil(32L)
val copyCost = Gas.valueOf(6).multiply(Gas.valueOf(numWords)).add(Gas.valueOf(30))
- val memoryCost = if (length.isZero) Gas.ZERO else {
+ val memoryCost = if (length.isZero) {
+ Gas.ZERO
+ } else {
val pre = memoryCost(memory.size())
val post: Gas = memoryCost(memory.newSize(from, length))
post.subtract(pre)
diff --git a/evm/src/test/kotlin/org/apache/tuweni/evm/EVMBrokenMetreAttack.kt b/evm/src/test/kotlin/org/apache/tuweni/evm/EVMBrokenMetreAttack.kt
index 12c014ad..ee821a4f 100644
--- a/evm/src/test/kotlin/org/apache/tuweni/evm/EVMBrokenMetreAttack.kt
+++ b/evm/src/test/kotlin/org/apache/tuweni/evm/EVMBrokenMetreAttack.kt
@@ -104,7 +104,7 @@ class EVMBrokenMetreAttack {
UInt256.valueOf(1234),
UInt256.valueOf(1),
CallKind.CALL,
- HardFork.ISTANBUL,
+ HardFork.ISTANBUL
)
assertEquals(expectedStatusCode, result.statusCode)
}
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 b55c7d31..e2e802fc 100644
--- a/evm/src/test/kotlin/org/apache/tuweni/evm/EVMReferenceTest.kt
+++ b/evm/src/test/kotlin/org/apache/tuweni/evm/EVMReferenceTest.kt
@@ -105,7 +105,6 @@ class EVMReferenceTest {
@Throws(IOException::class)
private fun prepareTests(input: InputStream): Stream<Arguments> {
-
val typeRef = object : TypeReference<HashMap<String, JsonReferenceTest>>() {}
val allTests: Map<String, JsonReferenceTest> = mapper.readValue(input, typeRef)
return allTests
@@ -289,7 +288,7 @@ data class Env(
var currentDifficulty: UInt256? = null,
var currentGasLimit: UInt256? = null,
var currentNumber: UInt256? = null,
- var currentTimestamp: UInt256? = null,
+ var currentTimestamp: UInt256? = null
)
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -301,7 +300,7 @@ data class Exec(
var gas: Gas? = null,
var gasPrice: Wei? = null,
var origin: Address? = null,
- var value: Bytes? = null,
+ var value: Bytes? = null
)
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -309,7 +308,7 @@ data class JsonAccountState(
var balance: Wei? = null,
var code: Bytes? = null,
var nonce: UInt256? = null,
- var storage: Map<UInt256, UInt256>? = null,
+ var storage: Map<UInt256, UInt256>? = null
)
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -320,5 +319,5 @@ data class JsonReferenceTest(
var logs: Bytes? = null,
var out: Bytes? = null,
var post: Map<Address, JsonAccountState>? = null,
- var pre: Map<Address, JsonAccountState>? = null,
+ var pre: Map<Address, JsonAccountState>? = null
)
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 edcebb16..d4bd5364 100644
--- a/evm/src/test/kotlin/org/apache/tuweni/evm/EvmCertificationTest.kt
+++ b/evm/src/test/kotlin/org/apache/tuweni/evm/EvmCertificationTest.kt
@@ -281,8 +281,12 @@ class EvmCertificationTest {
assertEquals(
test.allGasUsed.toLong(),
result.state.gasManager.gasCost.toLong(),
- " diff: " + if (test.allGasUsed > result.state.gasManager.gasLeft()) test.allGasUsed.subtract(result.state.gasManager.gasLeft()) else result.state.gasManager.gasLeft()
- .subtract(test.allGasUsed)
+ " diff: " + if (test.allGasUsed > result.state.gasManager.gasLeft()) {
+ test.allGasUsed.subtract(result.state.gasManager.gasLeft())
+ } else {
+ result.state.gasManager.gasLeft()
+ .subtract(test.allGasUsed)
+ }
)
} finally {
vm.stop()
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 dd772551..dc5ee3a4 100644
--- a/evm/src/test/kotlin/org/apache/tuweni/evm/OpcodeTest.kt
+++ b/evm/src/test/kotlin/org/apache/tuweni/evm/OpcodeTest.kt
@@ -278,8 +278,12 @@ class OpcodeTest {
assertEquals(
test.allGasUsed.toLong(),
result.state.gasManager.gasCost.toLong(),
- " diff: " + if (test.allGasUsed > result.state.gasManager.gasLeft()) test.allGasUsed.subtract(result.state.gasManager.gasLeft()) else result.state.gasManager.gasLeft()
- .subtract(test.allGasUsed)
+ " diff: " + if (test.allGasUsed > result.state.gasManager.gasLeft()) {
+ test.allGasUsed.subtract(result.state.gasManager.gasLeft())
+ } else {
+ result.state.gasManager.gasLeft()
+ .subtract(test.allGasUsed)
+ }
)
} finally {
vm.stop()
diff --git a/evm/src/test/kotlin/org/apache/tuweni/evm/OpcodeTestModel.kt b/evm/src/test/kotlin/org/apache/tuweni/evm/OpcodeTestModel.kt
index fda417f1..032535f2 100644
--- a/evm/src/test/kotlin/org/apache/tuweni/evm/OpcodeTestModel.kt
+++ b/evm/src/test/kotlin/org/apache/tuweni/evm/OpcodeTestModel.kt
@@ -31,7 +31,7 @@ import org.junit.jupiter.api.Test
data class StorageEntry @JsonCreator constructor(
@JsonProperty("key") val key: Bytes,
- @JsonProperty("value") val value: Bytes,
+ @JsonProperty("value") val value: Bytes
)
data class AccountInfo @JsonCreator constructor(
@@ -39,31 +39,31 @@ data class AccountInfo @JsonCreator constructor(
@JsonProperty("balance") val balance: Wei,
@JsonProperty("code") val code: Bytes,
@JsonProperty("nonce") val nonce: UInt256,
- @JsonProperty("storage") val storage: List<StorageEntry>,
+ @JsonProperty("storage") val storage: List<StorageEntry>
)
data class Before @JsonCreator constructor(
@JsonProperty("accounts") val accounts: List<AccountInfo>,
@JsonProperty("stack") val stack: List<Bytes>,
- @JsonProperty("memory") val memory: List<Bytes32>,
+ @JsonProperty("memory") val memory: List<Bytes32>
)
data class After @JsonCreator constructor(
@JsonProperty("accounts") val accounts: List<AccountInfo>,
@JsonProperty("stack") val stack: List<Bytes>,
@JsonProperty("memory") val memory: List<Bytes32>,
- @JsonProperty("logs") val logs: List<Log>,
+ @JsonProperty("logs") val logs: List<Log>
)
data class Operation @JsonCreator constructor(
@JsonProperty("name") val name: String,
- @JsonProperty("opcode") val opcode: Bytes,
+ @JsonProperty("opcode") val opcode: Bytes
)
data class Log @JsonCreator constructor(
@JsonProperty("logger") val logger: Address,
@JsonProperty("data") val data: Bytes,
- @JsonProperty("topics") val topics: List<Bytes32>,
+ @JsonProperty("topics") val topics: List<Bytes32>
)
/**
@@ -96,7 +96,7 @@ data class OpcodeTestModel @JsonCreator constructor(
@JsonProperty("value") val value: UInt256,
@JsonProperty("gasUsed") val gasUsed: Gas,
@JsonProperty("allGasUsed") val allGasUsed: Gas,
- @JsonProperty("refunds") val refunds: Map<Address, Wei>,
+ @JsonProperty("refunds") val refunds: Map<Address, Wei>
)
class OpcodeTestModelTest {
diff --git a/genesis/src/main/kotlin/org/apache/tuweni/genesis/Genesis.kt b/genesis/src/main/kotlin/org/apache/tuweni/genesis/Genesis.kt
index aece56d4..c05c2531 100644
--- a/genesis/src/main/kotlin/org/apache/tuweni/genesis/Genesis.kt
+++ b/genesis/src/main/kotlin/org/apache/tuweni/genesis/Genesis.kt
@@ -39,7 +39,7 @@ open class GenesisConfig(
val eip155Block: Int = 0,
val eip158Block: Int = 0,
val byzantiumBlock: Int = 0,
- val constantinopleBlock: Int = 0,
+ val constantinopleBlock: Int = 0
)
/**
@@ -71,7 +71,7 @@ class Genesis(
val extraData: Bytes,
private val gasLimit: Long,
val alloc: Map<Address, Map<String, UInt256>>,
- val config: GenesisConfig,
+ val config: GenesisConfig
) {
companion object {
@@ -106,7 +106,7 @@ class Genesis(
1_000_000L,
emptyMap(),
GenesisConfig(1337, 0, 0, 0, 0)
- ),
+ )
): Block {
return Block(
BlockHeader(
diff --git a/genesis/src/main/kotlin/org/apache/tuweni/genesis/Main.kt b/genesis/src/main/kotlin/org/apache/tuweni/genesis/Main.kt
index c095d9c4..395dc5b9 100644
--- a/genesis/src/main/kotlin/org/apache/tuweni/genesis/Main.kt
+++ b/genesis/src/main/kotlin/org/apache/tuweni/genesis/Main.kt
@@ -29,7 +29,8 @@ import java.security.Security
fun main(args: Array<String>) {
Security.addProvider(BouncyCastleProvider())
val config = QuorumConfig.generate(
- mixHash = Bytes32.random(), config = QuorumGenesisConfig(chainId = args[0].toInt()),
+ mixHash = Bytes32.random(),
+ config = QuorumGenesisConfig(chainId = args[0].toInt()),
numberValidators = 4,
numberAllocations = 100,
amount = UInt256.fromBytes(Bytes32.rightPad(Bytes.fromHexString("0x10")))
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 4611ae09..a1a3db07 100644
--- a/genesis/src/main/kotlin/org/apache/tuweni/genesis/Quorum.kt
+++ b/genesis/src/main/kotlin/org/apache/tuweni/genesis/Quorum.kt
@@ -43,7 +43,7 @@ class QuorumConfig(val genesis: Genesis, val validators: List<SECP256K1.KeyPair>
config: QuorumGenesisConfig,
numberValidators: Int,
numberAllocations: Int,
- amount: UInt256,
+ amount: UInt256
): QuorumConfig {
val allocations = AllocationGenerator().createAllocations(numberAllocations, amount)
@@ -77,7 +77,7 @@ class QuorumConfig(val genesis: Genesis, val validators: List<SECP256K1.KeyPair>
vanity: Bytes32 = Bytes32.ZERO,
mixHash: Bytes32,
allocations: List<Allocation>,
- validators: List<SECP256K1.KeyPair>,
+ validators: List<SECP256K1.KeyPair>
): QuorumConfig {
val allocs = mutableMapOf<Address, Map<String, UInt256>>()
for (alloc in allocations) {
@@ -140,7 +140,7 @@ class IstanbulConfigOptions(
val epoch: Int = 3000,
val policy: Int = 0,
val testQBFTBlock: Int = 0,
- val ceil2Nby3Block: Int = 0,
+ val ceil2Nby3Block: Int = 0
)
@JsonPropertyOrder(alphabetic = true)
@@ -154,7 +154,7 @@ class QuorumGenesisConfig(
constantinopleBlock: Int = 0,
val istanbul: IstanbulConfigOptions = IstanbulConfigOptions(),
val txnSizeLimit: Int = 64,
- val maxCodeSize: Int = 0,
+ val maxCodeSize: Int = 0
) : GenesisConfig(chainId, homesteadBlock, eip150Block, eip155Block, eip158Block, byzantiumBlock, constantinopleBlock) {
@JsonProperty("isQuorum")
diff --git a/genesis/src/test/kotlin/org/apache/tuweni/genesis/QuorumTest.kt b/genesis/src/test/kotlin/org/apache/tuweni/genesis/QuorumTest.kt
index 05b8daad..1284ee93 100644
--- a/genesis/src/test/kotlin/org/apache/tuweni/genesis/QuorumTest.kt
+++ b/genesis/src/test/kotlin/org/apache/tuweni/genesis/QuorumTest.kt
@@ -41,7 +41,7 @@ class QuorumTest {
timestamp = 0L,
gasLimit = 0L,
parentHash = Bytes32.leftPad(Bytes.fromHexString("0x00ff")),
- config = QuorumGenesisConfig(chainId = 1337,),
+ config = QuorumGenesisConfig(chainId = 1337),
numberAllocations = 10,
amount = UInt256.valueOf(123),
numberValidators = 4,
diff --git a/hobbits-relayer/src/main/kotlin/org/apache/tuweni/relayer/RelayerAppCommandlineArguments.kt b/hobbits-relayer/src/main/kotlin/org/apache/tuweni/relayer/RelayerAppCommandlineArguments.kt
index de95173d..f8d36334 100644
--- a/hobbits-relayer/src/main/kotlin/org/apache/tuweni/relayer/RelayerAppCommandlineArguments.kt
+++ b/hobbits-relayer/src/main/kotlin/org/apache/tuweni/relayer/RelayerAppCommandlineArguments.kt
@@ -19,7 +19,12 @@ package org.apache.tuweni.relayer
import picocli.CommandLine
internal class RelayerAppCommandlineArguments() {
- @CommandLine.Option(names = ["-b", "--bind"], description = ["Endpoint to bind to"]) var bind: String = ""
- @CommandLine.Option(names = ["-t", "--to"], description = ["Endpoint to relay to"]) var to: String = ""
- @CommandLine.Option(names = ["-h", "--help"], description = ["Prints usage prompt"]) var help: Boolean = false
+ @CommandLine.Option(names = ["-b", "--bind"], description = ["Endpoint to bind to"])
+ var bind: String = ""
+
+ @CommandLine.Option(names = ["-t", "--to"], description = ["Endpoint to relay to"])
+ var to: String = ""
+
+ @CommandLine.Option(names = ["-h", "--help"], description = ["Prints usage prompt"])
+ var help: Boolean = false
}
diff --git a/hobbits/src/integrationTest/kotlin/org/apache/tuweni/hobbits/InteractionTest.kt b/hobbits/src/integrationTest/kotlin/org/apache/tuweni/hobbits/InteractionTest.kt
index 0c9083c7..729a95c0 100644
--- a/hobbits/src/integrationTest/kotlin/org/apache/tuweni/hobbits/InteractionTest.kt
+++ b/hobbits/src/integrationTest/kotlin/org/apache/tuweni/hobbits/InteractionTest.kt
@@ -158,10 +158,13 @@ class HTTPTest {
client2.start()
client2.sendMessage(
Message(
- protocol = Protocol.PING, body = Bytes.fromHexString("deadbeef"),
+ protocol = Protocol.PING,
+ body = Bytes.fromHexString("deadbeef"),
headers = Bytes.random(16)
),
- Transport.HTTP, "127.0.0.1", newPort.get()
+ Transport.HTTP,
+ "127.0.0.1",
+ newPort.get()
)
}
Thread.sleep(200)
@@ -230,10 +233,13 @@ class UDPTest {
client2.start()
client2.sendMessage(
Message(
- protocol = Protocol.PING, body = Bytes.fromHexString("deadbeef"),
+ protocol = Protocol.PING,
+ body = Bytes.fromHexString("deadbeef"),
headers = Bytes.random(16)
),
- Transport.UDP, "localhost", 15000
+ Transport.UDP,
+ "localhost",
+ 15000
)
}
Thread.sleep(200)
@@ -296,10 +302,13 @@ class WebSocketTest {
client2.start()
client2.sendMessage(
Message(
- protocol = Protocol.PING, body = Bytes.fromHexString("deadbeef"),
+ protocol = Protocol.PING,
+ body = Bytes.fromHexString("deadbeef"),
headers = Bytes.random(16)
),
- Transport.WS, "127.0.0.1", newPort.get()
+ Transport.WS,
+ "127.0.0.1",
+ newPort.get()
)
}
Thread.sleep(200)
diff --git a/hobbits/src/main/kotlin/org/apache/tuweni/hobbits/HobbitsTransport.kt b/hobbits/src/main/kotlin/org/apache/tuweni/hobbits/HobbitsTransport.kt
index 5d60cfb0..389bcc1f 100644
--- a/hobbits/src/main/kotlin/org/apache/tuweni/hobbits/HobbitsTransport.kt
+++ b/hobbits/src/main/kotlin/org/apache/tuweni/hobbits/HobbitsTransport.kt
@@ -198,7 +198,9 @@ class HobbitsTransport(
Transport.WS -> {
try {
val websocket = httpClient!!.webSocket(
- port, host, requestURI
+ port,
+ host,
+ requestURI
).await()
websocket.exceptionHandler(exceptionHandler)
websocket.writeBinaryMessage(Buffer.buffer(message.toBytes().toArrayUnsafe())).await()
@@ -439,14 +441,17 @@ enum class Transport() {
* HTTP transport
*/
HTTP,
+
/**
* TCP transport
*/
TCP,
+
/**
* UDP transport
*/
UDP,
+
/**
* Websocket transport
*/
diff --git a/hobbits/src/main/kotlin/org/apache/tuweni/hobbits/Message.kt b/hobbits/src/main/kotlin/org/apache/tuweni/hobbits/Message.kt
index 6abf78d6..1a4c427b 100644
--- a/hobbits/src/main/kotlin/org/apache/tuweni/hobbits/Message.kt
+++ b/hobbits/src/main/kotlin/org/apache/tuweni/hobbits/Message.kt
@@ -23,6 +23,7 @@ import java.nio.charset.StandardCharsets.UTF_8
internal val PREAMBLE = "EWP".toByteArray(UTF_8)
internal val MESSAGE_HEADER_LENGTH = PREAMBLE.size + java.lang.Integer.BYTES * 3 + 1
+
/**
* Hobbits message.
*
@@ -111,10 +112,12 @@ enum class Protocol(val code: Byte) {
* Gossip protocol message
*/
GOSSIP(1),
+
/**
* Ping message
*/
PING(2),
+
/**
* RPC message
*/
diff --git a/hobbits/src/main/kotlin/org/apache/tuweni/hobbits/Relayer.kt b/hobbits/src/main/kotlin/org/apache/tuweni/hobbits/Relayer.kt
index 5b40abe7..cc1dd05a 100644
--- a/hobbits/src/main/kotlin/org/apache/tuweni/hobbits/Relayer.kt
+++ b/hobbits/src/main/kotlin/org/apache/tuweni/hobbits/Relayer.kt
@@ -47,7 +47,8 @@ class Relayer(
when (uri.scheme) {
"http" -> {
transport.createHTTPEndpoint(
- networkInterface = uri.host, port = uri.port,
+ networkInterface = uri.host,
+ port = uri.port,
handler = {
async {
interceptor(it)
@@ -58,7 +59,8 @@ class Relayer(
}
"tcp" -> {
transport.createTCPEndpoint(
- networkInterface = uri.host, port = uri.port,
+ networkInterface = uri.host,
+ port = uri.port,
handler = {
async {
interceptor(it)
@@ -69,7 +71,8 @@ class Relayer(
}
"udp" -> {
transport.createUDPEndpoint(
- networkInterface = uri.host, port = uri.port,
+ networkInterface = uri.host,
+ port = uri.port,
handler = {
async {
interceptor(it)
@@ -80,7 +83,8 @@ class Relayer(
}
"ws" -> {
transport.createWSEndpoint(
- networkInterface = uri.host, port = uri.port,
+ networkInterface = uri.host,
+ port = uri.port,
handler = {
async {
interceptor(it)
diff --git a/hobbits/src/test/kotlin/org/apache/tuweni/hobbits/HobbitsTransportTest.kt b/hobbits/src/test/kotlin/org/apache/tuweni/hobbits/HobbitsTransportTest.kt
index b4812b4d..38727757 100644
--- a/hobbits/src/test/kotlin/org/apache/tuweni/hobbits/HobbitsTransportTest.kt
+++ b/hobbits/src/test/kotlin/org/apache/tuweni/hobbits/HobbitsTransportTest.kt
@@ -48,7 +48,9 @@ class HobbitsTransportTest {
runBlocking {
server.sendMessage(
Message(protocol = Protocol.RPC, headers = Bytes.EMPTY, body = Bytes.EMPTY),
- Transport.TCP, "localhost", 9000
+ Transport.TCP,
+ "localhost",
+ 9000
)
}
}
diff --git a/hobbits/src/test/kotlin/org/apache/tuweni/hobbits/MessageTest.kt b/hobbits/src/test/kotlin/org/apache/tuweni/hobbits/MessageTest.kt
index 33a68943..f5a8af31 100644
--- a/hobbits/src/test/kotlin/org/apache/tuweni/hobbits/MessageTest.kt
+++ b/hobbits/src/test/kotlin/org/apache/tuweni/hobbits/MessageTest.kt
@@ -28,7 +28,8 @@ class MessageTest {
@Test
fun parseMessageRoundtrip() {
val msg = Message(
- protocol = Protocol.PING, headers = Bytes.fromHexString("deadbeef01"),
+ protocol = Protocol.PING,
+ headers = Bytes.fromHexString("deadbeef01"),
body = Bytes.fromHexString("deadbeef02")
)
val serialized = msg.toBytes()
@@ -50,7 +51,8 @@ class MessageTest {
@Test
fun testToString() {
val msg = Message(
- protocol = Protocol.PING, headers = Bytes.fromHexString("deadbeef01"),
+ protocol = Protocol.PING,
+ headers = Bytes.fromHexString("deadbeef01"),
body = Bytes.fromHexString("deadbeef02")
)
assertEquals(
@@ -64,18 +66,21 @@ class MessageTest {
@Test
fun testSize() {
val msg = Message(
- protocol = Protocol.PING, headers = Bytes.fromHexString("deadbeef01"),
+ protocol = Protocol.PING,
+ headers = Bytes.fromHexString("deadbeef01"),
body = Bytes.fromHexString("deadbeef02")
)
assertEquals(
- 26, msg.size()
+ 26,
+ msg.size()
)
}
@Test
fun testReadMessage() {
val msg = Message(
- protocol = Protocol.PING, headers = Bytes.fromHexString("deadbeef01"),
+ protocol = Protocol.PING,
+ headers = Bytes.fromHexString("deadbeef01"),
body = Bytes.fromHexString("deadbeef02")
)
val serialized = msg.toBytes()
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 afb8ea66..546ddcdc 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
@@ -25,9 +25,9 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.runBlocking
import org.apache.tuweni.app.commons.ApplicationUtils
-import org.apache.tuweni.eth.internalError
import org.apache.tuweni.bytes.Bytes
import org.apache.tuweni.eth.JSONRPCResponse
+import org.apache.tuweni.eth.internalError
import org.apache.tuweni.jsonrpc.JSONRPCClient
import org.apache.tuweni.jsonrpc.JSONRPCServer
import org.apache.tuweni.jsonrpc.methods.CachingHandler
@@ -92,7 +92,7 @@ object JSONRPCApp {
enableGrpcPush = config.metricsGrpcPushEnabled(),
enablePrometheus = config.metricsPrometheusEnabled(),
grpcEndpoint = config.metricsGrpcEndpoint(),
- grpcTimeout = config.metricsGrpcTimeout(),
+ grpcTimeout = config.metricsGrpcTimeout()
)
val vertx = Vertx.vertx(VertxOptions().setTracingOptions(OpenTelemetryOptions(metricsService.openTelemetry)))
val app = JSONRPCApplication(vertx, config, metricsService)
@@ -104,7 +104,7 @@ class JSONRPCApplication(
val vertx: Vertx,
val config: JSONRPCConfig,
val metricsService: MetricsService,
- override val coroutineContext: CoroutineContext = Dispatchers.Unconfined,
+ override val coroutineContext: CoroutineContext = Dispatchers.Unconfined
) : CoroutineScope {
fun run() {
@@ -127,7 +127,6 @@ class JSONRPCApplication(
val failureCounter = meter.longCounterBuilder("failure").build()
val nextHandler = if (config.cacheEnabled()) {
-
val builder = GlobalConfigurationBuilder().serialization().marshaller(PersistenceMarshaller())
val manager = DefaultCacheManager(builder.build())
val cache: Cache<String, JSONRPCResponse> = manager.createCache(
@@ -139,7 +138,8 @@ class JSONRPCApplication(
val cachingHandler =
CachingHandler(
- config.cachedMethods(), InfinispanKeyValueStore(cache),
+ config.cachedMethods(),
+ InfinispanKeyValueStore(cache),
meter.longCounterBuilder("cacheHits").build(),
meter.longCounterBuilder("cacheMisses").build(),
allowListHandler::handleRequest
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 b5318ef1..c9162947 100644
--- a/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/JSONRPCClient.kt
+++ b/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/JSONRPCClient.kt
@@ -50,7 +50,7 @@ class JSONRPCClient(
val basicAuthenticationEnabled: Boolean = false,
val basicAuthenticationUsername: String = "",
val basicAuthenticationPassword: String = "",
- override val coroutineContext: CoroutineContext = vertx.dispatcher(),
+ override val coroutineContext: CoroutineContext = vertx.dispatcher()
) : Closeable, CoroutineScope {
companion object {
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 4bb638c0..0679525f 100644
--- a/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/JSONRPCServer.kt
+++ b/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/JSONRPCServer.kt
@@ -72,7 +72,7 @@ class JSONRPCServer(
val ipRangeChecker: IPRangeChecker = IPRangeChecker.allowAll(),
val openTelemetry: OpenTelemetry = OpenTelemetry.noop(),
override val coroutineContext: CoroutineContext = Dispatchers.Default,
- val methodHandler: suspend (JSONRPCRequest) -> JSONRPCResponse,
+ val methodHandler: suspend (JSONRPCRequest) -> JSONRPCResponse
) : CoroutineScope {
companion object {
diff --git a/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/methods/MethodsHandler.kt b/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/methods/MethodsHandler.kt
index 2206f1aa..1cca4eec 100644
--- a/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/methods/MethodsHandler.kt
+++ b/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/methods/MethodsHandler.kt
@@ -49,7 +49,7 @@ class MethodsRouter(val methodsMap: Map<String, suspend (JSONRPCRequest) -> JSON
class MeteredHandler(
private val successCounter: LongCounter,
private val failCounter: LongCounter,
- private val delegateHandler: suspend (JSONRPCRequest) -> JSONRPCResponse,
+ private val delegateHandler: suspend (JSONRPCRequest) -> JSONRPCResponse
) {
suspend fun handleRequest(request: JSONRPCRequest): JSONRPCResponse {
@@ -66,7 +66,7 @@ class MeteredHandler(
class MethodAllowListHandler(
private val allowedMethods: List<String>,
- private val delegateHandler: suspend (JSONRPCRequest) -> JSONRPCResponse,
+ private val delegateHandler: suspend (JSONRPCRequest) -> JSONRPCResponse
) {
suspend fun handleRequest(request: JSONRPCRequest): JSONRPCResponse {
@@ -86,7 +86,7 @@ class MethodAllowListHandler(
class ThrottlingHandler(
private val threshold: Int,
- private val delegateHandler: suspend (JSONRPCRequest) -> JSONRPCResponse,
+ private val delegateHandler: suspend (JSONRPCRequest) -> JSONRPCResponse
) {
private val limiter: SimpleLimiter<Void> = SimpleLimiter
@@ -116,7 +116,7 @@ class CachingHandler(
private val cacheStore: KeyValueStore<String, JSONRPCResponse>,
private val cacheHitCounter: LongCounter,
private val cacheMissCounter: LongCounter,
- private val delegateHandler: suspend (JSONRPCRequest) -> JSONRPCResponse,
+ private val delegateHandler: suspend (JSONRPCRequest) -> JSONRPCResponse
) {
suspend fun handleRequest(request: JSONRPCRequest): JSONRPCResponse {
@@ -154,7 +154,7 @@ class CachingPollingHandler(
private val cacheHitCounter: LongCounter,
private val cacheMissCounter: LongCounter,
override val coroutineContext: CoroutineContext = Dispatchers.Default,
- private val delegateHandler: suspend (JSONRPCRequest) -> JSONRPCResponse,
+ private val delegateHandler: suspend (JSONRPCRequest) -> JSONRPCResponse
) : CoroutineScope {
companion object {
@@ -212,7 +212,7 @@ class CachingPollingHandler(
class LoggingHandler(
private val delegateHandler: suspend (JSONRPCRequest) -> JSONRPCResponse,
- loggerName: String,
+ loggerName: String
) {
private val logger = LoggerFactory.getLogger(loggerName)
diff --git a/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/methods/Net.kt b/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/methods/Net.kt
index 9061f6e6..eae7189f 100644
--- a/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/methods/Net.kt
+++ b/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/methods/Net.kt
@@ -23,7 +23,7 @@ import org.apache.tuweni.eth.JSONRPCResponse
fun registerNet(
networkId: String,
listeningToConnections: Boolean = true,
- peerCount: () -> Int,
+ peerCount: () -> Int
): Map<String, suspend (JSONRPCRequest) -> JSONRPCResponse> {
val version = ConstantStringResult(networkId)
val listening = ConstantBooleanResult(listeningToConnections)
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 a9e9868f..b1d8025c 100644
--- a/jsonrpc/src/test/kotlin/org/apache/tuweni/jsonrpc/JSONRPCClientTest.kt
+++ b/jsonrpc/src/test/kotlin/org/apache/tuweni/jsonrpc/JSONRPCClientTest.kt
@@ -58,7 +58,8 @@ class JSONRPCClientTest {
fun runServer(@VertxInstance vertx: Vertx): Unit = runBlocking {
Assumptions.assumeTrue(!System.getProperty("os.name").lowercase().contains("win"), "Server ports cannot bind on Windows")
server = JSONRPCServer(
- vertx, port = 0,
+ vertx,
+ port = 0,
methodHandler = {
handler.get().handle(it)
JSONRPCResponse(StringOrLong(3), "")
diff --git a/jsonrpc/src/test/kotlin/org/apache/tuweni/jsonrpc/JSONRPCServerTest.kt b/jsonrpc/src/test/kotlin/org/apache/tuweni/jsonrpc/JSONRPCServerTest.kt
index 4e497d82..12d0bf1f 100644
--- a/jsonrpc/src/test/kotlin/org/apache/tuweni/jsonrpc/JSONRPCServerTest.kt
+++ b/jsonrpc/src/test/kotlin/org/apache/tuweni/jsonrpc/JSONRPCServerTest.kt
@@ -52,7 +52,8 @@ class JSONRPCServerTest {
@Test
fun testNoAuth(@VertxInstance vertx: Vertx): Unit = runBlocking {
val server = JSONRPCServer(
- vertx, port = 0,
+ vertx,
+ port = 0,
methodHandler = {
JSONRPCResponse(StringOrLong(3), "")
},
@@ -72,7 +73,8 @@ class JSONRPCServerTest {
@Test
fun testBasicAuth(@VertxInstance vertx: Vertx): Unit = runBlocking {
val server = JSONRPCServer(
- vertx, port = 0,
+ vertx,
+ port = 0,
methodHandler = {
JSONRPCResponse(StringOrLong(3), "")
},
diff --git a/kv/src/main/kotlin/org/apache/tuweni/kv/CascadingKeyValueStore.kt b/kv/src/main/kotlin/org/apache/tuweni/kv/CascadingKeyValueStore.kt
index 64b7ee20..ca0745aa 100644
--- a/kv/src/main/kotlin/org/apache/tuweni/kv/CascadingKeyValueStore.kt
+++ b/kv/src/main/kotlin/org/apache/tuweni/kv/CascadingKeyValueStore.kt
@@ -35,7 +35,7 @@ internal data class Operation<K, V>(val operationType: OperationType, val key: K
class CascadingKeyValueStore<K, V>(
val frontKv: KeyValueStore<K, V>,
val backingKv: KeyValueStore<K, V>,
- override val coroutineContext: CoroutineContext = Dispatchers.IO,
+ override val coroutineContext: CoroutineContext = Dispatchers.IO
) : KeyValueStore<K, V> {
private val changes = mutableListOf<Operation<K, V>>()
diff --git a/kv/src/main/kotlin/org/apache/tuweni/kv/EntityManagerKeyValueStore.kt b/kv/src/main/kotlin/org/apache/tuweni/kv/EntityManagerKeyValueStore.kt
index 2eb0e9d0..f9a2b265 100644
--- a/kv/src/main/kotlin/org/apache/tuweni/kv/EntityManagerKeyValueStore.kt
+++ b/kv/src/main/kotlin/org/apache/tuweni/kv/EntityManagerKeyValueStore.kt
@@ -17,7 +17,6 @@
package org.apache.tuweni.kv
import kotlinx.coroutines.Dispatchers
-
import java.io.IOException
import java.util.function.Function
import java.util.function.Supplier
diff --git a/kv/src/main/kotlin/org/apache/tuweni/kv/ProxyKeyValueStore.kt b/kv/src/main/kotlin/org/apache/tuweni/kv/ProxyKeyValueStore.kt
index ede7abbf..8255808c 100644
--- a/kv/src/main/kotlin/org/apache/tuweni/kv/ProxyKeyValueStore.kt
+++ b/kv/src/main/kotlin/org/apache/tuweni/kv/ProxyKeyValueStore.kt
@@ -17,8 +17,8 @@
package org.apache.tuweni.kv
import java.util.function.BiFunction
-import kotlin.coroutines.CoroutineContext
import java.util.function.Function
+import kotlin.coroutines.CoroutineContext
/**
* A store used as a proxy for another store.
diff --git a/kv/src/main/kotlin/org/apache/tuweni/kv/SQLKeyValueStore.kt b/kv/src/main/kotlin/org/apache/tuweni/kv/SQLKeyValueStore.kt
index bf42f822..4f07d2f9 100644
--- a/kv/src/main/kotlin/org/apache/tuweni/kv/SQLKeyValueStore.kt
+++ b/kv/src/main/kotlin/org/apache/tuweni/kv/SQLKeyValueStore.kt
@@ -52,7 +52,7 @@ constructor(
private val valueSerializer: (V) -> Bytes,
private val keyDeserializer: (Bytes) -> K,
private val valueDeserializer: (Bytes?) -> V?,
- override val coroutineContext: CoroutineContext = Dispatchers.IO,
+ override val coroutineContext: CoroutineContext = Dispatchers.IO
) : KeyValueStore<K, V> {
companion object {
@@ -74,7 +74,7 @@ constructor(
keySerializer: (K) -> Bytes,
valueSerializer: (V) -> Bytes,
keyDeserializer: (Bytes) -> K,
- valueDeserializer: (Bytes?) -> V?,
+ valueDeserializer: (Bytes?) -> V?
) = SQLKeyValueStore<K, V>(
jdbcurl = jdbcUrl,
keySerializer = keySerializer,
@@ -107,7 +107,7 @@ constructor(
keySerializer: (K) -> Bytes,
valueSerializer: (V) -> Bytes,
keyDeserializer: (Bytes) -> K,
- valueDeserializer: (Bytes?) -> V?,
+ valueDeserializer: (Bytes?) -> V?
) =
SQLKeyValueStore<K, V>(
jdbcUrl,
diff --git a/les/src/main/kotlin/org/apache/tuweni/les/GetBlockHeadersMessage.kt b/les/src/main/kotlin/org/apache/tuweni/les/GetBlockHeadersMessage.kt
index 96daf796..9e7b40af 100644
--- a/les/src/main/kotlin/org/apache/tuweni/les/GetBlockHeadersMessage.kt
+++ b/les/src/main/kotlin/org/apache/tuweni/les/GetBlockHeadersMessage.kt
@@ -62,10 +62,11 @@ internal data class GetBlockHeadersMessage(val reqID: Long, val queries: List<Bl
Bytes32.wrap(queryReader.readValue()),
queryReader.readUInt256(),
queryReader.readUInt256(),
- if (queryReader.readInt() == 1)
+ if (queryReader.readInt() == 1) {
BlockHeaderQuery.Direction.BACKWARDS
- else
+ } else {
BlockHeaderQuery.Direction.FORWARD
+ }
)
}
)
diff --git a/les/src/main/kotlin/org/apache/tuweni/les/LESSubProtocolHandler.kt b/les/src/main/kotlin/org/apache/tuweni/les/LESSubProtocolHandler.kt
index ce7d5928..5e569271 100644
--- a/les/src/main/kotlin/org/apache/tuweni/les/LESSubProtocolHandler.kt
+++ b/les/src/main/kotlin/org/apache/tuweni/les/LESSubProtocolHandler.kt
@@ -139,7 +139,6 @@ internal class LESSubProtocolHandler(
connection: WireConnection,
getBlockHeadersMessage: GetBlockHeadersMessage
) {
-
val headersFound = TreeSet<BlockHeader>()
for (query in getBlockHeadersMessage.queries) {
headersFound.addAll(
diff --git a/les/src/main/kotlin/org/apache/tuweni/les/ReceiptsMessage.kt b/les/src/main/kotlin/org/apache/tuweni/les/ReceiptsMessage.kt
index 8199e025..23c0ca94 100644
--- a/les/src/main/kotlin/org/apache/tuweni/les/ReceiptsMessage.kt
+++ b/les/src/main/kotlin/org/apache/tuweni/les/ReceiptsMessage.kt
@@ -31,9 +31,9 @@ internal data class ReceiptsMessage(
writer.writeLong(reqID)
writer.writeLong(bufferValue)
writer.writeList(receipts) {
- eltWriter, listOfReceipts ->
+ eltWriter, listOfReceipts ->
eltWriter.writeList(listOfReceipts) {
- txWriter, txReceipt ->
+ txWriter, txReceipt ->
txReceipt.writeTo(txWriter)
}
}
diff --git a/les/src/test/kotlin/org/apache/tuweni/les/LESSubProtocolHandlerTest.kt b/les/src/test/kotlin/org/apache/tuweni/les/LESSubProtocolHandlerTest.kt
index e805ee1b..6fbfae8e 100644
--- a/les/src/test/kotlin/org/apache/tuweni/les/LESSubProtocolHandlerTest.kt
+++ b/les/src/test/kotlin/org/apache/tuweni/les/LESSubProtocolHandlerTest.kt
@@ -108,7 +108,8 @@ internal class LESSubProtocolHandlerTest {
private val blockchainInformation = SimpleBlockchainInformation(
UInt256.valueOf(42L),
UInt256.ONE,
- block.header.hash, UInt256.valueOf(42L),
+ block.header.hash,
+ UInt256.valueOf(42L),
block.header.hash,
emptyList()
)
diff --git a/les/src/test/kotlin/org/apache/tuweni/les/LESSubprotocolTest.kt b/les/src/test/kotlin/org/apache/tuweni/les/LESSubprotocolTest.kt
index 593208a6..00f53071 100644
--- a/les/src/test/kotlin/org/apache/tuweni/les/LESSubprotocolTest.kt
+++ b/les/src/test/kotlin/org/apache/tuweni/les/LESSubprotocolTest.kt
@@ -43,7 +43,8 @@ internal class LESSubprotocolTest {
private val blockchainInformation = SimpleBlockchainInformation(
UInt256.valueOf(42L),
UInt256.ONE,
- Hash.fromBytes(Bytes32.random()), UInt256.valueOf(42L),
+ Hash.fromBytes(Bytes32.random()),
+ UInt256.valueOf(42L),
Hash.fromBytes(Bytes32.random()),
emptyList()
)
@@ -51,7 +52,6 @@ internal class LESSubprotocolTest {
@Test
@Throws(Exception::class)
fun supportsLESv2() = runBlocking {
-
val sp = LESSubprotocol(
Dispatchers.Default,
blockchainInformation,
@@ -71,7 +71,6 @@ internal class LESSubprotocolTest {
@Test
@Throws(Exception::class)
fun noSupportForv3() = runBlocking {
-
val sp = LESSubprotocol(
Dispatchers.Default,
blockchainInformation,
diff --git a/les/src/test/kotlin/org/apache/tuweni/les/MessagesTest.kt b/les/src/test/kotlin/org/apache/tuweni/les/MessagesTest.kt
index 706ccc27..c6d1da71 100644
--- a/les/src/test/kotlin/org/apache/tuweni/les/MessagesTest.kt
+++ b/les/src/test/kotlin/org/apache/tuweni/les/MessagesTest.kt
@@ -98,7 +98,8 @@ internal class ReceiptsMessageTest {
listOf(
listOf(
TransactionReceipt(
- Bytes32.random(), 3,
+ Bytes32.random(),
+ 3,
LogsBloomFilter.compute(
logsList
),
diff --git a/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/BranchNode.kt b/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/BranchNode.kt
index 821f5211..dc6dcbfa 100644
--- a/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/BranchNode.kt
+++ b/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/BranchNode.kt
@@ -29,7 +29,7 @@ internal class BranchNode<V>(
private val children: List<Node<V>>,
private val value: V?,
private val nodeFactory: NodeFactory<V>,
- private val valueSerializer: (V) -> Bytes,
+ private val valueSerializer: (V) -> Bytes
) : Node<V> {
companion object {
@@ -38,6 +38,7 @@ internal class BranchNode<V>(
@Volatile
private var rlp: WeakReference<Bytes>? = null
+
@Volatile
private var hash: Bytes32? = null
diff --git a/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/ExtensionNode.kt b/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/ExtensionNode.kt
index 7dca98a9..c28ca78a 100644
--- a/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/ExtensionNode.kt
+++ b/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/ExtensionNode.kt
@@ -25,10 +25,11 @@ import java.lang.ref.WeakReference
internal class ExtensionNode<V>(
private val path: Bytes,
private val child: Node<V>,
- private val nodeFactory: NodeFactory<V>,
+ private val nodeFactory: NodeFactory<V>
) : Node<V> {
@Volatile
private var rlp: WeakReference<Bytes>? = null
+
@Volatile
private var hash: Bytes32? = null
diff --git a/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/LeafNode.kt b/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/LeafNode.kt
index 8a21daad..71bfdcb3 100644
--- a/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/LeafNode.kt
+++ b/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/LeafNode.kt
@@ -26,7 +26,7 @@ internal class LeafNode<V>(
private val path: Bytes,
private val value: V,
private val nodeFactory: NodeFactory<V>,
- private val valueSerializer: (V) -> Bytes,
+ private val valueSerializer: (V) -> Bytes
) : Node<V> {
@Volatile
private var rlp: WeakReference<Bytes>? = null
diff --git a/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/StoredMerklePatriciaTrie.kt b/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/StoredMerklePatriciaTrie.kt
index 53ef190f..32e7fa18 100644
--- a/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/StoredMerklePatriciaTrie.kt
+++ b/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/StoredMerklePatriciaTrie.kt
@@ -155,7 +155,7 @@ class StoredMerklePatriciaTrie<V> : MerkleTrie<Bytes, V> {
storage: MerkleStorage,
rootHash: Bytes32,
valueSerializer: (V) -> Bytes,
- valueDeserializer: (Bytes) -> V,
+ valueDeserializer: (Bytes) -> V
) {
this.storage = storage
this.nodeFactory = StoredNodeFactory(storage, valueSerializer, valueDeserializer)
diff --git a/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/StoredNode.kt b/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/StoredNode.kt
index b2669cfc..058ad461 100644
--- a/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/StoredNode.kt
+++ b/merkle-trie/src/main/kotlin/org/apache/tuweni/trie/StoredNode.kt
@@ -31,6 +31,7 @@ import java.util.concurrent.atomic.AtomicReference
internal class StoredNode<V> : Node<V>, CoroutineScope {
private val nodeFactory: StoredNodeFactory<V>
private val hash: Bytes32
+
@Volatile
private var loaded: SoftReference<Node<V>>? = null
private val loader = AtomicReference<Deferred<Node<V>>>()
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 772fd7e1..9f143369 100644
--- a/metrics/src/main/kotlin/org/apache/tuweni/metrics/MetricsService.kt
+++ b/metrics/src/main/kotlin/org/apache/tuweni/metrics/MetricsService.kt
@@ -41,7 +41,7 @@ class MetricsService(
enablePrometheus: Boolean = true,
enableGrpcPush: Boolean = true,
grpcEndpoint: String = "http://localhost:4317",
- grpcTimeout: Long = 2000,
+ grpcTimeout: Long = 2000
) {
companion object {
diff --git a/scuttlebutt-client-lib/src/main/kotlin/org/apache/tuweni/scuttlebutt/lib/FeedService.kt b/scuttlebutt-client-lib/src/main/kotlin/org/apache/tuweni/scuttlebutt/lib/FeedService.kt
index 4d057262..dc22e34d 100644
--- a/scuttlebutt-client-lib/src/main/kotlin/org/apache/tuweni/scuttlebutt/lib/FeedService.kt
+++ b/scuttlebutt-client-lib/src/main/kotlin/org/apache/tuweni/scuttlebutt/lib/FeedService.kt
@@ -45,6 +45,7 @@ class FeedService(private val multiplexer: Multiplexer) {
companion object {
private val objectMapper = ObjectMapper()
}
+
/**
* Publishes a message to the instance's own scuttlebutt feed, assuming the client established the connection using
* keys authorising it to perform this operation.
diff --git a/scuttlebutt-client-lib/src/main/kotlin/org/apache/tuweni/scuttlebutt/lib/ScuttlebuttClientFactory.kt b/scuttlebutt-client-lib/src/main/kotlin/org/apache/tuweni/scuttlebutt/lib/ScuttlebuttClientFactory.kt
index f4f5c9c0..0349c6e8 100644
--- a/scuttlebutt-client-lib/src/main/kotlin/org/apache/tuweni/scuttlebutt/lib/ScuttlebuttClientFactory.kt
+++ b/scuttlebutt-client-lib/src/main/kotlin/org/apache/tuweni/scuttlebutt/lib/ScuttlebuttClientFactory.kt
@@ -50,7 +50,7 @@ object ScuttlebuttClientFactory {
host: String,
port: Int,
keyPair: Signature.KeyPair?,
- serverPublicKey: Signature.PublicKey?,
+ serverPublicKey: Signature.PublicKey?
): AsyncResult<ScuttlebuttClient> {
return fromNetWithNetworkKey(vertx, host, port, keyPair, serverPublicKey, DEFAULT_NETWORK)
}
@@ -73,11 +73,12 @@ object ScuttlebuttClientFactory {
port: Int,
keyPair: Signature.KeyPair?,
serverPublicKey: Signature.PublicKey?,
- networkIdentifier: Bytes32?,
+ networkIdentifier: Bytes32?
): AsyncResult<ScuttlebuttClient> {
val secureScuttlebuttVertxClient = SecureScuttlebuttVertxClient(
vertx,
- keyPair!!, networkIdentifier!!
+ keyPair!!,
+ networkIdentifier!!
)
return secureScuttlebuttVertxClient
.connectTo(
@@ -113,11 +114,12 @@ object ScuttlebuttClientFactory {
vertx: Vertx,
keyPair: Signature.KeyPair?,
invite: Invite,
- networkIdentifier: Bytes32?,
+ networkIdentifier: Bytes32?
): AsyncResult<ScuttlebuttClient> {
val secureScuttlebuttVertxClient = SecureScuttlebuttVertxClient(
vertx,
- keyPair!!, networkIdentifier!!
+ keyPair!!,
+ networkIdentifier!!
)
return secureScuttlebuttVertxClient
.connectTo(
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 22480b2e..73cb9f70 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
@@ -36,6 +36,7 @@ class FeedValue(val previous: String, val author: Author, val sequence: Long, va
companion object {
private val mapper = ObjectMapper()
}
+
/**
* The message content as a JSON string.
*
diff --git a/scuttlebutt-discovery/src/integrationTest/kotlin/org/apache/tueni/scuttlebutt/discovery/ScuttlebuttLocalDiscoveryServiceTest.kt b/scuttlebutt-discovery/src/integrationTest/kotlin/org/apache/tueni/scuttlebutt/discovery/ScuttlebuttLocalDiscoveryServiceTest.kt
index a9561ccc..8daddc23 100644
--- a/scuttlebutt-discovery/src/integrationTest/kotlin/org/apache/tueni/scuttlebutt/discovery/ScuttlebuttLocalDiscoveryServiceTest.kt
+++ b/scuttlebutt-discovery/src/integrationTest/kotlin/org/apache/tueni/scuttlebutt/discovery/ScuttlebuttLocalDiscoveryServiceTest.kt
@@ -69,7 +69,8 @@ internal class ScuttlebuttLocalDiscoveryServiceTest {
) {
ScuttlebuttLocalDiscoveryService(
vertx,
- 8008, 0,
+ 8008,
+ 0,
"127.0.0.1",
"10.0.0.0"
)
diff --git a/scuttlebutt-discovery/src/main/kotlin/org/apache/tuweni/scuttlebutt/discovery/LocalIdentity.kt b/scuttlebutt-discovery/src/main/kotlin/org/apache/tuweni/scuttlebutt/discovery/LocalIdentity.kt
index 73428301..904d6e4e 100644
--- a/scuttlebutt-discovery/src/main/kotlin/org/apache/tuweni/scuttlebutt/discovery/LocalIdentity.kt
+++ b/scuttlebutt-discovery/src/main/kotlin/org/apache/tuweni/scuttlebutt/discovery/LocalIdentity.kt
@@ -50,11 +50,13 @@ class LocalIdentity(val addr: InetSocketAddress, val id: Identity) {
val result = regexpPattern.matcher(str)
return if (!result.matches()) {
null
- } else LocalIdentity(
- result.group(1),
- result.group(2),
- Identity.fromPublicKey(Signature.PublicKey.fromBytes(Bytes.fromBase64String(result.group(3))))
- )
+ } else {
+ LocalIdentity(
+ result.group(1),
+ result.group(2),
+ Identity.fromPublicKey(Signature.PublicKey.fromBytes(Bytes.fromBase64String(result.group(3))))
+ )
+ }
}
}
diff --git a/scuttlebutt-discovery/src/main/kotlin/org/apache/tuweni/scuttlebutt/discovery/ScuttlebuttLocalDiscoveryService.kt b/scuttlebutt-discovery/src/main/kotlin/org/apache/tuweni/scuttlebutt/discovery/ScuttlebuttLocalDiscoveryService.kt
index f5f9431d..1464eccb 100644
--- a/scuttlebutt-discovery/src/main/kotlin/org/apache/tuweni/scuttlebutt/discovery/ScuttlebuttLocalDiscoveryService.kt
+++ b/scuttlebutt-discovery/src/main/kotlin/org/apache/tuweni/scuttlebutt/discovery/ScuttlebuttLocalDiscoveryService.kt
@@ -49,7 +49,7 @@ class ScuttlebuttLocalDiscoveryService(
private val broadcastPort: Int,
private val listenNetworkInterface: String,
private val multicastAddress: String,
- private val validateMulticast: Boolean = true,
+ private val validateMulticast: Boolean = true
) {
companion object {
@@ -82,7 +82,8 @@ class ScuttlebuttLocalDiscoveryService(
datagramPacket
)
}.listen(
- listenPort, listenNetworkInterface
+ listenPort,
+ listenNetworkInterface
).await()
timerId = vertx.setPeriodic(60000) { broadcast() }
}
@@ -109,7 +110,9 @@ class ScuttlebuttLocalDiscoveryService(
fun broadcast() {
for (id in identities) {
udpSocket!!.send(
- id.toCanonicalForm(), broadcastPort, multicastAddress
+ id.toCanonicalForm(),
+ broadcastPort,
+ multicastAddress
) { res: AsyncResult<Void?> ->
if (res.failed()) {
logger.error(res.cause().message, res.cause())
diff --git a/stratum/proxy/src/main/kotlin/org/apache/tuweni/stratum/StratumServerApp.kt b/stratum/proxy/src/main/kotlin/org/apache/tuweni/stratum/StratumServerApp.kt
index 2cc25090..222ae1e7 100644
--- a/stratum/proxy/src/main/kotlin/org/apache/tuweni/stratum/StratumServerApp.kt
+++ b/stratum/proxy/src/main/kotlin/org/apache/tuweni/stratum/StratumServerApp.kt
@@ -48,7 +48,9 @@ fun main(args: Array<String>) {
val idCounter = AtomicLong(0)
val seedReference = AtomicReference<Bytes32>()
val server = StratumServer(
- vertx, port = port, networkInterface = "0.0.0.0",
+ vertx,
+ port = port,
+ networkInterface = "0.0.0.0",
submitCallback = { solution ->
logger.info("Got solution $solution")
withContext(client.coroutineContext) {
@@ -69,7 +71,8 @@ fun main(args: Array<String>) {
resp.result == true
}
},
- seedSupplier = { seedReference.get() }, sslOptions = null,
+ seedSupplier = { seedReference.get() },
+ sslOptions = null
)
runBlocking {
server.start()
diff --git a/stratum/server/src/main/kotlin/org/apache/tuweni/stratum/server/StratumConnection.kt b/stratum/server/src/main/kotlin/org/apache/tuweni/stratum/server/StratumConnection.kt
index 4c64a46f..43615c06 100644
--- a/stratum/server/src/main/kotlin/org/apache/tuweni/stratum/server/StratumConnection.kt
+++ b/stratum/server/src/main/kotlin/org/apache/tuweni/stratum/server/StratumConnection.kt
@@ -29,7 +29,7 @@ class StratumConnection(
val closeHandle: (Boolean) -> Unit,
val sender: (String) -> Unit,
val name: String,
- val threshold: Int = 3,
+ val threshold: Int = 3
) {
companion object {
diff --git a/stratum/server/src/main/kotlin/org/apache/tuweni/stratum/server/StratumProtocol.kt b/stratum/server/src/main/kotlin/org/apache/tuweni/stratum/server/StratumProtocol.kt
index 97174bc5..0a2dbd50 100644
--- a/stratum/server/src/main/kotlin/org/apache/tuweni/stratum/server/StratumProtocol.kt
+++ b/stratum/server/src/main/kotlin/org/apache/tuweni/stratum/server/StratumProtocol.kt
@@ -81,7 +81,7 @@ class Stratum1Protocol(
private val subscriptionIdCreator: () -> String = { createSubscriptionID() },
private val submitCallback: suspend (PoWSolution) -> (Boolean),
private val seedSupplier: () -> Bytes32,
- private val coroutineContext: CoroutineContext,
+ private val coroutineContext: CoroutineContext
) : StratumProtocol {
private var currentInput: PoWInput? = null
private val activeConnections: MutableList<StratumConnection> = ArrayList()
@@ -224,7 +224,7 @@ class Stratum1Protocol(
class Stratum1EthProxyProtocol(
private val submitCallback: suspend (PoWSolution) -> Boolean,
private val seedSupplier: () -> Bytes32,
- private val coroutineContext: CoroutineContext,
+ private val coroutineContext: CoroutineContext
) : StratumProtocol {
private val activeConnections: MutableList<StratumConnection> = ArrayList()
@@ -333,7 +333,7 @@ class Stratum1EthProxyProtocol(
fun handleHashrateSubmit(
mapper: JsonMapper,
conn: StratumConnection,
- message: JsonRpcRequest,
+ message: JsonRpcRequest
) {
val response = mapper.writeValueAsString(
JsonRpcSuccessResponse(
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 fc4b353a..39008bb5 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
@@ -40,8 +40,12 @@ import kotlin.coroutines.CoroutineContext
fun main() = runBlocking {
val selfSignedCertificate = SelfSignedCertificate.create()
val server = StratumServer(
- Vertx.vertx(), port = 10000, networkInterface = "0.0.0.0", sslOptions = selfSignedCertificate.keyCertOptions(),
- submitCallback = { true }, seedSupplier = { Bytes32.random() },
+ Vertx.vertx(),
+ port = 10000,
+ networkInterface = "0.0.0.0",
+ sslOptions = selfSignedCertificate.keyCertOptions(),
+ submitCallback = { true },
+ seedSupplier = { Bytes32.random() }
)
server.start()
Runtime.getRuntime().addShutdownHook(
@@ -67,7 +71,7 @@ class StratumServer(
seedSupplier: () -> Bytes32,
private val errorThreshold: Int = 3,
denyTimeout: Long = 600000, // 10 minutes in milliseconds
- override val coroutineContext: CoroutineContext = vertx.dispatcher(),
+ override val coroutineContext: CoroutineContext = vertx.dispatcher()
) : CoroutineScope {
companion object {
@@ -114,14 +118,16 @@ class StratumServer(
}
socket.exceptionHandler { e -> logger.error(e.message, e) }
val conn = StratumConnection(
- protocols, closeHandle = { addToDenyList ->
+ protocols,
+ closeHandle = { addToDenyList ->
if (addToDenyList) {
denyList.add(socket.remoteAddress().host())
}
socket.close()
- }, name = name,
+ },
+ name = name,
threshold = errorThreshold,
- sender = { bytes -> socket.write(Buffer.buffer(bytes)) },
+ sender = { bytes -> socket.write(Buffer.buffer(bytes)) }
)
socket.handler(conn::handleBuffer)
socket.closeHandler {
diff --git a/stratum/server/src/test/kotlin/org/apache/tuweni/stratum/server/StratumProtocolTest.kt b/stratum/server/src/test/kotlin/org/apache/tuweni/stratum/server/StratumProtocolTest.kt
index 3aaed4da..2f4ba54b 100644
--- a/stratum/server/src/test/kotlin/org/apache/tuweni/stratum/server/StratumProtocolTest.kt
+++ b/stratum/server/src/test/kotlin/org/apache/tuweni/stratum/server/StratumProtocolTest.kt
@@ -33,7 +33,9 @@ class StratumProtocolTest {
@Test
fun testStratum1CanHandle() {
val protocol = Stratum1Protocol(
- "", submitCallback = { true }, seedSupplier = Bytes32::random,
+ "",
+ submitCallback = { true },
+ seedSupplier = Bytes32::random,
coroutineContext = Dispatchers.Default,
subscriptionIdCreator = { "1234" }
)
@@ -47,7 +49,9 @@ class StratumProtocolTest {
@Test
fun testSendNewWorkStratum1() {
val protocol = Stratum1Protocol(
- "", submitCallback = { true }, seedSupplier = { Bytes32.repeat(1) },
+ "",
+ submitCallback = { true },
+ seedSupplier = { Bytes32.repeat(1) },
coroutineContext = Dispatchers.Default,
subscriptionIdCreator = { "1234" },
jobIdSupplier = { "5678" }
@@ -81,7 +85,9 @@ class StratumProtocolTest {
@Test
fun testGetWorkStratum1NoWork() {
val protocol = Stratum1Protocol(
- "", submitCallback = { true }, seedSupplier = { Bytes32.repeat(1) },
+ "",
+ submitCallback = { true },
+ seedSupplier = { Bytes32.repeat(1) },
coroutineContext = Dispatchers.Default,
subscriptionIdCreator = { "1234" },
jobIdSupplier = { "5678" }
@@ -108,7 +114,9 @@ class StratumProtocolTest {
@Test
fun testGetWorkStratum1() {
val protocol = Stratum1Protocol(
- "", submitCallback = { true }, seedSupplier = Bytes32::random,
+ "",
+ submitCallback = { true },
+ seedSupplier = Bytes32::random,
coroutineContext = Dispatchers.Default,
subscriptionIdCreator = { "1234" }
)
@@ -128,7 +136,7 @@ class StratumProtocolTest {
val protocol = Stratum1EthProxyProtocol(
submitCallback = { true },
seedSupplier = Bytes32::random,
- Dispatchers.Default,
+ Dispatchers.Default
)
val conn = StratumConnection(emptyArray(), {}, {}, "foo")
assertFalse(protocol.canHandle("", conn))
@@ -142,7 +150,7 @@ class StratumProtocolTest {
val protocol = Stratum1EthProxyProtocol(
submitCallback = { true },
seedSupplier = { Bytes32.ZERO },
- Dispatchers.Default,
+ Dispatchers.Default
)
val ref = AtomicReference<String>()
val conn = StratumConnection(emptyArray(), {}, ref::set, "foo")
@@ -160,7 +168,7 @@ class StratumProtocolTest {
val protocol = Stratum1EthProxyProtocol(
submitCallback = { true },
seedSupplier = { Bytes32.ZERO },
- Dispatchers.Default,
+ Dispatchers.Default
)
val ref = AtomicReference<String>()
val conn = StratumConnection(emptyArray(), {}, ref::set, "foo")
@@ -180,7 +188,7 @@ class StratumProtocolTest {
val protocol = Stratum1EthProxyProtocol(
submitCallback = { true },
seedSupplier = { Bytes32.ZERO },
- Dispatchers.Default,
+ Dispatchers.Default
)
val ref = AtomicReference<String>()
protocol.setCurrentWorkTask(PoWInput(UInt256.ZERO, Bytes32.ZERO, 0L))
@@ -204,7 +212,7 @@ class StratumProtocolTest {
val protocol = Stratum1EthProxyProtocol(
submitCallback = { false },
seedSupplier = { Bytes32.ZERO },
- Dispatchers.Default,
+ Dispatchers.Default
)
val ref = AtomicReference<String>()
protocol.setCurrentWorkTask(PoWInput(UInt256.ZERO, Bytes32.ZERO, 0L))
@@ -231,7 +239,7 @@ class StratumProtocolTest {
val protocol = Stratum1EthProxyProtocol(
submitCallback = { false },
seedSupplier = { Bytes32.ZERO },
- Dispatchers.Default,
+ Dispatchers.Default
)
val ref = AtomicReference<String>()
protocol.setCurrentWorkTask(PoWInput(UInt256.ZERO, Bytes32.ZERO, 0L))
@@ -257,17 +265,17 @@ class StratumProtocolTest {
protocol.handle(
conn,
"""{"method": "eth_submitWork", "id": 4, "params": ["${Bytes.random(8)}","${Bytes.random(32)}","${Bytes.random(32)}"]}
-""".trimMargin()
+ """.trimMargin()
)
protocol.handle(
conn,
"""{"method": "eth_submitWork", "id": 5, "params": ["${Bytes.random(8)}","${Bytes.random(32)}","${Bytes.random(32)}"]}
-""".trimMargin()
+ """.trimMargin()
)
protocol.handle(
conn,
"""{"method": "eth_submitWork", "id": 6, "params": ["${Bytes.random(8)}","${Bytes.random(32)}","${Bytes.random(32)}"]}
-""".trimMargin()
+ """.trimMargin()
)
assertTrue(closeRef.get())
}
@@ -281,7 +289,7 @@ class StratumProtocolTest {
counter == 2
},
seedSupplier = { Bytes32.ZERO },
- Dispatchers.Default,
+ Dispatchers.Default
)
val ref = AtomicReference<String>()
protocol.setCurrentWorkTask(PoWInput(UInt256.ZERO, Bytes32.ZERO, 0L))
@@ -308,17 +316,17 @@ class StratumProtocolTest {
protocol.handle(
conn,
"""{"method": "eth_submitWork", "id": 4, "params": ["${Bytes.random(8)}","${Bytes32.ZERO}","${Bytes.random(32)}"]}
-""".trimMargin()
+ """.trimMargin()
)
protocol.handle(
conn,
"""{"method": "eth_submitWork", "id": 5, "params": ["${Bytes.random(8)}","${Bytes32.ZERO}","${Bytes.random(32)}"]}
-""".trimMargin()
+ """.trimMargin()
)
protocol.handle(
conn,
"""{"method": "eth_submitWork", "id": 6, "params": ["${Bytes.random(8)}","${Bytes32.ZERO}","${Bytes.random(32)}"]}
-""".trimMargin()
+ """.trimMargin()
)
assertFalse(closeRef.get())
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tuweni.apache.org
For additional commands, e-mail: commits-help@tuweni.apache.org