Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into pedro/debug_logs
Browse files Browse the repository at this point in the history
  • Loading branch information
otherview committed Sep 27, 2023
2 parents c70a7b3 + 584b6a7 commit b966675
Show file tree
Hide file tree
Showing 64 changed files with 689 additions and 510 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/manual-deploy-testnet-l1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# The scheduled deployment runs at 03:05 on every day-of-week from Tuesday through Saturday, for dev-testnet only.

name: '[M] Deploy Testnet L1'

run-name: '[M] Deploy Testnet L1 ( ${{ github.event.inputs.testnet_type }} )'
on:
workflow_dispatch:
inputs:
Expand All @@ -30,6 +30,9 @@ on:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.testnet_type }}

steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -144,6 +147,6 @@ jobs:
--blockTimeSecs=15 --slotsPerEpoch=2 --slotsPerSecond=15 \
--numNodes=1 --gethHTTPStartPort=8025 --gethWSStartPort=9000 \
--logToFile=false \
--prefundedAddrs="${{ secrets.GETHNETWORK_PREFUNDED_ADDR_WORKER }},${{ secrets.GETHNETWORK_PREFUNDED_ADDR_0 }},${{ secrets.GETHNETWORK_PREFUNDED_ADDR_1 }}"'
--prefundedAddrs="${{ vars.WORKER_ADDR }},${{ vars.NODE_WALLET_ADDR_0 }},${{ vars.NODE_WALLET_ADDR_1 }}"'
196 changes: 90 additions & 106 deletions .github/workflows/manual-deploy-testnet-l2.yml

Large diffs are not rendered by default.

141 changes: 67 additions & 74 deletions .github/workflows/manual-upgrade-testnet-l2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
# repository dispatch.
#
# The scheduled deployment runs at 03:05 on every day-of-week.
#
# This script uses GitHub Environments for variables (vars) and secrets - these are configured on GitHub and
# the environments match the input.testnet_type options

name: '[M] Upgrade Testnet L2'

run-name: '[M] Upgrade Testnet L2 ( ${{ github.event.inputs.testnet_type }} )'
on:
# schedule:
# - cron: '05 03 * * *'
Expand All @@ -23,6 +26,7 @@ on:
options:
- 'dev-testnet'
- 'testnet'
- 'sepolia-testnet'
log_level:
description: 'Log Level 1-Error 5-Trace'
required: true
Expand All @@ -32,17 +36,11 @@ on:
jobs:
build:
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.testnet_type }}
# Map a step output to a job output
outputs:
L2_ENCLAVE_DOCKER_BUILD_TAG: ${{ steps.outputVars.outputs.L2_ENCLAVE_DOCKER_BUILD_TAG }}
L2_HOST_DOCKER_BUILD_TAG: ${{ steps.outputVars.outputs.L2_HOST_DOCKER_BUILD_TAG }}
RESOURCE_TAG_NAME: ${{ steps.outputVars.outputs.RESOURCE_TAG_NAME }}
RESOURCE_STARTING_NAME: ${{ steps.outputVars.outputs.RESOURCE_STARTING_NAME }}
RESOURCE_TESTNET_NAME: ${{ steps.outputVars.outputs.RESOURCE_TESTNET_NAME }}
L1_WS_URL: ${{ steps.outputVars.outputs.L1_WS_URL }}
VM_BUILD_NUMBER: ${{ steps.outputVars.outputs.VM_BUILD_NUMBER }}
BATCH_INTERVAL: ${{ steps.outputVars.outputs.BATCH_INTERVAL }}
ROLLUP_INTERVAL: ${{ steps.outputVars.outputs.ROLLUP_INTERVAL }}

steps:
- uses: actions/checkout@v3
Expand All @@ -51,39 +49,34 @@ jobs:
with:
go-version: 1.20.4

