Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coordinator: update besu dependency #475

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/coordinator-build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ concurrency:

jobs:
build-and-publish:
runs-on: gha-runner-scale-set-ubuntu-22.04-amd64-med
runs-on: gha-runner-scale-set-ubuntu-22.04-amd64-large
name: Coordinator build
env:
COMMIT_TAG: ${{ inputs.commit_tag }}
Expand All @@ -78,7 +78,7 @@ jobs:
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 #v4.2.1
- name: Build dist
run: |
./gradlew coordinator:app:installDist --no-daemon
./gradlew coordinator:app:installDist
- name: Login to Docker Hub
if: ${{ env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != '' }}
uses: docker/login-action@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import kotlinx.datetime.Clock
import net.consensys.linea.contract.AsyncFriendlyTransactionManager
import net.consensys.linea.jsonrpc.JsonRpcErrorResponseException
import net.consensys.linea.testing.filesystem.getPathTo
import net.consensys.toULong
import org.apache.logging.log4j.LogManager
Expand Down Expand Up @@ -136,35 +137,38 @@ private open class WhaleBasedAccountManager(
(0..numberOfAccounts).map {
val randomPrivKey = Bytes.random(32).toHexString().replace("0x", "")
val newAccount = Account(randomPrivKey, Credentials.create(randomPrivKey).address)
val transferResult = whaleTxManager.sendTransaction(
/*gasPrice*/ 300_000_000.toBigInteger(),
/*gasLimit*/ 21000.toBigInteger(),
newAccount.address,
"",
initialBalanceWei
)
if (transferResult.hasError()) {
val transactionHash = try {
retry {
whaleTxManager.sendTransaction(
/*gasPrice*/ 300_000_000.toBigInteger(),
/*gasLimit*/ 21000.toBigInteger(),
newAccount.address,
"",
initialBalanceWei
)
}
} catch (e: Exception) {
val accountBalance =
web3jClient.ethGetBalance(whaleAccount.address, DefaultBlockParameterName.LATEST).send().result
throw RuntimeException(
"Failed to send funds from accAddress=${whaleAccount.address}, " +
"accBalance=$accountBalance, " +
"accPrivKey=0x...${whaleAccount.privateKey.takeLast(8)}, " +
"error: ${transferResult.error.asString()}"
"error: ${e.message}"
)
}
newAccount to transferResult
newAccount to transactionHash
}
}
result.forEach { (account, transferTx) ->
result.forEach { (account, transactionHash) ->
log.debug(
"Waiting for account funding: newAccount={} txHash={} whaleAccount={}",
account.address,
transferTx.transactionHash,
transactionHash,
whaleAccount.address
)
web3jClient.waitForTxReceipt(
transferTx.transactionHash,
transactionHash,
expectedStatus = "0x1",
timeout = 40.seconds,
pollingInterval = 500.milliseconds
Expand All @@ -180,10 +184,6 @@ private open class WhaleBasedAccountManager(
return result.map { it.first }
}

fun Response.Error.asString(): String {
return "Response.Error(code=$code, message=$message)"
}

override fun getTransactionManager(account: Account): AsyncFriendlyTransactionManager {
return getTransactionManager(
web3jClient,
Expand Down Expand Up @@ -231,3 +231,32 @@ object L2AccountManager : AccountManager by WhaleBasedAccountManager(
genesisFile = getPathTo(System.getProperty("L2_GENESIS", "docker/config/linea-local-dev-genesis.json")),
log = LogManager.getLogger(L2AccountManager::class.java)
)

fun <R, T : Response<R>> retry(
timeout: Duration = 30.seconds,
retryInterval: Duration = 1.seconds,
action: () -> T
): R {
val start = Clock.System.now()
var response: T? = null
var latestError: Exception? = null
do {
try {
response = action()
if (response.hasError()) {
Thread.sleep(retryInterval.inWholeMilliseconds)
}
} catch (e: Exception) {
latestError = e
Thread.sleep(retryInterval.inWholeMilliseconds)
}
} while (response?.hasError() == true && Clock.System.now() < start + timeout)

return response?.let {
if (it.hasError()) {
throw JsonRpcErrorResponseException(it.error.code, it.error.message, it.error.data)
} else {
it.result
}
} ?: throw latestError!!
}
2 changes: 1 addition & 1 deletion docker/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ services:
coordinator:
hostname: coordinator
container_name: coordinator
image: consensys/linea-coordinator:${COORDINATOR_TAG:-bb7cd3d}
image: consensys/linea-coordinator:${COORDINATOR_TAG:-a5119c4}
platform: linux/amd64
profiles: [ "l2", "debug" ]
depends_on:
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jreleaser = {id = "org.jreleaser", version = "1.15.0"}
jreleaser = { group = "org.jreleaser", name = "jreleaser-gradle-plugin", version = "1.15.0" }

[versions]
besu = "24.10.0"
besu = "24.12.2"
caffeine = "3.1.6"
hoplite = "2.7.5"
jackson = "2.18.0"
Expand Down
Loading