Skip to content

Commit

Permalink
Merge branch 'main' into fix/ts-lib-build-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jpnovais authored Sep 12, 2024
2 parents 0f45d7d + 0cc4d6d commit d9e2c6a
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 167 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-nodejs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
node-version:
description: 'The version of node to use'
required: true
default: '18.15.0'
default: '20.17.0'
pnpm-version:
description: 'The version of pnpm to use'
required: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,59 +1,17 @@
import groovy.json.JsonSlurper

import java.nio.file.FileAlreadyExistsException
import java.nio.file.Files
import java.nio.file.Path
import java.time.Duration
import java.time.Instant

static def downloadAndParseJson(
String url,
Map<String, String> headers = [:]
) {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection()
connection.requestMethod = 'GET'
connection.setRequestProperty('Accept', 'application/json')
headers.each { key, value ->
connection.setRequestProperty(key, value)
}
connection.connect()
if (connection.responseCode == HttpURLConnection.HTTP_OK) {
def jsonResponse = connection.inputStream.text
def jsonSlurper = new JsonSlurper()
return jsonSlurper.parseText(jsonResponse)
} else {
throw new GradleException("Failed load JSON from $url HTTP error code: ${connection.responseCode}")
}
}


static def getReleaseAsset(
String releaseTagName,
String githubAccessToken
) {
def urlStr = 'https://api.github.com/repos/ConsenSys/zkevm-monorepo/releases'
def json = downloadAndParseJson(urlStr, ['Authorization': "token ${githubAccessToken}"])
def release = json.find { it.tag_name == releaseTagName }
if (release == null) {
def releases = json.collect { it.tag_name }
throw new GradleException("Release ${releaseTagName} not found! releases: ${releases}")
}
if (release.assets.size() == 0) {
throw new GradleException("Release ${releaseTagName} has no assets!")
}
def asset = release.assets.find { it.name.contains(releaseTagName) }
//println(JsonOutput.prettyPrint(JsonOutput.toJson(asset)))
asset
}