- name: 'Print GitHub variables'
# This is a useful record of what the environment variables were at the time the job ran, for debugging and reference
run: |
echo "L2_ENCLAVE_DOCKER_BUILD_TAG=${{vars.L2_ENCLAVE_DOCKER_BUILD_TAG}}"
echo "L2_HARDHATDEPLOYER_DOCKER_BUILD_TAG=${{vars.L2_HARDHATDEPLOYER_DOCKER_BUILD_TAG}}"
echo "L2_HOST_DOCKER_BUILD_TAG=${{vars.L2_HOST_DOCKER_BUILD_TAG}}"
echo "RESOURCE_STARTING_NAME=${{vars.RESOURCE_STARTING_NAME}}"
echo "RESOURCE_TAG_NAME=${{vars.RESOURCE_TAG_NAME}}"
echo "RESOURCE_TESTNET_NAME=${{vars.RESOURCE_TESTNET_NAME}}"
echo "L1_CHAIN_ID=${{vars.L1_CHAIN_ID}}"
echo "NODE_WALLET_ADDR_0=${{vars.NODE_WALLET_ADDR_0}}"
echo "NODE_WALLET_ADDR_1=${{vars.NODE_WALLET_ADDR_1}}"
echo "WORKER_ADDR=${{vars.WORKER_ADDR}}"
echo "BATCH_INTERVAL=${{vars.BATCH_INTERVAL}}"
echo "ROLLUP_INTERVAL=${{vars.ROLLUP_INTERVAL}}"
- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: 'Sets env vars for testnet'
if: ${{ github.event.inputs.testnet_type == 'testnet' }}
run: |
echo "L2_ENCLAVE_DOCKER_BUILD_TAG=testnetobscuronet.azurecr.io/obscuronet/enclave:latest" >> $GITHUB_ENV
echo "L2_HOST_DOCKER_BUILD_TAG=testnetobscuronet.azurecr.io/obscuronet/host:latest" >> $GITHUB_ENV
echo "RESOURCE_TAG_NAME=testnetlatest" >> $GITHUB_ENV
echo "RESOURCE_STARTING_NAME=T" >> $GITHUB_ENV
echo "RESOURCE_TESTNET_NAME=testnet" >> $GITHUB_ENV
echo "L1_WS_URL=ws://testnet-eth2network.uksouth.cloudapp.azure.com:9000" >> $GITHUB_ENV
echo "BATCH_INTERVAL=1s" >> $GITHUB_ENV
echo "ROLLUP_INTERVAL=10s" >> $GITHUB_ENV
- name: 'Sets env vars for dev-testnet'
if: ${{ (github.event.inputs.testnet_type == 'dev-testnet') || (github.event_name == 'schedule') }}
run: |
echo "L2_ENCLAVE_DOCKER_BUILD_TAG=testnetobscuronet.azurecr.io/obscuronet/dev_enclave:latest" >> $GITHUB_ENV
echo "L2_HOST_DOCKER_BUILD_TAG=testnetobscuronet.azurecr.io/obscuronet/dev_host:latest" >> $GITHUB_ENV
echo "RESOURCE_TAG_NAME=devtestnetlatest" >> $GITHUB_ENV
echo "RESOURCE_STARTING_NAME=D" >> $GITHUB_ENV
echo "RESOURCE_TESTNET_NAME=devtestnet" >> $GITHUB_ENV
echo "L1_WS_URL=ws://dev-testnet-eth2network.uksouth.cloudapp.azure.com:9000" >> $GITHUB_ENV
echo "BATCH_INTERVAL=1s" >> $GITHUB_ENV
echo "ROLLUP_INTERVAL=10s" >> $GITHUB_ENV
- name: 'Fetch latest VM hostnames by env tag and extract build number'
id: fetch_hostnames
run: |
VM_HOSTNAME=$(az vm list --query "[?tags.${{env.RESOURCE_TAG_NAME}}=='true'].{Name:name}[0]" -g Testnet -o tsv)
VM_HOSTNAME=$(az vm list --query "[?tags.${{vars.RESOURCE_TAG_NAME}}=='true'].{Name:name}[0]" -g Testnet -o tsv)
VM_BUILD_NUMBER=$(echo $VM_HOSTNAME | perl -ne 'if (/(-[0-9]{1}-)(\d+)/) { print $2 }') # Extract build number from VM hostname, e.g. D-0-321 -> 321
echo "VM_BUILD_NUMBER=${VM_BUILD_NUMBER}" >> $GITHUB_ENV
echo "VM_HOSTNAME: ${VM_HOSTNAME}"
Expand All @@ -96,15 +89,7 @@ jobs:
- name: 'Output env vars'
id: outputVars
run: |
echo "L2_ENCLAVE_DOCKER_BUILD_TAG=${{env.L2_ENCLAVE_DOCKER_BUILD_TAG}}" >> $GITHUB_OUTPUT
echo "L2_HOST_DOCKER_BUILD_TAG=${{env.L2_HOST_DOCKER_BUILD_TAG}}" >> $GITHUB_OUTPUT
echo "RESOURCE_TAG_NAME=${{env.RESOURCE_TAG_NAME}}" >> $GITHUB_OUTPUT
echo "RESOURCE_STARTING_NAME=${{env.RESOURCE_STARTING_NAME}}" >> $GITHUB_OUTPUT
echo "RESOURCE_TESTNET_NAME=${{env.RESOURCE_TESTNET_NAME}}" >> $GITHUB_OUTPUT
echo "L1_WS_URL=${{env.L1_WS_URL}}" >> $GITHUB_OUTPUT
echo "VM_BUILD_NUMBER=${{env.VM_BUILD_NUMBER}}" >> $GITHUB_OUTPUT
echo "BATCH_INTERVAL=${{env.BATCH_INTERVAL}}" >> $GITHUB_OUTPUT
echo "ROLLUP_INTERVAL=${{env.ROLLUP_INTERVAL}}" >> $GITHUB_OUTPUT
- name: 'Login to Azure docker registry'
uses: azure/docker-login@v1
Expand All @@ -115,33 +100,21 @@ jobs:

