Skip to content

Commit 62f0d64

Browse files
dnkolegovsnissnraulkauto-commitadlrocha
authored
Push the latest contracts (#516)
Signed-off-by: Alfonso de la Rocha <adlrocha@tutamail.com> Co-authored-by: Mikers <snissn@gmail.com> Co-authored-by: raulk <raul@protocol.ai> Co-authored-by: snissn <snissn@users.noreply.github.com> Co-authored-by: auto-commit <auto-commit@users.noreply.github.com> Co-authored-by: Alfonso de la Rocha <adlrocha@tutamail.com> Co-authored-by: adlrocha <adlrocha@users.noreply.github.com> Co-authored-by: raulk <raul.kripalani@gmail.com>
1 parent 003ac8f commit 62f0d64

53 files changed

Lines changed: 1191 additions & 590 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Contracts Deployment Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
pull_request:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v2
17+
18+
- name: Set up Node.js
19+
uses: actions/setup-node@v2
20+
with:
21+
node-version: '18' # Adjust this as needed for your project
22+
23+
- name: Install dependencies
24+
run: cd contracts && npm install
25+
26+
- name: Install Foundry
27+
run: |
28+
cd contracts
29+
curl -L https://foundry.paradigm.xyz | bash
30+
export PATH="$PATH:/home/runner/.config/.foundry/bin"
31+
foundryup
32+
forge install
33+
34+
- name: Generate Ethereum Private Key and Create .env File and run make
35+
run: |
36+
cd contracts
37+
PRIVATE_KEY=$(node -e "console.log(require('crypto').randomBytes(32).toString('hex'))")
38+
echo "export PRIVATE_KEY=0x$PRIVATE_KEY" > .env
39+
echo "export RPC_URL=http://127.0.0.1:1337" >> .env
40+
echo "export CHAIN_ID=1337" >> .env
41+
export PATH="$PATH:/home/runner/.config/.foundry/bin"
42+
npx ganache-cli -g0 -p1337 --account 0x$PRIVATE_KEY,1001901919191919191 &
43+
sleep 5
44+
make deploy-ipc

.github/workflows/contracts-npm-audit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: NPM Audit
1+
name: Contracts NPM Audit
22

33
# This workflow is triggered from the main CI workflow.
44
on:

.github/workflows/contracts-prettier.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# .github/workflows/prettier.yml
2-
3-
name: Prettier
2+
name: Contracts Prettier
43

54
# This workflow is triggered from the main CI workflow.
65
on:

.github/workflows/contracts-sast.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Static analysis
1+
name: Contracts Static analysis
22

33
# This workflow is triggered from the main CI workflow.
44
on:

.github/workflows/contracts-storage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Storage check
1+
name: Contracts Storage check
22

33
# This workflow is triggered from the main CI workflow.
44
on:

.github/workflows/contracts-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Tests
1+
name: Contracts Tests
22

33
# This workflow is triggered from the main CI workflow.
44
on:

contracts/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ OUTPUT ?= out
1010
deploy-ipc:
1111
./ops/deploy.sh $(NETWORK)
1212

13+
deploy-subnet-registry:
14+
./ops/deploy-subnet-registry.sh $(NETWORK)
15+
16+
deploy-subnet:
17+
./ops/deploy-subnet.sh $(NETWORK)
18+
1319
upgrade-gw-diamond:
1420
./ops/upgrade-gw-diamond.sh $(NETWORK)
1521

@@ -106,7 +112,6 @@ coverage-for-mac: | forge
106112

107113
prepare: build-selector-library fmt lint test slither
108114

109-
110115
build-selector-library: | forge
111116
python scripts/python/build_selector_library.py
112117
npx prettier -w test/helpers/SelectorLibrary.sol

contracts/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,48 @@ To deploy the contracts in some other network configured in the Hardhat config y
4949
make deploy-ipc NETWORK=<network-name>
5050
```
5151

52+
# Upgrading IPC Solidity Contracts
53+
54+
This repository's contracts use the Diamond pattern for upgradability, allowing new features to be added or issues to be corrected without a full redeployment. The upgrade process is automated and includes bytecode verification to ensure the integrity of the changes.
55+
56+
## Automated Upgrade and Bytecode Verification
57+
58+
When you run an upgrade command, the repository's scripts handle several tasks:
59+
60+
1. **Bytecode Verification**: The scripts fetch the bytecode of the currently deployed contracts on an FEVM-powered IPC network using the details stored in local JSON files in the root directory of the git repository. They compare this with the bytecode generated after applying the intended changes on a temporary Ganache network.
61+
62+
2. **Conditional Upgrades**: If the bytecode verification process detects changes that align with the intended upgrades, the `make` command conditionally triggers other scripts to perform the actual upgrade on the network.
63+
64+
## Upgrade Commands
65+
66+
To upgrade a contract, you may use the following commands. The NETWORK parameter is optional; if not specified, the scripts will default to "auto":
67+
68+
- **Gateway Diamond Upgrade**:
69+
70+
```bash
71+
make upgrade-gw-diamond [NETWORK=<network-name>]
72+
```
73+
74+
- **Subnet Actor Diamond Upgrade**:
75+
76+
```bash
77+
make upgrade-sa-diamond [NETWORK=<network-name>]
78+
```
79+
80+
- **Subnet Registry Diamond Upgrade**:
81+
```bash
82+
make upgrade-sr-diamond [NETWORK=<network-name>]
83+
```
84+
85+
After running any of these commands, the scripts will provide transaction details for verification. Check the transaction on the appropriate block explorer to confirm the upgrade's success.
86+
87+
## Important Notes
88+
89+
- The upgrade commands are intended for use by authorized personnel with a deep understanding of the contracts' functionality.
90+
- Ensure that your local repository is up to date with the latest contract code and JSON files before initiating an upgrade.
91+
- Backup all contract data and thoroughly test any new code in a controlled environment prior to an upgrade.
92+
- Monitor the output of the upgrade process carefully for transaction details and to verify its successful completion.
93+
5294
## Branching Strategy
5395

5496
### Production branch

contracts/binding/build.rs

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/binding/src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@ pub mod xnet_messaging_facet;
2424
#[allow(clippy::all)]
2525
pub mod gateway_messenger_facet;
2626
#[allow(clippy::all)]
27+
pub mod subnet_actor_checkpointing_facet;
28+
#[allow(clippy::all)]
2729
pub mod subnet_actor_diamond;
2830
#[allow(clippy::all)]
2931
pub mod subnet_actor_getter_facet;
3032
#[allow(clippy::all)]
3133
pub mod subnet_actor_manager_facet;
3234
#[allow(clippy::all)]
35+
pub mod subnet_actor_pause_facet;
36+
#[allow(clippy::all)]
37+
pub mod subnet_actor_reward_facet;
38+
#[allow(clippy::all)]
3339
pub mod subnet_registry_diamond;
3440
#[allow(clippy::all)]
3541
pub mod register_subnet_facet;
@@ -50,11 +56,11 @@ fvm_address_conversion!(gateway_getter_facet);
5056
fvm_address_conversion!(bottom_up_router_facet);
5157
fvm_address_conversion!(xnet_messaging_facet);
5258
fvm_address_conversion!(gateway_messenger_facet);
53-
fvm_address_conversion!(subnet_actor_manager_facet);
59+
fvm_address_conversion!(subnet_actor_checkpointing_facet);
60+
fvm_address_conversion!(subnet_actor_getter_facet);
5461
fvm_address_conversion!(lib_gateway);
5562

5663
// The list of contracts that need to convert common types between each other
57-
common_type_conversion!(gateway_getter_facet, subnet_actor_manager_facet);
5864
common_type_conversion!(subnet_actor_getter_facet, bottom_up_router_facet);
5965
common_type_conversion!(subnet_actor_getter_facet, checkpointing_facet);
6066
common_type_conversion!(subnet_actor_getter_facet, xnet_messaging_facet);

0 commit comments

Comments
 (0)