Skip to content

Commit

Permalink
Initialize morph (#1)
Browse files Browse the repository at this point in the history
* initialize morph

* add go.work and makefile

* update go.work

* delete submodules

---------

Co-authored-by: chengwenxi <[email protected]>
  • Loading branch information
chengwenxi and chengwenxi authored Jan 12, 2024
1 parent 23195b2 commit 7f2f887
Show file tree
Hide file tree
Showing 511 changed files with 128,540 additions and 1 deletion.
35 changes: 35 additions & 0 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Contracts

on:
push:
branches:
- main
paths:
- 'contracts/**'
pull_request:
paths:
- 'contracts/**'

defaults:
run:
working-directory: 'contracts'

jobs:
tests:
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
GAS: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run build
run: yarn && yarn build
- name: Run tests
run: yarn test
31 changes: 31 additions & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Node

on:
push:
branches:
- main
paths:
- 'node/**'
- '.github/workflows/node.yaml'
pull_request:
paths:
- 'node/**'
- '.github/workflows/node.yaml'

defaults:
run:
working-directory: 'node'

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.20.x
- name: Run build
run: make build
- name: Run tests
run: make test
25 changes: 25 additions & 0 deletions .github/workflows/prover.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Prover

on:
push:
branches:
- main
paths:
- 'prover/**'
- '.github/workflows/prover.yaml'
pull_request:
paths:
- 'prover/**'
- '.github/workflows/prover.yaml'

defaults:
run:
working-directory: 'prover'

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run build
run: build-prover
31 changes: 31 additions & 0 deletions .github/workflows/tx-submitter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Tx-submitter

on:
push:
branches:
- main
paths:
- 'tx-submitter/**'
- '.github/workflows/tx-submitter.yaml'
pull_request:
paths:
- 'tx-submitter/**'
- '.github/workflows/tx-submitter.yaml'

defaults:
run:
working-directory: 'tx-submitter'

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.20.x
- name: Run build
run: make build
- name: Run tests
run: make test
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Visual Studio Code
.vscode

# IntelliJ
.idea

# MacOS
.DS_Store
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 morphism-labs
Copyright (c) 2023 Morph

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.PHONY: update format

update: ## update the dependencies
git submodule update --init --recursive
go work sync
cd $(PWD)/l2geth && go mod tidy
cd $(PWD)/tendermint && go mod tidy

format: ## format the code
go work sync
goimports -local $(PWD)/bindings/ -w .
goimports -local $(PWD)/contracts/ -w .
goimports -local $(PWD)/node/ -w .
goimports -local $(PWD)/tx-submitter/ -w .

23 changes: 23 additions & 0 deletions bindings/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

.idea/

# Go workspace file
go.work
157 changes: 157 additions & 0 deletions bindings/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
SHELL := /bin/bash

pkg := bindings

all: version mkdir bindings more

bindings: l1block-bindings \
l1-blocknumber-bindings \
system-config-bindings \
l1-cross-domain-messenger-bindings \
l1-standard-bridge-bindings \
l2-to-l1-message-passer-bindings \
morph-portal-bindings \
gas-price-oracle-bindings \
legacy-message-passer-bindings \
address-manager-bindings \
l2-cross-domain-messenger-bindings \
l2-standard-bridge-bindings \
sequencer-fee-vault-bindings \
morph-mintable-erc20-factory-bindings \
morph-mintable-erc20-bindings \
proxy-bindings \
proxy-admin-bindings \
erc20-bindings \
weth9-bindings \
deployer-whitelist-bindings \
l2-erc721-bridge-bindings \
l1-erc721-bridge-bindings \
morph-mintable-erc721-factory-bindings \
l1-fee-vault-bindings \
basefee-vault-bindings \
morph-rollup-bindings \
legacy-erc20-eth-bindings \
l1-staking-bindings \
l1-sequencer-bindings \
l2-sequencer-bindings \
l2-gov-bindings \
submitter-bindings

version:
forge --version
abigen --version

compile:
./compile.sh

system-config-bindings: compile
./gen_bindings.sh contracts/L1/SystemConfig.sol:SystemConfig $(pkg)

l1-staking-bindings: compile
./gen_bindings.sh contracts/L1/staking/Staking.sol:Staking $(pkg)

l1-sequencer-bindings: compile
./gen_bindings.sh contracts/L1/staking/L1Sequencer.sol:L1Sequencer $(pkg)

l2-sequencer-bindings: compile
./gen_bindings.sh contracts/L2/L2Sequencer.sol:L2Sequencer $(pkg)

l2-gov-bindings: compile
./gen_bindings.sh contracts/L2/Gov.sol:Gov $(pkg)

submitter-bindings: compile
./gen_bindings.sh contracts/L2/Submitter.sol:Submitter $(pkg)

l1-cross-domain-messenger-bindings: compile
./gen_bindings.sh contracts/L1/L1CrossDomainMessenger.sol:L1CrossDomainMessenger $(pkg)

l1-standard-bridge-bindings: compile
./gen_bindings.sh contracts/L1/L1StandardBridge.sol:L1StandardBridge $(pkg)

morph-portal-bindings: compile
./gen_bindings.sh contracts/L1/MorphPortal.sol:MorphPortal $(pkg)

morph-rollup-bindings: compile
./gen_bindings.sh contracts/L1/Rollup.sol:Rollup $(pkg)

address-manager-bindings: compile
./gen_bindings.sh contracts/legacy/AddressManager.sol:AddressManager $(pkg)

l1block-bindings: compile
./gen_bindings.sh contracts/L2/L1Block.sol:L1Block $(pkg)

l2-to-l1-message-passer-bindings: compile
./gen_bindings.sh contracts/L2/L2ToL1MessagePasser.sol:L2ToL1MessagePasser $(pkg)

gas-price-oracle-bindings: compile
./gen_bindings.sh contracts/L2/GasPriceOracle.sol:GasPriceOracle $(pkg)

l2-cross-domain-messenger-bindings: compile
./gen_bindings.sh contracts/L2/L2CrossDomainMessenger.sol:L2CrossDomainMessenger $(pkg)

l2-standard-bridge-bindings: compile
./gen_bindings.sh contracts/L2/L2StandardBridge.sol:L2StandardBridge $(pkg)

l2-erc721-bridge-bindings:
./gen_bindings.sh contracts/L2/L2ERC721Bridge.sol:L2ERC721Bridge $(pkg)

l1-erc721-bridge-bindings:
./gen_bindings.sh contracts/L1/L1ERC721Bridge.sol:L1ERC721Bridge $(pkg)

morph-mintable-erc721-factory-bindings:
./gen_bindings.sh contracts/universal/MorphMintableERC721Factory.sol:MorphMintableERC721Factory $(pkg)

sequencer-fee-vault-bindings: compile
./gen_bindings.sh contracts/L2/SequencerFeeVault.sol:SequencerFeeVault $(pkg)

basefee-vault-bindings: compile
./gen_bindings.sh contracts/L2/BaseFeeVault.sol:BaseFeeVault $(pkg)

l1-fee-vault-bindings: compile
./gen_bindings.sh contracts/L2/L1FeeVault.sol:L1FeeVault $(pkg)

morph-mintable-erc20-factory-bindings: compile
./gen_bindings.sh contracts/universal/MorphMintableERC20Factory.sol:MorphMintableERC20Factory $(pkg)

morph-mintable-erc20-bindings: compile
./gen_bindings.sh contracts/universal/MorphMintableERC20.sol:MorphMintableERC20 $(pkg)

legacy-erc20-eth-bindings: compile
./gen_bindings.sh contracts/legacy/LegacyERC20ETH.sol:LegacyERC20ETH $(pkg)

proxy-bindings: compile
./gen_bindings.sh contracts/universal/Proxy.sol:Proxy $(pkg)

proxy-admin-bindings: compile
./gen_bindings.sh contracts/universal/ProxyAdmin.sol:ProxyAdmin $(pkg)

legacy-message-passer-bindings: compile
./gen_bindings.sh contracts/legacy/LegacyMessagePasser.sol:LegacyMessagePasser $(pkg)

erc20-bindings: compile
./gen_bindings.sh node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20 $(pkg)

weth9-bindings: compile
./gen_bindings.sh contracts/vendor/WETH9.sol:WETH9 $(pkg)

deployer-whitelist-bindings: compile
./gen_bindings.sh contracts/legacy/DeployerWhitelist.sol:DeployerWhitelist $(pkg)

l1-blocknumber-bindings: compile
./gen_bindings.sh contracts/legacy/L1BlockNumber.sol:L1BlockNumber $(pkg)

more:
go run ./gen/main.go \
-artifacts ../contracts/artifacts \
-out ./bindings \
-contracts GasPriceOracle,SystemConfig,MorphMintableERC20Factory,L2StandardBridge,L1BlockNumber,LegacyMessagePasser,DeployerWhitelist,Proxy,MorphPortal,L2ToL1MessagePasser,L2CrossDomainMessenger,SequencerFeeVault,L1Block,LegacyERC20ETH,WETH9,GovernanceToken,L1CrossDomainMessenger,L2ERC721Bridge,MorphMintableERC721Factory,ProxyAdmin,Rollup,Staking,L1Sequencer,L2Sequencer,Gov,Submitter \
-package bindings

mkdir:
mkdir -p bin $(pkg)

clean:
rm -rf bin $(pkg)

test:
go test ./...
30 changes: 30 additions & 0 deletions bindings/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# morph-bindings

This package contains built go bindings of the smart contracts. It must be
updated after any changes to the smart contracts to ensure that the bindings are
up to date.

The bindings include the bytecode for each contract so that go based tests
can deploy the contracts. There are also `more` files that include the deployed
bytecode as well as the storage layout. These are used to dynamically set
bytecode and storage slots in state.

## Dependencies

- `abigen` version 1.10.25
- `make`

To check the version of `abigen`, run the command `abigen --version`.

## abigen

The `abigen` tool is part of `go-ethereum` and can be used to build go bindings
for smart contracts. It can be installed with go using the commands:

```bash
$ go get -u github.com/ethereum/go-ethereum
$ cd $GOPATH/src/github.com/ethereum/go-ethereum/
$ make devtools
```

The geth docs for `abigen` can be found [here](https://geth.ethereum.org/docs/dapp/native-bindings).
Loading

0 comments on commit 7f2f887

Please sign in to comment.