[pallet-revive] fix delegate_call_contract in evm-test-suites#10510
[pallet-revive] fix delegate_call_contract in evm-test-suites#10510
Conversation
|
/cmd prdoc --audience runtime_dev --bump patch |
|
All GitHub workflows were cancelled due to failure one of the required jobs. |
…time_dev --bump patch'
Differential Tests Results (PolkaVM)Specified Tests
Counts
FailuresThe test specifiers seen in this section have the format 'path::case_idx::compilation_mode' and they're compatible with the revive differential tests framework and can be specified to it directly in the same way that they're provided through the The failures are provided in an expandable section to ensure that the PR does not get polluted with information. Please click on the section below for more information Detailed Differential Tests Failure Information
|
Differential Tests Results (REVM)Specified Tests
Counts
FailuresThe test specifiers seen in this section have the format 'path::case_idx::compilation_mode' and they're compatible with the revive differential tests framework and can be specified to it directly in the same way that they're provided through the The failures are provided in an expandable section to ensure that the PR does not get polluted with information. Please click on the section below for more information Detailed Differential Tests Failure Information
|
| self.calls.push(self.current_addr()); | ||
| if let Some(delegate_call) = delegate_call { | ||
| self.calls.push(Call::DelegateCall(self.current_addr(), delegate_call)); | ||
| self.read_account(delegate_call); |
There was a problem hiding this comment.
this is probably the only change we need and we only need to do it in prestate mode
There was a problem hiding this comment.
done, removed Call enum
There was a problem hiding this comment.
I guess we can optimize and only call read_account(delegate_call) if diff_mode is false
|
maybe as well complete the tests here to add some delegate traces If you do so, please merge Torsten branch first, as we don't want to create more conflicts in his branch, and it should land very soon on master anyway diff --git a/substrate/frame/revive/fixtures/contracts/tracing.rs b/substrate/frame/revive/fixtures/contracts/tracing.rs
index 8e79665b234..b789f05f2c9 100644
--- a/substrate/frame/revive/fixtures/contracts/tracing.rs
+++ b/substrate/frame/revive/fixtures/contracts/tracing.rs
@@ -62,6 +62,18 @@ pub extern "C" fn call() {
None,
);
+ // Delegate Call
+ api::delegate_call(
+ uapi::CallFlags::empty(),
+ callee_addr,
+ u64::MAX,
+ u64::MAX,
+ &[u8::MAX; 32],
+ &[0u8; 4],
+ None,
+ )
+ .unwrap();
+
api::deposit_event(&[], b"after");
// own address
diff --git a/substrate/frame/revive/src/tests/pvm.rs b/substrate/frame/revive/src/tests/pvm.rs
index dbeffcab840..2bc3ab1b839 100644
--- a/substrate/frame/revive/src/tests/pvm.rs
+++ b/substrate/frame/revive/src/tests/pvm.rs
@@ -4107,7 +4107,7 @@ fn call_tracing_works() {
address: addr,
topics: Default::default(),
data: b"after".to_vec().into(),
- position: 1,
+ position: 2,
},
]
} else {
@@ -4129,8 +4129,15 @@ fn call_tracing_works() {
error: Some("execution reverted".to_string()),
call_type: Call,
value: Some(U256::from(0)),
- gas: 0.into(),
- gas_used: 0.into(),
+ ..Default::default()
+ },
+ CallTrace {
+ from: ALICE_ADDR,
+ to: addr,
+ input: 0u32.encode().into(),
+ output: 0u32.to_le_bytes().to_vec().into(),
+ call_type: DelegateCall,
+ value: Some(U256::from(0)),
..Default::default()
},
CallTrace {
@@ -4140,8 +4147,6 @@ fn call_tracing_works() {
call_type: Call,
logs: logs.clone(),
value: Some(U256::from(0)),
- gas: 0.into(),
- gas_used: 0.into(),
calls: vec![
CallTrace {
from: addr,
@@ -4151,8 +4156,15 @@ fn call_tracing_works() {
error: Some("ContractTrapped".to_string()),
call_type: Call,
value: Some(U256::from(0)),
- gas: 0.into(),
- gas_used: 0.into(),
+ ..Default::default()
+ },
+ CallTrace {
+ from: addr,
+ to: addr,
+ input: 0u32.encode().into(),
+ output: 0u32.to_le_bytes().to_vec().into(),
+ call_type: DelegateCall,
+ value: Some(U256::from(0)),
..Default::default()
},
CallTrace {
@@ -4162,8 +4174,6 @@ fn call_tracing_works() {
call_type: Call,
logs: logs.clone(),
value: Some(U256::from(0)),
- gas: 0.into(),
- gas_used: 0.into(),
calls: vec![
CallTrace {
from: addr,
@@ -4172,8 +4182,15 @@ fn call_tracing_works() {
output: 0u32.to_le_bytes().to_vec().into(),
call_type: Call,
value: Some(U256::from(0)),
- gas: 0.into(),
- gas_used: 0.into(),
+ ..Default::default()
+ },
+ CallTrace {
+ from: addr,
+ to: addr,
+ input: 0u32.encode().into(),
+ output: 0u32.to_le_bytes().to_vec().into(),
+ call_type: DelegateCall,
+ value: Some(U256::from(0)),
..Default::default()
},
CallTrace {
@@ -4182,8 +4199,6 @@ fn call_tracing_works() {
input: (0u32, addr_callee).encode().into(),
call_type: Call,
value: Some(U256::from(0)),
- gas: 0.into(),
- gas_used: 0.into(),
calls: vec![
CallTrace {
from: addr,
@@ -4197,11 +4212,11 @@ fn call_tracing_works() {
..Default::default()
},
],
- child_call_count: 2,
+ child_call_count: 3,
..Default::default()
},
],
- child_call_count: 2,
+ child_call_count: 3,
..Default::default()
},
]
@@ -4221,9 +4236,7 @@ fn call_tracing_works() {
logs: logs.clone(),
value: Some(U256::from(0)),
calls: calls,
- child_call_count: 2,
- gas: 0.into(),
- gas_used: 0.into(),
+ child_call_count: 3,
..Default::default()
};
@@ -5373,12 +5386,9 @@ fn self_destruct_by_syscall_tracing_works() {
to: addr,
call_type: CallType::Call,
value: Some(U256::zero()),
- gas: 0.into(),
- gas_used: 0.into(),
calls: vec![CallTrace {
from: addr,
to: DJANGO_ADDR,
- gas: 0.into(),
call_type: CallType::Selfdestruct,
value: Some(Pallet::<Test>::convert_native_to_evm(100_000u64)), |
pkhry
left a comment
There was a problem hiding this comment.
now affected foundry tests works correctly. lgtm
Better to do this in a separate PR later |
| self.read_account(from); | ||
| self.read_account(to); |
There was a problem hiding this comment.
just to make sure I get it. Is that changing cause:
- we only need to read
towhen it's a call not a create - we move the
fromread above when it's not a delegate call since we have already readfromwhen it's a delegate call
There was a problem hiding this comment.
yes on both those points
Backport all pallet-revive related changes into `unstable2507`. These are all the changes we want to get onto the next Kusama release. Main changes include - EVM backend - Ethereum block storage - Generalized gas mapping The complete list of PRs in this backport is - #9482 - #9455 - #9454 - #9501 - #9177 - #9285 - #9606 - #9414 - #9557 - #9617 - #9385 - #9679 - #9705 - #9561 - #9744 - #9736 - #9701 - #9517 - #9771 - #9683 - #9791 - #9717 - #9759 - #9823 - #9768 - #9853 - #9801 - #9780 - #9796 - #9878 - #9841 - #9670 - #9865 - #9803 - #9928 - #9818 - #9911 - #9942 - #9831 - #9945 - #9603 - #9968 - #9939 - #9991 - #9914 - #9997 - #9985 - #10016 - #10027 - #10026 - #9418 - #9988 - #10041 - #10047 - #10032 - #10065 - #10089 - #10080 - #10090 - #10106 - #10020 - #9512 - #10109 - #9699 - #10100 - #9909 - #10120 - #10146 - #10157 - #10168 - #10169 - #10160 - #10129 - #10175 - #10186 - #10192 - #10148 - #10193 - #10220 - #10233 - #10191 - #10225 - #10246 - #10239 - #10159 - #10252 - #10224 - #10267 - #10271 - #10214 - #10297 - #10290 - #10281 - #10272 - #10303 - #10336 - #10244 - #10366 - #10380 - #10383 - #10387 - #10302 - #10309 - #10427 - #10385 - #10451 - #10471 - #10166 - #10510 - #10393 - #10540 - #9587 - #10071 - #10558 - #10554 - #10325 --------- Signed-off-by: xermicus <cyrill@parity.io> Co-authored-by: Pavlo Khrystenko <45178695+pkhry@users.noreply.github.com> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Javier Viola <363911+pepoviola@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Bastian Köcher <info@kchr.de> Co-authored-by: pgherveou <pgherveou@gmail.com> Co-authored-by: Omar <OmarAbdulla7@hotmail.com> Co-authored-by: 0xRVE <robertvaneerdewijk@gmail.com> Co-authored-by: xermicus <cyrill@parity.io> Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com>
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.