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

Implement generational storage #87

Merged
merged 23 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
37c8334
Base precompile code between connectors (#73)
mfornet May 12, 2021
02dbfd8
Document `aurora encode-address` usage.
artob May 14, 2021
53f4cc6
Merge branch 'master' into develop
artob May 14, 2021
996f9fc
Cache cargo artifacts between CI runs. (#92)
birchmd May 17, 2021
2474b5d
Merge branch 'master' into develop
artob May 17, 2021
45c1e52
Address comments from audit. (#86)
birchmd May 18, 2021
ca41305
Reduce size of `cargo cache` in CI. (#95)
birchmd May 18, 2021
bfaa2c2
Define a `Wei` newtype for balances. (#96)
birchmd May 18, 2021
7d4990f
Fix evm-bully builds after recent refactoring. (#100)
birchmd May 19, 2021
7b352b3
Refactor `Engine::get_state` to return a `Result`. (#99)
birchmd May 20, 2021
2689e3b
Ensure that `Cargo.lock` in the repo is valid. (#101)
matklad May 20, 2021
060f310
Remove unneeded nightly feature. (#102)
matklad May 20, 2021
7cdd7c3
Implement BC generational storage.
joshuajbouw May 14, 2021
1682bbd
fix address input
joshuajbouw May 14, 2021
3a5bac6
remove note
joshuajbouw May 14, 2021
fb3ca77
put key on the end of the storage key
joshuajbouw May 14, 2021
77ba897
remove pub from methods
joshuajbouw May 18, 2021
046a560
Dispatch precompiles on the full address. (#107)
birchmd May 28, 2021
b09b530
Support state migration on upgrade. (#103)
birchmd May 28, 2021
5144281
Implement the ETH connector. (#59)
mrLSD May 28, 2021
6b02195
Merge branch 'master' into feat/gen_storage
joshuajbouw Jun 1, 2021
bff62d4
Move when to call `set_generation`
joshuajbouw Jun 1, 2021
2ae28fb
Fix arg
joshuajbouw Jun 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,26 @@ jobs:
steps:
- name: Clone the repository
uses: actions/checkout@v2
- name: Cache Cargo artifacts
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install the toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-03-25
override: true
- run: make release
- run: ls -lH release.wasm
- run: make test-build
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --verbose
args: --locked --verbose
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# Rust artifacts
/*.wasm
/target/
etc/state-migration-test/target/

node_modules/
artifacts/
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ wee_alloc = { version = "0.4.5", default-features = false }
lunarity-lexer = { git = "https://github.com/ilblackdragon/lunarity", rev = "5201d9a76f7e491082b7f74af7e64049271e387f", default-features = false }
ethabi = { git = "https://github.com/darwinia-network/ethabi", branch = "xavier-no-std", default-features = false }
hex = { version = "0.4", default-features = false, features = ["alloc"] }
byte-slice-cast = { version = "1.0", default-features = false }
rjson = { version = "0.3.1", default-features = false }

[dev-dependencies]
Expand All @@ -76,5 +77,9 @@ git2 = "0.13"
default = ["sha2", "std"]
std = ["borsh/std", "evm/std", "primitive-types/std", "rlp/std", "sha3/std", "ethabi/std", "lunarity-lexer/std", "bn/std"]
testnet = []
contract = []
engine = []
contract = ["engine"]
evm_bully = []
log = []
exit-precompiles = ["contract"]
integration-test = ["log"]
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CARGO = cargo
NEAR = near
FEATURES = contract
FEATURES = contract,log

ifeq ($(evm-bully),yes)
FEATURES := $(FEATURES),evm_bully
Expand All @@ -15,6 +15,7 @@ release.wasm: target/wasm32-unknown-unknown/release/aurora_engine.wasm

target/wasm32-unknown-unknown/release/aurora_engine.wasm: Cargo.toml Cargo.lock $(wildcard src/*.rs)
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

debug: debug.wasm

Expand All @@ -24,8 +25,10 @@ debug.wasm: target/wasm32-unknown-unknown/debug/aurora_engine.wasm
target/wasm32-unknown-unknown/debug/aurora_engine.wasm: Cargo.toml Cargo.lock $(wildcard src/*.rs)
$(CARGO) build --target wasm32-unknown-unknown --no-default-features --features=$(FEATURES) -Z avoid-dev-deps

etc/eth-contracts/artifacts/contracts/StateTest.sol/SelfDestructFactory.json: etc/eth-contracts/contracts/StateTest.sol
cd etc/eth-contracts && yarn && yarn compile
test-build:
RUSTFLAGS='-C link-arg=-s' $(CARGO) build --target wasm32-unknown-unknown --release --no-default-features --features=contract,integration-test -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

.PHONY: all release debug

Expand All @@ -38,10 +41,10 @@ check-format:
$(CARGO) fmt -- --check

check-clippy:
$(CARGO) +nightly clippy --no-default-features --features=$(FEATURES) -- -D warnings
$(CARGO) clippy --no-default-features --features=$(FEATURES) -- -D warnings

# test depends on release since `tests/test_upgrade.rs` includes `release.wasm`
test: release etc/eth-contracts/artifacts/contracts/StateTest.sol/SelfDestructFactory.json
test: test-build
$(CARGO) test

format:
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ aurora deploy-code 0x600060005560648060106000396000f360e060020a6000350480638ada0

### Examining EVM contract state

```console
$ aurora encode-address test.near
0xCBdA96B3F2B8eb962f97AE50C3852CA976740e2B
```

```sh
aurora get-nonce 0xCBdA96B3F2B8eb962f97AE50C3852CA976740e2B
aurora get-balance 0xCBdA96B3F2B8eb962f97AE50C3852CA976740e2B
Expand All @@ -127,6 +132,11 @@ aurora get-storage-at 0xFc481F4037887e10708552c0D7563Ec6858640d6 0

### Calling an EVM contract read-only

```console
$ aurora encode-address test.near
0xCBdA96B3F2B8eb962f97AE50C3852CA976740e2B
```

```sh
aurora view --sender 0xCBdA96B3F2B8eb962f97AE50C3852CA976740e2B 0xFc481F4037887e10708552c0D7563Ec6858640d6 0x8ada066e # getCounter()
aurora view --sender 0xCBdA96B3F2B8eb962f97AE50C3852CA976740e2B 0xFc481F4037887e10708552c0D7563Ec6858640d6 0xd09de08a # increment()
Expand Down
42 changes: 42 additions & 0 deletions doc/eth-connector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# ETH connector

## Build
1. For production set in the Makefile
```
FEATURES = contract
```
1.1. For **development and testing** set in the Makefile
```
FEATURES = contract,integration-test
```
2. Build release: `$ make release`
3. Run tests: `$ cargo test`
4. Deploying process is common for Aurora itself. Please reference [README.md](../README.md)

## Initialize eth-conenctor
With `near-cli` run:
```
$ near call <NEAR_ACC> new_eth_connector '{"prover_account": "<PROVER_NEAR_ACCOUNT>", "eth_custodian_address": "<ETH_ADDRESS>"}' --account-id <NEAR_ACC>

```

## ETH connector specific methods
* new_eth_connector (call once)
* deposit (mutable)
* withdraw (mutable, payable)
* finish_deposit_near (private, mutable)
* ft_total_supply (view)
* ft_total_supply_near (view)
* ft_total_supply_eth (view)
* ft_balance_of (view)
* ft_balance_of_eth (view)
* ft_transfer (mutable, payable)
* ft_resolve_transfer (private, mutable)
* ft_transfer_call (mutable, payable)
* ft_on_transfer (private, mutable)
* storage_deposit (mutable)
* storage_withdraw (mutable, payable)
* storage_balance_of (view)

## Ethereum specific flow
Follow by [this instruction](https://github.com/aurora-is-near/eth-connector/blob/master/README.md).