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 forge fmt and solhint jobs #17

Merged
merged 58 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
58 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
a38c435
chore(lint): set up solhint config
MaxMustermann2 Jun 3, 2024
7d51848
build(ci): set up `solhint` workflow
MaxMustermann2 Jun 3, 2024
809c471
chore(lint): run `solhint`
MaxMustermann2 Jun 3, 2024
ae0a41b
chore(fmt): run `forge fmt`
MaxMustermann2 Jun 3, 2024
f515a20
fix(bootstrap): deploy vaults correctly
MaxMustermann2 Jun 3, 2024
dfc1583
fix(build): rename fmt workflow
MaxMustermann2 Jun 3, 2024
2e7f1af
fix(ci): rename `lint` workflow
MaxMustermann2 Jun 3, 2024
86c1887
Merge branch 'lint-workflow' into solhint-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
803df30
Merge branch 'lint-workflow' into solhint-workflow
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
faad720
Merge branch 'lint-workflow' into solhint-workflow
MaxMustermann2 Jun 5, 2024
ff62c90
refactor: getWhitelistedTokensCount in gateway
MaxMustermann2 Jun 5, 2024
a39c2a6
config: activate new Foundry rules
MaxMustermann2 Jun 5, 2024
aaa0916
chore(fmt): run `forge fmt`
MaxMustermann2 Jun 5, 2024
72c4bca
lint:Update src/core/ExocoreGateway.sol
adu-web3 Jun 5, 2024
d2df0ec
refactor(bootstrap): use modifier not require
MaxMustermann2 Jun 5, 2024
6becba2
lint: use disable-next-item for clarity
MaxMustermann2 Jun 5, 2024
da7b531
optimize: explicitly mark recipient as payable
adu-web3 Jun 5, 2024
071b965
chore(lint): run forge fmt
MaxMustermann2 Jun 5, 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
56 changes: 56 additions & 0 deletions .github/workflows/fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Format using `forge fmt`

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

env:
FOUNDRY_PROFILE: ci

jobs:
check:
strategy:
fail-fast: true

name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
# replace nightly because latest nightly release has some breaking changes that result in test failures
# this is a previous recent nightly release that should work
version: nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9

- name: Run Forge build
run: |
forge --version
forge build --sizes
id: build

- name: Run Forge Formatter
run: |
forge fmt --check
id: fmt

- name: Add comment on 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.'
})
45 changes: 45 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Run `solhint` linter

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

jobs:
check:
strategy:
fail-fast: true

name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '22'

- name: Install Solhint
run: npm install --save-dev solhint

- name: Run Solhint
run: |
npx solhint 'src/**/*.sol' -c ./src/.solhint.json

- name: Add comment on 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: 'Linting failed. Please check the logs.'
})
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'The GitHub Actions workflow has failed. Please check the logs for more details.'
body: 'The tests have failed. Please check the logs for more details.'
})
1 change: 1 addition & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/lzApp/*.sol
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
Loading