-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[pallet-revive] Add tracing support (1/3) #7166
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
Merged
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
d3baa2a
rm debug buffer
pgherveou fd2c61d
!fixup d3baa2a09c601e3cd907bbb6d54ca71bf0a1af67
pgherveou 2477f02
Add basic tracing support
pgherveou e07f355
fix kitchensink build
pgherveou b964051
fix rustdoc error
pgherveou 58c0c7a
Merge branch 'master' into pg/add-tracing-support
pgherveou ca3f378
fix merge conflict update misses
pgherveou 3ca2726
fixes
pgherveou aa8a9af
Simplify
pgherveou 3102f8a
no pub
pgherveou f8699c5
missing licences
pgherveou 839b986
Update serialization
pgherveou 8a57e4b
fix nostd build
pgherveou ba9ac59
fix zepter
pgherveou e15cc08
taplo fix
pgherveou 266616f
fix naming
pgherveou 49e78a3
left over
pgherveou 143d939
missing traces for balance transfer
pgherveou 8049343
Rename with_tracer -> if_tracer
pgherveou 6cc112f
Address PR comments
pgherveou 4d68032
fix test
pgherveou 9915c08
rm Debug config
pgherveou 461db51
fix comments
pgherveou 1a09c6b
Fix benchmark
pgherveou d7412f6
clippy
pgherveou 322c41e
tweak generic bound
pgherveou d5b8391
Add tests to report gas usage
pgherveou 6ca575c
fix type
pgherveou 76e56b9
Add build from config
pgherveou aaa2335
fix imports
pgherveou aee720f
PR review
pgherveou 787fb54
Update substrate/frame/revive/src/tracing.rs
pgherveou bc961cc
Merge branch 'master' into pg/add-tracing-support
pgherveou 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,75 @@ | ||
| // 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. | ||
|
|
||
| //! This fixture calls itself as many times as passed as argument. | ||
|
|
||
| #![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!(calls_left: u32, callee_addr: &[u8; 20],); | ||
| if calls_left == 0 { | ||
| return | ||
| } | ||
|
|
||
| let next_input = (calls_left - 1).to_le_bytes(); | ||
| api::deposit_event(&[], b"before"); | ||
|
|
||
| // Call the callee, ignore revert. | ||
| let _ = api::call( | ||
| uapi::CallFlags::empty(), | ||
| callee_addr, | ||
| u64::MAX, // How much ref_time to devote for the execution. u64::MAX = use all. | ||
| u64::MAX, // How much proof_size to devote for the execution. u64::MAX = use all. | ||
| &[u8::MAX; 32], // No deposit limit. | ||
| &[0u8; 32], // Value transferred to the contract. | ||
| &next_input, | ||
| None, | ||
| ); | ||
|
|
||
| api::deposit_event(&[], b"after"); | ||
|
|
||
| // own address | ||
| let mut addr = [0u8; 20]; | ||
| api::address(&mut addr); | ||
| let mut input = [0u8; 24]; | ||
|
|
||
| input[..4].copy_from_slice(&next_input); | ||
| input[4..24].copy_from_slice(&callee_addr[..20]); | ||
|
|
||
| // recurse | ||
| api::call( | ||
| uapi::CallFlags::ALLOW_REENTRY, | ||
| &addr, | ||
| u64::MAX, // How much ref_time to devote for the execution. u64::MAX = use all. | ||
| u64::MAX, // How much proof_size to devote for the execution. u64::MAX = use all. | ||
| &[u8::MAX; 32], // No deposit limit. | ||
| &[0u8; 32], // Value transferred to the contract. | ||
| &input, | ||
| None, | ||
| ) | ||
| .unwrap(); | ||
| } |
45 changes: 45 additions & 0 deletions
45
substrate/frame/revive/fixtures/contracts/tracing_callee.rs
This file contains hidden or 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,45 @@ | ||
| // 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!(id: u32, ); | ||
|
|
||
| match id { | ||
| // Revert with message "This function always fails" | ||
| 2 => { | ||
| let data = hex_literal::hex!( | ||
| "08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001a546869732066756e6374696f6e20616c77617973206661696c73000000000000" | ||
| ); | ||
| api::return_value(uapi::ReturnFlags::REVERT, &data) | ||
| }, | ||
| 1 => { | ||
| panic!("booum"); | ||
| }, | ||
| _ => api::return_value(uapi::ReturnFlags::empty(), &id.to_le_bytes()), | ||
| }; | ||
| } | ||
This file contains hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.