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

Pure no-std eth-connector implementation #10

Merged
merged 72 commits into from
Apr 3, 2021
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
86afcb5
Added Pure eth-conenctor space and implemented log-entry rlp logic
mrLSD Mar 9, 2021
63b617e
Adde no-std basic flow
mrLSD Mar 9, 2021
73a6216
Added ethabi no-std implementation
mrLSD Mar 10, 2021
7099e52
Clear ethabi
mrLSD Mar 11, 2021
6001860
Added no-std sdk
mrLSD Mar 11, 2021
ef85dab
Added types
mrLSD Mar 11, 2021
3e11252
Added basic fungible token no-std flow
mrLSD Mar 11, 2021
7cba867
Init contract
mrLSD Mar 12, 2021
714981e
Connector deposit logic
mrLSD Mar 12, 2021
4a940c2
Modified Deposit and extended sdk
mrLSD Mar 12, 2021
5631bbc
Added finish deposit & extended sdk
mrLSD Mar 12, 2021
0588f1e
Mint invoke
mrLSD Mar 13, 2021
954fd39
Record proof & extend sdk
mrLSD Mar 13, 2021
48cb555
Fungible token inner functions
mrLSD Mar 14, 2021
88f7486
Fungible token - extend core internal funcs
mrLSD Mar 15, 2021
9cce426
Added tests
mrLSD Mar 15, 2021
c14b5df
Function args serde serialization issue fix
mrLSD Mar 16, 2021
00075fb
Deposit prover data testing
mrLSD Mar 16, 2021
a46db00
Eth Event Prover fix issue
mrLSD Mar 16, 2021
57764a1
Fix Promise issue & remove ethabi custom implementation
mrLSD Mar 16, 2021
66113ea
Fix hex dependecy
mrLSD Mar 17, 2021
9ae3f8b
Changed verify_log
mrLSD Mar 17, 2021
567390e
Restructure sdk and code
mrLSD Mar 17, 2021
7aa6665
Exnted dependencies and Connector, reduce wasm size
mrLSD Mar 17, 2021
f138044
Fungible tokens extend
mrLSD Mar 18, 2021
14275a2
Transfer FT modifications
mrLSD Mar 18, 2021
2c8ac26
Added EthContract separeted privat implementation
mrLSD Mar 18, 2021
d27bc45
Withdraw & burn
mrLSD Mar 18, 2021
391cc1e
Extend Fungible tokens
mrLSD Mar 19, 2021
fc1a26c
Modified FT: ft_transfer_call
mrLSD Mar 19, 2021
f07749d
Added basic FT Storage functionality & modified SDK
mrLSD Mar 19, 2021
97b66f0
FT Storage Deposit
mrLSD Mar 20, 2021
8c5cae2
Added FT resolve transfer functionality
mrLSD Mar 20, 2021
c9f652a
Added sdk sha256 func and changed for Prover
mrLSD Mar 10, 2021
dbb77d7
fix free standing lib issues
joshuajbouw Mar 20, 2021
fc7e710
PR impovments, changed Cargo.toml dependencies
mrLSD Mar 21, 2021
b897b26
fix on_alloc_error
joshuajbouw Mar 20, 2021
8826d58
Merge branch 'pure-evm-connector' of github.com:joshuajbouw/eth-conne…
mrLSD Mar 20, 2021
2934d52
Clippy issues fix
mrLSD Mar 20, 2021
88df87a
PR review changes
mrLSD Mar 21, 2021
e9171d8
Simple json parser
mrLSD Mar 22, 2021
863c161
Fungible tokens: modife storage logic
mrLSD Mar 22, 2021
39fd66e
Modified storage flow
mrLSD Mar 22, 2021
d211de6
Changed key flow for storage
mrLSD Mar 23, 2021
15d824e
Clippy fixes for String
mrLSD Mar 23, 2021
d8c657e
Fix account types
mrLSD Mar 23, 2021
98686df
Modified init_contract - removed serde and added initialization check
mrLSD Mar 22, 2021
656e24b
Removed serde from Proof and added deserialization
mrLSD Mar 24, 2021
f2167e9
init contract - remove serde & fix json parser
mrLSD Mar 22, 2021
97723f5
Fix deposit serialization & record proof
mrLSD Mar 24, 2021
4f65be5
json parser improvements
mrLSD Mar 24, 2021
fd0aa1d
Fix proof json parser
mrLSD Mar 24, 2021
8204ad9
Removed Withdraw serde and modified serializations
mrLSD Mar 25, 2021
8e018b1
Extended remove serde json
mrLSD Mar 25, 2021
80e0e00
Removed serde for storage_deposit
mrLSD Mar 25, 2021
ed67870
Removed serde for ft_transfer_call
mrLSD Mar 25, 2021
ca3287e
Removed serde for ft_transfer
mrLSD Mar 26, 2021
ce69fac
Fix ft_resolve func & serde dependency. Remove format from panic
mrLSD Mar 26, 2021
5c13f98
Changed build contract logic. Fixed deploy issue for json parse
mrLSD Mar 26, 2021
9977754
Added Gas constants for Deposit function
mrLSD Mar 26, 2021
de7125c
Extend debug info. deposit small fix. Withdraw check
mrLSD Mar 26, 2021
a2e2843
Pure no-std smart contract integration tests basic implementation
mrLSD Mar 30, 2021
4ae78d5
Integration tests for Deposit
mrLSD Mar 31, 2021
f48c344
Integration tests for Withdraw
mrLSD Mar 30, 2021
2f11e22
Fix anyhow lib issue - updated toolchain
mrLSD Mar 31, 2021
389df3b
Extend EthConnector methods for tests
mrLSD Apr 1, 2021
1159819
Added test_ft_total_supply
mrLSD Apr 1, 2021
3788363
Added test_ft_transfer
mrLSD Apr 1, 2021
b38caa9
Incresed GAS_FOR_VERIFY_LOG_ENTRY to 9T/gas
mrLSD Mar 28, 2021
505b047
Changed tests for on_transfer
mrLSD Apr 3, 2021
72bcbb4
Fix resolve_transfer & changed integration test for trasfer_call
mrLSD Apr 3, 2021
3661b46
Changed Gas constants
mrLSD Apr 3, 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
4 changes: 0 additions & 4 deletions evm-fungible-token/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,6 @@ impl EthConnector {
self.token.storage_withdraw(amount)
}

