Skip to content

Commit

Permalink
Merge pull request #52 from sporeprotocol/chore/mainnet-deployment
Browse files Browse the repository at this point in the history
chore: prepare mainnet deployment
  • Loading branch information
ashuralyk authored Jan 25, 2024
2 parents 53bfd4d + 4406467 commit 466239f
Show file tree
Hide file tree
Showing 15 changed files with 141 additions and 42 deletions.
72 changes: 61 additions & 11 deletions .github/workflows/capsule.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
name: Capsule build/test
on:
push:
pull_request:
paths:
- contracts/**
- lib/**
- tests/**

jobs:
capsule:
capsule-build-and-test:
strategy:
fail-fast: false
matrix:
include:
- target: debug
cargo-option: ""
target-dir: "build/debug"
- target: testnet
cargo-option: "--release"
target-dir: "build/release"
- target: mainnet
cargo-option: "--release -- --features release_export"
target-dir: "build/release"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: actions/checkout@v4

- name: Prepare capsule v0.10.2
run: |
Expand All @@ -28,10 +38,50 @@ jobs:
run: cargo install cross --git https://github.com/cross-rs/cross

- name: Capsule build
run: capsule build
run: capsule build ${{ matrix.cargo-option }}

- name: Capsule test -- --nocapture
run: capsule test
- name: Capsule test
run: capsule test ${{ matrix.cargo-option }}



- name: List all the contract binaries of ${{ github.ref }}
run: ls -l ${{ matrix.target-dir }}

- name: Archive the contract binaries ${{ github.sha }}
uses: actions/upload-artifact@v4
with:
name: contract-binaries-${{ matrix.target }}-${{ github.sha }}
path: |
build/debug
build/release
outputs:
spore-contract-ref: ${{ github.sha }}

record-code-hash:
needs: capsule-build-and-test
strategy:
matrix:
target: [debug, testnet, mainnet]
runs-on: ubuntu-20.04
steps:
# TODO: add this codehash util into the `tests` directory
# or, simply use `ckb-cli util blake2b --binary-path ...` to get the codehash
- name: Checkout a code_hash tool
uses: actions/checkout@v4
with:
repository: Flouse/spore-contract
ref: codehash-tool

- uses: actions/download-artifact@v4
with:
name: contract-binaries-${{ matrix.target }}-${{ needs.capsule-build-and-test.outputs.spore-contract-ref }}
path: build

- name: Build codehash-tool
working-directory: build
run: cargo build

- name: Record code_hash of contract binaries
working-directory: build
run: |
echo "spore-contract-commit: ${{ needs.capsule-build-and-test.outputs.spore-contract-ref }}\n"
./target/debug/code_hash
23 changes: 1 addition & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,7 @@ The versioning philosophy is **"Using code_hash as version"** for Spore Protocol

Make sure you are using the proper version you want, because there's no such an "upgrade/downgrade" method but we suggest to use "destroy/reconstruct" method instead, which requires no modification of any fields in Spore cell.

Our `forzen` versions of contract, which are our prior versions, can be found in [directory](https://github.com/sporeprotocol/spore-contract/tree/master/deployment/frozen) `./deployment/frozen`. To describe more clearly, the `frozen` information contains each avaliable `code_hash` generated from Spore contracts with corresponding commit hash for the rolling back help.

`./deployment/migration` recorded the deployment detail for each Spore contract. Here's a list about the newest versions:

#### Spore
Pudge Testnet:
- data_hash: `0xa32df38d2de1da82cbcb9e4467f8c18479596394eea977e471b75be5fe3e9c67`

#### Cluster
Pudge Testnet:
- data_hash: `0x5203a3baf931c15a809c4a0bb7041aebb73118281e31e8d104d926b8523977b1`

#### Cluster Proxy
Pudge Testnet:
- data_hash: `0x08e5cecab2bbdea9139534a822d46b82929e06f12f00c68343a88a58827cd3db`

#### Cluster Agent
- data_hash: `0x88850ac632eed604f0ad784394004db384d0eea8038a24eee83439687d79343f`

#### Mutant (Lua Extension)
Pudge Testnet:
- data_hash: `0x94a9b875911ace20f1f0d063a26495d14e4b04e32fd218261bb747f34e71ae47`
Our `forzen` versions of contract, which are our prior versions, can be found in [directory](https://github.com/sporeprotocol/spore-contract/tree/master/deployment/frozen) `./deployment/frozen`. To describe more clearly, the `frozen` information contains each avaliable `code_hash` generated from Spore contracts. Historical version refers to [here](https://github.com/sporeprotocol/spore-contract/blob/master/docs/VERSIONS.md).

In addition, using Mutant contract requires the binary of Lua library. Information are recorded [here](https://github.com/sporeprotocol/spore-contract/tree/master/contracts/spore_extension_lua/lua). For simplicity, it's already deployed in the Pudge Testnet:

Expand Down
13 changes: 10 additions & 3 deletions deployment/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
#!/usr/bin/env bash

echo "deploying $1 from $3 to $2"
export network=$4

if [ -z $network ]
then
export network="testnet"
fi

echo "deploying $1 from $3 to $2 on $network"

ckb-cli --url $2 deploy gen-txs --from-address $3 --fee-rate 1000 --deployment-config ./toml/$1.toml \
--info-file ./$1.json --migration-dir ./migration/$1 --sign-now
--info-file ./$1.json --migration-dir ./migration/$network/$1 --sign-now

echo "ckb transacion file '$1.json' has generated"

ckb-cli --url $2 deploy apply-txs --info-file ./$1.json --migration-dir ./migration/$1
ckb-cli --url $2 deploy apply-txs --info-file ./$1.json --migration-dir ./migration/$network/$1

rm ./$1.json

Expand Down
3 changes: 1 addition & 2 deletions deployment/frozen/testnet.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# version v1
# version v0.1.0
[[code_hash_list]]
commit_hash = "457e32d23b5f401cad837e52a568281784943e18"
cluster = "598d793defef36e2eeba54a9b45130e4ca92822e1d193671f490950c3b856080"
spore = "bbad126377d45f90a8ee120da988a2d7332c78ba8fd679aab478a19d6c133494"
13 changes: 13 additions & 0 deletions deployment/migration/mainnet/cluster/2024-01-23-0.2.2-beta.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"cell_recipes": [
{
"name": "cluster",
"tx_hash": "0xe464b7fb9311c5e2820e61c99afc615d6b98bdefbe318c34868c010cbd0dc938",
"index": 0,
"occupied_capacity": 4690900000000,
"data_hash": "0x7366a61534fa7c7e6225ecc0d828ea3b5366adec2b58206f2ee84995fe030075",
"type_id": null
}
],
"dep_group_recipes": []
}
13 changes: 13 additions & 0 deletions deployment/migration/mainnet/spore/2024-01-23-40ef57a2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"cell_recipes": [
{
"name": "spore",
"tx_hash": "0xcb67e11a39594a183eae50664073a85fa0140ae25480df61114aca0e47726d38",
"index": 0,
"occupied_capacity": 7679700000000,
"data_hash": "0x9cb02fa8621d79fff300b910d52665f594d3ad468142a66213cfaaca0409502c",
"type_id": null
}
],
"dep_group_recipes": []
}
2 changes: 1 addition & 1 deletion deployment/toml/cluster.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ location = { file = "../build/release/cluster" }
# The lock script set to output cells
[lock]
code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
args = "0x470dcdc5e44064909650113a274b3b36aecb6dc7"
args = "0x20da6b70dfe59586e89635dbb3adc7aa998e7189"
hash_type = "type"
2 changes: 1 addition & 1 deletion deployment/toml/spore.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ location = { file = "../build/release/spore" }
# The lock script set to output cells
[lock]
code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
args = "0x470dcdc5e44064909650113a274b3b36aecb6dc7"
args = "0x20da6b70dfe59586e89635dbb3adc7aa998e7189"
hash_type = "type"
40 changes: 40 additions & 0 deletions docs/VERSIONS.md
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
# Historical Versions

## tag 0.2.1 (testnet)

**spore**:
| | |
|-|-|
|tx_hash|0x06995b9fc19461a2bf9933e57b69af47a20bf0a5bc6c0ffcb85567a2c733f0a1|
|index|0|
|code_hash|0x5e063b4c0e7abeaa6a428df3b693521a3050934cf3b0ae97a800d1bc31449398|

**cluster**:
| | |
|-|-|
|tx_hash|0xfbceb70b2e683ef3a97865bb88e082e3e5366ee195a9c826e3c07d1026792fcd|
|index|0|
|code_hash|0x7366a61534fa7c7e6225ecc0d828ea3b5366adec2b58206f2ee84995fe030075|

**cluster_agent**:
| | |
|-|-|
|tx_hash|0x53fdb9366637434ff685d0aca5e2a68a859b6fcaa4b608a7ecca0713fed0f5b7|
|index|0|
|code_hash|0xc986099b41d79ca1b2a56ce5874bcda8175440a17298ea5e2bbc3897736b8c21|

**cluster_proxy**:
| | |
|-|-|
|tx_hash|0x0231ea581bbc38965e10a2659da326ae840c038a9d0d6849f458b51d94870104|
|index|0|
|code_hash|0xbe8b9ce3d05a32c4bb26fe71cd5fc1407ce91e3a8b9e8719be2ab072cef1454b|

## tag 0.2.2 (mainnet)


**cluster**:
| | |
|-|-|
|tx_hash|0xe464b7fb9311c5e2820e61c99afc615d6b98bdefbe318c34868c010cbd0dc938|
|index|0|
|code_hash|0x7366a61534fa7c7e6225ecc0d828ea3b5366adec2b58206f2ee84995fe030075|
2 changes: 0 additions & 2 deletions lib/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ pub struct FrozenVersions {

#[derive(serde::Deserialize)]
pub struct PublishedCodeHash {
#[serde(rename(deserialize = "commit_hash"))]
_commit_hash: String,
#[serde(default)]
spore: String,
#[serde(default)]
Expand Down

0 comments on commit 466239f

Please sign in to comment.