Skip to content

Commit

Permalink
staterecovery: fix cli options regression (#567)
Browse files Browse the repository at this point in the history
* staterecovery: fix cli options regression & add CI jobs
  • Loading branch information
jpnovais authored Jan 20, 2025
1 parent 6c8a282 commit d01ef99
Show file tree
Hide file tree
Showing 61 changed files with 430 additions and 505 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
name: Filter commit changes
outputs:
coordinator: ${{ steps.filter.outputs.coordinator }}
staterecovery: ${{ steps.filter.outputs.staterecovery }}
postman: ${{ steps.filter.outputs.postman }}
prover: ${{ steps.filter.outputs.prover }}
traces-api-facade: ${{ steps.filter.outputs.traces-api-facade }}
Expand Down Expand Up @@ -50,6 +51,18 @@ jobs:
- 'docker/compose.yml'
- 'docker/compose-local-dev.overrides.yml'
- 'docker/compose-local-dev-traces-v2.overrides.yml'
staterecovery:
- 'state-recovery/**'
- 'buildSrc/**'
- 'jvm-libs/**'
- 'gradle/**'
- 'build.gradle'
- 'gradle.properties'
- 'settings.gradle'
- '.github/workflows/staterecovery-*.yml'
- '.github/workflows/main.yml'
- '.github/workflows/reuse-*.yml'
- 'e2e/**'
postman:
- 'postman/**'
- 'sdk/**'
Expand Down Expand Up @@ -172,6 +185,7 @@ jobs:
with:
commit_tag: ${{ needs.store-image-name-and-tags.outputs.commit_tag }}
coordinator_changed: ${{ needs.filter-commit-changes.outputs.coordinator }}
staterecovery_changed: ${{ needs.filter-commit-changes.outputs.staterecovery }}
postman_changed: ${{ needs.filter-commit-changes.outputs.postman }}
prover_changed: ${{ needs.filter-commit-changes.outputs.prover }}
traces_api_facade_changed: ${{ needs.filter-commit-changes.outputs.traces-api-facade }}
Expand Down
87 changes: 87 additions & 0 deletions .github/workflows/staterecovery-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: staterecovery-testing

on:
workflow_call:
inputs:
commit_tag:
required: true
type: string
secrets:
DOCKERHUB_USERNAME:
required: false
DOCKERHUB_TOKEN:
required: false

concurrency:
group: staterecovery-testing-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
cache-docker-images:
uses: ./.github/workflows/cache-docker-images.yml
secrets: inherit
run-tests:
env:
COMMIT_TAG: ${{ inputs.commit_tag }}
GITHUB_TOKEN: ${{ secrets._GITHUB_TOKEN_RELEASE_ACCESS }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
runs-on: gha-runner-scale-set-ubuntu-22.04-amd64-large
name: Staterecovery tests
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b #v4.5.0
with:
distribution: temurin
java-version: 21
- name: Setup Gradle
# Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 #v4.2.1
- name: Restore cached images
id: restore-cached-images
uses: actions/cache/restore@v4.0.2
with:
path: ~/docker-images
key: cached-images
restore-keys: |
cached-images
- name: Staterecovery - Build and Unit tests
run: |
./gradlew state-recovery:besu-plugin:buildNeeded
# Install pnpm to deploy smart contracts
# FIXME: use web3j to deploy contracts and remove this.
- name: Setup nodejs environment
uses: ./.github/actions/setup-nodejs
with:
pnpm-install-options: '--frozen-lockfile --prefer-offline --filter contracts --ignore-scripts'
- name: Staterecovery - Build plugin shadowJar
run: |
./gradlew state-recovery:besu-plugin:shadowJar
- name: Run integration tests
timeout-minutes: 15
run: |
./gradlew state-recovery:test-cases:integrationTest
- name: Run Jacoco
run: |
./gradlew jacocoRootReport
- name: Upload Jacoco test coverage report
uses: actions/upload-artifact@v4
with:
name: jacocoRootReport-${{ env.COMMIT_TAG }}.xml
if-no-files-found: error
path: |
${{ github.workspace }}/build/reports/jacoco/jacocoRootReport/jacocoRootReport.xml
- name: Upload coverage to Codecov
if: ${{ env.CODECOV_TOKEN != '' }}
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
files: ${{ github.workspace }}/build/reports/jacoco/jacocoRootReport/jacocoRootReport.xml
flags: kotlin
os: linux
name: codecov-staterecovery
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
14 changes: 12 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
coordinator_changed:
required: true
type: string
staterecovery_changed:
required: true
type: string
postman_changed:
required: true
type: string
Expand Down Expand Up @@ -47,11 +50,18 @@ jobs:
transaction-exclusion-api:
uses: ./.github/workflows/transaction-exclusion-api-testing.yml
if: ${{ inputs.transaction_exclusion_api_changed == 'true' }}


staterecovery:
uses: ./.github/workflows/staterecovery-testing.yml
if: ${{ inputs.staterecovery_changed == 'true' }}
with:
commit_tag: ${{ inputs.commit_tag }}
secrets: inherit

# If all jobs are skipped, the workflow will still succeed.
always_succeed:
runs-on: ubuntu-24.04
if: ${{ inputs.coordinator_changed == 'false' && inputs.prover_changed == 'false' && inputs.postman_changed == 'false' && inputs.traces_api_facade_changed == 'false' && inputs.transaction_exclusion_api_changed == 'false' }}
steps:
- name: Ensure Workflow Success
run: echo "All jobs were skipped, but workflow succeeds."
run: echo "All jobs were skipped, but workflow succeeds."
34 changes: 14 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ clean-testnet-folders:
rm -rf tmp/testnet/*

clean-environment:
docker compose -f docker/compose.yml -f docker/compose-local-dev-traces-v2.overrides.yml --profile l1 --profile l2 --profile debug --profile staterecover down || true
docker compose -f docker/compose.yml -f docker/compose-local-dev-traces-v2.overrides.yml --profile l1 --profile l2 --profile debug --profile staterecovery kill -s 9 || true
make clean-local-folders
docker network prune -f
docker volume rm linea-local-dev linea-logs || true # ignore failure if volumes do not exist already
Expand All @@ -47,7 +47,7 @@ start-l2-blockchain-only:
start-whole-environment: COMPOSE_PROFILES:=l1,l2
start-whole-environment:
# docker compose -f docker/compose.yml -f docker/compose-local-dev.overrides.yml build prover
COMPOSE_PROFILES=$(COMPOSE_PROFILES) docker compose -f docker/compose.yml -f docker/compose-local-dev.overrides.yml up -d
L1_GENESIS_TIME=$(get_future_time) COMPOSE_PROFILES=$(COMPOSE_PROFILES) docker compose -f docker/compose.yml -f docker/compose-local-dev.overrides.yml up -d


start-whole-environment-traces-v2: COMPOSE_PROFILES:=l1,l2
Expand Down Expand Up @@ -218,17 +218,22 @@ deploy-contracts-minimal:
cd .. && \
$(MAKE) -j6 deploy-linea-rollup-v$(L1_CONTRACT_VERSION) deploy-l2messageservice

fresh-start-all-staterecover: COMPOSE_PROFILES:=l1,l2,staterecover
fresh-start-all-staterecover: L1_CONTRACT_VERSION:=6
fresh-start-all-staterecover:
fresh-start-all-staterecovery: COMPOSE_PROFILES:=l1,l2,staterecovery
fresh-start-all-staterecovery: L1_CONTRACT_VERSION:=6
fresh-start-all-staterecovery:
make clean-environment
L1_GENESIS_TIME=$(get_future_time) make start-whole-environment-traces-v2 COMPOSE_PROFILES=$(COMPOSE_PROFILES)
$(MAKE) deploy-contracts-minimal L1_CONTRACT_VERSION=$(L1_CONTRACT_VERSION)

fresh-start-staterecover-for-replay-only: COMPOSE_PROFILES:=l1,staterecover
fresh-start-staterecover-for-replay-only:
make clean-environment
L1_GENESIS_TIME=$(get_future_time) make start-whole-environment-traces-v2 COMPOSE_PROFILES=$(COMPOSE_PROFILES)
fresh-start-staterecovery-for-replay-only: COMPOSE_PROFILES:=l1,staterecovery
fresh-start-staterecovery-for-replay-only:
make clean-environment
L1_GENESIS_TIME=$(get_future_time) make start-whole-environment-traces-v2 COMPOSE_PROFILES=$(COMPOSE_PROFILES)

staterecovery-replay-from-genesis: L1_ROLLUP_CONTRACT_ADDRESS:=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
staterecovery-replay-from-genesis:
docker compose -f docker/compose.yml down zkbesu-shomei-sr shomei-sr
L1_ROLLUP_CONTRACT_ADDRESS=$(L1_ROLLUP_CONTRACT_ADDRESS) docker compose -f docker/compose.yml up zkbesu-shomei-sr shomei-sr -d

testnet-start-l2:
docker compose -f docker/compose.yml -f docker/compose-testnet-sync.overrides.yml --profile l2 up -d
Expand Down Expand Up @@ -291,14 +296,3 @@ restart-coordinator:
make stop-coordinator
make start-coordinator

start-traces-api:
mkdir -p tmp/local/logs
mkdir -p tmp/local/traces/raw
./gradlew traces-api:app:run > tmp/local/logs/traces-app.log & echo "$$!" > tmp/local/traces-app.pid

stop-traces-api:
make stop_pid PID_FILE=tmp/local/traces-app.pid

restart-traces-api:
make stop-traces-api
make start-traces-api
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ dockerCompose {
"l1-node-genesis-generator",
"l1-el-node",
"l1-cl-node",
"l2-node",
"blobscan-api",
"blobscan-indexer",
"redis",
Expand All @@ -200,7 +199,7 @@ dockerCompose {
"--profile",
"l2",
"--profile",
"staterecover"
"staterecovery"
]
useComposeFiles = [
"${project.rootDir.path}/docker/compose.yml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import java.math.BigInteger
// this class is mainly intended to be used for testing purposes
class StaticGasProvider(
private val _chainId: Long,
// setting default high values because
// tests suite sends loads of Tx and blobs, causes spikes in gas prices
private val maxFeePerGas: ULong = 22uL.gwei,
private val maxPriorityFeePerGas: ULong = 20uL.gwei,
private val maxFeePerBlobGas: ULong = 1000uL.gwei,
private val gasLimit: ULong = 30_000_000uL
) : AtomicContractEIP1559GasProvider, EIP4844GasProvider {
override fun getEIP1559GasFees(): EIP1559GasFees {
Expand Down Expand Up @@ -54,6 +57,6 @@ class StaticGasProvider(
}

override fun getEIP4844GasFees(): EIP4844GasFees {
return EIP4844GasFees(getEIP1559GasFees(), maxFeePerGas)
return EIP4844GasFees(getEIP1559GasFees(), maxFeePerBlobGas)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package linea.testing

import net.consensys.linea.async.toSafeFuture
import net.consensys.linea.testing.filesystem.getPathTo
import org.apache.logging.log4j.LogManager
import tech.pegasys.teku.infrastructure.async.SafeFuture
import java.io.BufferedReader
import java.io.File
import java.io.InputStreamReader
import kotlin.time.Duration
import kotlin.time.Duration.Companion.minutes

data class CommandResult(
val exitCode: Int,
val stdOut: List<String>,
val stdErr: List<String>
)

object Runner {

fun executeCommand(
command: String,
envVars: Map<String, String> = emptyMap(),
executionDir: File = getPathTo("Makefile").parent.toFile(),
timeout: Duration = 1.minutes
): SafeFuture<CommandResult> {
val log = LogManager.getLogger("net.consensys.zkevm.ethereum.CommandExecutor")
val processBuilder = ProcessBuilder("/bin/sh", "-c", command)
processBuilder.directory(executionDir)

// Set environment variables
val env = processBuilder.environment()
for ((key, value) in envVars) {
env[key] = value
}

val process = processBuilder.start()
val stdOutReader = BufferedReader(InputStreamReader(process.inputStream))
val stdErrorReader = BufferedReader(InputStreamReader(process.errorStream))

// Read the standard output
log.debug(
"going to execute command: dir='{}', command='{}', envVars={} commandProcessId={} processInfo={}",
executionDir,
command,
envVars,
process.pid(),
process.info()
)
process.waitFor(timeout.inWholeMilliseconds, java.util.concurrent.TimeUnit.MILLISECONDS)
val futureResult = process
.onExit()
.thenApply { processResult ->
val stdOutLines = stdOutReader.lines().toList()
val stdErrLines = stdErrorReader.lines().toList()
log.debug(
"command finished: dir='{}', command='{}', exitCode={} envVars={} processId={} threadId={}",
executionDir,
command,
processResult.exitValue(),
envVars,
ProcessHandle.current().pid(),
Thread.currentThread().threadId()
)
log.debug(
"stdout: {}",
stdOutLines.joinToString("\n")
)
log.debug(
"stderr: {}",
stdErrLines.joinToString("\n")
)
CommandResult(processResult.exitValue(), stdOutLines, stdErrLines)
}

return futureResult.toSafeFuture()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package net.consensys.zkevm.ethereum
import build.linea.contract.l1.LineaContractVersion
import com.sksamuel.hoplite.ConfigLoaderBuilder
import com.sksamuel.hoplite.addFileSource
import net.consensys.gwei
import net.consensys.linea.contract.AsyncFriendlyTransactionManager
import net.consensys.linea.contract.EIP1559GasProvider
import net.consensys.linea.contract.LineaRollupAsyncFriendly
Expand Down Expand Up @@ -64,8 +65,9 @@ interface ContractsManager {
transactionManager: AsyncFriendlyTransactionManager,
gasProvider: ContractEIP1559GasProvider = StaticGasProvider(
L1AccountManager.chainId,
maxFeePerGas = 11_000uL,
maxPriorityFeePerGas = 10_000uL,
maxFeePerGas = 55UL.gwei,
maxPriorityFeePerGas = 50UL.gwei,
maxFeePerBlobGas = 1_000UL.gwei,
gasLimit = 1_000_000uL
),
smartContractErrors: SmartContractErrors? = null
Expand Down Expand Up @@ -93,8 +95,9 @@ interface ContractsManager {
transactionManager: AsyncFriendlyTransactionManager,
gasProvider: ContractEIP1559GasProvider = StaticGasProvider(
L1AccountManager.chainId,
maxFeePerGas = 11_000uL,
maxPriorityFeePerGas = 10_000uL,
maxFeePerGas = 55UL.gwei,
maxPriorityFeePerGas = 50UL.gwei,
maxFeePerBlobGas = 1_000UL.gwei,
gasLimit = 1_000_000uL
)
): LineaRollupAsyncFriendly
Expand Down
Loading

0 comments on commit d01ef99

Please sign in to comment.