Skip to content
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
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@
default = ocamlPackages.mina;
inherit (pkgs)
libp2p_helper kimchi_bindings_stubs snarky_js validation trace-tool
zkapp-cli;
zkapp-cli hardfork_test;
inherit (dockerImages)
mina-image-slim mina-image-full mina-archive-image-full
mina-image-instr-full;
Expand Down
1 change: 1 addition & 0 deletions nix/go-hashes/hardfork_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"go.mod":"b4592235afa6583ad9fa5ace6072a5b9733165d1580bfb47954fd154da9fe6ee","go.sum":"a66a7ea9363eecf0990f36729b257548c44b114ce588890dccdf633b123974d3","vendorSha256":"sha256-2Qy9V5NOKli0bjnhOykBYShk6+TYqIJshOXdWk+9O4c="}
File renamed without changes.
51 changes: 35 additions & 16 deletions nix/go.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@
# in libp2p libraries, and we'd need to update these libraries in
# order to use a higher version

let
goHashes = final: name:
let
hashes = final.lib.importJSON ./go-hashes/${name}.json;
# sanity check, to make sure the fixed output drv doesn't keep working
# when the inputs change
in if builtins.hashFile "sha256" ../src/app/${name}/src/go.mod
== hashes."go.mod"
&& builtins.hashFile "sha256" ../src/app/${name}/src/go.sum
== hashes."go.sum" then
hashes.vendorSha256
else
final.lib.warn ''
Below, you will find an error about a hash mismatch.
This is likely because you have updated go.mod and/or go.sum in ${name}.
Please, locate the "got: " hash in the aforementioned error. If it's in SRI format (sha256-<...>), copy the entire hash, including the `sha256-'. Otherwise (if it's in the base32 format, like `sha256:<...>'), copy only the base32 part, without `sha256:'.
Then, run ./nix/update-go-hashes.sh ${name} "<got hash here>"
'' final.lib.fakeHash;

in

final: prev: {
vend = final.callPackage ./vend { };

Expand Down Expand Up @@ -43,22 +64,7 @@ final: prev: {
version = "0.1";
src = ../src/app/libp2p_helper/src;
doCheck = false; # TODO: tests hang
vendorHash = let
hashes = final.lib.importJSON ./libp2p_helper.json;
# sanity check, to make sure the fixed output drv doesn't keep working
# when the inputs change
in if builtins.hashFile "sha256" ../src/app/libp2p_helper/src/go.mod
== hashes."go.mod"
&& builtins.hashFile "sha256" ../src/app/libp2p_helper/src/go.sum
== hashes."go.sum" then
hashes.vendorSha256
else
final.lib.warn ''
Below, you will find an error about a hash mismatch.
This is likely because you have updated go.mod and/or go.sum in libp2p_helper.
Please, locate the "got: " hash in the aforementioned error. If it's in SRI format (sha256-<...>), copy the entire hash, including the `sha256-'. Otherwise (if it's in the base32 format, like `sha256:<...>'), copy only the base32 part, without `sha256:'.
Then, run ./nix/update-libp2p-hashes.sh "<got hash here>"
'' final.lib.fakeHash;
vendorHash = goHashes final "libp2p_helper";
NO_MDNS_TEST = 1; # no multicast support inside the nix sandbox
overrideModAttrs = n: {
# Yo dawg
Expand Down Expand Up @@ -98,4 +104,17 @@ final: prev: {
};
vendorHash = "sha256-lCBAsCNtorEu0WRZRLEMEaNyjtVIdJSAZg3icrpHIsQ=";
};

# Hardfork test application
hardfork_test = final.buildGoModule {
pname = "hardfork_test";
version = "0.1.0";
src = ../src/app/hardfork_test/src;
# Completely skip vendoring and let go download dependencies
vendorHash = goHashes final "hardfork_test";
# Set the output binary name to hardfork_test
postInstall = ''
mv $out/bin/cmd $out/bin/hardfork_test
'';
};
}
15 changes: 15 additions & 0 deletions nix/update-go-hashes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

NAME="$1"
VENDOR_HASH="$2"

if [[ "$NAME" == "" ]] || [[ "$VENDOR_HASH" == "" ]]; then
echo "Usage: $0 <name> <vendor hash>"
exit 1
fi

cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.."
printf '{"go.mod":"%s","go.sum":"%s","vendorSha256":"%s"}' \
"$(sha256sum "src/app/$NAME/src/go.mod" | cut -d\ -f1)" \
"$(sha256sum "src/app/$NAME/src/go.sum" | cut -d\ -f1)" \
"$VENDOR_HASH" | tee "nix/go-hashes/$NAME.json"
7 changes: 0 additions & 7 deletions nix/update-libp2p-hashes.sh

This file was deleted.

13 changes: 11 additions & 2 deletions scripts/hardfork/build-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,18 @@ EOF
nix --experimental-features nix-command copy --to "s3://mina-nix-cache?endpoint=https://storage.googleapis.com" --stdin </tmp/nix-paths
fi