- name: 'Build and push obscuro node images'
run: |
DOCKER_BUILDKIT=1 docker build -t ${{env.L2_ENCLAVE_DOCKER_BUILD_TAG}} -f dockerfiles/enclave.Dockerfile .
docker push ${{env.L2_ENCLAVE_DOCKER_BUILD_TAG}}
DOCKER_BUILDKIT=1 docker build -t ${{env.L2_HOST_DOCKER_BUILD_TAG}} -f dockerfiles/host.Dockerfile .
docker push ${{env.L2_HOST_DOCKER_BUILD_TAG}}
DOCKER_BUILDKIT=1 docker build -t ${{vars.L2_ENCLAVE_DOCKER_BUILD_TAG}} -f dockerfiles/enclave.Dockerfile .
docker push ${{vars.L2_ENCLAVE_DOCKER_BUILD_TAG}}
DOCKER_BUILDKIT=1 docker build -t ${{vars.L2_HOST_DOCKER_BUILD_TAG}} -f dockerfiles/host.Dockerfile .
docker push ${{vars.L2_HOST_DOCKER_BUILD_TAG}}
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.testnet_type }}

strategy:
matrix:
host_id: [ 0,1 ]
include:
# Hardcoded host addresses
- host_addr: 0x0000000000000000000000000000000000000000
host_id: 0
- host_addr: 0x0000000000000000000000000000000000000001
host_id: 1
# Hardcoded host prefunded keys
- node_pk_str: GETHNETWORK_PREFUNDED_PKSTR_0
host_id: 0
- node_pk_str: GETHNETWORK_PREFUNDED_PKSTR_1
host_id: 1
- node_pk_addr: GETHNETWORK_PREFUNDED_ADDR_0
host_id: 0
- node_pk_addr: GETHNETWORK_PREFUNDED_ADDR_1
host_id: 1
# Ensure there is a single genesis node
- is_genesis: true
host_id: 0
Expand All @@ -152,6 +125,19 @@ jobs:
host_id: 0
- node_type: validator
host_id: 1
# Hardcoded lookup keys because GH actions doesn't let you build them inline with the host_id
- node_pk_lookup: NODE_WALLET_PK_0
host_id: 0
- node_pk_lookup: NODE_WALLET_PK_1
host_id: 1
- node_addr_lookup: NODE_WALLET_ADDR_0
host_id: 0
- node_addr_lookup: NODE_WALLET_ADDR_1
host_id: 1
- node_l1_ws_lookup: L1_WS_URL_0
host_id: 0
- node_l1_ws_lookup: L1_WS_URL_1
host_id: 1

