-
Notifications
You must be signed in to change notification settings - Fork 776
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 host function to_account_id
#7091
Merged
athei
merged 16 commits into
paritytech:master
from
use-ink:cmichi-expose-to_account_id-from-pallet-revive
Jan 15, 2025
+225
−0
Merged
Changes from 8 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
fbd9c78
Add host function `to_account_id`
cmichi dd980f7
Fix `prdoc` syntax
cmichi bde4b55
Mark `to_account_id` unstable + move it to unstable section
cmichi 84ac767
Use `to_account_id` from `exec.rs` instead
cmichi 304d1a9
Benchmark worst case of `to_account_id`
cmichi b901e43
Asser that worst case is benchmarked
cmichi c88a188
Merge branch 'master' into cmichi-expose-to_account_id-from-pallet-re…
cmichi e133aaa
Merge branch 'paritytech:master' into cmichi-expose-to_account_id-fro…
cmichi a8b398a
Fix type inference error
cmichi 89f2460
Move `to_account_id` down to other unstable functions
cmichi ab570bb
Remove empty line
cmichi 699bb45
Apply `cargo fmt`
cmichi 63654f0
Fund account used for benchmark
cmichi 734118b
Merge branch 'master' into cmichi-expose-to_account_id-from-pallet-re…
cmichi 1d748f8
Merge branch 'master' into cmichi-expose-to_account_id-from-pallet-re…
cmichi 0165c83
Adapt to new function signature
cmichi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
title: '[pallet-revive] Add new host function `to_account_id`' | ||
doc: | ||
- audience: Runtime Dev | ||
description: A new host function `to_account_id` is added. It allows retrieving | ||
the account id for a `H160` address. | ||
crates: | ||
- name: pallet-revive-fixtures | ||
bump: minor | ||
- name: pallet-revive | ||
bump: minor | ||
- name: pallet-revive-uapi | ||
bump: minor |
40 changes: 40 additions & 0 deletions
40
substrate/frame/revive/fixtures/contracts/to_account_id.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// 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] | ||
|
||
use common::input; | ||
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() { | ||
input!( | ||
address: &[u8; 20], | ||
expected_account_id: &[u8; 32], | ||
); | ||
|
||
let mut account_id = [0u8; 32]; | ||
api::to_account_id(address, &mut account_id); | ||
|
||
assert!(&account_id == expected_account_id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also fix the type inference error (hopefully).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just applied your suggestion. I didn't get a type inference error locally though when running the benchmark, where did you see it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CI failed with a compilation error.