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: zksync support #4725

Open
wants to merge 196 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
196 commits
Select commit Hold shift + click to select a range
91a2077
chore: add zksolc compiler for zksync
ljankovic-txfusion Sep 12, 2024
6fc9f02
update: make hardhat tests compatible with zksync
ljankovic-txfusion Sep 13, 2024
e5724aa
update: linking workspaces & contract compilation
ljankovic-txfusion Sep 16, 2024
0a692b3
chore: remove non-compatible zksync code from SDK
ljankovic-txfusion Sep 16, 2024
de77dba
feature: exporting zksync contract artifacts from core
ljankovic-txfusion Sep 17, 2024
1e1d748
feat: zksync deployer
ljankovic-txfusion Sep 18, 2024
2848efe
fix: artifacts compilation; add:typechain-types to .gitignore
ljankovic-txfusion Sep 18, 2024
79ceac4
update: wip deploying contracts via cli
ljankovic-txfusion Sep 18, 2024
04f390c
update: load artifacts from factory
ljankovic-txfusion Sep 18, 2024
e76bbf2
feat: cli bash script for automating core deployment
ljankovic-txfusion Sep 18, 2024
e1929f8
update: wip sdk hardhat test on zksync
ljankovic-txfusion Sep 19, 2024
8b2596a
update: wip making sdk tests compatible with zksync
ljankovic-txfusion Sep 19, 2024
e10d557
cleanup: minor test changes
ljankovic-txfusion Sep 19, 2024
e4cef73
cleanup: minor changes
ljankovic-txfusion Sep 19, 2024
2d2fb15
fix: should derive a token type from contract
ljankovic-txfusion Sep 19, 2024
a29df94
chore: refactoring multi provider
ljankovic-txfusion Sep 23, 2024
49c3812
feat: ProviderTypes for zksync
ljankovic-txfusion Sep 23, 2024
82e0938
refactor: deployment gasLimit for in memory node
ljankovic-txfusion Sep 23, 2024
53f8e61
feat: relaying messages locally
ljankovic-txfusion Sep 24, 2024
3022cd0
chore: remove gasLimit overrides for zksync
ljankovic-txfusion Sep 24, 2024
3e3637a
refactor: MultiProvider added defaultZKProviderBuilder in tryGetProvider
ljankovic-txfusion Sep 25, 2024
23f6e94
feat: singe cli/sdk to deploy to both evm and zkevm chains
ljankovic-txfusion Sep 27, 2024
733572a
feat: mutable storage multisig ISM
mortezashojaei Sep 30, 2024
629a4c8
fix: add missing addBufferToGasLimit function on utils
mortezashojaei Sep 30, 2024
2c0cb55
feat: compile contracts with solc & zksolc using single command
ljankovic-txfusion Sep 30, 2024
dcaecea
minor: cleanup
mortezashojaei Sep 30, 2024
36244c9
feature: support zksync protocol in addresses utils
mortezashojaei Sep 30, 2024
ecb3c49
minor: cleanup
mortezashojaei Sep 30, 2024
2b76f59
minot: revert back estimate handle in HyperlaneRelayer
mortezashojaei Sep 30, 2024
0ea4e51
feat: zksync support for TypedTransaction
ljankovic-txfusion Sep 30, 2024
74c3a67
Merge branch 'txfusion/sending-messages' of github.com:hyperlane-xyz/…
ljankovic-txfusion Sep 30, 2024
15de0ad
fix: prevent handle estimation on zksync protocol
mortezashojaei Sep 30, 2024
50903a6
feat: deploying StorageMerkleRootMultisigIsm
ljankovic-txfusion Oct 1, 2024
5e36ece
feat: deploying StorageMessageIdMultisigIsm
ljankovic-txfusion Oct 4, 2024
4273265
feat: refactor of contract deployment
ljankovic-txfusion Oct 4, 2024
d0fb3c8
chore: reverted & removed unused code
ljankovic-txfusion Oct 9, 2024
9bf46bc
chore: minor refactoring & adding types
ljankovic-txfusion Oct 9, 2024
8b5afe3
chore: minor changes & refactoring
ljankovic-txfusion Oct 9, 2024
0891c62
chore: minor refactoring
ljankovic-txfusion Oct 9, 2024
be23123
chore: minor cleanup
ljankovic-txfusion Oct 10, 2024
35260d6
minor refactor & cleanup
ljankovic-txfusion Oct 10, 2024
b8862ae
fix: yarn lock for cli e2e test
ljankovic-txfusion Oct 11, 2024
a432fbe
temp: testing verification
mortezashojaei Oct 8, 2024
b79b813
minor: revert contract verifier changes
mortezashojaei Oct 9, 2024
ccccce0
feat: zk verifier
mortezashojaei Oct 9, 2024
93af451
feat: verifying contract implementation on zksync explorer
ljankovic-txfusion Oct 10, 2024
6753e1f
fix: change the way load contract content
mortezashojaei Oct 10, 2024
4f39405
feat: verifying zksync contracts on block explorer
ljankovic-txfusion Oct 10, 2024
f44d3d3
minor: return verification id in zksync contract verification
mortezashojaei Oct 10, 2024
ac29b9d
feat: manage contract verification for both zksync and evm based chains
mortezashojaei Oct 11, 2024
b87cd54
minor: cleanup
mortezashojaei Oct 11, 2024
21add82
fix: support explorer just for etherum and zksync based chains
mortezashojaei Oct 11, 2024
1f0d464
minor: yarn lock
mortezashojaei Oct 11, 2024
9f98407
feat: handle verification on evm module deployer
mortezashojaei Oct 11, 2024
cb81ec7
feat: dynamic zksync artifact import
ljankovic-txfusion Oct 15, 2024
8383e95
chore: reverted/added comments
ljankovic-txfusion Oct 15, 2024
957375f
improvement: comments on zksync contract verifier
mortezashojaei Oct 15, 2024
eb79bea
fix: update hardat config type output directories
mortezashojaei Oct 15, 2024
cff1960
fix: update chain technical stack with latest values
mortezashojaei Oct 15, 2024
075f699
Merge remote-tracking branch 'origin/txfusion/sending-messages' into …
mortezashojaei Oct 15, 2024
dedaa34
merge with main repo latest changes
mortezashojaei Oct 16, 2024
52b221d
merge: latest main changes
mortezashojaei Oct 16, 2024
1c591a1
minor: yarn fix
mortezashojaei Oct 16, 2024
317f6d7
fix: add zksync address on explorer health test
mortezashojaei Oct 16, 2024
2f4cc62
naming: core/artifacts to core/zksync-artifacts
ljankovic-txfusion Oct 16, 2024
dec3ef4
feat: blacklist static contracts from being deployed on zksync on `hy…
ljankovic-txfusion Oct 18, 2024
8cc652d
test: e2e on zksync for warp read & apply
ljankovic-txfusion Oct 18, 2024
29205fb
feat: migrating from ProtocolType to chain technical stack for zksync
ljankovic-txfusion Oct 21, 2024
fbc7c31
feat: checking core config for Aggregation ISM on zksync core deployment
ljankovic-txfusion Oct 22, 2024
4f541e3
Merge remote-tracking branch 'origin-root/main'
mortezashojaei Oct 22, 2024
48c9b8c
merge: latest changes from root repo main
mortezashojaei Oct 22, 2024
570084a
minor: cleanup
mortezashojaei Oct 22, 2024
014e959
chore: reverting from workspace to npm versioning in package.json
ljankovic-txfusion Oct 22, 2024
c459f50
minor: cleanup
mortezashojaei Oct 22, 2024
057eae0
refactor: contract verification contracts
mortezashojaei Oct 22, 2024
59bff45
fix: PackageVersioned import in Mailbox.sol
ljankovic-txfusion Oct 23, 2024
e26c969
Merge branch 'feat/zksync-support' into improvement/verification
mortezashojaei Oct 23, 2024
f10e542
Merge remote-tracking branch 'origin-root/main'
mortezashojaei Oct 25, 2024
3a0ceca
merge: update with latest changes from root
mortezashojaei Oct 25, 2024
36e2b00
Merge remote-tracking branch 'origin-root/main'
mortezashojaei Oct 28, 2024
d938378
Merge branch 'feat/zksync-support' into improvement/verification
mortezashojaei Oct 30, 2024
ece0885
fix: linting & refactoring
ljankovic-txfusion Oct 30, 2024
400009e
fix: file not found issue in verification
mortezashojaei Oct 30, 2024
fecdf66
feat: fix etherscan and support zksync etherscan
mortezashojaei Oct 30, 2024
e523e4e
Merge pull request #3 from txfusion/improvement/zksync-support
mshojaei-txfusion Oct 31, 2024
4c3996d
Merge remote-tracking branch 'origin-root/main' into feat/zksync-support
mortezashojaei Oct 31, 2024
1927aea
cleanup: remove unused imports
mortezashojaei Oct 31, 2024
4d03c3e
Merge remote-tracking branch 'origin-txfusion/feat/zksync-support' in…
mortezashojaei Oct 31, 2024
274a778
Merge remote-tracking branch 'origin-txfusion/feat/zksync-support' in…
mortezashojaei Oct 31, 2024
44a8f3c
feat: deployStorageMultisigIsm on HyperlaneIsmFactory
ljankovic-txfusion Oct 31, 2024
e2b0158
Merge pull request #4 from txfusion/temp/merge-root-changes
mshojaei-txfusion Oct 31, 2024
bd472de
Merge remote-tracking branch 'origin-txfusion/feat/zksync-support' in…
mortezashojaei Oct 31, 2024
27bfc90
Merge pull request #1 from txfusion/improvement/verification
mshojaei-txfusion Oct 31, 2024
c103657
feat: static deployment refactor
ljankovic-txfusion Oct 31, 2024
1b737c5
fix: contract verification on warp deploy
ljankovic-txfusion Oct 31, 2024
c72805b
feat: static ISM type & technical stack assertion
ljankovic-txfusion Oct 31, 2024
4e5ed79
perf: check for static ism compatibility
ljankovic-txfusion Nov 1, 2024
eee7d78
fix: cleanup lint issue
mortezashojaei Nov 1, 2024
53042da
minor: comment explains state of zksync explorers support
mortezashojaei Nov 1, 2024
9e9baba
refactor: verification delay based on explorer family
mortezashojaei Nov 1, 2024
264b241
improvement: replace if with assert
mortezashojaei Nov 1, 2024
3755332
fix: test imports
ljankovic-txfusion Nov 1, 2024
915de97
fix: imports and assertion
ljankovic-txfusion Nov 1, 2024
07c3e64
chore: skip e2e zksync tests
ljankovic-txfusion Nov 1, 2024
3b1e97f
minor: change
ljankovic-txfusion Nov 1, 2024
44ca8ef
fix: overrides no longer override contract.initialize
ljankovic-txfusion Nov 1, 2024
b85b075
fix: ExplorerFamily casing & /dist/evm/ -> /core-utils/evm/
ljankovic-txfusion Nov 1, 2024
421071a
fix: dist/evm -> core-utils/evm in all tests
ljankovic-txfusion Nov 1, 2024
b212311
chore: reorg core exports, handing zksync json artifacts
ljankovic-txfusion Nov 4, 2024
2006daf
chore: reduce yarn.lock diff
ljankovic-txfusion Nov 5, 2024
f638c20
fix: skip zksync typechain creation
ljankovic-txfusion Nov 6, 2024
ba0d6ea
feat: Singe/MultiVM signer strategy
ljankovic-txfusion Nov 7, 2024
2bf349b
feat: Deployment strategies & refactoring
ljankovic-txfusion Nov 8, 2024
9c43d1c
fix: e2e test working
ljankovic-txfusion Nov 11, 2024
3602abd
chore: add comments & minor refactoring
ljankovic-txfusion Nov 11, 2024
ce81b48
chore: minor fixes
ljankovic-txfusion Nov 12, 2024
ff2b4c9
Merge remote-tracking branch 'origin-root/main'
ljankovic-txfusion Nov 12, 2024
af97d7f
Merge remote-tracking branch 'origin-root/main'
ljankovic-txfusion Nov 12, 2024
e4839a1
perf: removed unused code and refactoring
ljankovic-txfusion Nov 12, 2024
4abd806
feat: masked pk, refactoring
ljankovic-txfusion Nov 13, 2024
188dced
feat: MultiChainHandler support to extract chains from WarpCoreConfig…
ljankovic-txfusion Nov 14, 2024
0b92c68
chore: refactoring & adding comments
ljankovic-txfusion Nov 15, 2024
ea205dc
Merge remote-tracking branch 'origin/main' into feat/key-command
ljankovic-txfusion Nov 15, 2024
ac6d5c1
feat: relay command chain resolver strategy & refactoring
ljankovic-txfusion Nov 15, 2024
925621c
feat: Signer strategy based on chain's protocol/tech stack
ljankovic-txfusion Nov 18, 2024
a0ea88b
chore: minor refactoring
ljankovic-txfusion Nov 18, 2024
f030f23
Merge remote-tracking branch 'origin/main' into feat/key-command
ljankovic-txfusion Nov 18, 2024
52efa81
add: strategy types for submitter
ljankovic-txfusion Nov 18, 2024
12679af
chore: following naming conventions & comments
ljankovic-txfusion Nov 18, 2024
b7d439b
feat: requiresKey options on strategy `read` command
ljankovic-txfusion Nov 19, 2024
24b9d7a
chore: revert MessageOptionsArgTypes origin & destination optionality
ljankovic-txfusion Nov 19, 2024
60a2ae2
feat: strategy init chain agnostic
ljankovic-txfusion Nov 20, 2024
884db14
feat: logging private key source
ljankovic-txfusion Nov 20, 2024
2cc7ca4
chore: MultiProtocolSignerOptions refactor
ljankovic-txfusion Nov 20, 2024
d7326a6
docs(changeset): Added strategy management CLI commands and MultiProt…
ljankovic-txfusion Nov 20, 2024
05a3d19
refactor: convert dynamic import to static for ethers Interface
ljankovic-txfusion Nov 21, 2024
2afd302
refactor: simplify provider architecture and remove ZKSync specifics
ljankovic-txfusion Nov 21, 2024
92878d5
refactor: use ethers.utils.Interface instead of direct @ethersproject…
ljankovic-txfusion Nov 21, 2024
a9df9e8
feat: integrate zksync-ethers wallet for ZKSync signer strategy
ljankovic-txfusion Nov 21, 2024
6561504
refactor: improve signer management in warp route deploy config creation
ljankovic-txfusion Nov 21, 2024
de879a3
merge: latest changes on main
mortezashojaei Nov 22, 2024
e532b1a
refactor: improve strategy config handling and type safety & sensitiv…
ljankovic-txfusion Nov 22, 2024
afb3b21
refactor: sensitive key function name
ljankovic-txfusion Nov 22, 2024
fc1188a
docs(changeset): Added `isPrivateKeyEvm` function for validating EVM …
ljankovic-txfusion Nov 22, 2024
366aab5
refactor: simplify address validation and reorganize chain utils
ljankovic-txfusion Nov 22, 2024
e6ce0c8
Merge remote-tracking branch 'origin/feat/key-command' into feat/zksy…
ljankovic-txfusion Nov 22, 2024
0b793c7
chore: change cli changeset to minor
ljankovic-txfusion Nov 22, 2024
24b0c55
refactor: update SignerConfig address type to use Address from hyperl…
ljankovic-txfusion Nov 25, 2024
2076ef6
refactor: move CommandType enum to signCommands.ts
ljankovic-txfusion Nov 25, 2024
e61baff
fix: passed key used for setting signer
ljankovic-txfusion Nov 25, 2024
2d08d1e
Merge remote-tracking branch 'origin/main' into feat/key-command
mortezashojaei Nov 27, 2024
92115c0
fix: update getWarpCoreConfigOrExit import on MultiChainResolver
mortezashojaei Nov 27, 2024
c6cc7e9
Merge remote-tracking branch 'origin-root/main'
mortezashojaei Nov 27, 2024
0c8dc01
Merge remote-tracking branch 'origin-root/main' into feat/key-command
mortezashojaei Nov 27, 2024
ccc7df6
fix: no-unused-vars linting issues
mortezashojaei Nov 27, 2024
bdf0107
minor: remove catch unused param
mortezashojaei Nov 27, 2024
e13e08a
Merge branch 'hyperlane-xyz:main' into main
mshojaei-txfusion Nov 28, 2024
2258bbc
Merge branch 'feat/key-command' into feat/zksync-signer-strategy
mortezashojaei Nov 28, 2024
d6c3c75
Merge remote-tracking branch 'origin-root/main' into feat/zksync-sign…
mortezashojaei Nov 28, 2024
0546e10
Merge branch 'hyperlane-xyz:main' into main
mshojaei-txfusion Nov 28, 2024
dd87034
docs(changeset): Added ZKSync signer support using zksync-ethers package
mortezashojaei Nov 28, 2024
2ee37d4
Merge branch 'hyperlane-xyz:main' into main
mshojaei-txfusion Nov 28, 2024
befa5a9
Merge branch 'feat/zksync-signer-strategy' into feat/zksync-support
mortezashojaei Nov 28, 2024
7770bd7
Merge branch 'hyperlane-xyz:main' into main
mshojaei-txfusion Nov 29, 2024
21758af
fix: read multiProtocolSigner from sginer middleware on warp init
mortezashojaei Nov 29, 2024
38310f8
refactor: standardize signer address handling on context
mortezashojaei Dec 4, 2024
6e437c7
feat(cli): Add 'check' command to SIGN_COMMANDS and use signer for co…
mortezashojaei Dec 4, 2024
4820623
fix: handle warp check as a sign command on signer strategies
mortezashojaei Dec 4, 2024
3146e93
fix: handle warp read and warp check as sign command temporary
mortezashojaei Dec 4, 2024
fa2b0e8
chore: fix typo
mortezashojaei Dec 5, 2024
7d6a156
Merge branch 'hyperlane-xyz:main' into main
mshojaei-txfusion Dec 5, 2024
250b2b1
Merge branch 'feat/key-command' into feat/zksync-signer-strategy
mortezashojaei Dec 5, 2024
b90d0f7
Merge branch 'hyperlane-xyz:main' into main
mshojaei-txfusion Dec 5, 2024
80533e1
Merge branch 'main' into feat/key-command
mortezashojaei Dec 5, 2024
293e1b2
Merge branch 'feat/key-command' into feat/zksync-signer-strategy
mortezashojaei Dec 5, 2024
17d3e88
Merge branch 'feat/zksync-signer-strategy' into feat/zksync-support
mortezashojaei Dec 5, 2024
4e3b65c
chore: modify type of signer on context
mortezashojaei Dec 5, 2024
ea2cf3a
Merge branch 'feat/key-command' into feat/zksync-signer-strategy
mortezashojaei Dec 5, 2024
a0fe63d
Merge branch 'feat/zksync-signer-strategy' into feat/zksync-support
mortezashojaei Dec 5, 2024
c33d90f
Merge branch 'hyperlane-xyz:main' into main
mshojaei-txfusion Dec 6, 2024
e3fba6a
Merge branch 'hyperlane-xyz:main' into main
mshojaei-txfusion Dec 9, 2024
a45c50a
Merge branch 'hyperlane-xyz:main' into main
ljankovic-txfusion Dec 10, 2024
b7e3c81
fix: ICA_ROUTING on isIsmStatic
mortezashojaei Dec 10, 2024
86996e1
Merge remote-tracking branch 'origin' into feat/zksync-signer-strategy
ljankovic-txfusion Dec 11, 2024
b118669
Merge branch 'main' of github.com:hyperlane-xyz/hyperlane-monorepo in…
ljankovic-txfusion Dec 11, 2024
394055f
feat: replace Ethers Wallet with ZKSync-specific wallet implementatio…
ljankovic-txfusion Dec 11, 2024
576744b
Merge branch 'hyperlane-xyz:main' into main
ljankovic-txfusion Dec 11, 2024
6c786de
Merge branch 'main' of github.com:hyperlane-xyz/hyperlane-monorepo in…
ljankovic-txfusion Dec 11, 2024
b58434e
refactor(cli): remove unused multiProtocolSigner from warp init command
ljankovic-txfusion Dec 11, 2024
8f7d04d
Merge branch 'hyperlane-xyz:main' into main
ljankovic-txfusion Dec 11, 2024
e16b0e3
Merge branch 'hyperlane-xyz:main' into main
ljankovic-txfusion Dec 12, 2024
b6fc019
Merge branch 'main' into feat/zksync-signer-strategy
ljankovic-txfusion Dec 12, 2024
b89aaa0
Merge remote-tracking branch 'origin/feat/zksync-signer-strategy' int…
ljankovic-txfusion Dec 12, 2024
b8065df
refactor: rename TokenRouterConfig and reorganize type imports
ljankovic-txfusion Dec 12, 2024
fae0a67
refactor: apply mutable storage ISMs commit and reorganize exports
ljankovic-txfusion Dec 12, 2024
94920ae
fix: linting errors and remove duplicate switch cases
ljankovic-txfusion Dec 12, 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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"husky": "^8.0.0",
"lint-staged": "^12.4.3",
"prettier": "^2.8.8",
"tsx": "^4.7.1"
"tsx": "^4.7.1",
"zksync-ethers": "^5"
jmrossy marked this conversation as resolved.
Show resolved Hide resolved
},
"dependencies": {
"@changesets/cli": "^2.26.2"
Expand Down
12 changes: 11 additions & 1 deletion solidity/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules/
cache/
artifacts/
.artifacts/
types/
dist/
coverage/
Expand All @@ -15,3 +15,13 @@ docs
flattened/
buildArtifact.json
fixtures/


# zksync artifacts
artifacts-zk
cache-zk

core-utils/zksync/artifacts/output

.zksolc-libraries-cache/
typechain-types/
2 changes: 1 addition & 1 deletion solidity/contracts/Mailbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {IInterchainSecurityModule, ISpecifiesInterchainSecurityModule} from "./i
import {IPostDispatchHook} from "./interfaces/hooks/IPostDispatchHook.sol";
import {IMessageRecipient} from "./interfaces/IMessageRecipient.sol";
import {IMailbox} from "./interfaces/IMailbox.sol";
import {PackageVersioned} from "contracts/PackageVersioned.sol";
import {PackageVersioned} from "./PackageVersioned.sol";

// ============ External Imports ============
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
Expand Down
9 changes: 9 additions & 0 deletions solidity/contracts/interfaces/IThresholdAddressFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.0;

interface IThresholdAddressFactory {
function deploy(
address[] calldata _values,
uint8 _threshold
) external returns (address);
}
2 changes: 1 addition & 1 deletion solidity/contracts/isms/multisig/AbstractMultisigIsm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ abstract contract AbstractMultisig is PackageVersioned {
* @notice Manages per-domain m-of-n Validator sets of AbstractMultisig that are used to verify
* interchain messages.
*/
abstract contract AbstractMultisigIsm is AbstractMultisig {
abstract contract AbstractMultisigIsm is AbstractMultisig, IMultisigIsm {
// ============ Virtual Functions ============
// ======= OVERRIDE THESE TO IMPLEMENT =======

Expand Down
130 changes: 130 additions & 0 deletions solidity/contracts/isms/multisig/StorageMultisigIsm.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.0;

// ============ Internal Imports ============
import {AbstractMultisigIsm} from "./AbstractMultisigIsm.sol";
import {AbstractMerkleRootMultisigIsm} from "./AbstractMerkleRootMultisigIsm.sol";
import {AbstractMessageIdMultisigIsm} from "./AbstractMessageIdMultisigIsm.sol";
import {IInterchainSecurityModule} from "../../interfaces/IInterchainSecurityModule.sol";
import {IThresholdAddressFactory} from "../../interfaces/IThresholdAddressFactory.sol";
import {MinimalProxy} from "../../libs/MinimalProxy.sol";

// ============ External Imports ============
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

abstract contract AbstractStorageMultisigIsm is
AbstractMultisigIsm,
OwnableUpgradeable
{
address[] public validators;
uint8 public threshold;

event ValidatorsAndThresholdSet(address[] validators, uint8 threshold);

constructor(
address[] memory _validators,
uint8 _threshold
) OwnableUpgradeable() {
validators = _validators;
threshold = _threshold;
_disableInitializers();
}

function initialize(
address[] memory _validators,
uint8 _threshold
) external initializer {
__Ownable_init();
setValidatorsAndThreshold(_validators, _threshold);
}

function setValidatorsAndThreshold(
address[] memory _validators,
uint8 _threshold
) public onlyOwner {
require(_threshold <= _validators.length, "Invalid threshold");
validators = _validators;
threshold = _threshold;
emit ValidatorsAndThresholdSet(_validators, _threshold);
}

function validatorsAndThreshold(
bytes calldata /* _message */
) public view override returns (address[] memory, uint8) {
return (validators, threshold);
}
}

contract StorageMerkleRootMultisigIsm is
AbstractMerkleRootMultisigIsm,
AbstractStorageMultisigIsm
{
uint8 public constant moduleType =
uint8(IInterchainSecurityModule.Types.MERKLE_ROOT_MULTISIG);

constructor(
address[] memory _validators,
uint8 _threshold
) AbstractStorageMultisigIsm(_validators, _threshold) {}
}

contract StorageMessageIdMultisigIsm is
AbstractMessageIdMultisigIsm,
AbstractStorageMultisigIsm
{
uint8 public constant moduleType =
uint8(IInterchainSecurityModule.Types.MESSAGE_ID_MULTISIG);

constructor(
address[] memory _validators,
uint8 _threshold
) AbstractStorageMultisigIsm(_validators, _threshold) {}
}

abstract contract StorageMultisigIsmFactory is IThresholdAddressFactory {
/**
* @notice Emitted when a multisig module is deployed
* @param module The deployed ISM
*/
event ModuleDeployed(address module);

// ============ External Functions ============
function deploy(
address[] calldata _validators,
uint8 _threshold
) external returns (address ism) {
ism = MinimalProxy.create(implementation());
emit ModuleDeployed(ism);
AbstractStorageMultisigIsm(ism).initialize(_validators, _threshold);
}

function implementation() public view virtual returns (address);
}

contract StorageMerkleRootMultisigIsmFactory is StorageMultisigIsmFactory {
address internal immutable _implementation;

constructor() {
_implementation = address(
new StorageMerkleRootMultisigIsm(new address[](0), 0)
);
}

function implementation() public view override returns (address) {
return _implementation;
}
}

contract StorageMessageIdMultisigIsmFactory is StorageMultisigIsmFactory {
address internal immutable _implementation;

constructor() {
_implementation = address(
new StorageMessageIdMultisigIsm(new address[](0), 0)
);
}

function implementation() public view override returns (address) {
return _implementation;
}
}
Empty file.
102 changes: 102 additions & 0 deletions solidity/core-utils/zksync/artifacts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { readdirSync } from 'fs';
import path, { join } from 'path';
import { fileURLToPath } from 'url';

/**
* @dev Represents a ZkSync artifact.
*/
export type ZkSyncArtifact = {
contractName: string;
sourceName: string;
abi: any;
bytecode: string;
deployedBytecode: string;
factoryDeps?: Record<string, string>;
};

/**
* @dev A mapping of artifact names to their corresponding ZkSync artifacts.
*/
export type ArtifactMap = {
[key: string]: ZkSyncArtifact; // Key is the artifact name, value is the ZkSyncArtifact
};

// Get the resolved path to the current file
const currentFilePath = fileURLToPath(import.meta.url); // Convert the module URL to a file path
const currentDirectory = path.dirname(currentFilePath);

/**
* @dev Reads artifact files from the specified directory.
* @param directory The directory to read artifact files from.
* @return An array of artifact file names that end with '.js'.
*/
const getArtifactFiles = (directory: string): string[] => {
return readdirSync(directory).filter((file) => file.endsWith('.js')); // Filter for .js files
};

/**
* @dev Exports the list of artifact names without the .js extension.
* @return An array of artifact names without the .js extension.
*/
export const zksyncArtifactNames = getArtifactFiles(
join(currentDirectory, 'output'),
).map((file) => file.replace('.js', ''));

/**
* @dev Checks if a ZkSync artifact exists by its name.
* @param name The name of the artifact to check.
* @return True if the artifact exists, false otherwise.
*/
export const artifactExists = (name: string): boolean => {
return zksyncArtifactNames.includes(`${name}.js`); // Check if the artifact file exists
};

/**
* @dev Loads a ZkSync artifact by its name.
* @param name The name of the artifact to load.
* @return The loaded ZkSyncArtifact or undefined if it cannot be loaded.
*/
const loadZkArtifact = async (
name: string,
): Promise<ZkSyncArtifact | undefined> => {
try {
const artifactModule = await import(
join(currentDirectory, 'output', `${name}.js`)
); // Dynamically import the artifact module
return artifactModule[name]; // Return the artifact from the artifactModule
} catch (error) {
console.error(`Error loading artifact: ${name}`, error);
return undefined;
}
};

/**
* @dev Loads all ZkSync artifacts into a map.
* @return A map of artifact names to their corresponding ZkSync artifacts.
*/
export const loadAllZkArtifacts = async (): Promise<ArtifactMap> => {
paulbalaji marked this conversation as resolved.
Show resolved Hide resolved
const zkSyncArtifactMap: ArtifactMap = {};

// Load all artifacts concurrently
const loadPromises = zksyncArtifactNames.map(async (artifactFileName) => {
const artifact = await loadZkArtifact(artifactFileName);
if (artifact) {
zkSyncArtifactMap[artifactFileName] = artifact;
}
});

await Promise.all(loadPromises);

return zkSyncArtifactMap; // Return the populated artifact map
};

/**
* @dev Retrieves a specific ZkSync artifact by its file name.
* @param name The name of the artifact to retrieve.
* @return The loaded ZkSyncArtifact or undefined if it cannot be loaded.
*/
export const getZkArtifactByName = async (
name: string,
): Promise<ZkSyncArtifact | undefined> => {
return loadZkArtifact(name);
};
45 changes: 41 additions & 4 deletions solidity/exportBuildArtifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ cd "$(dirname "$0")"
# Define the artifacts directory
artifactsDir="./artifacts/build-info"
# Define the output file
outputFileJson="./dist/buildArtifact.json"
outputFileJs="./dist/buildArtifact.js"
outputFileTsd="./dist/buildArtifact.d.ts"
outputFileJson="./dist/evm/buildArtifact.json"
outputFileJs="./dist/evm/buildArtifact.js"
outputFileTsd="./dist/evm/buildArtifact.d.ts"

# log that we're in the script
echo 'Finding and processing hardhat build artifact...'
echo 'Finding and processing hardhat build EVM artifact...'

# Find most recently modified JSON build artifact
if [ "$(uname)" = "Darwin" ]; then
Expand All @@ -37,3 +37,40 @@ else
echo 'Failed to process build artifact with jq'
exit 1
fi

# ZKSYNC

# Define the artifacts directory
artifactsDir="./artifacts-zk/build-info"
# Define the output file
outputFileJson="./dist/zksync/buildArtifact.json"
outputFileJs="./dist/zksync/buildArtifact.js"
outputFileTsd="./dist/zksync/buildArtifact.d.ts"

# log that we're in the script
echo 'Finding and processing hardhat build ZKSync artifact...'

# Find most recently modified JSON build artifact
if [ "$(uname)" = "Darwin" ]; then
# for local flow
jsonFiles=$(find "$artifactsDir" -type f -name "*.json" -exec stat -f "%m %N" {} \; | sort -rn | head -n 1 | cut -d' ' -f2-)
else
# for CI flow
jsonFiles=$(find "$artifactsDir" -type f -name "*.json" -exec stat -c "%Y %n" {} \; | sort -rn | head -n 1 | cut -d' ' -f2-)
fi

if [ ! -f "$jsonFiles" ]; then
echo 'Failed to find build artifact'
exit 1
fi

# Extract required keys and write to outputFile
if jq -c '{input, solcLongVersion, zk_version: .output.zk_version}' "$jsonFiles" > "$outputFileJson"; then
echo "export const buildArtifact = " > "$outputFileJs"
cat "$outputFileJson" >> "$outputFileJs"
echo "export const buildArtifact: any" > "$outputFileTsd"
echo 'Finished processing build artifact.'
else
echo 'Failed to process build artifact with jq'
exit 1
fi
Loading
Loading