steps:
- name: 'Extract branch name'
Expand All @@ -169,44 +155,47 @@ jobs:
uses: azure/CLI@v1
with:
inlineScript: |
az vm run-command invoke -g Testnet -n "${{needs.build.outputs.RESOURCE_STARTING_NAME}}-${{ matrix.host_id }}-${{needs.build.outputs.VM_BUILD_NUMBER}}" \
az vm run-command invoke -g Testnet -n "${{vars.RESOURCE_STARTING_NAME}}-${{ matrix.host_id }}-${{needs.build.outputs.VM_BUILD_NUMBER}}" \
--command-id RunShellScript \
--scripts '
docker pull ${{needs.build.outputs.L2_HOST_DOCKER_BUILD_TAG}} \
&& docker pull ${{needs.build.outputs.L2_ENCLAVE_DOCKER_BUILD_TAG}} \
docker pull ${{vars.L2_HOST_DOCKER_BUILD_TAG}} \
&& docker pull ${{vars.L2_ENCLAVE_DOCKER_BUILD_TAG}} \
&& rm -rf /home/obscuro/go-obscuro \
&& git clone --depth 1 -b ${{ env.BRANCH_NAME }} https://github.com/obscuronet/go-obscuro.git /home/obscuro/go-obscuro \
&& cd /home/obscuro/go-obscuro/ \
&& sudo go run /home/obscuro/go-obscuro/go/node/cmd \
-is_genesis=${{ matrix.is_genesis }} \
-node_type=${{ matrix.node_type }} \
-is_sgx_enabled=true \
-host_id=${{ secrets[matrix.node_pk_addr] }} \
-l1_ws_url=${{needs.build.outputs.L1_WS_URL}} \
-private_key=${{ secrets[matrix.node_pk_str] }} \
-sequencer_id=${{ secrets.GETHNETWORK_PREFUNDED_ADDR_0 }} \
-host_public_p2p_addr=obscuronode-${{ matrix.host_id }}-${{needs.build.outputs.RESOURCE_TESTNET_NAME}}-${{needs.build.outputs.VM_BUILD_NUMBER}}.uksouth.cloudapp.azure.com:10000 \
-host_id=${{ vars[matrix.node_addr_lookup] }} \
-l1_ws_url=${{ secrets[matrix.node_l1_ws_lookup] }} \
-private_key=${{ secrets[matrix.node_pk_lookup] }} \
-sequencer_id=${{ vars.NODE_WALLET_ADDR_0 }} \
-host_public_p2p_addr=obscuronode-${{ matrix.host_id }}-${{vars.RESOURCE_TESTNET_NAME}}-${{needs.build.outputs.VM_BUILD_NUMBER}}.uksouth.cloudapp.azure.com:10000 \
-host_p2p_port=10000 \
-enclave_docker_image=${{needs.build.outputs.L2_ENCLAVE_DOCKER_BUILD_TAG}} \
-host_docker_image=${{needs.build.outputs.L2_HOST_DOCKER_BUILD_TAG}} \
-enclave_docker_image=${{vars.L2_ENCLAVE_DOCKER_BUILD_TAG}} \
-host_docker_image=${{vars.L2_HOST_DOCKER_BUILD_TAG}} \
-log_level=${{ github.event.inputs.log_level }} \
-batch_interval=${{needs.build.outputs.BATCH_INTERVAL}} \
-rollup_interval=${{needs.build.outputs.ROLLUP_INTERVAL}} \
-batch_interval=${{vars.BATCH_INTERVAL}} \
-rollup_interval=${{vars.ROLLUP_INTERVAL}} \
-l1_chain_id=${{vars.L1_CHAIN_ID}} \
upgrade'
check-obscuro-is-healthy:
needs:
- build
- deploy
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.testnet_type }}
steps:
- uses: actions/checkout@v3

