Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): add fmt workflow #16

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
9a4f47b
chore(build): add prettier and solidity plugin
MaxMustermann2 Jun 3, 2024
0868a71
chore(build): add `lint.yml` workflow
MaxMustermann2 Jun 3, 2024
74d91e6
chore(lint): add prettier config
MaxMustermann2 Jun 3, 2024
65c0671
chore(lint): apply lint
MaxMustermann2 Jun 3, 2024
d748b17
chore(lint): apply lint on missed file
MaxMustermann2 Jun 3, 2024
54dd5dc
chore(ci): change trigger for lint ci
MaxMustermann2 Jun 3, 2024
c5e5b46
chore(lint): add solidity parser to prettierrc
MaxMustermann2 Jun 3, 2024
2f70e38
doc(bootstrap): remove superfluous comments
MaxMustermann2 Jun 3, 2024
60c949e
doc(test): remove unnecessary comments
MaxMustermann2 Jun 3, 2024
925bf36
refactor: implement token whitelisting in storage
MaxMustermann2 Jun 3, 2024
3751546
chore(lint)
MaxMustermann2 Jun 3, 2024
5c2aec1
fix(test): update test strings in Bootstrap
MaxMustermann2 Jun 3, 2024
f4d94b4
chore(lint)
MaxMustermann2 Jun 3, 2024
19eb40a
Merge main
MaxMustermann2 Jun 3, 2024
3e9e6cb
Revert chore(build): add prettier solidity plugin
MaxMustermann2 Jun 3, 2024
a4540c6
chore(build): remove prettier
MaxMustermann2 Jun 3, 2024
b3a9064
fix(build): move to `forge fmt` from prettier
MaxMustermann2 Jun 3, 2024
01b28ec
fix(ci): update test comment
MaxMustermann2 Jun 3, 2024
45f95de
chore(lint): apply `forge fmt`
MaxMustermann2 Jun 3, 2024
478b6be
fix(ci): fail if not formatted
MaxMustermann2 Jun 3, 2024
dfc1583
fix(build): rename fmt workflow
MaxMustermann2 Jun 3, 2024
542cd4b
fix(bootstrap): validate client chain init params
MaxMustermann2 Jun 3, 2024
2f9a9e7
fix(mocks): return value in withdraw mock
MaxMustermann2 Jun 3, 2024
4c19337
test(doc): add comments for Bootstrap deposit test
MaxMustermann2 Jun 3, 2024
cabcaa9
fix(bootstrap): validate length of init data >= 4
MaxMustermann2 Jun 3, 2024
63a6032
doc(test): update bootstrap unit test comments
MaxMustermann2 Jun 3, 2024
30cc514
chore(ci): forge fmt
MaxMustermann2 Jun 3, 2024
c82d71d
chore(fmt): bring back Endian.sol and add config
MaxMustermann2 Jun 4, 2024
0429b22
build(ci): merge workflows and use cache
MaxMustermann2 Jun 4, 2024
c256322
build(ci): use a common foundry-setup action
MaxMustermann2 Jun 4, 2024
1a0bb45
build(ci): another attempt at common workflow
MaxMustermann2 Jun 4, 2024
001b107
fix(ci): correct extension of foundry-setup
MaxMustermann2 Jun 4, 2024
3f620c7
build(ci): another attempt
MaxMustermann2 Jun 4, 2024
9173375
fix(ci): save key cache correctly
MaxMustermann2 Jun 4, 2024
2dc216b
fix(ci): remove deprecated code
MaxMustermann2 Jun 4, 2024
3aeebcb
fix(ci): use output instead of env
MaxMustermann2 Jun 4, 2024
10999c0
fix(ci): save install dir for forge
MaxMustermann2 Jun 4, 2024
3be29a6
fix(ci): finally, fix the workflows
MaxMustermann2 Jun 4, 2024
ffbfa7a
fix(git): ignore the forge snapshot
MaxMustermann2 Jun 4, 2024
e929b0a
fix(ci): also cache git submodules
MaxMustermann2 Jun 4, 2024
bb1ab95
chore(lint): lint the ci
MaxMustermann2 Jun 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions .github/workflows/forge-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Forge CI to build, test and format

