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

Add different networks to makefile #193

Merged
merged 6 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 10 additions & 10 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ jobs:
toolchain: nightly-2021-03-25
override: true
- run: make release
- run: ls -lH release.wasm
- name: Upload the release.wasm artifact
- run: ls -lH mainnet-release.wasm
- name: Upload the mainnet-release.wasm artifact
uses: actions/upload-artifact@v2
with:
name: release.wasm
path: release.wasm
name: mainnet-release.wasm
path: mainnet-release.wasm
- name: Update the latest release
uses: svenstaro/upload-release-action@v2
with:
tag: latest
file: release.wasm
file: mainnet-release.wasm
overwrite: true
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Update the latest tag
Expand All @@ -46,17 +46,17 @@ jobs:
toolchain: nightly-2021-03-25
override: true
- run: make debug
- run: ls -lH debug.wasm
- name: Upload the debug.wasm artifact
- run: ls -lH mainnet-debug.wasm
- name: Upload the mainnet-debug.wasm artifact
uses: actions/upload-artifact@v2
with:
name: debug.wasm
path: debug.wasm
name: mainnet-debug.wasm
path: mainnet-debug.wasm
- name: Update the latest release
uses: svenstaro/upload-release-action@v2
with:
tag: latest
file: debug.wasm
file: mainnet-debug.wasm
overwrite: true
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Update the latest tag
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:
profile: minimal
toolchain: nightly-2021-03-25
override: true
- run: make test-build
- run: make mainnet-test-build
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --locked --verbose --features meta-call
args: --locked --verbose --features mainnet-test
bully-build:
name: Bully build
runs-on: self-hosted
Expand All @@ -40,8 +40,8 @@ jobs:
profile: minimal
toolchain: nightly-2021-03-25
override: true
- run: make evm-bully=yes
- run: ls -lH release.wasm
- run: make mainnet-debug evm-bully=yes
- run: ls -lH mainnet-debug.wasm
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ res/
etc/state-migration-test/target/