pub fn storage_minimum_balance(&self) -> U128 {
self.token.storage_minimum_balance()
}

Comment on lines -295 to -298
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of scope for this PR

pub fn storage_balance_of(&self, account_id: ValidAccountId) -> AccountStorageBalance {
self.token.storage_balance_of(account_id)
}
Expand Down
1 change: 1 addition & 0 deletions pure-eth-connector/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cargo.lock
44 changes: 44 additions & 0 deletions pure-eth-connector/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[package]
name = "pure-eth-connector"
version = "0.1.0"
authors = ["Near Inc <hello@near.org>"]
edition = "2018"
license = "Apache2"
publish = false
resolver = "2"

[lib]
crate-type = ["cdylib", "rlib"]

Copy link
Contributor

Choose a reason for hiding this comment

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

Its missing a panic = "abort" under [profile.dev]. I have this fixed on my branch linked in earlier message.

[profile.dev]
panic = "abort"

[profile.release]
codegen-units = 1
# Tell `rustc` to optimize for small code size.
opt-level = "z"
lto = true
debug = false
panic = "abort"
debug-assertions = false

[dependencies]
wee_alloc = { version = "0.4.5", default-features = false }
rlp = { version = "0.5", default-features = false }
borsh = { version = "0.8", default-features = false }
primitive-types = { version = "0.8.0", default-features = false, features = ["rlp"] }
hex = { version = "0.4", default-features = false, features = ["alloc"] }
sha3 = { version = "0.8", default-features = false }
serde = { version = "1.0", default-features = false, features=["derive", "alloc"] }
serde_json = { version = "1.0", default-features = false, features=["alloc"] }
ethabi = { git = "https://github.com/darwinia-network/ethabi", branch = "xavier-no-std", default-features = false }
rjson = "0.3.1"

[dev-dependencies]
near-sdk = { git = "https://github.com/near/near-sdk-rs", tag = "3.0.0" }
near-sdk-sim = { git = "https://github.com/near/near-sdk-rs", tag = "3.0.0" }
funty = "=1.1.0" # temp pin of funty as 1.2.0 is API breaking

[features]
default = ["log"]
log = []
34 changes: 34 additions & 0 deletions pure-eth-connector/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
NEAR_ACC=nostd01.eth-connector.testnet
#NEAR_ACC=dev-1616437086828-5300267

build:
@./build.sh
@cp ~/dev/rs/near/eth-connector/pure-eth-connector/Makefile ~/dev/vagrant/near/ || true

clippy:
@cargo clippy

check:
@cargo check

fmt:
@cargo fmt

test:
@cargo test -- --nocapture

dev-deploy:
@near dev-deploy -f pure_eth_connector.wasm

pure-deploy:
@near deploy ${NEAR_ACC} pure_eth_connector.wasm

balance-of:
@near view ${NEAR_ACC} ft_balance_of --args '{"account_id":"testlocal.testnet"}' --account-id ${NEAR_ACC}

init-contract:
@near call ${NEAR_ACC} new '{"prover_account": "nostd01.eth-connector.testnet", "eth_custodian_address": "A0DA4462a8e18299b43BAb74F3D9D4dd73B832f3"}' --account-id ${NEAR_ACC}