on:
pull_request:
push:
branches:
- main
- release/**
tags:
- "*"

env:
FOUNDRY_PROFILE: ci

jobs:
build:
uses: ./.github/workflows/foundry-setup.yml
with:
version: nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9
steps:
- name: Build
run: forge build

- name: Add comment for build failure
if: failure()
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'The build has failed. Please check the logs.'
})

- name: Cache Foundry artifacts (excluding binaries)
uses: actions/cache/save@v3
with:
key: "${{ runner.os }}-build-${{ github.sha }}"
path: |
- ./out
- ./cache
- ./broadcast

test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: ./.github/workflows/foundry-setup.yml
with:
version: nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9

- name: Restore cached Foundry artifacts
uses: actions/cache/restore@v3
with:
key: "${{ runner.os }}-build-${{ github.sha }}"
path: |
- ./out
- ./cache
- ./broadcast

- name: Run tests
run: forge test -vvv

- name: Add comment for test failure
if: failure()
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'The tests have failed. Please check the logs.'
})

fmt:
runs-on: ubuntu-latest
needs: build
steps:
- uses: ./.github/workflows/foundry-setup.yml
with:
version: nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9

- name: Restore cached Foundry artifacts
uses: actions/cache/restore@v3
with:
key: "${{ runner.os }}-build-${{ github.sha }}"
path: |
- ./out
- ./cache
- ./broadcast

- name: Check formatting
run: forge fmt --check

- name: Add comment for format failure
if: failure()
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'The code is not formatted correctly. Please run `forge fmt` and push the changes.'
})
25 changes: 25 additions & 0 deletions .github/workflows/foundry-setup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Foundry Setup

on:
workflow_call:
inputs:
version:
required: true
type: string
secrets:
GITHUB_TOKEN:
required: true

jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: ${{ inputs.version }}

- name: Print forge version
run: forge --version
56 changes: 0 additions & 56 deletions .github/workflows/test.yml

This file was deleted.

10 changes: 9 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ evm_version = "paris"
[rpc_endpoints]
ethereum_local_rpc = "${ETHEREUM_LOCAL_RPC}"
exocore_local_rpc = "${EXOCORE_LOCAL_RPC}"
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

[fmt]
ignore = ["src/libraries/Endian.sol"]
# TODO: enable these after linter is merged
# number_underscore = "thousands"
# sort_imports = true
# wrap_comments = true
# single_line_statement_blocks = "multi"
# contract_new_lines = true
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
MaxMustermann2 marked this conversation as resolved.
Show resolved Hide resolved
13 changes: 5 additions & 8 deletions script/10_DeployExocoreGatewayOnly.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ pragma solidity ^0.8.19;
import {ILayerZeroEndpointV2} from "@layerzero-v2/protocol/contracts/interfaces/ILayerZeroEndpointV2.sol";

import {ProxyAdmin} from "@openzeppelin-contracts/contracts/proxy/transparent/ProxyAdmin.sol";
import {TransparentUpgradeableProxy} from "@openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import {TransparentUpgradeableProxy} from
"@openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

import {ExocoreGateway} from "../src/core/ExocoreGateway.sol";
import "forge-std/Script.sol";
import {BaseScript} from "./BaseScript.sol";

contract DeployExocoreGatewayOnly is BaseScript {

function setUp() public virtual override {
// load keys
super.setUp();
Expand All @@ -35,8 +35,7 @@ contract DeployExocoreGatewayOnly is BaseScript {
address(exocoreGatewayLogic),
address(exocoreProxyAdmin),
abi.encodeWithSelector(
exocoreGatewayLogic.initialize.selector,
payable(exocoreValidatorSet.addr)
exocoreGatewayLogic.initialize.selector, payable(exocoreValidatorSet.addr)
)
)
)
Expand All @@ -52,10 +51,8 @@ contract DeployExocoreGatewayOnly is BaseScript {
vm.serializeAddress(exocoreContracts, "exocoreGateway", address(exocoreGateway));

string memory deployedContracts = "deployedContracts";
string memory finalJson =
vm.serializeString(deployedContracts, "exocore", exocoreContractsOutput);
string memory finalJson = vm.serializeString(deployedContracts, "exocore", exocoreContractsOutput);

vm.writeJson(finalJson, "script/deployedExocoreGatewayOnly.json");

}
}
}
7 changes: 3 additions & 4 deletions script/11_SetPeers.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ contract SetPeersAndUpgrade is BaseScript {
uint256 i = 0;
uint256 tries = 5;
bool success;
while(i < tries) {

while (i < tries) {
vm.selectFork(exocore);
success = gateway.peers(clientChainId) == bootstrapAddr.toBytes32();

Expand Down Expand Up @@ -90,8 +89,8 @@ contract SetPeersAndUpgrade is BaseScript {
console.log(
"source .env && cast send --rpc-url $EXOCORE_TESETNET_RPC",
exocoreGatewayAddr,
"\"markBootstrapOnAllChains()\"",
'"markBootstrapOnAllChains()"',
"--private-key $TEST_ACCOUNT_THREE_PRIVATE_KEY"
);
}
}
}
46 changes: 15 additions & 31 deletions script/12_RedeployClientChainGateway.s.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pragma solidity ^0.8.19;

import {TransparentUpgradeableProxy} from "@openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import {TransparentUpgradeableProxy} from
"@openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import {UpgradeableBeacon} from "@openzeppelin-contracts/contracts/proxy/beacon/UpgradeableBeacon.sol";

import {Bootstrap} from "../src/core/Bootstrap.sol";
Expand All @@ -24,29 +25,19 @@ contract RedeployClientChainGateway is BaseScript {
super.setUp();
// load contracts
string memory prerequisiteContracts = vm.readFile("script/deployedBootstrapOnly.json");
clientChainLzEndpoint = ILayerZeroEndpointV2(
stdJson.readAddress(prerequisiteContracts, ".clientChain.lzEndpoint")
);
clientChainLzEndpoint =
ILayerZeroEndpointV2(stdJson.readAddress(prerequisiteContracts, ".clientChain.lzEndpoint"));
require(address(clientChainLzEndpoint) != address(0), "client chain l0 endpoint should not be empty");
beaconOracle = EigenLayerBeaconOracle(
stdJson.readAddress(prerequisiteContracts, ".clientChain.beaconOracle")
);
beaconOracle = EigenLayerBeaconOracle(stdJson.readAddress(prerequisiteContracts, ".clientChain.beaconOracle"));
require(address(beaconOracle) != address(0), "beacon oracle should not be empty");
vaultBeacon = UpgradeableBeacon(
stdJson.readAddress(prerequisiteContracts, ".clientChain.vaultBeacon")
);
vaultBeacon = UpgradeableBeacon(stdJson.readAddress(prerequisiteContracts, ".clientChain.vaultBeacon"));
require(address(vaultBeacon) != address(0), "vault beacon should not be empty");
capsuleBeacon = UpgradeableBeacon(
stdJson.readAddress(prerequisiteContracts, ".clientChain.capsuleBeacon")
);
capsuleBeacon = UpgradeableBeacon(stdJson.readAddress(prerequisiteContracts, ".clientChain.capsuleBeacon"));
require(address(capsuleBeacon) != address(0), "capsule beacon should not be empty");
beaconProxyBytecode = BeaconProxyBytecode(
stdJson.readAddress(prerequisiteContracts, ".clientChain.beaconProxyBytecode")
);
beaconProxyBytecode =
BeaconProxyBytecode(stdJson.readAddress(prerequisiteContracts, ".clientChain.beaconProxyBytecode"));
require(address(beaconProxyBytecode) != address(0), "beacon proxy bytecode should not be empty");
bootstrap = Bootstrap(
stdJson.readAddress(prerequisiteContracts, ".clientChain.bootstrap")
);
bootstrap = Bootstrap(stdJson.readAddress(prerequisiteContracts, ".clientChain.bootstrap"));
require(address(bootstrap) != address(0), "bootstrap should not be empty");
clientChain = vm.createSelectFork(clientChainRPCURL);
}
Expand All @@ -64,25 +55,18 @@ contract RedeployClientChainGateway is BaseScript {
);
// then the client chain initialization
address[] memory emptyList;
bytes memory initialization = abi.encodeWithSelector(
clientGatewayLogic.initialize.selector,
exocoreValidatorSet.addr,
emptyList
);
bootstrap.setClientChainGatewayLogic(
address(clientGatewayLogic),
initialization
);
bytes memory initialization =
abi.encodeWithSelector(clientGatewayLogic.initialize.selector, exocoreValidatorSet.addr, emptyList);
bootstrap.setClientChainGatewayLogic(address(clientGatewayLogic), initialization);
vm.stopBroadcast();

string memory clientChainContracts = "clientChainContracts";
string memory clientChainContractsOutput =
vm.serializeAddress(clientChainContracts, "clientGatewayLogic", address(clientGatewayLogic));

string memory deployedContracts = "deployedContracts";
string memory finalJson =
vm.serializeString(deployedContracts, "clientChain", clientChainContractsOutput);
string memory finalJson = vm.serializeString(deployedContracts, "clientChain", clientChainContractsOutput);

vm.writeJson(finalJson, "script/redeployClientChainGateway.json");
}
}
}
6 changes: 2 additions & 4 deletions script/2_DeployBoth.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ contract DeployScript is BaseScript {

// deploy beacon chain oracle
beaconOracle = _deployBeaconOracle();

/// deploy vault implementation contract and capsule implementation contract
/// that has logics called by proxy
vaultImplementation = new Vault();
Expand Down Expand Up @@ -90,9 +90,7 @@ contract DeployScript is BaseScript {
address(clientGatewayLogic),
address(clientChainProxyAdmin),
abi.encodeWithSelector(
clientGatewayLogic.initialize.selector,
payable(exocoreValidatorSet.addr),
whitelistTokens
clientGatewayLogic.initialize.selector, payable(exocoreValidatorSet.addr), whitelistTokens
)
)
)
Expand Down
Loading