Skip to content

Commit deac3bf

Browse files
authored
added ethereum address20 support (#2216)
# 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?
1 parent eea11ae commit deac3bf

33 files changed

+886
-134
lines changed

.github/workflows/verify-pr-commit.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ jobs:
362362
# with:
363363
# path: ${{env.WASM_DIR}}/${{env.BUILT_WASM_FILENAME}}
364364
# key: runtimes-${{runner.os}}-${{matrix.network}}-${{github.head_ref}}
365+
- name: Login to DockerHub
366+
uses: docker/login-action@v3
367+
with:
368+
username: ${{secrets.DOCKERHUB_USERNAME}}
369+
password: ${{secrets.DOCKERHUB_TOKEN}}
365370
- name: Build Deterministic WASM
366371
id: srtool_build
367372
if: steps.cache-wasm.outputs.cache-hit != 'true'

Cargo.lock

Lines changed: 17 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ serde = { version = "1.0", default-features = false }
5454
serial_test = { version = "0.9.0", default-features = false }
5555
base64-url = { version = "3.0.0", default-features = false }
5656
p256 = { version = "0.13.2", default-features = false, features = ["ecdsa"] }
57+
libsecp256k1 = { version = "0.7", default-features = false }
5758

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

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

163165
[profile.release]
164166
panic = "unwind"

common/primitives/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ sp-std = { workspace = true }
3030
numtoa = { workspace = true }
3131
sp-externalities = { workspace = true }
3232
sp-runtime-interface = { workspace = true }
33+
libsecp256k1 = { workspace = true, features = ["hmac"] }
34+
log = "0.4.22"
3335

3436
[features]
3537
default = ['std']
3638
runtime-benchmarks = []
3739
std = [
40+
'libsecp256k1/std',
3841
'parity-scale-codec/std',
3942
'frame-support/std',
4043
'frame-system/std',
@@ -47,4 +50,4 @@ std = [
4750
'sp-externalities/std',
4851
'sp-runtime-interface/std'
4952
]
50-
test = []
53+
test = []

common/primitives/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ pub mod offchain;
4141
#[cfg(feature = "runtime-benchmarks")]
4242
/// Benchmarking helper trait
4343
pub mod benchmarks;
44+
45+
/// Signature support for ethereum
46+
pub mod signatures;

common/primitives/src/node.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub use sp_runtime::{
66
};
77
use sp_std::{boxed::Box, vec::Vec};
88

9+
use crate::signatures::UnifiedSignature;
910
use frame_support::dispatch::DispatchResultWithPostInfo;
1011

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

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

3637
/// Index of a transaction in the chain.
3738
pub type Index = u32;

0 commit comments

Comments
 (0)