node_modules/*
artifacts/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this?

Copy link
Contributor Author

@joshuajbouw joshuajbouw Jul 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cache
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,6 @@ integration-test = ["log"]
mainnet = ["contract", "log"]
testnet = ["contract", "log"]
betanet = ["contract", "log", "meta-call"]
mainnet-test = ["meta-call"]
testnet-test = ["meta-call"]
betanet-test = ["meta-call"]
81 changes: 58 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,86 @@ ifeq ($(evm-bully),yes)
FEATURES := $(FEATURES),evm_bully
endif

all: release
# TODO: This isn't updating the `FEATURES` for some reason. Disabled to prevent accidental compilation of the same binary for release.
#all: mainnet testnet betanet

release: mainnet

mainnet: FEATURES=mainnet
mainnet: release
mainnet: mainnet-release.wasm

testnet: FEATURES=testnet
testnet: release
testnet: testnet-release.wasm

betanet: FEATURES=betanet
betanet: release
betanet: betanet-release.wasm

mainnet-release.wasm: target/wasm32-unknown-unknown/release/aurora_engine.wasm
cp $< $@

release: release.wasm
testnet-release.wasm: target/wasm32-unknown-unknown/release/aurora_engine.wasm
cp $< $@

release.wasm: target/wasm32-unknown-unknown/release/aurora_engine.wasm
ln -sf $< $@
betanet-release.wasm: target/wasm32-unknown-unknown/release/aurora_engine.wasm
cp $< $@

target/wasm32-unknown-unknown/release/aurora_engine.wasm: Cargo.toml Cargo.lock $(shell find src -name "*.rs") etc/eth-contracts/res/EvmErc20.bin
RUSTFLAGS='-C link-arg=-s' $(CARGO) build --target wasm32-unknown-unknown --release --no-default-features --features=$(FEATURES) -Z avoid-dev-deps
ls -l target/wasm32-unknown-unknown/release/aurora_engine.wasm

etc/eth-contracts/res/EvmErc20.bin: $(shell find etc/eth-contracts/contracts -name "*.sol") etc/eth-contracts/package.json
cd etc/eth-contracts && yarn && yarn build

etc/eth-contracts/artifacts/contracts/test/StateTest.sol/StateTest.json: $(shell find etc/eth-contracts/contracts -name "*.sol") etc/eth-contracts/package.json
cd etc/eth-contracts && yarn && yarn build

debug: debug.wasm
# TODO: This isn't updating the `FEATURES` for some reason. Disabled to prevent accidental compilation of the same binary for debug.
#all-debug: mainnet-debug testnet-debug betanet-debug

debug: mainnet-debug

mainnet-debug: FEATURES=mainnet
mainnet-debug: mainnet-debug.wasm

testnet-debug: FEATURES=testnet
testnet-debug: testnet-debug.wasm

betanet-debug: FEATURES=betanet
betanet-debug: betanet-debug.wasm

mainnet-debug.wasm: target/wasm32-unknown-unknown/debug/aurora_engine.wasm
cp $< $@

debug.wasm: target/wasm32-unknown-unknown/debug/aurora_engine.wasm
ln -sf $< $@
testnet-debug.wasm: target/wasm32-unknown-unknown/debug/aurora_engine.wasm
cp $< $@

betanet-debug.wasm: target/wasm32-unknown-unknown/debug/aurora_engine.wasm
cp $< $@

target/wasm32-unknown-unknown/debug/aurora_engine.wasm: Cargo.toml Cargo.lock $(wildcard src/*.rs) etc/eth-contracts/res/EvmErc20.bin
$(CARGO) build --target wasm32-unknown-unknown --no-default-features --features=$(FEATURES) -Z avoid-dev-deps

test-build: etc/eth-contracts/artifacts/contracts/test/StateTest.sol/StateTest.json etc/eth-contracts/res/EvmErc20.bin
RUSTFLAGS='-C link-arg=-s' $(CARGO) build --target wasm32-unknown-unknown --release --no-default-features --features=mainnet,integration-test,meta-call -Z avoid-dev-deps
ln -sf target/wasm32-unknown-unknown/release/aurora_engine.wasm release.wasm
ls -l target/wasm32-unknown-unknown/release/aurora_engine.wasm
# test depends on release since `tests/test_upgrade.rs` includes `mainnet-release.wasm`
test: test-mainnet

mainnet-test-build: FEATURES=mainnet,integration-test,meta-call
mainnet-test-build: mainnet-release.wasm

betanet-test-build: FEATURES=betanet,integration-test,meta-call
betanet-test-build: betanet-release.wasm

testnet-test-build: FEATURES=testnet,integration-test,meta-call
testnet-test-build: testnet-release.wasm

.PHONY: all release debug eth-contracts mainnet testnet betanet
test-mainnet: mainnet-test-build
$(CARGO) test --features mainnet-test

deploy: release.wasm
test-testnet: betanet-test-build
$(CARGO) test --features testnet-test

test-betanet: testnet-test-build
$(CARGO) test --features betanet-test

deploy: mainnet-release.wasm
$(NEAR) deploy --account-id=$(or $(NEAR_EVM_ACCOUNT),aurora.test.near) --wasm-file=$<

check: test test-sol check-format check-clippy
Expand All @@ -58,20 +96,17 @@ check-format:
check-clippy:
$(CARGO) clippy --no-default-features --features=$(FEATURES) -- -D warnings

# test depends on release since `tests/test_upgrade.rs` includes `release.wasm`
test: test-build
$(CARGO) test --features meta-call

test-sol:
cd etc/eth-contracts && yarn && yarn test

format:
$(CARGO) fmt

clean:
@rm -Rf *.wasm target *~
@rm -Rf *.wasm
cargo clean

.PHONY: deploy check check-format check-clippy test format clean
.PHONY: release mainnet testnet betanet compile-release test-build deploy check check-format check-clippy test test-sol format clean debug mainnet-debug testnet-debug betanet-debug compile-debug mainnet-test-build testnet-test-build betanet-test-build target/wasm32-unknown-unknown/release/aurora_engine.wasm target/wasm32-unknown-unknown/debug/aurora_engine.wasm

.SECONDARY:
.SUFFIXES:
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ rustup target add wasm32-unknown-unknown --toolchain nightly-2021-03-25
### Building the EVM binary

```sh
make release # produces mainnet-release.wasm (300+ KiB)
make -B mainnet # produces Mainnet build
make -B testnet # produces Testnet build
make -B betanet # produces Betanet build
make release # produces release.wasm (300+ KiB)
make debug # produces debug.wasm (1+ MiB), which includes symbols

make debug # produces mainnet-debug.wasm (1+ MiB), which includes symbols
make -B mainnet-debug # produces Mainnet debug build
make -B testnet-debug # produces Testnet debug build
make -B betanet-debug #produces Betanet debug build
```

### Running unit & integration tests
Expand All @@ -70,7 +74,7 @@ make check
### Downloading the latest EVM release

```sh
wget https://github.com/aurora-is-near/aurora-engine/releases/download/latest/release.wasm
wget https://github.com/aurora-is-near/aurora-engine/releases/download/latest/mainnet-release.wasm
```

### Installing the Aurora CLI tool
Expand All @@ -85,7 +89,7 @@ npm install -g aurora-is-near/aurora-cli
export NEAR_ENV=local
near delete aurora.test.near test.near # if needed
near create-account aurora.test.near --master-account=test.near --initial-balance 1000000
aurora install --chain 1313161556 --owner test.near release.wasm
aurora install --chain 1313161556 --owner test.near mainnet-release.wasm
```

### Deploying the EVM without the CLI
Expand All @@ -94,7 +98,7 @@ aurora install --chain 1313161556 --owner test.near release.wasm
export NEAR_ENV=local
near delete aurora.test.near test.near # if needed
near create-account aurora.test.near --master-account=test.near --initial-balance 1000000
near deploy --account-id=aurora.test.near --wasm-file=release.wasm
near deploy --account-id=aurora.test.near --wasm-file=mainnet-release.wasm
aurora initialize --chain 1313161556 --owner test.near
```

Expand Down
2 changes: 0 additions & 2 deletions src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use crate::engine::Engine;
use crate::json::parse_json;
use crate::prelude::*;
use crate::storage::{self, EthConnectorStorageId, KeyPrefix};
#[cfg(feature = "log")]
use alloc::format;
use borsh::{BorshDeserialize, BorshSerialize};

pub(crate) const ERR_NOT_ENOUGH_BALANCE_FOR_FEE: &str = "ERR_NOT_ENOUGH_BALANCE_FOR_FEE";
Expand Down
22 changes: 21 additions & 1 deletion src/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,28 @@ use crate::transaction::{LegacyEthSignedTransaction, LegacyEthTransaction};
use crate::types;
use crate::types::AccountId;

#[cfg(all(
feature = "mainnet-test",
not(any(feature = "testnet", feature = "betanet"))
))]
lazy_static_include::lazy_static_include_bytes! {
EVM_WASM_BYTES => "release.wasm"
EVM_WASM_BYTES => "mainnet-release.wasm"
}

#[cfg(all(
feature = "testnet-test",
not(any(feature = "mainnet", feature = "betanet"))
))]
lazy_static_include::lazy_static_include_bytes! {
EVM_WASM_BYTES => "testnet-release.wasm"
}

#[cfg(all(
feature = "betanet-test",
not(any(feature = "mainnet", feature = "testnet"))
))]
lazy_static_include::lazy_static_include_bytes! {
EVM_WASM_BYTES => "betanet-release.wasm"
}

// TODO(Copied from #84): Make sure that there is only one Signer after both PR are merged.
Expand Down