- name: "Wait until obscuro node is healthy"
shell: bash
run: |
./.github/workflows/runner-scripts/wait-node-healthy.sh --host=obscuronode-0-${{needs.build.outputs.RESOURCE_TESTNET_NAME}}-${{needs.build.outputs.VM_BUILD_NUMBER}}.uksouth.cloudapp.azure.com
./.github/workflows/runner-scripts/wait-node-healthy.sh --host=obscuronode-1-${{needs.build.outputs.RESOURCE_TESTNET_NAME}}-${{needs.build.outputs.VM_BUILD_NUMBER}}.uksouth.cloudapp.azure.com
./.github/workflows/runner-scripts/wait-node-healthy.sh --host=obscuronode-0-${{vars.RESOURCE_TESTNET_NAME}}-${{needs.build.outputs.VM_BUILD_NUMBER}}.uksouth.cloudapp.azure.com
./.github/workflows/runner-scripts/wait-node-healthy.sh --host=obscuronode-1-${{vars.RESOURCE_TESTNET_NAME}}-${{needs.build.outputs.VM_BUILD_NUMBER}}.uksouth.cloudapp.azure.com
deploy-faucet-on-dispatch:
uses: ./.github/workflows/manual-deploy-testnet-faucet.yml
Expand All @@ -228,6 +217,8 @@ jobs:

obscuro-test-signal-on-dispatch:
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.testnet_type }}
needs:
- deploy-faucet-on-dispatch
steps:
Expand All @@ -243,6 +234,8 @@ jobs:
obscuro-test-signal-on-schedule:
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.testnet_type }}
needs:
- deploy-faucet-on-schedule
steps:
Expand Down
2 changes: 1 addition & 1 deletion contracts/config/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
]
},
"localObscuro": {
"chainId": 777,
"chainId": 443,
"url": "http://127.0.0.1:3000/v1/",
"obscuroEncRpcUrl": "ws://127.0.0.1:37901",
"companionNetworks" : {
Expand Down
4 changes: 2 additions & 2 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
"@nomicfoundation/hardhat-toolbox": "~2.0.0",
"@openzeppelin/contracts": "4.5.0",
"@openzeppelin/hardhat-upgrades": "^1.21.0",
"@solidstate/hardhat-bytecode-exporter": "^1.1.1",
"hardhat": "~2.12.4",
"hardhat-abi-exporter": "^2.10.1",
"hardhat-deploy": "~0.11.22",
"node-docker-api": "^1.1.22",
"ts-node": "^10.9.1",
"ts-node": "~10.9.1",
"typescript": "^4.9.4"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ release). An arbitrary `gasPrice` should be given e.g. the current price on the
'nonce': w3.eth.getTransactionCount(account.address),
'gasPrice': 1499934385,
'gas': 720000,
'chainId': 777
'chainId': 443
}
)
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def run():
'nonce': w3.eth.getTransactionCount(account.address),
'gasPrice': 1499934385,
'gas': 720000,
'chainId': 777
'chainId': 443
}
)

Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/testnet/deploying-a-smart-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ You can now go ahead and deploy your smart contract to the Obscuro Testnet.