deposit:
@near call ${NEAR_ACC} deposit '{"log_index":0,"log_entry_data":[248,251,148,160,218,68,98,168,225,130,153,180,59,171,116,243,217,212,221,115,184,50,243,248,66,160,91,253,175,236,57,174,146,96,226,220,66,250,35,21,1,244,101,251,175,87,166,187,188,197,23,157,14,86,105,51,218,174,160,0,0,0,0,0,0,0,0,0,0,0,0,137,27,39,73,35,139,39,255,88,233,81,8,142,85,176,77,231,29,195,116,184,160,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,188,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,194,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,116,101,115,116,108,111,99,97,108,46,116,101,115,116,110,101,116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"receipt_index":0,"receipt_data":[249,2,6,1,130,98,212,185,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,16,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,32,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,253,248,251,148,160,218,68,98,168,225,130,153,180,59,171,116,243,217,212,221,115,184,50,243,248,66,160,91,253,175,236,57,174,146,96,226,220,66,250,35,21,1,244,101,251,175,87,166,187,188,197,23,157,14,86,105,51,218,174,160,0,0,0,0,0,0,0,0,0,0,0,0,137,27,39,73,35,139,39,255,88,233,81,8,142,85,176,77,231,29,195,116,184,160,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,188,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,194,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,116,101,115,116,108,111,99,97,108,46,116,101,115,116,110,101,116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"header_data":[249,2,10,160,52,175,28,35,212,43,219,118,100,50,155,243,67,151,135,25,107,63,152,47,27,12,152,84,217,12,55,46,152,0,27,209,160,236,241,119,41,165,201,28,176,193,50,105,138,144,20,102,185,249,31,127,18,132,218,106,114,131,158,60,163,247,161,58,74,148,195,209,112,108,44,194,22,138,43,214,152,220,160,114,168,112,46,237,105,13,160,136,150,190,124,203,215,26,177,22,122,114,88,32,157,249,176,74,228,176,62,200,3,164,220,187,78,66,232,223,55,69,150,160,118,196,96,197,96,10,249,177,143,193,228,135,86,120,113,174,85,212,247,104,218,99,25,111,31,205,135,41,156,57,124,190,160,11,137,69,203,17,143,230,78,116,142,231,228,166,250,243,175,251,128,92,231,109,252,212,60,130,203,250,201,72,54,102,41,185,1,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,64,0,0,0,16,16,0,128,0,128,0,192,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,32,0,64,0,0,0,0,0,128,0,1,0,0,0,0,0,0,0,0,8,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,0,0,0,2,0,0,0,0,0,0,2,0,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,48,0,0,1,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,4,0,0,4,0,0,64,0,0,0,0,0,32,0,0,2,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,2,0,0,0,0,5,64,0,0,0,0,17,0,0,32,0,64,0,0,0,1,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,8,0,64,0,8,2,0,0,0,0,0,0,0,0,0,0,0,132,23,190,160,119,131,150,74,168,131,122,18,0,131,100,11,213,132,96,80,190,238,140,115,112,105,100,101,114,49,48,1,0,92,232,160,108,84,192,236,215,221,108,3,203,227,241,55,170,71,149,12,225,89,118,4,252,87,168,230,200,179,177,65,40,61,23,65,136,191,224,164,14,79,193,69,164],"proof":[[248,113,160,191,130,100,43,198,25,70,230,107,127,147,206,10,34,24,53,38,15,190,133,85,218,172,121,58,216,57,211,81,181,104,226,160,44,196,36,108,23,215,156,136,179,114,2,36,249,248,242,60,163,116,55,75,27,155,203,12,210,211,28,47,38,78,132,123,128,128,128,128,128,128,160,148,123,179,172,166,113,217,60,161,148,169,218,181,106,200,124,214,60,70,50,1,244,213,68,180,214,73,135,185,174,53,244,128,128,128,128,128,128,128,128],[249,2,13,48,185,2,9,249,2,6,1,130,98,212,185,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,16,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,32,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,253,248,251,148,160,218,68,98,168,225,130,153,180,59,171,116,243,217,212,221,115,184,50,243,248,66,160,91,253,175,236,57,174,146,96,226,220,66,250,35,21,1,244,101,251,175,87,166,187,188,197,23,157,14,86,105,51,218,174,160,0,0,0,0,0,0,0,0,0,0,0,0,137,27,39,73,35,139,39,255,88,233,81,8,142,85,176,77,231,29,195,116,184,160,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,188,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,194,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,116,101,115,116,108,111,99,97,108,46,116,101,115,116,110,101,116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],"skip_bridge_call":false}' --account-id ${NEAR_ACC} --gas 300000000000000

10 changes: 10 additions & 0 deletions pure-eth-connector/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

# RUSTFLAGS='-C link-arg=-s' cargo build --lib --target wasm32-unknown-unknown --no-default-features --release -Z avoid-dev-deps
RUSTFLAGS='-C link-arg=-s' cargo build --lib --target wasm32-unknown-unknown --release -Z avoid-dev-deps
mkdir -p res
cp target/wasm32-unknown-unknown/release/pure_eth_connector.wasm ./res/

# wasm-opt -Oz --output ./res/near_evm.wasm ./res/near_evm.wasm
ls -lh res/
1 change: 1 addition & 0 deletions pure-eth-connector/rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nightly-2021-01-30
Loading