Skip to content

Commit

Permalink
Merge pull request #2069 from oasisprotocol/kostko/feature/rofl-tdx-docs
Browse files Browse the repository at this point in the history
examples: Add TDX-based oracle
  • Loading branch information
kostko authored Dec 6, 2024
2 parents 8444b42 + 7e3afb7 commit a44ad91
Show file tree
Hide file tree
Showing 15 changed files with 4,525 additions and 16 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ jobs:

- name: 'testnet: Wait for node socket'
run: |
while [ ! -e /tmp/oasis-net-runner-sdk-rt/net-runner/network/client-0/internal.sock ]; do
while [[ ! -e /tmp/oasis-net-runner-sdk-rt/net-runner/network/client-0/internal.sock || ! -e /tmp/cfg_ready ]]; do
sleep 1
done
Expand All @@ -370,6 +370,10 @@ jobs:
name: e2e-ts-web-rt-logs
path: |
/tmp/oasis-net-runner-sdk-rt/**/*.log
/tmp/oasis-net-runner-sdk-rt/**/*.json
/tmp/oasis-net-runner-sdk-rt/**/*.yaml
/tmp/genesis.json
/tmp/fixture.json
e2e-rt:
# NOTE: This name appears in GitHub's Checks API.
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ exclude = [
"examples/contract-sdk/c10l-hello-world",
"examples/runtime-sdk/minimal-runtime",
"examples/runtime-sdk/rofl-oracle",
"examples/runtime-sdk/rofl-oracle-tdx",
]
resolver = "2"

Expand Down
4 changes: 3 additions & 1 deletion client-sdk/ts-web/core/playground/sample-run-network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ mkdir -p /tmp/oasis-net-runner-sdk-core
--fixture.default.node.binary "$TEST_NODE_BINARY" \
--fixture.default.setup_runtimes=false \
--basedir /tmp/oasis-net-runner-sdk-core \
--basedir.no_temp_dir
--basedir.no_temp_dir \
--log.format json \
--log.level debug
60 changes: 55 additions & 5 deletions client-sdk/ts-web/rt/playground/sample-run-network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ TESTS_DIR=../../../../tests
. "$TESTS_DIR/consts.sh"
. "$TESTS_DIR/paths.sh"

mkdir -p /tmp/oasis-net-runner-sdk-rt
WORKDIR=/tmp/oasis-net-runner-sdk-rt
mkdir -p "$WORKDIR"

FIXTURE_FILE="/tmp/oasis-net-runner-sdk-rt/fixture.json"
FIXTURE_FILE="$WORKDIR/fixture.json"

"$TEST_NET_RUNNER" \
dump-fixture \
Expand All @@ -21,7 +22,8 @@ FIXTURE_FILE="/tmp/oasis-net-runner-sdk-rt/fixture.json"
--fixture.default.halt_epoch 100000 \
--fixture.default.runtime.version 0.1.0 \
--fixture.default.runtime.version 0.1.0 \
--fixture.default.staking_genesis ./staking.json >"$FIXTURE_FILE"
--fixture.default.staking_genesis ./staking.json >"$FIXTURE_FILE" \
--fixture.default.deterministic_entities

# Use mock SGX.
jq '
Expand All @@ -38,7 +40,55 @@ jq '
' "$FIXTURE_FILE" >"$FIXTURE_FILE.tmp"
mv "$FIXTURE_FILE.tmp" "$FIXTURE_FILE"

# Run test runner to generate genesis document.
"$TEST_NET_RUNNER" \
--fixture.file "$FIXTURE_FILE" \
--basedir /tmp/oasis-net-runner-sdk-rt \
--basedir.no_temp_dir
--basedir "$WORKDIR" \
--basedir.no_temp_dir &
RUNNER_PID=$!

# Below is a workaround for there being no way to change the default max tx size which
# prevents the compute nodes from registering.
#
# Wait for genesis file to be created so we can patch it.
GENESIS_FILE="$WORKDIR/net-runner/network/genesis.json"
OUTPUT_GENESIS_FILE=/tmp/genesis.json
while [ ! -e "$GENESIS_FILE" ]; do
sleep 1
done
# Stop the runner.
kill $RUNNER_PID
killall oasis-node
wait
# Wait for all the nodes to stop before proceeding.
while [ $(pgrep oasis-node) ]; do
sleep 1
done
# Patch the genesis file.
jq '
.consensus.params.max_tx_size = 131072 |
.consensus.params.max_block_size = 4194304
' "$GENESIS_FILE" >"$OUTPUT_GENESIS_FILE"
# Update the fixture to use the patched genesis.
mv "$FIXTURE_FILE" /tmp/fixture.json
jq '
.network.genesis_file = "'$OUTPUT_GENESIS_FILE'" |
.network.restore_identities = true |
.entities[1].Restore = true
' /tmp/fixture.json > "$FIXTURE_FILE"
# Reset state.
rm -rf $WORKDIR/net-runner/network/client-*/{consensus,runtime,persistent-store.badger.db}
rm -rf $WORKDIR/net-runner/network/compute-*/{consensus,runtime,persistent-store.badger.db}
rm -rf $WORKDIR/net-runner/network/keymanager-*/{consensus,runtime,persistent-store.badger.db}
rm -rf $WORKDIR/net-runner/network/seed-*/seed
rm -rf $WORKDIR/net-runner/network/validator-*/consensus
# Signal that we can continue.
touch /tmp/cfg_ready

# Run the test runner again.
"$TEST_NET_RUNNER" \
--fixture.file "$FIXTURE_FILE" \
--basedir "$WORKDIR" \
--basedir.no_temp_dir \
--log.format json \
--log.level debug
2 changes: 2 additions & 0 deletions examples/runtime-sdk/rofl-oracle-tdx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Built runtime bundles.
*.orc
Loading

0 comments on commit a44ad91

Please sign in to comment.