-
Notifications
You must be signed in to change notification settings - Fork 78
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
ETH connector #59
ETH connector #59
Changes from all commits
98b302a
97a3759
a889328
25154f0
a0942a2
5876814
facc786
b055a54
eb9e361
fcc1332
978474b
041879e
b5ffb23
a7e73f4
45a5ca9
676a86c
e345d71
de7f36d
f1f6479
944b6e2
1201a39
11dec10
89f572c
d6830ea
dd1f8e1
96b3c0e
348e5cc
80f033b
07251fd
2de5af8
e71d52a
09b79c1
f2e1f11
356ad42
6cae502
d920662
27f90ef
3b8f0d5
1074daf
e2f3746
5d26090
628dfd8
8b8043c
41011e9
a4c1cc1
afb5291
a7b5d45
886c7f9
402223c
6c100d0
4217a5a
919f704
a662f50
909b295
a0a02b1
c056e59
9eac293
253fb11
5b46752
1148981
fd7f31c
bae83f0
e97e7a8
f3f8e22
6bc6d3e
e98cd2b
da067eb
95c80ff
8fbb523
cdf2e84
5a0e427
79602e5
d1cf4d7
8db04bc
81f935e
0617912
9e4cbe5
61ae593
c64d81a
a2f7dd7
8812294
ee4add9
4a5624b
805971a
0df9382
a9837cc
d14d045
8cfb9c5
5cb842d
530163c
46b1793
b9bb3ca
6a88507
e99e928
c7b5579
85fec05
735bd8c
92e3a20
05711e3
d50be39
4a009af
87dfbf2
5b0e843
f2a24fe
d7298dd
3b3e2f2
d7d902e
19fa058
f180a08
7fb4239
b4a5d1e
edc8e1d
92f877d
ef24c7f
540ccb1
29785ce
f86197d
ab69d39
60374b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 | ||
|
@@ -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 | ||
|
||
|
@@ -24,6 +25,11 @@ 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 | ||
|
||
.PHONY: all release debug | ||
|
||
deploy: release.wasm | ||
|
@@ -35,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 | ||
Comment on lines
-38
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
# test depends on release since `tests/test_upgrade.rs` includes `release.wasm` | ||
test: release | ||
test: test-build | ||
$(CARGO) test | ||
|
||
format: | ||
|
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). |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use crate::sdk; | ||
|
||
pub type PausedMask = u8; | ||
|
||
pub trait AdminControlled { | ||
/// Returns true if the current account is owner | ||
fn is_owner(&self) -> bool { | ||
sdk::current_account_id() == sdk::predecessor_account_id() | ||
} | ||
|
||
/// Return the current mask representing all paused events. | ||
fn get_paused(&self) -> PausedMask; | ||
|
||
/// Update mask with all paused events. | ||
/// Implementor is responsible for guaranteeing that this function can only be | ||
/// called by owner of the contract. | ||
fn set_paused(&mut self, paused: PausedMask); | ||
|
||
/// Return if the contract is paused for the current flag and user | ||
fn is_paused(&self, flag: PausedMask) -> bool { | ||
(self.get_paused() & flag) != 0 && !self.is_owner() | ||
} | ||
|
||
/// Asserts the passed paused flag is not set. Panics with "ERR_PAUSED" if the flag is set. | ||
fn assert_not_paused(&self, flag: PausedMask) { | ||
assert!(!self.is_paused(flag), "ERR_PAUSED"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be on by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a discussion about this on Slack.
Summary is: if something goes wrong in production there's basically no way to know what happened without logging and it's not that expensive to have it (@mrLSD measured it to be ~0.5 Tgas which is much much less than any operation currently).