diff --git a/config/coordinator/log4j2-dev.xml b/config/coordinator/log4j2-dev.xml index f5a86e90..88486e13 100644 --- a/config/coordinator/log4j2-dev.xml +++ b/config/coordinator/log4j2-dev.xml @@ -75,9 +75,6 @@ - - - diff --git a/coordinator/clients/smart-contract-client/src/main/kotlin/net/consensys/linea/contract/l1/Web3JLineaRollupSmartContractClient.kt b/coordinator/clients/smart-contract-client/src/main/kotlin/net/consensys/linea/contract/l1/Web3JLineaRollupSmartContractClient.kt index 59582a96..23afad8c 100644 --- a/coordinator/clients/smart-contract-client/src/main/kotlin/net/consensys/linea/contract/l1/Web3JLineaRollupSmartContractClient.kt +++ b/coordinator/clients/smart-contract-client/src/main/kotlin/net/consensys/linea/contract/l1/Web3JLineaRollupSmartContractClient.kt @@ -2,6 +2,7 @@ package net.consensys.linea.contract.l1 import build.linea.contract.LineaRollupV6 import linea.contract.l1.Web3JLineaRollupSmartContractClientReadOnly +import linea.domain.BlockParameter.Companion.toBlockParameter import linea.domain.gas.GasPriceCaps import linea.kotlin.toULong import linea.web3j.SmartContractErrors @@ -91,9 +92,9 @@ class Web3JLineaRollupSmartContractClient internal constructor( return transactionManager.currentNonce().toULong() } - private fun resetNonce(blockNumber: BigInteger?): SafeFuture { + private fun resetNonce(blockNumber: BigInteger): SafeFuture { return transactionManager - .resetNonce(blockNumber) + .resetNonce(blockNumber.toBlockParameter()) .thenApply { currentNonce() } } diff --git a/jvm-libs/linea/clients/linea-contract-clients/src/main/kotlin/linea/contract/l2/Web3JL2MessageServiceSmartContractClient.kt b/jvm-libs/linea/clients/linea-contract-clients/src/main/kotlin/linea/contract/l2/Web3JL2MessageServiceSmartContractClient.kt index 87d66bb7..3677795b 100644 --- a/jvm-libs/linea/clients/linea-contract-clients/src/main/kotlin/linea/contract/l2/Web3JL2MessageServiceSmartContractClient.kt +++ b/jvm-libs/linea/clients/linea-contract-clients/src/main/kotlin/linea/contract/l2/Web3JL2MessageServiceSmartContractClient.kt @@ -13,7 +13,6 @@ import linea.web3j.ethapi.Web3jEthApiClient import linea.web3j.gas.EIP1559GasProvider import linea.web3j.requestAsync import linea.web3j.transactionmanager.AsyncFriendlyTransactionManager -import net.consensys.linea.async.toSafeFuture import net.consensys.linea.contract.L2MessageService import net.consensys.linea.contract.Web3JContractAsyncHelper import org.apache.logging.log4j.LogManager @@ -157,7 +156,9 @@ class Web3JL2MessageServiceSmartContractClient( override fun getAddress(): String = contractAddress override fun getVersion(): SafeFuture = getSmartContractVersion() - override fun getDeploymentBlock(): SafeFuture { return deploymentBlockNumberProvider() } + override fun getDeploymentBlock(): SafeFuture { + return deploymentBlockNumberProvider() + } override fun getLastAnchoredL1MessageNumber(block: BlockParameter): SafeFuture { return contractClientAtBlock(block, L2MessageService::class.java) @@ -202,14 +203,18 @@ class Web3JL2MessageServiceSmartContractClient( ) return web3jContractHelper - .sendTransactionAfterEthCallAsync( - function = function, - weiValue = BigInteger.ZERO, - gasPriceCaps = null, - ) + .transactionManager + .resetNonce(blockParameter = BlockParameter.Tag.LATEST) + .thenCompose { + web3jContractHelper + .sendTransactionAfterEthCallAsync( + function = function, + weiValue = BigInteger.ZERO, + gasPriceCaps = null, + ) + } .thenApply { response -> response.transactionHash } - .toSafeFuture() } } diff --git a/jvm-libs/linea/web3j-extensions/src/main/kotlin/linea/web3j/transactionmanager/AsyncFriendlyTransactionManager.kt b/jvm-libs/linea/web3j-extensions/src/main/kotlin/linea/web3j/transactionmanager/AsyncFriendlyTransactionManager.kt index 9b736bd1..747a40b0 100644 --- a/jvm-libs/linea/web3j-extensions/src/main/kotlin/linea/web3j/transactionmanager/AsyncFriendlyTransactionManager.kt +++ b/jvm-libs/linea/web3j-extensions/src/main/kotlin/linea/web3j/transactionmanager/AsyncFriendlyTransactionManager.kt @@ -1,5 +1,8 @@ package linea.web3j.transactionmanager +import linea.domain.BlockParameter +import linea.kotlin.toULong +import linea.web3j.domain.toWeb3j import linea.web3j.requestAsync import org.apache.logging.log4j.LogManager import org.web3j.abi.datatypes.Function @@ -7,8 +10,6 @@ import org.web3j.crypto.Blob import org.web3j.crypto.Credentials import org.web3j.crypto.RawTransaction import org.web3j.protocol.Web3j -import org.web3j.protocol.core.DefaultBlockParameter -import org.web3j.protocol.core.DefaultBlockParameterName import org.web3j.protocol.core.RemoteFunctionCall import org.web3j.protocol.core.methods.response.EthSendTransaction import org.web3j.protocol.core.methods.response.TransactionReceipt @@ -66,16 +67,15 @@ class AsyncFriendlyTransactionManager : RawTransactionManager { resetNonce().get() } - fun resetNonce(blockNumber: BigInteger? = null): SafeFuture { - val blockParameter = blockNumber - ?.let { DefaultBlockParameter.valueOf(blockNumber) } - ?: DefaultBlockParameterName.LATEST - + fun resetNonce(blockParameter: BlockParameter = BlockParameter.Tag.LATEST): SafeFuture { return web3j.ethGetTransactionCount( fromAddress, - blockParameter, + blockParameter.toWeb3j(), ) - .requestAsync { setNonce(it.transactionCount) } + .requestAsync { + setNonce(it.transactionCount) + it.transactionCount.toULong() + } } fun currentNonce(): BigInteger {