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

pallet-revive: Add stateful address mapping #6096

Merged
merged 20 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 16 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
15 changes: 15 additions & 0 deletions prdoc/pr_6096.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
title: 'pallet-revive: Add stateful address mapping'
doc:
- audience:
- Runtime Dev
description: |-
Fixes #5576

This allows contracts to be used with an AccountId32 through normal extrinsics and not only through the eth compat layer. It works by adding a new extrinsic `map_account` that lets people register their AccountId32.
crates:
- name: pallet-revive-fixtures
bump: minor
- name: pallet-revive-mock-network
bump: patch
- name: pallet-revive
bump: major
2 changes: 1 addition & 1 deletion substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ impl pallet_revive::Config for Runtime {
type WeightPrice = pallet_transaction_payment::Pallet<Self>;
type WeightInfo = pallet_revive::weights::SubstrateWeight<Self>;
type ChainExtension = ();
type AddressMapper = pallet_revive::DefaultAddressMapper;
type AddressMapper = pallet_revive::AccountId32Mapper<Self>;
type RuntimeMemory = ConstU32<{ 128 * 1024 * 1024 }>;
type PVFMemory = ConstU32<{ 512 * 1024 * 1024 }>;
type UnsafeUnstableInterface = ConstBool<false>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use common::input;
use uapi::{HostFn, HostFnImpl as api};

const ETH_ALICE: [u8; 20] = [1u8; 20];
const ALICE_FALLBACK: [u8; 20] = [1u8; 20];

/// Load input data and perform the action specified by the input.
/// If `delegate_call` is true, then delegate call into the contract.
Expand All @@ -44,7 +44,7 @@ fn load_input(delegate_call: bool) {
},
// 3 = Terminate
3 => {
api::terminate(&ETH_ALICE);
api::terminate(&ALICE_FALLBACK);
},
// Everything else is a noop
_ => {},
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/revive/fixtures/contracts/self_destruct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use common::input;
use uapi::{HostFn, HostFnImpl as api};

const ETH_DJANGO: [u8; 20] = [4u8; 20];
const DJANGO_FALLBACK: [u8; 20] = [4u8; 20];

#[no_mangle]
#[polkavm_derive::polkavm_export]
Expand Down Expand Up @@ -52,6 +52,6 @@ pub extern "C" fn call() {
.unwrap();
} else {
// Try to terminate and give balance to django.
api::terminate(&ETH_DJANGO);
api::terminate(&DJANGO_FALLBACK);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// This file is part of Substrate.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![no_std]
#![no_main]

extern crate common;
use uapi::{HostFn, HostFnImpl as api};

#[no_mangle]
#[polkavm_derive::polkavm_export]
pub extern "C" fn deploy() {}

#[no_mangle]
#[polkavm_derive::polkavm_export]
pub extern "C" fn call() {
let eve = [5u8; 20];
api::terminate(&eve);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use frame_support::derive_impl;

#[derive_impl(pallet_revive::config_preludes::TestDefaultConfig)]
impl pallet_revive::Config for Runtime {
type AddressMapper = pallet_revive::DefaultAddressMapper;
type AddressMapper = pallet_revive::AccountId32Mapper<Self>;
type Currency = Balances;
type Time = super::Timestamp;
type Xcm = pallet_xcm::Pallet<Self>;
Expand Down
Loading
Loading