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/release-reusable-rc-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ jobs:

- name: Install resolc
run: |
VERSION="0.5.0"
VERSION="1.0.0"
ASSET_URL="https://github.com/paritytech/revive/releases/download/v$VERSION/resolc-universal-apple-darwin"
echo "Downloading resolc v$VERSION from $ASSET_URL"
curl -Lsf --show-error -o $HOME/.cargo/bin/resolc "$ASSET_URL"
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/tests-linux-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install resolc
run: |
VERSION="1.0.0"
ASSET_URL="https://github.com/paritytech/revive/releases/download/v$VERSION/resolc-x86_64-unknown-linux-musl"
echo "Downloading resolc v$VERSION from $ASSET_URL"
curl -Lsf --show-error -o /usr/local/bin/resolc "$ASSET_URL"
chmod +x /usr/local/bin/resolc
resolc --version
- name: script
id: required
run: |
Expand Down Expand Up @@ -144,6 +152,14 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install resolc
run: |
VERSION="1.0.0"
ASSET_URL="https://github.com/paritytech/revive/releases/download/v$VERSION/resolc-x86_64-unknown-linux-musl"
echo "Downloading resolc v$VERSION from $ASSET_URL"
curl -Lsf --show-error -o /usr/local/bin/resolc "$ASSET_URL"
chmod +x /usr/local/bin/resolc
resolc --version
- name: script
id: required
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ jobs:
- name: Install resolc
run: |
source $HOME/.cargo/env
VERSION="0.5.0"
VERSION="1.0.0"
ASSET_URL="https://github.com/paritytech/revive/releases/download/v$VERSION/resolc-universal-apple-darwin"
echo "Downloading resolc v$VERSION from $ASSET_URL"
curl -Lsf --show-error -o $HOME/.cargo/bin/resolc "$ASSET_URL"
Expand Down
12 changes: 12 additions & 0 deletions prdoc/pr_10849.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
title: 'pallet-revive: Enable call_invalid_opcode test'
doc:
- audience: Runtime Dev
description: |-
Fixes https://github.com/paritytech/contract-issues/issues/206

This PR enables the call_invalid_opcode test, which verifies that the INVALID opcode consumes all forwarded gas when executed in a nested call. The underlying issue was fixed in the following PRs:
https://github.com/paritytech/revive/pull/433
https://github.com/paritytech/polkadot-sdk/pull/9997
crates:
- name: pallet-revive
bump: patch
30 changes: 19 additions & 11 deletions substrate/frame/revive/src/tests/sol/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ fn deploy_revert() {

// This test has a `caller` contract calling into a `callee` contract which then executes the
// INVALID opcode. INVALID consumes all gas which means that it will error with OutOfGas.
#[ignore = "TODO: ignore until we decide what is the correct way to handle this"]
#[test_case(FixtureType::Solc, FixtureType::Solc; "solc->solc")]
#[test_case(FixtureType::Solc, FixtureType::Resolc; "solc->resolc")]
#[test_case(FixtureType::Resolc, FixtureType::Solc; "resolc->solc")]
Expand All @@ -233,6 +232,9 @@ fn call_invalid_opcode(caller_type: FixtureType, callee_type: FixtureType) {
ExtBuilder::default().build().execute_with(|| {
let _ = <Test as Config>::Currency::set_balance(&ALICE, 100_000_000_000);

// Pass a large gas stipend to the callee
let gas_limit = 200_000_000_000u64;

// Instantiate the callee contract, which can echo a value.
let Contract { addr: callee_addr, .. } =
builder::bare_instantiate(Code::Upload(callee_code)).build_and_unwrap_contract();
Expand All @@ -241,23 +243,29 @@ fn call_invalid_opcode(caller_type: FixtureType, callee_type: FixtureType) {
let Contract { addr: caller_addr, .. } =
builder::bare_instantiate(Code::Upload(caller_code)).build_and_unwrap_contract();

let result = builder::bare_call(caller_addr)
let contract_result = builder::bare_call(caller_addr)
.data(
Caller::normalCall {
_callee: callee_addr.0.into(),
_value: 0,
_data: Callee::invalidCall {}.abi_encode().into(),
_gas: u64::MAX,
_gas: gas_limit,
}
.abi_encode(),
)
.build_and_unwrap_result();
let result = Caller::normalCall::abi_decode_returns(&result.data).unwrap();

assert!(!result.success, "Invalid opcode should propagate as error");
.build();

let data = result.output.as_ref();
assert!(data.iter().all(|&x| x == 0), "Returned data should be empty")
let result = contract_result.result.expect("Outer call should succeed");
assert!(
contract_result.gas_consumed > gas_limit,
"Inner call should consume all forwarded gas. Consumed: {}, Limit: {}",
contract_result.gas_consumed,
gas_limit
);
let decoded = Caller::normalCall::abi_decode_returns(&result.data)
.expect("Should decode return data");
assert!(!decoded.success, "INVALID opcode should cause inner call to fail");
assert!(decoded.output.is_empty(), "Output should be empty on INVALID opcode");
});
}

Expand All @@ -268,7 +276,7 @@ fn invalid_opcode_evm() {
ExtBuilder::default().build().execute_with(|| {
let _ = <Test as Config>::Currency::set_balance(&ALICE, 100_000_000_000);

// Instantiate the callee contract, which can echo a value.
// Instantiate the callee contract.
let Contract { addr: callee_addr, .. } =
builder::bare_instantiate(Code::Upload(callee_code)).build_and_unwrap_contract();

Expand All @@ -290,7 +298,7 @@ fn call_stop_opcode(caller_type: FixtureType, callee_type: FixtureType) {
ExtBuilder::default().build().execute_with(|| {
let _ = <Test as Config>::Currency::set_balance(&ALICE, 100_000_000_000);

// Instantiate the callee contract, which can echo a value.
// Instantiate the callee contract.
let Contract { addr: callee_addr, .. } =
builder::bare_instantiate(Code::Upload(callee_code)).build_and_unwrap_contract();

Expand Down
Loading