void downloadFileUsingWget(
String url,
String githubAccessToken,
String outputFilePath
) {
println("Downloading ${url.replace(githubAccessToken, "*****")} into ${outputFilePath}")
def command = "curl -L -H 'Accept:application/octet-stream' -u ${githubAccessToken}: -o ${outputFilePath} ${url}"
// println("# " + command)
println("Downloading ${url} into ${outputFilePath}")

String command = "curl -L -H 'Accept:application/octet-stream' -o ${outputFilePath} ${url}"
// println("# " + command)

def execResult = exec {
commandLine 'bash', '-c', command
Expand All @@ -72,12 +30,11 @@ ext.architectureResourceDirMapping = [
"linux_x86_64" : "linux-x86-64"
]

private String downloadReleaseAsset(
private String downloadAssetIfNotPresent(
String libsZipUrl,
String releaseTag,
String outputDir,
String githubAccessToken
String outputDir
) {
def releaseAssetJsonInfo = getReleaseAsset(releaseTag.toString(), githubAccessToken)
def fileName = releaseTag + ".zip"
def outputFilePath = Path.of(outputDir).resolve(fileName)

Expand All @@ -92,7 +49,7 @@ private String downloadReleaseAsset(
}
}

downloadFileUsingWget(releaseAssetJsonInfo.url.toString(), githubAccessToken, outputFilePath.toString())
downloadFileUsingWget(libsZipUrl, outputFilePath.toString())

return outputFilePath.toString()
}
Expand Down Expand Up @@ -156,16 +113,12 @@ def lazyUnzipWithRetry(
}
}

def downloadReleaseAndExtractToResources(
String releaseTag,
String libName,
String outputDir,
String githubAccessToken
def extractLibToResources(
Path zipFile,
Path outputUnzipDir,
String libName
) {
def outputUnzipDir = Path.of(outputDir).resolve(releaseTag)
def outputFile = downloadReleaseAsset(releaseTag, outputDir, githubAccessToken)
lazyUnzipWithRetry(Path.of(outputFile), outputUnzipDir, Duration.ofSeconds(60))

lazyUnzipWithRetry(zipFile, outputUnzipDir, Duration.ofSeconds(60))
fileTree(outputUnzipDir.toFile())
.filter { it.name.contains(libName) && (it.name.endsWith(".so") || it.name.endsWith(".dylib")) }
.each { File file ->
Expand All @@ -190,14 +143,22 @@ def downloadReleaseAndExtractToResources(
}
}

ext.fetchLib = {
def downloadZipReleaseAndExtractToResources(
String libsZipUrl,
String releaseTag,
String libName,
String outputDir,
String githubAccessToken = System.getenv("GITHUB_TOKEN")
String outputDir
) {
def zipFile = downloadAssetIfNotPresent(libsZipUrl, releaseTag, outputDir)
def outputUnzipDir = Path.of(outputDir).resolve(releaseTag)
extractLibToResources(Path.of(zipFile), outputUnzipDir, libName)
}

ext.fetchLibFromZip = {
String libsZipUrl,
String libName,
String outputDir
->
if (githubAccessToken == null) {
throw new GradleException("GITHUB_TOKEN is required")
}
downloadReleaseAndExtractToResources(releaseTag, libName, outputDir, githubAccessToken)
def releaseTag = libsZipUrl.split("/").last().replace(".zip", "")
downloadZipReleaseAndExtractToResources(libsZipUrl, releaseTag, libName, outputDir)
}
2 changes: 1 addition & 1 deletion coordinator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.description="Coordinator for Linea" \
org.label-schema.url="https://consensys.io/" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/ConsenSys/zkevm-monorepo" \
org.label-schema.vcs-url="https://github.com/ConsenSys/linea-monorepo" \
org.label-schema.vendor="ConsenSys" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal fun buildSubmitBlobsFunction(
/*snarkHash*/ blobCompressionProof.snarkHash
)

LineaRollup.BlobSubmissionData(
BlobSubmissionData(
/*submissionData*/ supportingSubmissionData,
/*dataEvaluationClaim*/ BigInteger(blobCompressionProof.expectedY),
/*kzgCommitment*/ blobCompressionProof.commitment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ class L2MessageServiceGasLimitEstimate(
FUNC_ANCHORL1L2MESSAGEHASHES,
listOf<Type<*>>(
DynamicArray(
org.web3j.abi.datatypes.generated.Bytes32::class.java,
messageHashes.map { org.web3j.abi.datatypes.generated.Bytes32(it) }
Bytes32::class.java,
messageHashes.map { Bytes32(it) }
),
Uint256(startingMessageNumber),
Uint256(finalMessageNumber),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import tech.pegasys.teku.infrastructure.async.SafeFuture
* WARNING: Existing mappings should not chane. Otherwise, can break production New One can be added
* though.
*/
public fun batchStatusToDbValue(status: Batch.Status): Int {
fun batchStatusToDbValue(status: Batch.Status): Int {
// using manual mapping to catch errors at compile time instead of runtime
return when (status) {
Batch.Status.Finalized -> 1
Expand Down
6 changes: 3 additions & 3 deletions docker/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ services:
- ../tmp/linea-besu-sequencer/plugins:/linea-besu-sequencer/

linea-besu-sequencer-finalized-tag-updater-plugin-downloader:
image: badouralix/curl-jq
command: [ "sh", "/finalized-tag-updater-jar-downloader.sh", "${GITHUB_TOKEN}", "0.0.1", "/linea-besu-sequencer" ]
image: busybox:1.36.1
command: [ "sh", "/file-downloader.sh", "https://github.com/Consensys/linea-monorepo/releases/download/finalized-tag-updater-v0.0.2/finalized-tag-updater-v0.0.2.jar", "/linea-besu-sequencer" ]
volumes:
- ./scripts/finalized-tag-updater-jar-downloader.sh:/finalized-tag-updater-jar-downloader.sh:ro
- ./scripts/file-downloader.sh:/file-downloader.sh:ro
- ../tmp/linea-besu-sequencer/plugins:/linea-besu-sequencer/

l2-node:
Expand Down
32 changes: 0 additions & 32 deletions docker/scripts/finalized-tag-updater-jar-downloader.sh

This file was deleted.

4 changes: 2 additions & 2 deletions finalized-tag-updater/jreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project:
description: Finalized Tag Updater Fat Jar
longDescription: Finalized Tag Updater (linea-besu plugin)
links:
homepage: https://github.com/Consensys/zkevm-monorepo
homepage: https://github.com/Consensys/linea-monorepo
authors:
- Linea automations
license: APACHE-2.0
Expand All @@ -28,4 +28,4 @@ distributions:
finalized-tag-updater:
type: SINGLE_JAR
artifacts:
- path: 'build/libs/{{tagName}}.jar'
- path: 'build/libs/{{tagName}}.jar'
29 changes: 2 additions & 27 deletions jvm-libs/blob-compressor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,8 @@ def libsZipDownloadOutputDir = project.parent.layout.buildDirectory.asFile.get()

task downloadNativeLibs {
doLast {
fetchLib("blob-libs-v0.1.0", "blob_compressor", libsZipDownloadOutputDir)
fetchLib("blob-libs-v1.0.1", "blob_compressor", libsZipDownloadOutputDir)
}
}

// GITHUB_TOKEN=ghp_XXX ./gradlew jvm-libs:blob-compressor:downloadNativeLib -PreleaseTag=blob-libs-v0.1.0 -PlibName=blob_compressor
tasks.register('downloadNativeLib') {
def releaseTag
def libName

doLast {
if (project.hasProperty("releaseTag")) {
releaseTag = project.releaseTag
} else {
throw new GradleException("releaseTag is required")
}
if (project.hasProperty("libName")) {
libName = project.libName
} else {
throw new GradleException("libName is required")
}

fetchLib(
releaseTag,
libName,
libsZipDownloadOutputDir
)
fetchLibFromZip("https://github.com/Consensys/linea-monorepo/releases/download/blob-libs-v0.1.0/linea-blob-libs-v0.1.0.zip", "blob_compressor", libsZipDownloadOutputDir)
fetchLibFromZip("https://github.com/Consensys/linea-monorepo/releases/download/blob-libs-v1.0.1/linea-blob-libs-v1.0.1.zip", "blob_compressor", libsZipDownloadOutputDir)
}
}

Expand Down
29 changes: 2 additions & 27 deletions jvm-libs/blob-shnarf-calculator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,8 @@ def libsZipDownloadOutputDir = project.parent.layout.buildDirectory.asFile.get()

task downloadNativeLibs {
doLast {
fetchLib("blob-libs-v0.1.0", "shnarf_calculator", libsZipDownloadOutputDir)
fetchLib("blob-libs-v1.0.1", "shnarf_calculator", libsZipDownloadOutputDir)
}
}

// GITHUB_TOKEN=ghp_XXX ./gradlew jvm-libs:blob-compressor:downloadNativeLib -PreleaseTag=blob-libs-v0.1.0 -PlibName=blob_compressor
tasks.register('downloadNativeLib') {
def releaseTag
def libName

doLast {
if (project.hasProperty("releaseTag")) {
releaseTag = project.releaseTag
} else {
throw new GradleException("releaseTag is required")
}
if (project.hasProperty("libName")) {
libName = project.libName
} else {
throw new GradleException("libName is required")
}

fetchLib(
releaseTag,
libName,
libsZipDownloadOutputDir
)
fetchLibFromZip("https://github.com/Consensys/linea-monorepo/releases/download/blob-libs-v0.1.0/linea-blob-libs-v0.1.0.zip", "shnarf_calculator", libsZipDownloadOutputDir)
fetchLibFromZip("https://github.com/Consensys/linea-monorepo/releases/download/blob-libs-v1.0.1/linea-blob-libs-v1.0.1.zip", "shnarf_calculator", libsZipDownloadOutputDir)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ sealed interface TracingModule {
val name: String
}

/** More info: https://github.com/ConsenSys/zkevm-monorepo/issues/525 */
enum class TracingModuleV1 : TracingModule {
// EMV Module limits
ADD,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "zkevm-monorepo",
"name": "linea-monorepo",
"author": "Consensys Software Inc.",
"engines": {
"node": ">=20",
Expand Down
2 changes: 1 addition & 1 deletion traces-api-facade/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.description="Linea Traces API" \
org.label-schema.url="https://consensys.io/" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/ConsenSys/zkevm-monorepo" \
org.label-schema.vcs-url="https://github.com/ConsenSys/linea-monorepo" \
org.label-schema.vendor="ConsenSys" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0"
Expand Down

0 comments on commit d9e2c6a

Please sign in to comment.