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
2 changes: 1 addition & 1 deletion .github/workflows/tests-evm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: paritytech/evm-test-suite
ref: 9359438a13e8ab68f73320724f8783e170ecc193
ref: f3a2e98620adfc233166728230247d479a159e76
path: evm-test-suite

- uses: denoland/setup-deno@v2
Expand Down
9 changes: 9 additions & 0 deletions prdoc/pr_10510.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: '[pallet-revive] fix delegate_call_contract in evm-test-suites'
doc:
- audience: Runtime Dev
description: evm-test-suite was not correctly executing delegate_call_contract causing
pallet-revive to silently reject the delegatecall. After evm-test-suite was fixed
we found that the trace for delegate calls is incorrect. This fixes it.
crates:
- name: pallet-revive
bump: patch
4 changes: 2 additions & 2 deletions substrate/frame/revive/src/evm/tracing/call_tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<Gas: Default + core::fmt::Debug, GasMapper: Fn(Weight) -> Gas> Tracing
&mut self,
from: H160,
to: H160,
is_delegate_call: bool,
delegate_call: Option<H160>,
is_read_only: bool,
value: U256,
input: &[u8],
Expand Down Expand Up @@ -117,7 +117,7 @@ impl<Gas: Default + core::fmt::Debug, GasMapper: Fn(Weight) -> Gas> Tracing
None => {
let call_type = if is_read_only {
CallType::StaticCall
} else if is_delegate_call {
} else if delegate_call.is_some() {
CallType::DelegateCall
} else {
CallType::Call
Expand Down
10 changes: 6 additions & 4 deletions substrate/frame/revive/src/evm/tracing/prestate_tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,23 +254,25 @@ where
&mut self,
from: H160,
to: H160,
is_delegate_call: bool,
delegate_call: Option<H160>,
_is_read_only: bool,
_value: U256,
_input: &[u8],
_gas: Weight,
) {
if is_delegate_call {
if let Some(delegate_call) = delegate_call {
self.calls.push(self.current_addr());
self.read_account(delegate_call);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is probably the only change we need and we only need to do it in prestate mode

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, removed Call enum

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can optimize and only call read_account(delegate_call) if diff_mode is false

} else {
self.calls.push(to);
self.read_account(from);
}

if self.create_code.take().is_some() {
self.created_addrs.insert(to);
} else {
self.read_account(to);
}
self.read_account(from);
self.read_account(to);
Comment on lines -272 to -273
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to make sure I get it. Is that changing cause:

  • we only need to read to when it's a call not a create
  • we move the from read above when it's not a delegate call since we have already read from when it's a delegate call

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes on both those points

}

fn exit_child_span_with_error(&mut self, _error: crate::DispatchError, _gas_used: Weight) {
Expand Down
8 changes: 4 additions & 4 deletions substrate/frame/revive/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ struct Frame<T: Config> {

/// This structure is used to represent the arguments in a delegate call frame in order to
/// distinguish who delegated the call and where it was delegated to.
#[derive(Clone)]
#[derive(Clone, RuntimeDebugNoBound)]
pub struct DelegateInfo<T: Config> {
/// The caller of the contract.
pub caller: Origin<T>,
Expand Down Expand Up @@ -816,7 +816,7 @@ where
t.enter_child_span(
origin.account_id().map(T::AddressMapper::to_address).unwrap_or_default(),
T::AddressMapper::to_address(&dest),
false,
None,
false,
value,
&input_data,
Expand Down Expand Up @@ -1181,7 +1181,7 @@ where
tracer.enter_child_span(
self.caller().account_id().map(T::AddressMapper::to_address).unwrap_or_default(),
T::AddressMapper::to_address(&frame.account_id),
frame.delegate.is_some(),
frame.delegate.as_ref().map(|delegate| delegate.callee),
frame.read_only,
frame.value_transferred,
&input_data,
Expand Down Expand Up @@ -2041,7 +2041,7 @@ where
t.enter_child_span(
T::AddressMapper::to_address(self.account_id()),
T::AddressMapper::to_address(&dest),
false,
None,
is_read_only,
value,
&input_data,
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub trait Tracing {
&mut self,
_from: H160,
_to: H160,
_is_delegate_call: bool,
_delegate_call: Option<H160>,
_is_read_only: bool,
_value: U256,
_input: &[u8],
Expand Down
Loading