Skip to content

Commit

Permalink
connectors-gateway: Add Ethereum Transaction pallet (#1460)
Browse files Browse the repository at this point in the history
* connectors-gateway: Add Ethereum Transaction pallet

* ethereum-transaction: Remove unused deps

* integration-tests: Remove default-features flag for EVM deps

* primitives: Add transaction recovery ID

* ethereum-transaction: Add pallet errors, use dispatch info var

* tests: Simplify mock runtime, add author const, add func for default test params

* integration-test: Simplify contract address retrieval by using iterator find

* taplo: Obey

* primitives: Fix doc link
  • Loading branch information
cdamian committed Jul 31, 2023
1 parent 43bf08c commit 5237396
Show file tree
Hide file tree
Showing 19 changed files with 1,055 additions and 8 deletions.
48 changes: 48 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ members = [
"pallets/collator-allowlist",
"pallets/crowdloan-claim",
"pallets/crowdloan-reward",
"pallets/ethereum-transaction",
"pallets/fees",
"pallets/interest-accrual",
"pallets/investments",
Expand Down
5 changes: 5 additions & 0 deletions libs/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ pub mod constants {

/// Unhashed 36-bytes prefix for currencies managed by Connectors.
pub const GENERAL_CURRENCY_INDEX_PREFIX: [u8; 36] = *b"CentrifugeGeneralCurrencyIndexPrefix";

/// Transaction recovery ID used for generating a signature in the Ethereum
/// Transaction pallet. As per:
/// <https://github.com/PureStake/moonbeam/blob/fb63014a5e487f17e31283776e4f6b0befd009a2/primitives/xcm/src/ethereum_xcm.rs#L167>
pub const TRANSACTION_RECOVERY_ID: u64 = 42;
}

/// Listing of parachains we integrate with.
Expand Down
16 changes: 16 additions & 0 deletions libs/traits/src/ethereum.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use frame_support::dispatch::DispatchResultWithPostInfo;
use sp_runtime::app_crypto::sp_core::{H160, U256};

/// Something capable of managing transactions in an EVM/Ethereum context
pub trait EthereumTransactor {
/// Transacts the specified call in the EVM context,
/// exposing the call and any events to the EVM block.
fn call(
from: H160,
to: H160,
data: &[u8],
value: U256,
gas_price: U256,
gas_limit: U256,
) -> DispatchResultWithPostInfo;
}
2 changes: 2 additions & 0 deletions libs/traits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub mod changes;
pub mod connectors;
/// Traits related to data registry and collection.
pub mod data;
/// Traits related to Ethereum/EVM.
pub mod ethereum;
/// Traits related to interest rates.
pub mod interest;
/// Traits related to rewards.
Expand Down
78 changes: 78 additions & 0 deletions pallets/ethereum-transaction/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
[package]
authors = ["Centrifuge <admin@centrifuge.io>"]
description = "Centrifuge Ethereum Transaction Pallet"
edition = "2021"
license = "LGPL-3.0"
name = "pallet-ethereum-transaction"
repository = "https://github.com/centrifuge/centrifuge-chain"
version = "0.0.1"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"], default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }
scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }

# Benchmarking
frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.38" }

# Substrate crates
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }

# Ethereum
ethereum = { version = "0.14.0", default-features = false }
fp-evm = { git = "https://github.com/PureStake/frontier", default-features = false, branch = "moonbeam-polkadot-v0.9.38" }
pallet-ethereum = { git = "https://github.com/PureStake/frontier", default-features = false, branch = "moonbeam-polkadot-v0.9.38" }
pallet-evm = { git = "https://github.com/PureStake/frontier", default-features = false, branch = "moonbeam-polkadot-v0.9.38" }

# Our custom traits
cfg-primitives = { path = "../../libs/primitives", default-features = false }
cfg-traits = { path = "../../libs/traits", default-features = false }

[dev-dependencies]
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }

pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
pallet-evm-precompile-simple = { git = "https://github.com/PureStake/frontier", branch = "moonbeam-polkadot-v0.9.38" }
pallet-timestamp = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.38" }

[features]
default = ["std"]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"cfg-traits/runtime-benchmarks",
"pallet-ethereum/runtime-benchmarks",
"pallet-evm/runtime-benchmarks",
]
std = [
"codec/std",
"cfg-traits/std",
"frame-support/std",
"frame-system/std",
"frame-benchmarking/std",
"sp-core/std",
"sp-std/std",
"sp-runtime/std",
"scale-info/std",
"pallet-ethereum/std",
"pallet-evm/std",
"fp-evm/std",
"ethereum/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"cfg-traits/try-runtime",
"pallet-ethereum/try-runtime",
"pallet-evm/try-runtime",
"sp-runtime/try-runtime",
]

0 comments on commit 5237396

Please sign in to comment.