Skip to content

Commit

Permalink
Import analog-gmp. (#1541)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvc94ch authored Feb 11, 2025
1 parent 80496ff commit aeda47c
Show file tree
Hide file tree
Showing 53 changed files with 9,348 additions and 11 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/pr-test-forge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: forge

on:
push:
branches:
- master
- main
- staging
- release-v*
pull_request:
paths:
- '.github/workflows/pr-test-forge.yaml'
- 'analog-gmp/**'
- 'lib/**'
env:
FOUNDRY_PROFILE: ci

jobs:
check:
strategy:
fail-fast: true

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

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

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

- name: Run Forge tests
run: |
cd analog-gmp
forge test -vvv
id: test
22 changes: 14 additions & 8 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
[submodule "lib/forge-std"]
path = lib/forge-std
[submodule "analog-gmp/lib/forge-std"]
path = analog-gmp/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/frost-evm"]
path = lib/frost-evm
url = https://github.com/analog-labs/frost-evm
[submodule "analog-gmp"]
path = analog-gmp
url = [email protected]:Analog-Labs/analog-gmp.git
[submodule "analog-gmp/lib/frost-evm"]
path = analog-gmp/lib/frost-evm
url = https://github.com/Analog-Labs/frost-evm
[submodule "analog-gmp/lib/universal-factory"]
path = analog-gmp/lib/universal-factory
url = https://github.com/Analog-Labs/universal-factory
[submodule "analog-gmp/lib/solmate"]
path = analog-gmp/lib/solmate
url = https://github.com/transmissions11/solmate
[submodule "analog-gmp/lib/evm-interpreter"]
path = analog-gmp/lib/evm-interpreter
url = https://github.com/Analog-Labs/evm-interpreter
1 change: 0 additions & 1 deletion analog-gmp
Submodule analog-gmp deleted from 8db5a4
7 changes: 7 additions & 0 deletions analog-gmp/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PRIVATE_KEY=
PROXY_ADDRESS=0x000000033763b9d6d94efd3209dc255686aa8fba
PROXY_DEPLOYER=0x9020e86C34Da64C78fd290eBee2E171C402F6890
#PROXY_ADDRESS=0x000000007f56768de3133034fa730a909003a165
SEPOLIA_RPC_URL=https://ethereum-sepolia-rpc.publicnode.com
SHIBUYA_RPC_URL=https://evm.shibuya.astar.network
POLYGON_AMOY_RPC_URL=https://rpc-amoy.polygon.technology
20 changes: 20 additions & 0 deletions analog-gmp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Compiler files
cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env

# MacOS
**/.DS_Store

# built artifacts
src/artifacts/
22 changes: 22 additions & 0 deletions analog-gmp/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2016-2024 Zeppelin Group Ltd and contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
53 changes: 53 additions & 0 deletions analog-gmp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
## Analog's Contracts

**This repository contains all the necessary ingredients for successful cross-chain development utilizing the Analog General Message Passing protocol.**

## Dependencies

This project uses **Forge** Ethereum testing framework (like Truffle, Hardhat and DappTools).
Install instructions: https://book.getfoundry.sh/

## Usage

### Build

```sh
forge build
```

### Test

```sh
forge test
```

### Format

```sh
forge fmt
```

### Gas Snapshots

```sh
forge snapshot
```

## Documentation

Use the following command to generate project documentation:

```sh
forge doc -b
```

You can now read the docs from the generated [mdbook](https://github.com/rust-lang/mdBook) as follows:

``` sh
cd docs
mdbook serve --open
```

## License

Analog's Contracts is released under the [MIT License](LICENSE).
75 changes: 75 additions & 0 deletions analog-gmp/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[profile.default]
src = "src"
test = "test"
out = "out"
libs = ["lib"]
# Permissions
fs_permissions = [{ access = "read", path = "./lib/universal-factory/abi" }]

########
# Lint #
########
deny_warnings = true

################
# Solc options #
################
solc = '0.8.28'
# Using `shanghai` once other EVM chains such as `Astar/Shibuya` and
# `Ethereum Classic` doesn't support `cancun` yet.
# - https://github.com/rust-ethereum/evm/issues/290
# - https://ethereumclassic.org/knowledge/history
evm_version = 'shanghai'
optimizer = true
optimizer_runs = 200000

###############
# EVM options #
###############
gas_limit = 30000000
gas_price = 1
block_base_fee_per_gas = 0
block_gas_limit = 30000000

#####################
# optimizer details #
#####################
[profile.default.optimizer_details]
yul = true
# The peephole optimizer is always on if no details are given,
# use details to switch it off.
peephole = true
# The inliner is always off if no details are given,
# use details to switch it on.
inliner = true
# The unused jumpdest remover is always on if no details are given,
# use details to switch it off.
jumpdest_remover = true
# Sometimes re-orders literals in commutative operations.
order_literals = true
# Removes duplicate code blocks
deduplicate = true
# Common subexpression elimination, this is the most complicated step but
# can also provide the largest gain.
cse = true
# Optimize representation of literal numbers and strings in code.
constant_optimizer = true
# Use unchecked arithmetic when incrementing the counter of for loops
# under certain circumstances. It is always on if no details are given.
simple_counter_for_loop_unchecked_increment = true

# Fuzz tests options
[fuzz]
# Reduce the numbers of runs if fuzz tests takes too long in your machine.
runs = 2500

# When debuging fuzz tests, uncomment this seed to make tests reproducible.
# seed = "0xdeadbeefdeadbeefdeadbeefdeadbeef"

# RPC endpoints
[rpc_endpoints]
sepolia = "https://ethereum-sepolia-rpc.publicnode.com"
shibuya = "https://evm.shibuya.astar.network"
amoy = "https://rpc-amoy.polygon.technology"
arbitrum_sepolia = "https://arbitrum-sepolia.gateway.tenderly.co"
bnb_testnet = "https://bsc-testnet-rpc.publicnode.com"
1 change: 1 addition & 0 deletions analog-gmp/lib/evm-interpreter
Submodule evm-interpreter added at 75df08
1 change: 1 addition & 0 deletions analog-gmp/lib/forge-std
Submodule forge-std added at bf909b
1 change: 1 addition & 0 deletions analog-gmp/lib/frost-evm
Submodule frost-evm added at 8f10a6
1 change: 1 addition & 0 deletions analog-gmp/lib/solmate
Submodule solmate added at c93f77
1 change: 1 addition & 0 deletions analog-gmp/lib/universal-factory
Submodule universal-factory added at f19228
8 changes: 8 additions & 0 deletions analog-gmp/remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
forge-std/=lib/forge-std/src/
@frost-evm/=lib/frost-evm/sol/
@solmate/=lib/solmate/src/
ds-test/=lib/solmate/lib/ds-test/src/
@universal-factory/=lib/universal-factory/src/
@evm-interpreter/=lib/evm-interpreter/src/
@analog-gmp/=src/
@analog-gmp-testing/=test/
93 changes: 93 additions & 0 deletions analog-gmp/run-migration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/bash
set -e

# By default, doesn't broadcast any transactions.
DRY_RUN=1

# Setup console colors
if test -t 1 && command -v tput >/dev/null 2>&1; then
ncolors=$(tput colors)
if test -n "${ncolors}" && test "${ncolors}" -ge 8; then
bold_color=$(tput bold)
green_color=$(tput setaf 2)
warn_color=$(tput setaf 3)
error_color=$(tput setaf 1)
reset_color=$(tput sgr0)
fi
# 72 used instead of 80 since that's the default of pr
ncols=$(tput cols)
fi
: "${ncols:=72}"

# process arguments
while [[ $# -gt 0 ]]
do
case "$1" in
--migrate)
unset DRY_RUN
shift 1
;;
--proxy=*)
PROXY_ADDRESS="${i#*=}"
shift 1
;;
-pk=*|--private-key=*)
PRIVATE_KEY="${i#*=}"
shift 1
;;
--sepolia-rpc=*)
SEPOLIA_RPC_URL="${i#*=}"
shift 1
;;
--shibuya-rpc=*)
SHIBUYA_RPC_URL="${i#*=}"
shift 1
;;
--amoy-rpc=*)
POLYGON_AMOY_RPC_URL="${i#*=}"
shift 1
;;
*)
warn "Unknown argument: $1"
echo "Usage: $0 --pk=<PRIVATE_KEY> --proxy=PROXY_ADDRESS [--migrate] [--sepolia-rpc=] [--shibuya-rpc=] [--amoy-rpc=]"
;;
esac
done

# Load .env file
if [ -f .env ]; then
echo "Load .env file"
source .env
else
echo ".env file not found, run 'cp .env.example .env' and fill the values"
fi

# Check if PRIVATE_KEY is set
if [ -z "${PRIVATE_KEY}" ]; then
echo "PRIVATE_KEY is not set"
exit 1
fi

# Check if PROXY_ADDRESS is set
if [ -z "${PROXY_ADDRESS}" ]; then
echo "PROXY_ADDRESS is not set"
exit 1
fi

# Set fork-url
PARAMS=(-vvvv)

# Verify if the migration is going to be broadcasted
if [ -z "${DRY_RUN}" ]; then
read -r -p "running in broadcast mode, the transaction will be broadcasted, are you sure you want to continue? [y/n] " response
case "$response" in
[yY][eE][sS]|[yY])
PARAMS+=(--broadcast)
;;
*)
echo "running in dry-mode..."
;;
esac
fi

forge script ./scripts/Migrate.sol "${PARAMS[@]}"
Loading

0 comments on commit aeda47c

Please sign in to comment.