1. Log in to MetaMask and confirm you are connected to Obscuro Testnet network. The parameters for the Obscuro Testnet can be found [here](https://docs.obscu.ro/testnet/essentials/).

1. In the _Deploy & Run Transactions_ section of Remix change the Environment to _Injected Web3_. This tells Remix to use the network settings currently configured in your MetaMask wallet, which in this case is the Obscuro Testnet. If the connection to Obscuro Testnet is successful you will see the text _Custom (777) network_ displayed under _Injected Web3_.
1. In the _Deploy & Run Transactions_ section of Remix change the Environment to _Injected Web3_. This tells Remix to use the network settings currently configured in your MetaMask wallet, which in this case is the Obscuro Testnet. If the connection to Obscuro Testnet is successful you will see the text _Custom (443) network_ displayed under _Injected Web3_.

1. Click the _Deploy_ button to deploy your smart contract to the Obscuro Testnet.

Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/testnet/example-dapps.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Building the guessing game in Obscuro addresses both scenarios described above.
1. Start up the wallet extension. Follow instructions [here](https://docs.obscu.ro/wallet-extension/wallet-extension).
1. For the moment, the Guessing Game includes an ERC20 token (called OGG, short for Obscuro Guessing Game). This is partly because OGG is modified to have a built-in faucet: It allocates tokens to addresses as they make a request to allow other addresses to take tokens from their account.
1. If you want to see this balance in your wallet, you have to import a new Token with the address: ``0x5FbDB2315678afecb367f032d93F642f64180aa3``
1. Browse to [the number guessing game](http://obscuronet.github.io/sample-applications/number-guessing-game). Check you see `Network ID: 777` at the top of the game window to confirm you are connected to Obscuro Testnet.
1. Browse to [the number guessing game](http://obscuronet.github.io/sample-applications/number-guessing-game). Check you see `Network ID: 443` at the top of the game window to confirm you are connected to Obscuro Testnet.
1. MetaMask will open and ask to connect your account. Click `Next` then click `Connect`.
1. Approve the payment of 1 or more token units to play the game (this will be added to the prize pool) by clicking the `Approve game fee` button.
1. MetaMask will ask for your account to sign a transaction specifying the Guess contract address as the approval delegate. This means that you're giving permission for the game to take the participation fee. Click `Confirm`. Once approved you will see a confirmation popup. Click `OK`.
Expand Down
4 changes: 2 additions & 2 deletions docs/_docs/wallet-extension/configure-metamask.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ To keep data encrypted between MetaMask and the Obscuro network, MetaMask needs

* Network Name: Obscuro Testnet
* New RPC URL: `http://127.0.0.1:3000/`
* Chain ID: 777
* Currency Symbol: OBX
* Chain ID: 443
* Currency Symbol: ETH

It should look like this:

Expand Down
2 changes: 1 addition & 1 deletion go/config/enclave_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func DefaultEnclaveConfig() *EnclaveConfig {
Address: "127.0.0.1:11000",
NodeType: common.Sequencer,
L1ChainID: 1337,
ObscuroChainID: 777,
ObscuroChainID: 443,
WillAttest: false, // todo (config) - attestation should be on by default before production release
ValidateL1Blocks: false,
GenesisJSON: nil,
Expand Down
2 changes: 1 addition & 1 deletion go/config/host_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func DefaultHostParsedConfig() *HostInputConfig {
LogPath: "",
PrivateKeyString: "0000000000000000000000000000000000000000000000000000000000000001",
L1ChainID: 1337,
ObscuroChainID: 777,
ObscuroChainID: 443,
ProfilerEnabled: false,
L1StartHash: common.L1BlockHash{}, // this hash will not be found, host will log a warning and then stream from L1 genesis
SequencerID: gethcommon.BytesToAddress([]byte("")),
Expand Down
Loading

0 comments on commit b966675

Please sign in to comment.