nix "${NIX_OPTS[@]}" build "$INIT_DIR?submodules=1#hardfork_test" --out-link "$INIT_DIR/hardfork_test"

SLOT_TX_END=${SLOT_TX_END:-$((RANDOM%120+30))}
export SLOT_TX_END
SLOT_CHAIN_END=${SLOT_CHAIN_END:-$((SLOT_TX_END+8))}

echo "Running HF test with SLOT_TX_END=$SLOT_TX_END"

"$SCRIPT_DIR"/test.sh compatible-devnet{/bin/mina,-genesis/bin/runtime_genesis_ledger} fork-devnet{/bin/mina,-genesis/bin/runtime_genesis_ledger} && echo "HF test completed successfully"
"$INIT_DIR/hardfork_test/bin/hardfork_test" \
--main-mina-exe "$INIT_DIR/compatible-devnet/bin/mina" \
--main-runtime-genesis-ledger "$INIT_DIR/compatible-devnet-genesis/bin/runtime_genesis_ledger" \
--fork-mina-exe "$INIT_DIR/fork-devnet/bin/mina" \
--fork-runtime-genesis-ledger "$INIT_DIR/fork-devnet-genesis/bin/runtime_genesis_ledger" \
--slot-tx-end "$SLOT_TX_END" \
--slot-chain-end "$SLOT_CHAIN_END" && echo "HF test completed successfully"
1 change: 1 addition & 0 deletions scripts/hardfork/create_runtime_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ DIFFERENCE_IN_SECONDS=$(($(date -d "$GENESIS_TIMESTAMP" "+%s") - $(date -d "$ORI
SECONDS_PER_SLOT=${SECONDS_PER_SLOT:=180}
DIFFERENCE_IN_SLOTS=$(($DIFFERENCE_IN_SECONDS / $SECONDS_PER_SLOT))

# TODO modify, this won't work in a hardfork with Berkeley as basis
SLOT=$((DIFFERENCE_IN_SLOTS+OFFSET))

# jq expression below could be written with less code,
Expand Down
16 changes: 12 additions & 4 deletions scripts/hardfork/run-localnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,20 @@ GENESIS_LEDGER_DIR=${GENESIS_LEDGER_DIR:-}
# Slot duration (a.k.a. block window duration), seconds
SLOT=${SLOT:-30}

echo "Creates a quick-epoch-turnaround configuration in localnet/ and launches two Mina nodes" >&2
echo "Usage: $0 [-m|--mina $MINA_EXE] [-i|--tx-interval $TX_INTERVAL] [-d|--delay-min $DELAY_MIN] [-s|--slot $SLOT] [--develop] [-c|--config ./config.json] [--slot-tx-end 100] [--slot-chain-end 130] [--genesis-ledger-dir ./genesis]" >&2
echo "Consider reading script's code for information on optional arguments" >&2
usage() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes were introduced to make output of the script nicer, not directly related to rewrite to Go

echo "Creates a quick-epoch-turnaround configuration in localnet/ and launches two Mina nodes" >&2
echo "Usage: $0 [-m|--mina $MINA_EXE] [-i|--tx-interval $TX_INTERVAL] [-d|--delay-min $DELAY_MIN] [-s|--slot $SLOT] [--develop] [-c|--config ./config.json] [--slot-tx-end 100] [--slot-chain-end 130] [--genesis-ledger-dir ./genesis]" >&2
echo "Consider reading script's code for information on optional arguments" >&2
}

##########################################################
# Parse arguments
##########################################################

while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
usage; exit 0 ;;
-d|--delay-min)
DELAY_MIN="$2"; shift; shift ;;
-i|--tx-interval)
Expand All @@ -66,14 +70,17 @@ while [[ $# -gt 0 ]]; do
--genesis-ledger-dir)
GENESIS_LEDGER_DIR="$2"; shift; shift ;;
-*)
echo "Unknown option $1"; exit 1 ;;
echo "Unknown option $1" >&2
usage
exit 1 ;;
*)
KEYS+=("$1") ; shift ;;
esac
done

if [[ "$CONF_SUFFIX" != "" ]] && [[ "$CUSTOM_CONF" != "" ]]; then
echo "Can't use both --develop and --config options" >&2
usage
exit 1
fi

Expand Down Expand Up @@ -161,6 +168,7 @@ rm -Rf localnet/runtime_1 localnet/runtime_2
"${NODE_ARGS_1[@]}" \
--block-producer-key "$PWD/$CONF_DIR/bp" \
--config-directory "$PWD/localnet/runtime_1" \
--run-snark-worker "$(cat $CONF_DIR/bp.pub)" --work-selection seq \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fix of a pre-existing glitch, not directly related to rewrite to Go

--client-port 10301 --external-port 10302 --rest-port 10303 &

bp_pid=$!
Expand Down
128 changes: 0 additions & 128 deletions scripts/hardfork/test-helper.sh

This file was deleted.

Loading