Skip to content

Commit

Permalink
🪄 [QA] Update stage environments (#471)
Browse files Browse the repository at this point in the history
This is a pull request that upon merging will update stage environments
with recent `main` changes.
  • Loading branch information
andreachapman authored Oct 23, 2023
2 parents 8ea0435 + 06464dd commit 9efa97b
Show file tree
Hide file tree
Showing 44 changed files with 492 additions and 652 deletions.
37 changes: 31 additions & 6 deletions .github/workflows/update-environments.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Refer to docs/testing-env.md to learn more about deployments configuration.
name: Update staging and production environments

on:
push:
branches:
- main
- stage-live
workflow_dispatch:

jobs:
sync-main-to-stage-live:
Expand All @@ -14,28 +16,51 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Open/update a PR from `main` to `stage-live`
id: pull
uses: tretuna/[email protected]
id: pr
uses: tretuna/sync-branches@ea58ab6e406fd3ad016a064b31270bbb41127f41 # 1.4.0
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
FROM_BRANCH: "main"
TO_BRANCH: "stage-live"
PULL_REQUEST_TITLE: "Update stage environments"
PULL_REQUEST_TITLE: "🪄 [QA] Update stage environments"
PULL_REQUEST_BODY: "This is a pull request that upon merging will update stage environments with recent `main` changes."
REVIEWERS: '["andreachapman"]'
- uses: studroid/label-pr-or-issue-action@ff48a93f6e1a8d8a6befdae900f54da173b17215 # v1.0.1
with:
pr-or-issue-number: ${{ steps.pr.outputs.PULL_REQUEST_NUMBER }}
label: "⚙️ deployment"
sync-stage-live-to-stage-fork:
if: github.ref == 'refs/heads/stage-live'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Sync `stage-fork` with `stage-live`
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
git checkout stage-fork
git merge origin/stage-live
git push origin stage-fork
sync-stage-live-to-release:
if: github.ref == 'refs/heads/stage-live'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Open/update a PR from `main` to `stage-live`
id: pull
uses: tretuna/[email protected]
id: pr
uses: tretuna/sync-branches@ea58ab6e406fd3ad016a064b31270bbb41127f41 # 1.4.0
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
FROM_BRANCH: "stage-live"
TO_BRANCH: "release"
PULL_REQUEST_TITLE: "Update release branch"
PULL_REQUEST_TITLE: "🚀 [QA] Update release environment"
PULL_REQUEST_BODY: "This is a pull request that upon merging will update production environment with recent `stage-live` changes."
REVIEWERS: '["andreachapman"]'
- uses: studroid/label-pr-or-issue-action@ff48a93f6e1a8d8a6befdae900f54da173b17215 # v1.0.1
with:
pr-or-issue-number: ${{ steps.pr.outputs.PULL_REQUEST_NUMBER }}
label: "⚙️ deployment"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
## Docs

- [Local environment setup](docs/local-env-setup.md)
- [Testing environment](docs/testing-env.md)
- [Testing environment](docs/testing-env.md)
67 changes: 62 additions & 5 deletions docs/local-env-setup.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Working with locally forked Arbitrum Sepolia chain
# Working with forked Arbitrum Sepolia chain

### In the dapp:

- Override `USE_LOCALHOST_FORK="true"` in `.env` file.
- Override `USE_ARBITRUM_FORK="true"` in `.env` file.
- Run the dapp

### In the [extension](https://github.com/tahowallet/extension):
Expand All @@ -28,17 +28,74 @@ Instruction based on [the system tests readme](https://github.com/tahowallet/con
- `nvm use`
- `yarn install`
- Provide [`.envrc`](https://github.com/tahowallet/contracts/blob/main/system-tests/.envrc.SAMPLE) variables, make sure you have [Direnv](https://direnv.net/) installed

```bash
export FORKING_URL="https://sepolia-rollup.arbitrum.io/rpc"
export TAHO_DEPLOYER_PRIVATE_KEY="..." # mnemonic or first private key from `testertesting.eth`

export TAHO_DEPLOYER_PRIVATE_KEY="..." # private key of testertesting.eth
export TAHO_TEST_WALLET_PRIVATE_KEY="..." # private key of testertesting.eth
export GUARDA_PRIVATE_KEY="..." # private key of testertesting.eth

export FORKING_BLOCK="..." # historical block; optional - setting this var enables cache and speeds up repatable read operations
export FORKING_CHAIN_ID="421614" # Arbitrum Sepolia chain id
export ARBITRUM_HTTPS_RPC_URL="http://127.0.0.1:8545/"
```
- Open first terminal and run `yarn run test:fork`

- Open terminal and run `yarn run test:fork`

---

After all the steps above you should have:

- the Taho token deployed on the Arbitrum Sepolia forked chain
- the dapp should be able to interact with the token
- the extension should be able to display the token's balance
- the extension should be able to display the token's balance

---

### XP allocations deployment

To be able to test XP allocations you need to:

#### Prepare merkle tree file:

1. In the contracts repository create a file with XP allocations in the format:
```json
[
{
"account": "0x...",
"amount": "4000"
},
{
"account": "0x...",
"amount": "2000"
},
{
"account": "0x...",
"amount": "3000"
}
]
```
2. Run `yarn run merkle:generate <path-to-input-file>.json <path-to-output-file>.json`. This command will create an JSON file with a merkle tree of the XP allocations.
3. Copy the output file to the dapp's `src/data/xp/<realm-id>` directory. Name the file `xp_<realm-id>_<drop-index>.json`. Drop index should start from `1` and be incremented by `1` for each new drop.

#### Deploy XP allocations:

1. In the contracts repository set correct environment variables based on where you want to publish the XP drop.
```bash
export GUARDA_PRIVATE_KEY="..." # private key for account that will publish the drop, locally use testertesting.eth
export ARBITRUM_HTTPS_RPC_URL="http://127.0.0.1:8545/" # RPC url of the chain where you want to publish the drop
```
2. Then run:
```
yarn run merkle:allocate-xp <realm-address> <merkle-root> <amount> <merkle-data-url>
```
Where
```
<realm-address> - address of the realm where you want to publish the drop
<merkle-root> - merkle root of the merkle tree, copy from the output file
<amount> - amount of XP to be distributed, copy from the output file
<merkle-data-url> - url to the merkle tree file, can't be empty, doesn't matter locally, on public chain should be set to the actual url of the merkle tree json file
```
3. Drop should be accessible on the chain now and dapp should be able to fetch info about the drops and claim the XP.
4. Leaderboard data is just a sum of all drops for a given realm, script to generate leaderboard file is TODO
4 changes: 2 additions & 2 deletions docs/testing-env.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ flowchart
style 788810 fill:#64e3db
788810 -->|"Auto deploy"| 588961(("PR-preview"))
style 588961 fill:#e3c464
140433 -->|"Auto deploy"| 836305(("stage-fork\n"))
140433 -->|"Auto deploy"| 836305(("stage-live\n"))
style 836305 fill:#e3c464
809682{"stage-fork\nbranch"} -->|"Auto deploy"| 490721(("stage-live\n"))
809682{"stage-fork\nbranch"} -->|"Auto deploy"| 490721(("stage-fork\n"))
style 809682 fill:#64e3db
style 490721 fill:#e36464
804724{"release\nbranch"} -->|"Auto deploy"| 389165(("app.taho.xyz"))
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
"start": "yarn write-types && patch-package && webpack serve --mode=development",
"build": "yarn write-types && patch-package && webpack build --mode=production",
"write-types": "node scripts/write-taho-types.mjs",
"generate-xp": "node scripts/generate-xp-merkle-tree.mjs",
"distribute-xp": "node scripts/distribute-xp-localhost.mjs",
"lint:eslint": "eslint .",
"lint:fix:eslint": "eslint . --fix",
"lint:config": "prettier -c '**/*.@(json|yaml|toml)'",
Expand Down
93 changes: 0 additions & 93 deletions scripts/distribute-xp-localhost.mjs

This file was deleted.

86 changes: 0 additions & 86 deletions scripts/generate-xp-merkle-tree.mjs

This file was deleted.

Loading

0 comments on commit 9efa97b

Please sign in to comment.