Skip to content

Commit

Permalink
feat(raiko): update docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
smtmfft committed May 20, 2024
1 parent bead6e9 commit fb52471
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ RUN curl -o setup.sh -sL https://deb.nodesource.com/setup_18.x && \
libsgx-dcap-ql \
libsgx-urts \
sgx-pck-id-retrieval-tool \
jq \
sudo && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
Expand All @@ -49,6 +50,7 @@ COPY --from=builder /opt/raiko/docker/entrypoint.sh ./bin/
COPY --from=builder /opt/raiko/provers/sgx/config/sgx-guest.docker.manifest.template ./provers/sgx/config/sgx-guest.local.manifest.template
# copy to /etc/raiko, but if self register mode, the mounted one will overwrite it.
COPY --from=builder /opt/raiko/host/config/config.sgx.json /etc/raiko/
COPY --from=builder /opt/raiko/host/config/chain_spec_list_default.json /etc/raiko/chain_spec_list.docker.json
COPY --from=builder /opt/raiko/target/release/sgx-guest ./bin/
COPY --from=builder /opt/raiko/target/release/raiko-host ./bin/
COPY --from=builder /opt/raiko/target/release/raiko-setup ./bin/
Expand Down
4 changes: 2 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ services:
dockerfile: Dockerfile
image: gcr.io/evmchain/raiko:latest
container_name: raiko
command: --config-path=/etc/raiko/config.sgx.json
command: --config-path=/etc/raiko/config.sgx.json --chain-spec-path=/etc/raiko/chain_spec_list.docker.json
devices:
- "/dev/sgx_enclave:/dev/sgx_enclave"
- "/dev/sgx_provision:/dev/sgx_provision"
Expand All @@ -76,7 +76,7 @@ services:
dockerfile: Dockerfile
image: gcr.io/evmchain/raiko-self-register:latest
container_name: raiko-self-register
command: --config-path=/etc/raiko/config.sgx.json
command: --config-path=/etc/raiko/config.sgx.json --chain-spec-path=/etc/raiko/chain_spec_list.docker.json
devices:
- "/dev/sgx_enclave:/dev/sgx_enclave"
- "/dev/sgx_provision:/dev/sgx_provision"
Expand Down
26 changes: 26 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ RAIKO_DOCKER_VOLUME_CONFIG_PATH="$RAIKO_DOCKER_VOLUME_PATH/config"
RAIKO_DOCKER_VOLUME_SECRETS_PATH="$RAIKO_DOCKER_VOLUME_PATH/secrets"
RAIKO_DOCKER_VOLUME_PRIV_KEY_PATH="$RAIKO_DOCKER_VOLUME_SECRETS_PATH/priv.key"
RAIKO_APP_DIR="/opt/raiko/bin"
RAIKO_CONF_DIR="/etc/raiko"
RAIKO_GUEST_APP_FILENAME="sgx-guest"
RAIKO_GUEST_SETUP_FILENAME="raiko-setup"
RAIKO_INPUT_MANIFEST_FILENAME="$RAIKO_GUEST_APP_FILENAME.docker.manifest.template"
Expand Down Expand Up @@ -37,6 +38,29 @@ function bootstrap_with_self_register() {
cd -
}

function update_docker_chain_specs() {
CONFIG_FILE="$RAIKO_CONF_DIR/chain_spec_list.docker.json"
if [ ! -f $CONFIG_FILE ]; then
echo "chain_spec_list.docker.json file not found."
return 1
fi

if [ -n "${HOLESKY_RPC}" ]; then
jq --arg rpc "$HOLESKY_RPC" 'map(if .name == "holesky" then .rpc = $rpc else . end)' $CONFIG_FILE > /tmp/config_tmp.json && mv /tmp/config_tmp.json $CONFIG_FILE;
echo "Updated config.json with .rpc=$HOLESKY_RPC"
fi

if [ -n "${HOLESKY_BEACON_RPC}" ]; then
jq --arg beacon_rpc "$HOLESKY_L1_BEACON_RPC" 'map(if .name == "holesky" then .beacon_rpc = $beacon_rpc else . end)' $CONFIG_FILE > /tmp/config_tmp.json && mv /tmp/config_tmp.json $CONFIG_FILE;
echo "Updated config.json with .beacon_rpc=$HOLESKY_L1_BEACON_RPC"
fi

if [ -n "${TAIKO_A7_RPC}" ]; then
jq --arg taiko_a7_rpc "$TAIKO_A7_RPC" 'map(if .name == "taiko_a7" then .rpc = $taiko_a7_rpc else . end)' $CONFIG_FILE > /tmp/config_tmp.json && mv /tmp/config_tmp.json $CONFIG_FILE;
echo "Updated config.json with .taiko_a7_rpc=$TAIKO_A7_RPC"
fi
}

if [[ -z "${PCCS_HOST}" ]]; then
MY_PCCS_HOST=pccs:8081
else
Expand Down Expand Up @@ -66,5 +90,7 @@ else
sed -i "s/123456/${SGX_INSTANCE_ID}/" /etc/raiko/config.sgx.json
fi

update_docker_chain_specs

/opt/raiko/bin/raiko-host "$@"
fi
4 changes: 2 additions & 2 deletions host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use clap::Parser;
use raiko_lib::consts::SupportedChainSpecs;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use tracing::info;
use tracing::{info, debug};

type MerkleProof = HashMap<Address, EIP1186AccountProofResponse>;

Expand Down Expand Up @@ -152,11 +152,11 @@ impl ProverState {
let chain_specs = if let Some(cs_path) = &opts.chain_spec_path {
let chain_specs = SupportedChainSpecs::merge_from_file(cs_path.clone())
.unwrap_or(SupportedChainSpecs::default());
info!("Supported chains: {:?}", chain_specs.supported_networks());
chain_specs
} else {
SupportedChainSpecs::default()
};
info!("Supported chains: {:?}", chain_specs);

// Check if the cache path exists and create it if it doesn't.
if let Some(cache_path) = &opts.cache_path {
Expand Down

0 comments on commit fb52471

Please sign in to comment.