Skip to content

Commit

Permalink
added ethereum address20 support (#2216)
Browse files Browse the repository at this point in the history
# Goal
The goal of this PR is to allow sending transactions using ethereum
signatures and ethereum addresses

Closes #2206 

# Changes
- Replaced `MultiSignature` with `UnifiedSignature` in the runtime which
supports ethereum signatures for ecdsa
- Replaced `AccountIdLookup` with `EthereumCompatibleAccountIdLookup` in
runtime which support 20 bytes accounts in MultiAddress
- Showing runtime logs for `start-frequency-instant` mode (this would be
helpful in debugging)

# Warning
- For e2e test we should use `getUnifiedAddress(keyPair)` function
instead of `keypair.address` directly. Thisb would ensure we are using
correct ethereum address for ethereum keys.


# Checklist
- [x] Updated js/api-augment for Custom RPC APIs?
- [x] Unit Tests added?
- [x] e2e Tests added?
- [x] Spec version incremented?
  • Loading branch information
aramikm authored Nov 15, 2024
1 parent eea11ae commit deac3bf
Show file tree
Hide file tree
Showing 33 changed files with 886 additions and 134 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/verify-pr-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ jobs:
# with:
# path: ${{env.WASM_DIR}}/${{env.BUILT_WASM_FILENAME}}
# key: runtimes-${{runner.os}}-${{matrix.network}}-${{github.head_ref}}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}
- name: Build Deterministic WASM
id: srtool_build
if: steps.cache-wasm.outputs.cache-hit != 'true'
Expand Down
31 changes: 17 additions & 14 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ serde = { version = "1.0", default-features = false }
serial_test = { version = "0.9.0", default-features = false }
base64-url = { version = "3.0.0", default-features = false }
p256 = { version = "0.13.2", default-features = false, features = ["ecdsa"] }
libsecp256k1 = { version = "0.7", default-features = false }

# substrate pallets
pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false }
Expand Down Expand Up @@ -159,6 +160,7 @@ substrate-test-utils = { git = "https://github.com/paritytech/polkadot-sdk", bra

substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0" }
sp-debug-derive = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false }

[profile.release]
panic = "unwind"
Expand Down
5 changes: 4 additions & 1 deletion common/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ sp-std = { workspace = true }
numtoa = { workspace = true }
sp-externalities = { workspace = true }
sp-runtime-interface = { workspace = true }
libsecp256k1 = { workspace = true, features = ["hmac"] }
log = "0.4.22"

[features]
default = ['std']
runtime-benchmarks = []
std = [
'libsecp256k1/std',
'parity-scale-codec/std',
'frame-support/std',
'frame-system/std',
Expand All @@ -47,4 +50,4 @@ std = [
'sp-externalities/std',
'sp-runtime-interface/std'
]
test = []
test = []
3 changes: 3 additions & 0 deletions common/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ pub mod offchain;
#[cfg(feature = "runtime-benchmarks")]
/// Benchmarking helper trait
pub mod benchmarks;

/// Signature support for ethereum
pub mod signatures;
3 changes: 2 additions & 1 deletion common/primitives/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub use sp_runtime::{
};
use sp_std::{boxed::Box, vec::Vec};

use crate::signatures::UnifiedSignature;
use frame_support::dispatch::DispatchResultWithPostInfo;

/// Some way of identifying an account on the chain. We intentionally make it equivalent
Expand All @@ -31,7 +32,7 @@ pub type BlockNumber = u32;
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;

/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
pub type Signature = MultiSignature;
pub type Signature = UnifiedSignature;

/// Index of a transaction in the chain.
pub type Index = u32;
Expand Down
Loading

0 comments on commit deac3bf

Please sign in to comment.