Skip to content
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

[frontier] Add support for PoV gas refunding #3036

Merged
merged 12 commits into from
Nov 27, 2024
55 changes: 29 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/rpc/debug/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ sp-blockchain = { workspace = true }
sp-core = { workspace = true, features = [ "std" ] }
sp-io = { workspace = true, features = [ "std" ] }
sp-runtime = { workspace = true, features = [ "std" ] }
sp-trie = { workspace = true, features = [ "std" ] }

# Frontier
ethereum = { workspace = true, features = [ "std", "with-codec" ] }
Expand Down
30 changes: 27 additions & 3 deletions client/rpc/debug/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,15 @@ where
}?;

// Get ApiRef. This handle allow to keep changes between txs in an internal buffer.
let api = client.runtime_api();
let mut api = client.runtime_api();

// Enable proof recording
api.record_proof();
api.proof_recorder().map(|recorder| {
let ext = sp_trie::proof_size_extension::ProofSizeExt::new(recorder);
api.register_extension(ext);
});

// Get Blockchain backend
let blockchain = backend.blockchain();
// Get the header I want to work with.
Expand Down Expand Up @@ -556,7 +564,15 @@ where
Err(e) => return Err(e),
};
// Get ApiRef. This handle allow to keep changes between txs in an internal buffer.
let api = client.runtime_api();
let mut api = client.runtime_api();

// Enable proof recording
api.record_proof();
api.proof_recorder().map(|recorder| {
let ext = sp_trie::proof_size_extension::ProofSizeExt::new(recorder);
api.register_extension(ext);
});

// Get Blockchain backend
let blockchain = backend.blockchain();
// Get the header I want to work with.
Expand Down Expand Up @@ -762,7 +778,15 @@ where
}?;

// Get ApiRef. This handle allow to keep changes between txs in an internal buffer.
let api = client.runtime_api();
let mut api = client.runtime_api();

// Enable proof recording
api.record_proof();
api.proof_recorder().map(|recorder| {
let ext = sp_trie::proof_size_extension::ProofSizeExt::new(recorder);
api.register_extension(ext);
});

// Get the header I want to work with.
let Ok(hash) = client.expect_block_hash_from_id(&reference_id) else {
return Err(internal_err("Block header not found"));
Expand Down
10 changes: 5 additions & 5 deletions test/moonwall.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@
{
"name": "lazy_loading_moonbeam",
"testFileDir": ["suites/lazy-loading"],
"include": ["**/*test*"],
"include": ["**/*test*.ts"],
"timeout": 180000,
"contracts": "contracts/",
"runScripts": [
Expand Down Expand Up @@ -392,7 +392,7 @@
{
"name": "dev_moonbeam",
"testFileDir": ["suites/dev/moonbeam", "suites/dev/common"],
"include": ["**/*test*"],
"include": ["**/*test*.ts"],
"timeout": 180000,
"contracts": "contracts/",
"runScripts": [
Expand Down Expand Up @@ -435,7 +435,7 @@
{
"name": "dev_moonriver",
"testFileDir": ["suites/dev/common"],
"include": ["**/*test*"],
"include": ["**/*test*.ts"],
"timeout": 180000,
"contracts": "contracts/",
"runScripts": [
Expand Down Expand Up @@ -478,7 +478,7 @@
{
"name": "dev_moonbase",
"testFileDir": ["suites/dev/moonbase", "suites/dev/common"],
"include": ["**/*test*"],
"include": ["**/*test*.ts"],
"timeout": 180000,
"contracts": "contracts/",
"runScripts": [
Expand Down Expand Up @@ -521,7 +521,7 @@
{
"name": "dev_moonbase_tracing",
"testFileDir": ["suites/tracing-tests"],
"include": ["**/*test*"],
"include": ["**/*test*.ts"],
"contracts": "contracts/",
"runScripts": [
"compile-contracts.ts compile",
Expand Down
22 changes: 12 additions & 10 deletions test/suites/dev/moonbase/test-gas/test-gas-estimation-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,23 @@ describeSuite({
it({
id: "T05",
title: "Should be able to estimate gas of infinite loop call",
timeout: 240000,
timeout: 60000,
test: async function () {
const { contractAddress, abi } = await deployCreateCompiledContract(context, "Looper");

expect(
async () =>
await context.viem().estimateGas({
account: ALITH_ADDRESS,
to: contractAddress,
data: encodeFunctionData({
abi: abi,
functionName: "infinite",
args: [],
}),
})
await customDevRpcRequest("eth_estimateGas", [
{
from: ALITH_ADDRESS,
to: contractAddress,
data: encodeFunctionData({
abi: abi,
functionName: "infinite",
args: [],
}),
},
])
).rejects.toThrowError("gas required exceeds allowance 6000000");
},
});
Expand Down
Loading
Loading