Skip to content

Commit

Permalink
Merge pull request #549 from oasisprotocol/CedarMist/EIP-2718
Browse files Browse the repository at this point in the history
fix: decode both legacy and EIP-7218 transactions
  • Loading branch information
ptrus authored May 27, 2024
2 parents fcb49e7 + 60c03f9 commit 791c8df
Show file tree
Hide file tree
Showing 14 changed files with 370 additions and 465 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ jobs:
ports:
- 5432:5432
env:
OASIS_CORE_VERSION: "23.0.9"
OASIS_CORE_VERSION: "24.0"
OASIS_NODE: ${{ github.workspace }}/oasis_core/oasis-node
OASIS_NET_RUNNER: ${{ github.workspace }}/oasis_core/oasis-net-runner
SAPPHIRE_PARATIME_VERSION: 0.6.4
SAPPHIRE_PARATIME_VERSION: 0.7.3
GATEWAY__CHAIN_ID: 23293
SAPPHIRE_PARATIME: ${{ github.workspace }}/oasis_core/sapphire-paratime
OASIS_NODE_DATADIR: /tmp/oasis-sapphire-benchmarks
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
ports:
- 5432:5432
env:
OASIS_CORE_VERSION: "23.0.9"
OASIS_CORE_VERSION: "24.0"
OASIS_NODE: ${{ github.workspace }}/oasis_core/oasis-node
OASIS_NET_RUNNER: ${{ github.workspace }}/oasis_core/oasis-net-runner
EMERALD_PARATIME_VERSION: 11.0.0-testnet
Expand Down Expand Up @@ -106,14 +106,14 @@ jobs:
ports:
- 5432:5432
env:
OASIS_CORE_VERSION: "23.0.10"
OASIS_CORE_VERSION: "24.0"
OASIS_NODE: ${{ github.workspace }}/oasis_core/oasis-node
OASIS_NET_RUNNER: ${{ github.workspace }}/oasis_core/oasis-net-runner
SAPPHIRE_PARATIME_VERSION: 0.7.3-testnet
GATEWAY__CHAIN_ID: 23293
GATEWAY__OASIS_RPCS: true
SAPPHIRE_PARATIME: ${{ github.workspace }}/oasis_core/sapphire-paratime
KEYMANAGER_ARTIFACT_URL: https://buildkite.com/organizations/oasisprotocol/pipelines/oasis-core-ci/builds/12411/jobs/018c1053-3187-4498-9317-cc122f6e6808/artifacts/018c1056-039a-45bd-bdac-9fd267052c75 # Find this at https://buildkite.com/oasisprotocol/oasis-core-ci/builds?branch=stable%2F<...> under "Build runtimes".
KEYMANAGER_ARTIFACT_URL: https://buildkite.com/organizations/oasisprotocol/pipelines/oasis-core-ci/builds/13622/jobs/018fb976-afd1-442d-a628-7b61a0c234a5/artifacts/018fb97b-3100-4035-b1ca-4295076e9ec3 # Find this at https://buildkite.com/oasisprotocol/oasis-core-ci/builds?branch=stable%2F<...> under "Build runtimes".
KEYMANAGER_BINARY: ${{ github.workspace }}/oasis_core/simple-keymanager
OASIS_NODE_DATADIR: /tmp/eth-runtime-test
steps:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Web3 Gateway for Oasis-SDK Paratime EVM module.
- [PostgreSQL](https://www.postgresql.org/) (at least version 13.3).

Additionally, for testing:
- [Oasis Core](https://github.com/oasisprotocol/oasis-core) at least version 23.0.x.
- [Oasis Core](https://github.com/oasisprotocol/oasis-core) at least version 24.0.x.
- [Emerald Paratime](https://github.com/oasisprotocol/emerald-paratime) at least version 11.x.x.
- (or) [Sapphire Paratime](https://github.com/oasisprotocol/sapphire-paratime) at least version 0.7.x.
- (or) [Sapphire Paratime](https://github.com/oasisprotocol/sapphire-paratime) at least version 0.7.3.

### Build

Expand Down
2 changes: 1 addition & 1 deletion docker/common/oasis-deposit/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/oasisprotocol/web3-tests/test/tools/oasis-deposit

go 1.22
go 1.22.3

replace (
// Should be synced with Oasis Core as replace directives are not propagated.
Expand Down
198 changes: 115 additions & 83 deletions docker/common/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,39 +35,63 @@ OASIS_WEB3_GATEWAY_PID=""
OASIS_NODE_PID=""

function cleanup {
if [[ -n "${OASIS_WEB3_GATEWAY_PID}" ]]; then
kill -9 ${OASIS_WEB3_GATEWAY_PID}
fi
if [[ -n "${OASIS_NODE_PID}" ]]; then
kill -9 ${OASIS_NODE_PID}
fi
if [[ -n "${OASIS_WEB3_GATEWAY_PID}" ]]; then
kill -9 ${OASIS_WEB3_GATEWAY_PID}
fi
if [[ -n "${OASIS_NODE_PID}" ]]; then
kill -9 ${OASIS_NODE_PID}
fi
}

trap cleanup INT TERM EXIT

# If we have an interactive terminal, use colors.
if [[ -t 0 ]]; then
GREEN="\e[32;1m"
YELLOW="\e[33;1m"
CYAN="\e[36;1m"
OFF="\e[0m"
GREEN="\e[32;1m"
YELLOW="\e[33;1m"
CYAN="\e[36;1m"
OFF="\e[0m"
else
GREEN=""
YELLOW=""
CYAN=""
OFF=""
GREEN=""
YELLOW=""
CYAN=""
OFF=""
fi

if [[ "x${OASIS_DOCKER_USE_TIMESTAMPS_IN_NOTICES}" == "xyes" ]]; then
function notice {
printf "${GREEN}[$(date +'%Y-%m-%d %H:%M:%S')]${OFF} $@"
printf "${GREEN}[$(date +'%Y-%m-%d %H:%M:%S')]${OFF} $@"
}
else
function notice {
printf "${CYAN} *${OFF} $@"
printf "${CYAN} *${OFF} $@"
}
fi

if [[ "${OASIS_NODE_LOG_LEVEL}" == "debug" ]]; then
if [[ "x${OASIS_DOCKER_USE_TIMESTAMPS_IN_NOTICES}" == "xyes" ]]; then
function notice_debug {
if [ "$1" == "-l" ]; then
shift
printf "\n"
fi
printf "${GREEN}[$(date +'%Y-%m-%d %H:%M:%S')]${OFF} $@"
}
else
function notice_debug {
if [ "$1" == "-l" ]; then
shift
printf "\n"
fi
printf "${CYAN} *${OFF} $@"
}
fi
else
notice_debug() {
:
}
fi

T_START="$(date +%s)"

notice "Starting oasis-net-runner with ${CYAN}${PARATIME_NAME}${OFF}...\n"
Expand All @@ -77,7 +101,7 @@ OASIS_NODE_PID=$!
notice "Waiting for Postgres to start"
su -c "POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres /usr/local/bin/docker-entrypoint.sh postgres &" postgres 2>1 &>/var/log/postgres.log
function is_postgres_ready() {
pg_isready -h 127.0.0.1 -p 5432 2>1 &>/dev/null
pg_isready -h 127.0.0.1 -p 5432 2>1 &>/dev/null
}
until is_postgres_ready; do echo -n .; sleep 1; done
echo
Expand All @@ -101,46 +125,54 @@ OASIS_WEB3_GATEWAY_PID=$!
# Wait for compute nodes before initiating deposit.
notice "Bootstrapping network (this might take a minute)"
if [[ ${BEACON_BACKEND} == 'mock' ]]; then
echo -n .
${OASIS_NODE} debug control wait-nodes -n 2 -a unix:${OASIS_NODE_SOCKET}

echo -n .
${OASIS_NODE} debug control set-epoch --epoch 1 -a unix:${OASIS_NODE_SOCKET}

# Transition to the final epoch when the KM generates ephemeral secret.
if [[ ${PARATIME_NAME} == 'sapphire' ]]; then
while (${OASIS_NODE} control status -a unix:${OASIS_KM_SOCKET} | jq -e ".keymanager.worker.ephemeral_secrets.last_generated_epoch!=2" >/dev/null); do
sleep 0.5
done
fi

echo -n .
${OASIS_NODE} debug control set-epoch --epoch 2 -a unix:${OASIS_NODE_SOCKET}
echo -n .
notice_debug -l "Waiting for nodes to be ready..."
${OASIS_NODE} debug control wait-nodes -n 2 -a unix:${OASIS_NODE_SOCKET}

echo -n .
notice_debug -l "Setting epoch to 1..."
${OASIS_NODE} debug control set-epoch --epoch 1 -a unix:${OASIS_NODE_SOCKET}

# Transition to the final epoch when the KM generates ephemeral secret.
if [[ ${PARATIME_NAME} == 'sapphire' ]]; then
notice_debug -l "Waiting for key manager to generate ephemeral secret..."
while (${OASIS_NODE} control status -a unix:${OASIS_KM_SOCKET} | jq -e ".keymanager.secrets.worker.ephemeral_secrets.last_generated_epoch!=2" >/dev/null); do
sleep 0.5
done
fi

echo -n .
notice_debug -l "Setting epoch to 2..."
${OASIS_NODE} debug control set-epoch --epoch 2 -a unix:${OASIS_NODE_SOCKET}
else
echo -n ...
${OASIS_NODE} debug control wait-ready -a unix:${OASIS_NODE_SOCKET}
echo -n ...
notice_debug -l "Waiting for nodes to be ready..."
${OASIS_NODE} debug control wait-ready -a unix:${OASIS_NODE_SOCKET}
fi
echo

if [[ ${PARATIME_NAME} == 'sapphire' ]]; then
notice "Waiting for key manager..."
function is_km_ready() {
curl -X POST -s \
-H 'Content-Type: application/json' \
--data '{"jsonrpc":"2.0","method":"oasis_callDataPublicKey","params":[],"id":1}' \
http://127.0.0.1:8545 2>1 | jq -e '.result | has("key")' 2>1 &>/dev/null
}
until is_km_ready; do
if [[ ${BEACON_BACKEND} == 'mock' ]]; then
epoch=`${OASIS_NODE} control status -a unix:${OASIS_NODE_SOCKET} | jq '.consensus.latest_epoch'`
epoch=$((epoch + 1))
${OASIS_NODE} debug control set-epoch --epoch $epoch -a unix:${OASIS_NODE_SOCKET}
fi

echo -n .
sleep 1
done
echo
notice "Waiting for key manager..."
function is_km_ready() {
curl -X POST -s \
-H 'Content-Type: application/json' \
--data '{"jsonrpc":"2.0","method":"oasis_callDataPublicKey","params":[],"id":1}' \
http://127.0.0.1:8545 2>1 | jq -e '.result | has("key")' 2>1 &>/dev/null
}
until is_km_ready; do
if [[ ${BEACON_BACKEND} == 'mock' ]]; then
epoch=`${OASIS_NODE} control status -a unix:${OASIS_NODE_SOCKET} | jq '.consensus.latest_epoch'`
epoch=$((epoch + 1))
${OASIS_NODE} debug control set-epoch --epoch $epoch -a unix:${OASIS_NODE_SOCKET}
fi

echo -n .
sleep 1
done
echo
else
# Wait a bit to ensure client is ready if we're not waiting for keymanager.
sleep 10
fi

notice "Populating accounts...\n\n"
Expand All @@ -154,39 +186,39 @@ notice "Listening on ${CYAN}http://localhost:8545${OFF} and ${CYAN}ws://localhos
notice "Container start-up took ${CYAN}$((T_END-T_START))${OFF} seconds, node log level is set to ${CYAN}${OASIS_NODE_LOG_LEVEL}${OFF}.\n"

if [[ "x${OASIS_DOCKER_DEBUG_DISK_AND_CPU_USAGE}" == "xyes" ]]; then
# When debugging disk and CPU usage, we terminate the container
# after 60 minutes.
QUIT_AFTER_N_REPORTS=6
NUM_REPORTS=0

# Also print a header for the readings below.
echo
echo "Uptime [minutes],Total node dir size [kB],Size of node logs [kB],Percent usage by logs [%],Load average (1 min),Load average (5 min),Load average (15 min)"
# When debugging disk and CPU usage, we terminate the container
# after 60 minutes.
QUIT_AFTER_N_REPORTS=6
NUM_REPORTS=0

# Also print a header for the readings below.
echo
echo "Uptime [minutes],Total node dir size [kB],Size of node logs [kB],Percent usage by logs [%],Load average (1 min),Load average (5 min),Load average (15 min)"
fi

if [[ ${BEACON_BACKEND} == 'mock' ]]; then
# Run background task to switch epochs every 10 minutes.
while true; do
if [[ "x${OASIS_DOCKER_DEBUG_DISK_AND_CPU_USAGE}" == "xyes" ]]; then
LOADAVG=$(uptime | cut -d':' -f5 | tr -d ' ')
TOTAL_NODE_DIR_SIZE_KB=$(du -sk /serverdir/node | cut -f1)
TOTAL_NODE_LOGS_SIZE_KB=$(du -skc /serverdir/node/net-runner/network/*/*.log | tail -1 | cut -f1)
LOGS_PCT=$(echo "scale=4; (${TOTAL_NODE_LOGS_SIZE_KB} / ${TOTAL_NODE_DIR_SIZE_KB}) * 100" | bc)

echo "$((NUM_REPORTS * 10)),${TOTAL_NODE_DIR_SIZE_KB},${TOTAL_NODE_LOGS_SIZE_KB},${LOGS_PCT},${LOADAVG}"

if [[ ${NUM_REPORTS} -ge ${QUIT_AFTER_N_REPORTS} ]]; then
exit 0
fi
NUM_REPORTS=$((NUM_REPORTS + 1))
fi

sleep $((60*10))

epoch=`${OASIS_NODE} control status -a unix:${OASIS_NODE_SOCKET} | jq '.consensus.latest_epoch'`
epoch=$((epoch + 1))
${OASIS_NODE} debug control set-epoch --epoch $epoch -a unix:${OASIS_NODE_SOCKET}
done
# Run background task to switch epochs every 10 minutes.
while true; do
if [[ "x${OASIS_DOCKER_DEBUG_DISK_AND_CPU_USAGE}" == "xyes" ]]; then
LOADAVG=$(uptime | cut -d':' -f5 | tr -d ' ')
TOTAL_NODE_DIR_SIZE_KB=$(du -sk /serverdir/node | cut -f1)
TOTAL_NODE_LOGS_SIZE_KB=$(du -skc /serverdir/node/net-runner/network/*/*.log | tail -1 | cut -f1)
LOGS_PCT=$(echo "scale=4; (${TOTAL_NODE_LOGS_SIZE_KB} / ${TOTAL_NODE_DIR_SIZE_KB}) * 100" | bc)

echo "$((NUM_REPORTS * 10)),${TOTAL_NODE_DIR_SIZE_KB},${TOTAL_NODE_LOGS_SIZE_KB},${LOGS_PCT},${LOADAVG}"

if [[ ${NUM_REPORTS} -ge ${QUIT_AFTER_N_REPORTS} ]]; then
exit 0
fi
NUM_REPORTS=$((NUM_REPORTS + 1))
fi

sleep $((60*10))

epoch=`${OASIS_NODE} control status -a unix:${OASIS_NODE_SOCKET} | jq '.consensus.latest_epoch'`
epoch=$((epoch + 1))
${OASIS_NODE} debug control set-epoch --epoch $epoch -a unix:${OASIS_NODE_SOCKET}
done
else
wait
wait
fi
4 changes: 2 additions & 2 deletions docker/emerald-localnet/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ RUN apk add --no-cache bash gcompat libseccomp jq binutils \
&& su -c "POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres /usr/local/bin/docker-entrypoint.sh postgres &" postgres

# Docker-specific variables
ENV OASIS_CORE_VERSION=23.0.9
ENV OASIS_CLI_VERSION=0.6.0
ENV OASIS_CORE_VERSION=24.0
ENV OASIS_CLI_VERSION=0.8.1
ENV PARATIME_VERSION=11.0.0-testnet
ENV PARATIME_NAME=emerald
ENV GATEWAY__CHAIN_ID=0xa514
Expand Down
5 changes: 3 additions & 2 deletions docker/sapphire-localnet/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ COPY . /go/oasis-web3-gateway
RUN cd oasis-web3-gateway && make && strip -S -x oasis-web3-gateway docker/common/oasis-deposit/oasis-deposit

# Build simple-keymanager
FROM ghcr.io/oasisprotocol/oasis-core-dev:stable-23.0.x AS oasis-core-dev
FROM ghcr.io/oasisprotocol/oasis-core-dev:stable-24.0.x AS oasis-core-dev

ENV OASIS_UNSAFE_SKIP_KM_POLICY=1
ENV OASIS_CORE_VERSION=stable/23.0.x
ENV OASIS_UNSAFE_ALLOW_DEBUG_ENCLAVES=1
ENV OASIS_CORE_VERSION=stable/24.0.x
ENV OASIS_CLI_VERSION=0.8.1

RUN git clone https://github.com/oasisprotocol/oasis-core.git --branch ${OASIS_CORE_VERSION} --depth 1 \
Expand Down
5 changes: 5 additions & 0 deletions gas/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/oasisprotocol/oasis-core/go/common/pubsub"
"github.com/oasisprotocol/oasis-core/go/common/quantity"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/client"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/modules/core"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/types"

Expand Down Expand Up @@ -69,6 +70,10 @@ func (m *mockCoreClient) MinGasPrice(_ context.Context) (map[types.Denomination]
}, nil
}

func (m *mockCoreClient) DecodeEvent(*types.Event) ([]client.DecodedEvent, error) {
panic("unimplemented")
}

type mockBlockEmitter struct {
notifier *pubsub.Broker
}
Expand Down
Loading

0 comments on commit 791c8df

Please sign in to comment.