Skip to content

Commit

Permalink
feat: certification v2 (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpeterparker authored Nov 9, 2023
1 parent e045b90 commit 31e46cd
Show file tree
Hide file tree
Showing 34 changed files with 1,885 additions and 569 deletions.
157 changes: 156 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"declarations": {
"node_compatibility": true
},
"optimize": "cycles"
"optimize": "cycles",
"metadata": [{ "name": "supported_certificate_versions", "content": "1,2" }]
},
"orbiter": {
"candid": "src/orbiter/orbiter.did",
Expand Down
68 changes: 32 additions & 36 deletions docker/build
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@ cd "$SCRIPTS_DIR/.."
#########

function title() {
echo "Builds Juno Canisters"
echo "Build Juno Canister"
}

function usage() {
cat << EOF
Usage:
$0 [--only-dependencies] [--mission_control] [--satellite] [--console] [--observatory] [--orbiter]
$0 [--mission_control] [--satellite] [--console] [--observatory] [--orbiter]
Options:
--only-dependencies only build rust dependencies (no js build, no wasm optimization)
--mission_control build the mission_control canister (default)
--satellite build the satellite canister
--console build the console canister
Expand All @@ -33,15 +32,15 @@ EOF
function help() {
cat << EOF
Builds the Mission Control, Satellite and Console canisters.
Build the Mission Control, Satellite, Orbiter, Observatory or Console canister.
NOTE: This requires a working rust toolchain as well as ic-wasm.
EOF

}

ONLY_DEPS=
CANISTERS=()
CERTIFICATION=
CANISTER=

while [[ $# -gt 0 ]]
do
Expand All @@ -52,29 +51,26 @@ do
help
exit 0
;;
--only-dependencies)
ONLY_DEPS=1
shift
;;
--mission_control)
CANISTERS+=("mission_control")
shift
CANISTER="mission_control"
break
;;
--satellite)
CANISTERS+=("satellite")
shift
CANISTER="satellite"
CERTIFICATION="true"
break
;;
--console)
CANISTERS+=("console")
shift
CANISTER="console"
break
;;
--observatory)
CANISTERS+=("observatory")
shift
CANISTER="observatory"
break
;;
--orbiter)
CANISTERS+=("orbiter")
shift
CANISTER="orbiter"
break
;;
*)
echo "ERROR: unknown argument $1"
Expand All @@ -87,8 +83,8 @@ do
done

# build Mission Control by default
if [ ${#CANISTERS[@]} -eq 0 ]; then
CANISTERS=("mission_control")
if [ ${#CANISTER} -eq 0 ]; then
CANISTER=("mission_control")
fi

# Checking for dependencies
Expand Down Expand Up @@ -129,23 +125,23 @@ function build_canister() {

RUSTFLAGS="$RUSTFLAGS" cargo build "${cargo_build_args[@]}"

if [ "$ONLY_DEPS" != "1" ]
then
CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$SRC_DIR/../../target/}"
CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$SRC_DIR/../../target/}"

ic-wasm \
"$CARGO_TARGET_DIR/$TARGET/release/$canister.wasm" \
-o "./$canister.wasm" \
shrink
ic-wasm \
"$CARGO_TARGET_DIR/$TARGET/release/$canister.wasm" \
-o "./$canister.wasm" \
shrink

# adds the content of $canister.did to the `icp:public candid:service` custom section of the public metadata in the wasm
ic-wasm "$canister.wasm" -o "$canister.wasm" metadata candid:service -f "$SRC_DIR/$canister.did" -v public
# adds the content of $canister.did to the `icp:public candid:service` custom section of the public metadata in the wasm
ic-wasm "$canister.wasm" -o "$canister.wasm" metadata candid:service -f "$SRC_DIR/$canister.did" -v public

gzip "./$canister.wasm"
if [ "$CERTIFICATION" == "true" ]
then
# indicate support for certificate version 1 and 2 in the canister metadata
ic-wasm "$canister.wasm" -o "$canister.wasm" metadata supported_certificate_versions -d "1,2" -v public
fi

gzip "./$canister.wasm"
}

for canister in "${CANISTERS[@]}"
do
build_canister "$canister"
done
build_canister "$CANISTER"
Loading

0 comments on commit 31e46cd

Please sign in to comment.