Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ebb2edf
Remove the dependency on Lunarity. (#115)
birchmd Jun 1, 2021
418a473
Fix Clippy complaint with +nightly. (#117)
birchmd Jun 1, 2021
0f11b37
Add an `evm-bully=yes` build to CI. (#121)
Jun 4, 2021
544ad92
Fix evm-bully builds. (#130)
birchmd Jun 4, 2021
aaeec76
Handle transaction gas limit properly. (#123)
birchmd Jun 4, 2021
a7d2b19
Merge branch 'master' into develop
artob Jun 4, 2021
d8f042d
Add an `is_used_proof` interface. (#120)
sept-en Jun 5, 2021
b76c7a3
Simplify the `sdk::read_u64` return type. (#118)
birchmd Jun 5, 2021
9c81e52
Merge branch 'master' into develop
artob Jun 5, 2021
2bf9b25
Implement generational storage with `SELFDESTRUCT` tests (#84)
mfornet Jun 10, 2021
faff25c
Fix needless borrows. (#135)
birchmd Jun 11, 2021
c1b8466
Add JSON custom error types. (#131)
sept-en Jun 11, 2021
94cb338
Don't burn NEP-141 on deposit. (#133)
sept-en Jun 11, 2021
cb64a2d
Eth-connector: fixed u128 json parsing & tests (#125)
mrLSD Jun 12, 2021
99b4e17
Macro for logging (#142)
birchmd Jun 16, 2021
9c4b1d0
Add changelog sections.
artob Jun 17, 2021
cbb878f
Introduce precompiles for the ETH & ERC-20 connectors. (#51)
mfornet Jun 17, 2021
1007ce2
Improve and refactor the ETH connector. (#136)
sept-en Jun 17, 2021
7376cfb
Add missing trailing newline.
artob Jun 17, 2021
3b6bc37
Fix SPDX identifiers.
artob Jun 17, 2021
1dff687
Add missing trailing newlines.
artob Jun 17, 2021
680f519
Merge branch 'master' into develop
artob Jun 17, 2021
d923a02
Bump normalize-url from 4.5.0 to 4.5.1. (#144)
dependabot[bot] Jun 17, 2021
3caa772
Fix CI debug pipeline. (#145)
mfornet Jun 17, 2021
7715d90
Enable `meta_call` only with feature flag. (#146)
sept-en Jun 17, 2021
790c3f4
Implement EIP-2565 support. (#138)
joshuajbouw Jun 17, 2021
37961b2
Add `mainnet`, `testnet`, and `betanet` feature flags. (#147)
sept-en Jun 17, 2021
879c736
Fix `clippy::unnecessary_unwrap`. (#149)
birchmd Jun 17, 2021
1215c02
Prohibit static calls in exit precompiles. (#148)
sept-en Jun 17, 2021
ca8c5cc
Fix all Clippy warnings. (#150)
sept-en Jun 17, 2021
3054a27
Create the `ExitToNear` receiver account if it does not exist. (#151)
birchmd Jun 18, 2021
21a14bb
Update the changelog.
artob Jun 18, 2021
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
11 changes: 7 additions & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ 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.4.0] - 2021-06-18

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

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

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

## [1.0.0] - 2021-05-12

[1.4.0]: https://github.com/aurora-is-near/aurora-engine/compare/1.3.0...1.4.0
[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
Expand Down
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ base64 = "0.13.0"
[features]
default = ["sha2", "std"]
std = ["borsh/std", "evm/std", "primitive-types/std", "rlp/std", "sha3/std", "ethabi/std", "logos/std", "bn/std"]
testnet = []
engine = []
contract = ["engine"]
evm_bully = []
log = []
exit-precompiles = ["contract"]
meta-call = ["contract"]
integration-test = ["log"]
mainnet = ["contract", "log"]
testnet = ["contract", "log"]
betanet = ["contract", "log", "meta-call"]
17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
CARGO = cargo
NEAR = near
FEATURES = contract,log,exit-precompiles
FEATURES = mainnet

ifeq ($(evm-bully),yes)
FEATURES := $(FEATURES),evm_bully
endif

all: release

mainnet: FEATURES=mainnet
mainnet: release

testnet: FEATURES=testnet
testnet: release

betanet: FEATURES=betanet
betanet: release

release: release.wasm

release.wasm: target/wasm32-unknown-unknown/release/aurora_engine.wasm
Expand All @@ -25,18 +34,18 @@ etc/eth-contracts/artifacts/contracts/test/StateTest.sol/StateTest.json: $(shell

debug: debug.wasm

debug.wasm: target/wasm32-unknown-unknown/debug/aurora_engine.wasm
debug.wasm: target/wasm32-unknown-unknown/debug/aurora_engine.wasm etc/eth-contracts/res/EvmErc20.bin
ln -sf $< $@

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: 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
RUSTFLAGS='-C link-arg=-s' $(CARGO) build --target wasm32-unknown-unknown --release --no-default-features --features=contract,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

.PHONY: all release debug eth-contracts
.PHONY: all release debug eth-contracts mainnet testnet betanet

deploy: release.wasm
$(NEAR) deploy --account-id=$(or $(NEAR_EVM_ACCOUNT),aurora.test.near) --wasm-file=$<
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ rustup target add wasm32-unknown-unknown --toolchain nightly-2021-03-25
### Building the EVM binary

```sh
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
```
Expand Down
4 changes: 2 additions & 2 deletions etc/eth-contracts/contracts/EvmErc20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contract EvmErc20 is Context, ERC20, AdminControlled, IExit {
uint input_size = 1 + 32 + recipient.length;

assembly {
let res := staticcall(gas(), 0xe9217bc70b7ed1f598ddd3199e80b093fa71124f, add(input, 32), input_size, 0, 32)
let res := call(gas(), 0xe9217bc70b7ed1f598ddd3199e80b093fa71124f, 0, add(input, 32), input_size, 0, 32)
}
}

Expand All @@ -49,7 +49,7 @@ contract EvmErc20 is Context, ERC20, AdminControlled, IExit {
uint input_size = 1 + 32 + 20;

assembly {
let res := staticcall(gas(), 0xb0bd02f6a392af548bdf1cfaee5dfa0eefcc8eab, add(input, 32), input_size, 0, 32)
let res := call(gas(), 0xb0bd02f6a392af548bdf1cfaee5dfa0eefcc8eab, 0, add(input, 32), input_size, 0, 32)
}
}
}
6 changes: 3 additions & 3 deletions etc/eth-contracts/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5522,9 +5522,9 @@ normalize-path@^3.0.0, normalize-path@~3.0.0:
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==

normalize-url@^4.1.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.0.tgz#453354087e6ca96957bd8f5baf753f5982142129"
integrity sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ==
version "4.5.1"
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.1.tgz#0dd90cf1288ee1d1313b87081c9a5932ee48518a"
integrity sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==

npm-run-path@^2.0.0:
version "2.0.2"
Expand Down
13 changes: 6 additions & 7 deletions src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ impl EthConnectorContract {
}

/// ft_on_transfer callback function
#[allow(clippy::unnecessary_unwrap)]
pub fn ft_on_transfer(&mut self, engine: &Engine, args: &NEP141FtOnTransferArgs) {
crate::log!("Call ft_on_transfer");
// Parse message with specific rules
Expand All @@ -555,12 +554,12 @@ impl EthConnectorContract {
let fee = message_data.fee.as_u128();
// Mint fee to relayer
let relayer = engine.get_relayer(message_data.relayer.as_bytes());
if fee > 0 && relayer.is_some() {
self.mint_eth_on_aurora(message_data.recipient, args.amount - fee);
let evm_relayer_address: EthAddress = relayer.unwrap().0;
self.mint_eth_on_aurora(evm_relayer_address, fee);
} else {
self.mint_eth_on_aurora(message_data.recipient, args.amount);
match (fee, relayer) {
(fee, Some(crate::prelude::H160(evm_relayer_address))) if fee > 0 => {
self.mint_eth_on_aurora(message_data.recipient, args.amount - fee);
self.mint_eth_on_aurora(evm_relayer_address, fee);
}
_ => self.mint_eth_on_aurora(message_data.recipient, args.amount),
}
self.save_ft_contract();
sdk::return_output(0.to_string().as_bytes());
Expand Down
13 changes: 7 additions & 6 deletions src/deposit_event.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::prelude::{vec, String, ToString};
#[cfg(not(feature = "contract"))]
use crate::prelude::{TryInto, Vec};
use crate::prelude::Vec;
use crate::prelude::{vec, String, ToString};

use crate::types::*;
use ethabi::{EventParam, ParamType};
Expand Down Expand Up @@ -45,7 +45,8 @@ impl DepositedEvent {
]
}

/// Parse raw log Etherium proof entry data.
/// Parses raw Ethereum logs proof's entry data
#[cfg(feature = "engine")]
pub fn from_log_entry_data(data: &[u8]) -> Self {
let event = EthEvent::fetch_log_entry_data(DEPOSITED_EVENT, Self::event_params(), data);
let sender = event.log.params[0].value.clone().into_address().unwrap().0;
Expand All @@ -65,15 +66,15 @@ impl DepositedEvent {
#[cfg(not(feature = "contract"))]
#[allow(dead_code)]
pub fn to_log_entry_data(&self) -> Vec<u8> {
EthEvent::to_log_entry_data(
EthEvent::params_to_log_entry_data(
DEPOSITED_EVENT,
DepositedEvent::event_params(),
self.eth_custodian_address,
vec![self.sender.to_vec()],
vec![
ethabi::Token::String(self.recipient.clone()),
ethabi::Token::Uint(self.amount.into()),
ethabi::Token::Uint(self.fee.clone()),
ethabi::Token::Uint(self.amount),
ethabi::Token::Uint(self.fee),
],
)
}
Expand Down
20 changes: 13 additions & 7 deletions src/fungible_token.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#[cfg(feature = "engine")]
use crate::parameters::*;
#[cfg(feature = "log")]
use crate::prelude::format;
use crate::prelude::TryInto;
#[cfg(feature = "engine")]
use crate::prelude::{self, Ordering, String, ToString, Vec, U256};
use crate::types::*;
#[cfg(feature = "engine")]
use crate::{connector, engine, sdk, storage};
use borsh::{BorshDeserialize, BorshSerialize};
#[cfg(feature = "engine")]
use {
crate::connector,
crate::engine,
crate::parameters::*,
crate::prelude::{self, Ordering, String, ToString, TryInto, Vec, U256},
crate::sdk,
crate::storage,
};

#[cfg(feature = "engine")]
const GAS_FOR_RESOLVE_TRANSFER: Gas = 5_000_000_000_000;
Expand Down Expand Up @@ -142,6 +144,10 @@ impl FungibleToken {
"Sender and receiver should be different"
);
assert!(amount > 0, "The amount should be a positive number");
if !self.accounts_contains_key(receiver_id) {
// TODO: how does this interact with the storage deposit concept?
self.internal_register_account(receiver_id)
}
self.internal_withdraw_eth_from_near(sender_id, amount);
self.internal_deposit_eth_to_near(receiver_id, amount);
crate::log!(&format!(
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::parameters::PromiseCreateArgs;

#[cfg(feature = "engine")]
mod map;
#[cfg(feature = "meta-call")]
pub mod meta_parsing;
pub mod parameters;
pub mod prelude;
Expand Down Expand Up @@ -279,6 +280,7 @@ mod contract {
.sdk_process();
}

#[cfg(feature = "meta-call")]
#[no_mangle]
pub extern "C" fn meta_call() {
let input = sdk::read_input();
Expand Down
20 changes: 10 additions & 10 deletions src/parameters.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use borsh::{BorshDeserialize, BorshSerialize};

#[cfg(feature = "engine")]
use crate::admin_controlled::PausedMask;
#[cfg(feature = "engine")]
use crate::json;
use crate::prelude::{is_valid_account_id, String, ToString, TryFrom, Vec};
#[cfg(feature = "engine")]
use crate::sdk;
use crate::types::{AccountId, Balance, Proof, RawAddress, RawH256, RawU256};
#[cfg(feature = "engine")]
use crate::types::{EthAddress, SdkUnwrap};
use crate::prelude::{String, Vec};
use crate::types::{AccountId, Balance, RawAddress, RawH256, RawU256};
#[cfg(feature = "engine")]
use crate::{
admin_controlled::PausedMask,
json,
prelude::{is_valid_account_id, ToString, TryFrom},
sdk,
types::{EthAddress, Proof, SdkUnwrap},
};
use evm::backend::Log;

/// Borsh-encoded parameters for the `new` function.
Expand Down
1 change: 1 addition & 0 deletions src/precompiles/blake2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mod consts {
pub(super) struct Blake2F<S>(PhantomData<S>);

impl<S> Blake2F<S> {
#[cfg_attr(not(feature = "engine"), allow(dead_code))]
pub(super) const ADDRESS: [u8; 20] = super::make_address(0, 9);
}

Expand Down
3 changes: 3 additions & 0 deletions src/precompiles/bn128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ mod consts {
pub(super) mod addresses {
use crate::precompiles;

#[cfg_attr(not(feature = "engine"), allow(dead_code))]
pub const ADD: [u8; 20] = precompiles::make_address(0, 6);
#[cfg_attr(not(feature = "engine"), allow(dead_code))]
pub const MUL: [u8; 20] = precompiles::make_address(0, 7);
#[cfg_attr(not(feature = "engine"), allow(dead_code))]
pub const PAIR: [u8; 20] = precompiles::make_address(0, 8);
}

Expand Down
2 changes: 2 additions & 0 deletions src/precompiles/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ mod consts {
pub struct SHA256<S>(PhantomData<S>);

impl<S> SHA256<S> {
#[cfg_attr(not(feature = "engine"), allow(dead_code))]
pub(super) const ADDRESS: [u8; 20] = super::make_address(0, 2);
}

Expand Down Expand Up @@ -89,6 +90,7 @@ impl<S: AuroraState> Precompile<S> for SHA256<S> {
pub struct RIPEMD160<S>(PhantomData<S>);

impl<S> RIPEMD160<S> {
#[cfg_attr(not(feature = "engine"), allow(dead_code))]
pub(super) const ADDRESS: [u8; 20] = super::make_address(0, 3);
}

Expand Down
1 change: 1 addition & 0 deletions src/precompiles/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ mod consts {
pub struct Identity<S>(PhantomData<S>);

impl<S> Identity<S> {
#[cfg_attr(not(feature = "engine"), allow(dead_code))]
pub(super) const ADDRESS: [u8; 20] = super::make_address(0, 4);
}

Expand Down
Loading