Skip to content

Commit

Permalink
Release 1.3.0. (#143)
Browse files Browse the repository at this point in the history
* Introduce precompiles for the ETH & ERC-20 connectors. (#51)
* Implement generational storage with `SELFDESTRUCT` tests. (#84)
* Fix u128 JSON parsing & tests in the ETH connector. (#125)
* Add JSON custom error types. (#131)
* Don't burn NEP-141 on deposit. (#133)
* Fix needless borrows. (#135)
* Improve and refactor the ETH connector. (#136)
* Add a macro for logging. (#142)

Co-authored-by: Aleksey Kladov <aleksey@near.org>
Co-authored-by: Arto Bendiken <arto@aurora.dev>
Co-authored-by: Evgeny Ukhanov <evgeny@aurora.dev>
Co-authored-by: Frank Braun <frank@aurora.dev>
Co-authored-by: Joshua J. Bouw <joshua@aurora.dev>
Co-authored-by: Kirill <kirill@aurora.dev>
Co-authored-by: Marcelo Fornet <marcelo@aurora.dev>
Co-authored-by: Michael Birch <michael@aurora.dev>
  • Loading branch information
8 people committed Jun 17, 2021
1 parent 0e45d87 commit e8e68ac
Show file tree
Hide file tree
Showing 59 changed files with 12,224 additions and 979 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/lints.yml
Expand Up @@ -34,8 +34,23 @@ jobs:
toolchain: nightly-2021-03-25
override: true
components: clippy
- name: Run cargo clippy
- run: make etc/eth-contracts/res/EvmErc20.bin
- name: Run Contract cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --no-default-features --features=contract -- -D warnings
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy

contracts:
name: eth-contracts
runs-on: ubuntu-latest
steps:
- name: Clone the repository
uses: actions/checkout@v2
- name: Run yarn lint
working-directory: etc/eth-contracts
run: yarn && yarn lint
12 changes: 12 additions & 0 deletions .gitignore
Expand Up @@ -13,4 +13,16 @@
# Rust artifacts
/*.wasm
/target/

# Solidity artifacts
artifacts/
cache/
node_modules/
res/

# Other
etc/state-migration-test/target/

node_modules/*
artifacts/
cache
13 changes: 13 additions & 0 deletions CHANGES.md
Expand Up @@ -4,3 +4,16 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### [1.3.0] - 2021-06-17

### [1.2.0] - 2021-06-05

### [1.1.0] - 2021-05-28

### [1.0.0] - 2021-05-12

[1.3.0]: https://github.com/aurora-is-near/aurora-engine/compare/1.2.0...1.3.0
[1.2.0]: https://github.com/aurora-is-near/aurora-engine/compare/1.1.0...1.2.0
[1.1.0]: https://github.com/aurora-is-near/aurora-engine/compare/1.0.0...1.1.0
[1.0.0]: https://github.com/aurora-is-near/aurora-engine/tree/1.0.0
20 changes: 12 additions & 8 deletions Cargo.lock

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

8 changes: 6 additions & 2 deletions Cargo.toml
Expand Up @@ -41,8 +41,8 @@ rpath = false
blake2 = { git = "https://github.com/near/near-blake2.git", version = "0.9.1", default-features = false }
borsh = { version = "0.8.2", default-features = false }
bn = { package = "aurora-bn", git = "https://github.com/aurora-is-near/aurora-bn.git", default-features = false }
evm = { version = "0.27.0", default-features = false }
evm-core = { version = "0.27.1", default-features = false }
evm = { version = "0.28.0", default-features = false }
evm-core = { version = "0.28.0", default-features = false }
libsecp256k1 = { version = "0.3.5", default-features = false }
num = { version = "0.4.0", default-features = false, features = ["alloc"] }
primitive-types = { version = "0.9.0", default-features = false, features = ["rlp"] }
Expand All @@ -59,6 +59,8 @@ rjson = { version = "0.3.1", default-features = false }

[dev-dependencies]
bstr = "0.2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
hex = { version = "0.4.3", default-features = false }
near-sdk = { git = "https://github.com/near/near-sdk-rs", rev = "9d99077c6acfde68c06845f2a1eb2b5ed7983401" }
near-sdk-sim = { git = "https://github.com/near/near-sdk-rs", rev = "9d99077c6acfde68c06845f2a1eb2b5ed7983401" }
Expand All @@ -70,6 +72,8 @@ libsecp256k1 = "0.3.5"
rand = "0.7.3"
criterion = "0.3.4"
git2 = "0.13"
lazy-static-include = "3.1.1"
base64 = "0.13.0"

[features]
default = ["sha2", "std"]
Expand Down
22 changes: 14 additions & 8 deletions Makefile
@@ -1,6 +1,6 @@
CARGO = cargo
NEAR = near
FEATURES = contract,log
FEATURES = contract,log,exit-precompiles

ifeq ($(evm-bully),yes)
FEATURES := $(FEATURES),evm_bully
Expand All @@ -13,9 +13,15 @@ release: release.wasm
release.wasm: target/wasm32-unknown-unknown/release/aurora_engine.wasm
ln -sf $< $@

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

Expand All @@ -25,12 +31,12 @@ 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

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
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=contract,integration-test,exit-precompiles -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
.PHONY: all release debug eth-contracts

deploy: release.wasm
$(NEAR) deploy --account-id=$(or $(NEAR_EVM_ACCOUNT),aurora.test.near) --wasm-file=$<
Expand Down
8 changes: 4 additions & 4 deletions doc/eth-connector.md
Expand Up @@ -22,12 +22,12 @@ $ near call <NEAR_ACC> new_eth_connector '{"prover_account": "<PROVER_NEAR_ACCOU

## ETH connector specific methods
* new_eth_connector (call once)
* deposit (mutable)
* deposit (mutable)
* withdraw (mutable, payable)
* finish_deposit_near (private, mutable)
* finish_deposit (private, mutable)
* ft_total_supply (view)
* ft_total_supply_near (view)
* ft_total_supply_eth (view)
* ft_total_eth_supply_on_near (view)
* ft_total_eth_supply_on_aurora (view)
* ft_balance_of (view)
* ft_balance_of_eth (view)
* ft_transfer (mutable, payable)
Expand Down
1 change: 1 addition & 0 deletions etc/eth-contracts/.eslintignore
@@ -0,0 +1 @@
node_modules/
52 changes: 52 additions & 0 deletions etc/eth-contracts/.eslintrc
@@ -0,0 +1,52 @@
{
"extends" : [
"standard",
"plugin:promise/recommended"
],
"plugins": [
"promise"
],
"env": {
"browser" : true,
"node": true,
"mocha": true,
"jest": true
},
"globals" : {
"artifacts": false,
"contract": false,
"assert": false,
"web3": false
},
"rules": {

// Strict mode
"strict": [2, "global"],

// Code style
"indent": [2, 4],
"quotes": [2, "single"],
"semi": ["error", "always"],
"space-before-function-paren": ["error", "always"],
"no-use-before-define": 0,
"no-unused-expressions": "off",
"eqeqeq": [2, "smart"],
"dot-notation": [2, {"allowKeywords": true, "allowPattern": ""}],
"no-redeclare": [2, {"builtinGlobals": true}],
"no-trailing-spaces": [2, { "skipBlankLines": true }],
"eol-last": 1,
"comma-spacing": [2, {"before": false, "after": true}],
"camelcase": [2, {"properties": "always"}],
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
"comma-dangle": [1, "always-multiline"],
"no-dupe-args": 2,
"no-dupe-keys": 2,
"no-debugger": 0,
"no-undef": 2,
"object-curly-spacing": [2, "always"],
"max-len": [2, 200, 2],
"generator-star-spacing": ["error", "before"],
"promise/avoid-new": 0,
"promise/always-return": 0
}
}
9 changes: 9 additions & 0 deletions etc/eth-contracts/.soliumignore
@@ -0,0 +1,9 @@
node_modules

# solium fails to run linter in Tester.sol
# see issue for more details: https://github.com/duaraghav8/Ethlint/issues/293
contracts/test/Tester.sol

# solium fails to run linter in Tester.sol
# see issue for more details: https://github.com/duaraghav8/Ethlint/issues/294
contracts/test/StateTest.sol
23 changes: 23 additions & 0 deletions etc/eth-contracts/.soliumrc.json
@@ -0,0 +1,23 @@
{
"extends": "solium:all",
"plugins": ["security"],
"rules": {
"mixedcase": "off",
"error-reason": "off",
"indentation": ["error", 4],
"lbrace": "off",
"linebreak-style": ["error", "unix"],
"max-len": ["error", 139],
"no-constant": ["error"],
"no-empty-blocks": "off",
"quotes": ["error", "double"],
"uppercase": "off",
"visibility-first": "error",
"arg-overflow": ["error", 5],
"function-order": "off",

"security/enforce-explicit-visibility": ["error"],
"security/no-block-members": ["off"],
"security/no-inline-assembly": ["warning"]
}
}
47 changes: 47 additions & 0 deletions etc/eth-contracts/contracts/AdminControlled.sol
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.0;


contract AdminControlled {
address public admin;
uint public paused;

constructor(address _admin, uint flags) {
admin = _admin;

// Add the possibility to set pause flags on the initialization
paused = flags;
}

modifier onlyAdmin {
require(msg.sender == admin);
_;
}

modifier pausable(uint flag) {
require((paused & flag) == 0 || msg.sender == admin);
_;
}

function adminPause(uint flags) public onlyAdmin {
paused = flags;
}

function adminSstore(uint key, uint value) public onlyAdmin {
assembly {
sstore(key, value)
}
}

function adminSendEth(address payable destination, uint amount) public onlyAdmin {
destination.transfer(amount);
}

function adminReceiveEth() public payable onlyAdmin {}

function adminDelegatecall(address target, bytes memory data) public payable onlyAdmin returns (bytes memory) {
(bool success, bytes memory rdata) = target.delegatecall(data);
require(success);
return rdata;
}
}

0 comments on commit e8e68ac

Please sign in to comment.