Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions prdoc/pr_10336.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: fix P256Verify precompile address
doc:
- audience: Runtime Dev
description: fix https://github.com/paritytech/contract-issues/issues/220
crates:
- name: pallet-revive
bump: patch
2 changes: 1 addition & 1 deletion substrate/frame/revive/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2288,7 +2288,7 @@ mod benchmarks {
{
result = run_builtin_precompile(
&mut ext,
H160::from_low_u64_be(100).as_fixed_bytes(),
H160::from_low_u64_be(0x100).as_fixed_bytes(),
input,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct Blake2F<T>(PhantomData<T>);

impl<T: Config> PrimitivePrecompile for Blake2F<T> {
type T = T;
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(9).unwrap());
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(0x9).unwrap());
const HAS_CONTRACT_INFO: bool = false;

fn call(
Expand Down
6 changes: 3 additions & 3 deletions substrate/frame/revive/src/precompiles/builtin/bn128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct Bn128Add<T>(PhantomData<T>);

impl<T: Config> PrimitivePrecompile for Bn128Add<T> {
type T = T;
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(6).unwrap());
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(0x6).unwrap());
const HAS_CONTRACT_INFO: bool = false;

fn call(
Expand Down Expand Up @@ -58,7 +58,7 @@ pub struct Bn128Mul<T>(PhantomData<T>);

impl<T: Config> PrimitivePrecompile for Bn128Mul<T> {
type T = T;
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(7).unwrap());
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(0x7).unwrap());
const HAS_CONTRACT_INFO: bool = false;

fn call(
Expand Down Expand Up @@ -86,7 +86,7 @@ pub struct Bn128Pairing<T>(PhantomData<T>);

impl<T: Config> PrimitivePrecompile for Bn128Pairing<T> {
type T = T;
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(8).unwrap());
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(0x8).unwrap());
const HAS_CONTRACT_INFO: bool = false;

fn call(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct EcRecover<T>(PhantomData<T>);

impl<T: Config> PrimitivePrecompile for EcRecover<T> {
type T = T;
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(1).unwrap());
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(0x1).unwrap());
const HAS_CONTRACT_INFO: bool = false;

fn call(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct Identity<T>(PhantomData<T>);

impl<T: Config> PrimitivePrecompile for Identity<T> {
type T = T;
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(4).unwrap());
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(0x4).unwrap());
const HAS_CONTRACT_INFO: bool = false;

fn call(
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/src/precompiles/builtin/modexp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct Modexp<T>(PhantomData<T>);

impl<T: Config> PrimitivePrecompile for Modexp<T> {
type T = T;
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(5).unwrap());
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(0x5).unwrap());
const HAS_CONTRACT_INFO: bool = false;

fn call(
Expand Down
11 changes: 10 additions & 1 deletion substrate/frame/revive/src/precompiles/builtin/p256_verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ pub struct P256Verify<T>(PhantomData<T>);

impl<T: Config> PrimitivePrecompile for P256Verify<T> {
type T = T;
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(100).unwrap());
const MATCHER: BuiltinAddressMatcher =
BuiltinAddressMatcher::Fixed(NonZero::new(0x100).unwrap());
const HAS_CONTRACT_INFO: bool = false;

/// [RIP-7212](https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md#specification) secp256r1 precompile.
Expand Down Expand Up @@ -70,4 +71,12 @@ mod tests {
// https://github.com/ethereum/go-ethereum/blob/master/core/vm/testdata/precompiles/p256Verify.json
run_test_vectors::<P256Verify<Test>>(include_str!("./testdata/256-p256_verify.json"));
}

#[test]
fn test_p256_verify_address_match() {
assert_eq!(
<P256Verify<Test> as PrimitivePrecompile>::MATCHER.base_address(),
hex_literal::hex!("0000000000000000000000000000000000000100")
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct Ripemd160<T>(PhantomData<T>);

impl<T: Config> PrimitivePrecompile for Ripemd160<T> {
type T = T;
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(3).unwrap());
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(0x3).unwrap());
const HAS_CONTRACT_INFO: bool = false;

fn call(
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/src/precompiles/builtin/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct Sha256<T>(PhantomData<T>);

impl<T: Config> PrimitivePrecompile for Sha256<T> {
type T = T;
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(2).unwrap());
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(0x2).unwrap());
const HAS_CONTRACT_INFO: bool = false;

fn call(
Expand Down
Loading