diff --git a/buildkite/scripts/tests/rosetta-block-race-test.sh b/buildkite/scripts/tests/rosetta-block-race-test.sh new file mode 100755 index 000000000000..06fb2b523894 --- /dev/null +++ b/buildkite/scripts/tests/rosetta-block-race-test.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Main purpose of this is script is to wrap around rosetta-block-race.sh +# So env vars from docker buildkite step are passed down to the script + +LEDGER_URL="https://storage.googleapis.com/o1labs-ci-test-data/ledgers/single-bp-ledger.tar" +LEDGER_DIR="ledger" + +echo "Downloading&extracting ledger archive from $LEDGER_URL ..." +curl -L "$LEDGER_URL" | tar -x -C "$LEDGER_DIR" + +chmod 700 "$LEDGER_DIR" + +sudo apt-get update +sudo apt-get install -y python3 + +./scripts/rosetta/test-block-race.sh \ + --mina-exe /usr/local/bin/mina \ + --archive-exe /usr/local/bin/mina-archive \ + --rosetta-exe /usr/local/bin/mina-rosetta \ + --postgres-uri ${PG_CONN} \ + --ledger ${LEDGER_DIR} diff --git a/buildkite/src/Command/RosettaBlockRaceTest.dhall b/buildkite/src/Command/RosettaBlockRaceTest.dhall new file mode 100644 index 000000000000..5e9fa7ef7fcc --- /dev/null +++ b/buildkite/src/Command/RosettaBlockRaceTest.dhall @@ -0,0 +1,40 @@ +let Artifacts = ../Constants/Artifacts.dhall + +let BuildFlags = ../Constants/BuildFlags.dhall + +let Command = ./Base.dhall + +let Size = ./Size.dhall + +let RunWithPostgres = ./RunWithPostgres.dhall + +let key = "rosetta-block-race-test" + +in { step = + \(dependsOn : List Command.TaggedKey.Type) + -> Command.build + Command.Config::{ + , commands = + [ RunWithPostgres.runInDockerWithPostgresConn + ([] : List Text) + ( Some + ( RunWithPostgres.ScriptOrArchive.OnlineTarGzDump + "https://storage.googleapis.com/mina-archive-dumps/mainnet-archive-dump-2025-11-11_0000.sql.tar.gz" + ) + ) + ( Artifacts.fullDockerTag + Artifacts.Tag::{ + , artifact = Artifacts.Type.FunctionalTestSuite + , buildFlags = BuildFlags.Type.Instrumented + } + ) + ( "./buildkite/scripts/tests/rosetta-block-race-test.sh " + ++ "&& ./buildkite/scripts/upload-partial-coverage-data.sh ${key}" + ) + ] + , label = "Rosetta: Rosetta Block Race test" + , key = key + , target = Size.Large + , depends_on = dependsOn + } + } diff --git a/buildkite/src/Command/RunWithPostgres.dhall b/buildkite/src/Command/RunWithPostgres.dhall index 45dbdc3c2f69..11f298b68470 100644 --- a/buildkite/src/Command/RunWithPostgres.dhall +++ b/buildkite/src/Command/RunWithPostgres.dhall @@ -58,7 +58,10 @@ let ContainerImages = ../Constants/ContainerImages.dhall let ScriptOrArchive : Type - = < Script : Text | Archive : { Script : Text, Archive : Text } > + = < Script : Text + | Archive : { Script : Text, Archive : Text } + | OnlineTarGzDump : Text + > let runInDockerWithPostgresConn : List Text -> Optional ScriptOrArchive -> Text -> Text -> Cmd.Type @@ -116,6 +119,11 @@ let runInDockerWithPostgresConn -> [ "tar -xzf ${archive.Archive}" , "docker exec ${postgresDockerName} find /workdir -name \"${archive.Script}\" -exec psql ${pg_conn} -f {} \\;" ] + , OnlineTarGzDump = + \(url : Text) + -> [ "curl -sSL ${url} | tar -xz" + , "docker exec ${postgresDockerName} find /workdir -name \"*.sql\" -exec psql ${pg_conn} -f {} \\;" + ] } script , None = [] : List Text diff --git a/buildkite/src/Constants/DebianVersions.dhall b/buildkite/src/Constants/DebianVersions.dhall index e263a0bc4b31..d229f5f99251 100644 --- a/buildkite/src/Constants/DebianVersions.dhall +++ b/buildkite/src/Constants/DebianVersions.dhall @@ -83,6 +83,9 @@ let minimalDirtyWhen = , S.strictlyStart (S.contains "scripts/docker") , S.exactly "buildkite/scripts/build-artifact" "sh" , S.exactly "buildkite/scripts/version-linter" "sh" + , S.strictlyStart (S.contains "buildkite/scripts/tests") + , S.strictlyStart (S.contains "scripts/rosetta") + , S.exactly "scripts/rosetta/test-block-race" "sh" , S.exactly "scripts/version-linter" "py" , S.exactly "buildkite/scripts/version-linter-patch-missing-type-shapes" diff --git a/buildkite/src/Jobs/Test/RosettaBlockRaceTest.dhall b/buildkite/src/Jobs/Test/RosettaBlockRaceTest.dhall new file mode 100644 index 000000000000..d3ca869e4ee5 --- /dev/null +++ b/buildkite/src/Jobs/Test/RosettaBlockRaceTest.dhall @@ -0,0 +1,44 @@ +let S = ../../Lib/SelectFiles.dhall + +let Pipeline = ../../Pipeline/Dsl.dhall + +let PipelineTag = ../../Pipeline/Tag.dhall + +let JobSpec = ../../Pipeline/JobSpec.dhall + +let Artifacts = ../../Constants/Artifacts.dhall + +let Dockers = ../../Constants/DockerVersions.dhall + +let BuildFlags = ../../Constants/BuildFlags.dhall + +let RosettaBlockRaceTest = ../../Command/RosettaBlockRaceTest.dhall + +let dependsOn = + Dockers.dependsOn + Dockers.DepsSpec::{ + , artifact = Artifacts.Type.FunctionalTestSuite + , buildFlags = BuildFlags.Type.Instrumented + } + +in Pipeline.build + Pipeline.Config::{ + , spec = JobSpec::{ + , dirtyWhen = + [ S.strictlyStart (S.contains "src") + , S.exactly "scripts/rosetta/test-block-race-with-data" "sh" + , S.exactly "scripts/rosetta/test-block-race" "sh" + , S.exactly "buildkite/scripts/tests/rosetta-block-race-test" "sh" + , S.exactly "buildkite/src/Jobs/Test/RosettaBlockRaceTest" "dhall" + , S.exactly "buildkite/src/Command/RosettaBlockRaceTest" "dhall" + ] + , path = "Test" + , name = "RosettaBlockRaceTest" + , tags = + [ PipelineTag.Type.Long + , PipelineTag.Type.Test + , PipelineTag.Type.Stable + ] + } + , steps = [ RosettaBlockRaceTest.step dependsOn ] + } diff --git a/dockerfiles/Dockerfile-mina-test-suite b/dockerfiles/Dockerfile-mina-test-suite index 5d999e81c1f9..5bf14c2a2e24 100644 --- a/dockerfiles/Dockerfile-mina-test-suite +++ b/dockerfiles/Dockerfile-mina-test-suite @@ -80,7 +80,7 @@ RUN locale-gen en_US.UTF-8 RUN echo "Building image with version $deb_version from repo $deb_release $deb_codename " \ && echo "deb [trusted=yes] ${deb_repo} $deb_codename $deb_release" > /etc/apt/sources.list.d/o1.list \ && apt-get update --quiet --yes \ - && apt-get install --no-install-recommends --quiet --yes --allow-downgrades -o Dpkg::Options::="--force-overwrite" "mina-test-suite=$deb_version" "mina-$network-instrumented=$deb_version" "mina-archive-$network-instrumented=$deb_version" \ + && apt-get install --no-install-recommends --quiet --yes --allow-downgrades -o Dpkg::Options::="--force-overwrite" "mina-test-suite=$deb_version" "mina-$network-instrumented=$deb_version" "mina-archive-$network-instrumented=$deb_version" "mina-rosetta-$network=$deb_version" \ && rm -rf /var/lib/apt/lists/* ENTRYPOINT ["sleep","infinity"] \ No newline at end of file diff --git a/scripts/rosetta/test-block-race-with-data.sh b/scripts/rosetta/test-block-race-with-data.sh index 80fe6e101557..85b20125de9d 100755 --- a/scripts/rosetta/test-block-race-with-data.sh +++ b/scripts/rosetta/test-block-race-with-data.sh @@ -36,6 +36,12 @@ LEDGER_ARCHIVE="ledger.tar" DB_DIR="db" LEDGER_DIR="ledger" +CURRENT_USER=$(whoami) +POSTGRES_USER="$CURRENT_USER" +POSTGRES_PASSWORD="" +POSTGRES_DB="archive" +POSTGRES_HOST="localhost" + # Function to display usage usage() { cat << EOF @@ -48,6 +54,10 @@ Required parameters: Optional parameters: --postgres-port PORT PostgreSQL server port (default: $POSTGRES_PORT) + --postgres-user USER PostgreSQL user (default: $POSTGRES_USER) + --postgres-password PASS PostgreSQL password (default: empty) + --postgres-db DB PostgreSQL database name (default: $POSTGRES_DB) + --postgres-host HOST PostgreSQL host (default: $POSTGRES_HOST) --port-base PORT Base port number for services (default: $PORT_BASE) --num-blocks N Number of blocks to generate (default: $NUM_BLOCKS) --num-zkapp-txs N Number of zkApp transactions (default: $NUM_ZKAPP_TXS) @@ -71,6 +81,22 @@ while [[ $# -gt 0 ]]; do POSTGRES_PORT="$2" shift 2 ;; + --postgres-user) + POSTGRES_USER="$2" + shift 2 + ;; + --postgres-password) + POSTGRES_PASSWORD="$2" + shift 2 + ;; + --postgres-db) + POSTGRES_DB="$2" + shift 2 + ;; + --postgres-host) + POSTGRES_HOST="$2" + shift 2 + ;; --port-base) PORT_BASE="$2" shift 2 @@ -182,8 +208,7 @@ if [[ ! -x "$ROSETTA_EXE" ]]; then fi # Get current username for postgres URI -CURRENT_USER=$(whoami) -POSTGRES_URI="postgres://$CURRENT_USER@localhost:$POSTGRES_PORT/archive" +POSTGRES_URI="postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB" # PID for postgres cleanup POSTGRES_PID="" diff --git a/scripts/rosetta/test-block-race.sh b/scripts/rosetta/test-block-race.sh index ec4b041dd6a9..20441676acd2 100755 --- a/scripts/rosetta/test-block-race.sh +++ b/scripts/rosetta/test-block-race.sh @@ -289,7 +289,7 @@ cp -R "$LEDGER_DIR/ledgers/" genesis mkdir -p tmp echo "Running warmup mina advanced test submit-to-archive (1 block, 1 payment, 0 zkapp)..." -TMP=tmp MINA_PRIVKEY_PASS="$MINA_EXE" advanced test submit-to-archive \ +MINA_PRIVKEY_PASS="" "$MINA_EXE" advanced test submit-to-archive \ --archive-node-port "$ARCHIVE_PORT" \ --config-file "$LEDGER_DIR/runtime_config.json" \ --privkey-path "$LEDGER_DIR/plain1" \ @@ -320,7 +320,7 @@ echo "" # Run main submit-to-archive test echo "[Main Test] Submitting blocks to archive..." echo "Running mina advanced test submit-to-archive..." -TMP=tmp MINA_PRIVKEY_PASS="$MINA_EXE" advanced test submit-to-archive \ +MINA_PRIVKEY_PASS="" "$MINA_EXE" advanced test submit-to-archive \ --archive-node-port "$ARCHIVE_PORT" \ --config-file "$LEDGER_DIR/runtime_config.json" \ --privkey-path "$LEDGER_DIR/plain1" \