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

[pallet-revive] eth-prc fix geth diff #6608

Merged
merged 30 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
06e289c
squashed
pgherveou Nov 22, 2024
3529fbb
Add geth-diff-tests
pgherveou Nov 22, 2024
87fd63f
fixup cargo.toml
pgherveou Nov 22, 2024
aa1f1be
gen fixes
pgherveou Nov 22, 2024
e9823a0
fix generator
pgherveou Nov 22, 2024
61619bd
type generator update fixes
pgherveou Nov 22, 2024
716f40a
wip
pgherveou Nov 26, 2024
3a10a37
fixes
pgherveou Nov 26, 2024
f8fc0fc
rm codegen files
pgherveou Nov 26, 2024
8210606
rm prdoc
pgherveou Nov 26, 2024
45f8b7b
fix benchmarking tests
pgherveou Nov 26, 2024
0733fb6
fix tests & doc
pgherveou Nov 26, 2024
0941800
rename unchecked to skip_transfer
pgherveou Nov 26, 2024
d4460d6
clippy
pgherveou Nov 26, 2024
c164368
lint
pgherveou Nov 26, 2024
434b2d1
use relative path for polkadot-sdk
pgherveou Nov 26, 2024
868ae85
rm console.log
pgherveou Nov 26, 2024
0e1c3dc
Update from pgherveou running command 'prdoc --audience runtime_dev -…
actions-user Nov 26, 2024
4206a1f
Merge branch 'master' into pg/fix-geth-diff
pgherveou Nov 26, 2024
edd099c
fix tests
pgherveou Nov 26, 2024
65caf0b
Update substrate/frame/revive/rpc/src/client.rs
pgherveou Nov 26, 2024
326f52b
update comment
pgherveou Nov 27, 2024
037c58e
fix from address default
pgherveou Nov 28, 2024
31ed649
pr review
pgherveou Nov 29, 2024
76e3fda
PR review
pgherveou Nov 29, 2024
ec41a82
rm json files
pgherveou Nov 29, 2024
80dceac
rm types
pgherveou Nov 29, 2024
1117b0d
Add extra test
pgherveou Nov 29, 2024
6e7cd93
fix CI error
pgherveou Nov 29, 2024
dacbfa2
Merge branch 'master' into pg/fix-geth-diff
athei Dec 1, 2024
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
1 change: 1 addition & 0 deletions Cargo.lock

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

30 changes: 8 additions & 22 deletions cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: alloc::borrow::Cow::Borrowed("westmint"),
impl_name: alloc::borrow::Cow::Borrowed("westmint"),
authoring_version: 1,
spec_version: 1_016_006,
spec_version: 1_016_008,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 16,
Expand Down Expand Up @@ -2088,18 +2088,10 @@ impl_runtime_apis! {
let account = <Runtime as pallet_revive::Config>::AddressMapper::to_account_id(&address);
System::account_nonce(account)
}
fn eth_transact(
from: H160,
dest: Option<H160>,
value: U256,
input: Vec<u8>,
gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>,
) -> pallet_revive::EthContractResult<Balance>

fn eth_transact(tx: pallet_revive::evm::GenericTransaction) -> Result<pallet_revive::EthTransactInfo<Balance>, pallet_revive::EthTransactError>
{
use pallet_revive::AddressMapper;
let blockweights = <Runtime as frame_system::Config>::BlockWeights::get();
let origin = <Runtime as pallet_revive::Config>::AddressMapper::to_account_id(&from);
let blockweights: BlockWeights = <Runtime as frame_system::Config>::BlockWeights::get();

let encoded_size = |pallet_call| {
let call = RuntimeCall::Revive(pallet_call);
Expand All @@ -2108,15 +2100,9 @@ impl_runtime_apis! {
};

Revive::bare_eth_transact(
origin,
dest,
value,
input,
gas_limit.unwrap_or(blockweights.max_block),
storage_deposit_limit.unwrap_or(u128::MAX),
tx,
blockweights.max_block,
encoded_size,
pallet_revive::DebugInfo::UnsafeDebug,
pallet_revive::CollectEvents::UnsafeCollect,
)
}

Expand All @@ -2134,7 +2120,7 @@ impl_runtime_apis! {
dest,
value,
gas_limit.unwrap_or(blockweights.max_block),
storage_deposit_limit.unwrap_or(u128::MAX),
pallet_revive::DepositLimit::Balance(storage_deposit_limit.unwrap_or(u128::MAX)),
input_data,
pallet_revive::DebugInfo::UnsafeDebug,
pallet_revive::CollectEvents::UnsafeCollect,
Expand All @@ -2156,7 +2142,7 @@ impl_runtime_apis! {
RuntimeOrigin::signed(origin),
value,
gas_limit.unwrap_or(blockweights.max_block),
storage_deposit_limit.unwrap_or(u128::MAX),
pallet_revive::DepositLimit::Balance(storage_deposit_limit.unwrap_or(u128::MAX)),
code,
data,
salt,
Expand Down
14 changes: 14 additions & 0 deletions prdoc/pr_6608.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
title: '[pallet-revive] eth-prc fix geth diff'
doc:
- audience: Runtime Dev
description: |-
* Add a bunch of differential tests to ensure that responses from eth-rpc matches the one from `geth`
* EVM RPC server will not fail gas_estimation if no gas is specified, I updated pallet-revive to add an extra `skip_transfer` boolean check to replicate this behavior in our pallet
* `eth_transact` and `bare_eth_transact` api have been updated to use `GenericTransaction` directly as this is what is used by `eth_estimateGas` and `eth_call`
crates:
- name: pallet-revive-eth-rpc
bump: minor
- name: pallet-revive
bump: minor
- name: asset-hub-westend-runtime
bump: minor
25 changes: 5 additions & 20 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3218,18 +3218,9 @@ impl_runtime_apis! {
System::account_nonce(account)
}

fn eth_transact(
from: H160,
dest: Option<H160>,
value: U256,
input: Vec<u8>,
gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>,
) -> pallet_revive::EthContractResult<Balance>
fn eth_transact(tx: pallet_revive::evm::GenericTransaction) -> Result<pallet_revive::EthTransactInfo<Balance>, pallet_revive::EthTransactError>
{
use pallet_revive::AddressMapper;
let blockweights: BlockWeights = <Runtime as frame_system::Config>::BlockWeights::get();
let origin = <Runtime as pallet_revive::Config>::AddressMapper::to_account_id(&from);

let encoded_size = |pallet_call| {
let call = RuntimeCall::Revive(pallet_call);
Expand All @@ -3238,15 +3229,9 @@ impl_runtime_apis! {
};

Revive::bare_eth_transact(
origin,
dest,
value,
input,
gas_limit.unwrap_or(blockweights.max_block),
storage_deposit_limit.unwrap_or(u128::MAX),
tx,
blockweights.max_block,
encoded_size,
pallet_revive::DebugInfo::UnsafeDebug,
pallet_revive::CollectEvents::UnsafeCollect,
)
}

Expand All @@ -3263,7 +3248,7 @@ impl_runtime_apis! {
dest,
value,
gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block),
storage_deposit_limit.unwrap_or(u128::MAX),
pallet_revive::DepositLimit::Balance(storage_deposit_limit.unwrap_or(u128::MAX)),
input_data,
pallet_revive::DebugInfo::UnsafeDebug,
pallet_revive::CollectEvents::UnsafeCollect,
Expand All @@ -3284,7 +3269,7 @@ impl_runtime_apis! {
RuntimeOrigin::signed(origin),
value,
gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block),
storage_deposit_limit.unwrap_or(u128::MAX),
pallet_revive::DepositLimit::Balance(storage_deposit_limit.unwrap_or(u128::MAX)),
code,
data,
salt,
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pallet-revive-fixtures = { workspace = true, default-features = true }
secp256k1 = { workspace = true, features = ["recovery"] }
serde_json = { workspace = true }
hex-literal = { workspace = true }
env_logger = { workspace = true }
pgherveou marked this conversation as resolved.
Show resolved Hide resolved

# Polkadot SDK Dependencies
pallet-balances = { workspace = true, default-features = true }
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/revive/mock-network/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use frame_support::traits::{fungibles::Mutate, Currency};
use frame_system::RawOrigin;
use pallet_revive::{
test_utils::{self, builder::*},
Code,
Code, DepositLimit,
};
use pallet_revive_fixtures::compile_module;
use pallet_revive_uapi::ReturnErrorCode;
Expand Down Expand Up @@ -52,7 +52,7 @@ fn instantiate_test_contract(name: &str) -> Contract<parachain::Runtime> {
RawOrigin::Signed(ALICE).into(),
Code::Upload(wasm),
)
.storage_deposit_limit(1_000_000_000_000)
.storage_deposit_limit(DepositLimit::Balance(1_000_000_000_000))
.build_and_unwrap_contract()
});

Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ hex = { workspace = true }
hex-literal = { workspace = true, optional = true }
scale-info = { workspace = true }
secp256k1 = { workspace = true, optional = true, features = ["recovery"] }
env_logger = { workspace = true }
ethabi = { version = "18.0.0" }

[features]
example = ["hex-literal", "rlp", "secp256k1", "subxt-signer"]

[dev-dependencies]
env_logger = { workspace = true }
static_init = { workspace = true }
hex-literal = { workspace = true }
pallet-revive-fixtures = { workspace = true }
Expand Down
106 changes: 106 additions & 0 deletions substrate/frame/revive/rpc/examples/js/abi/errorTester.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
export const abi = [
{
inputs: [
{
internalType: 'string',
name: 'message',
type: 'string',
},
],
name: 'CustomError',
type: 'error',
},
{
inputs: [
{
internalType: 'bool',
name: 'newState',
type: 'bool',
},
],
name: 'setState',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [],
name: 'state',
outputs: [
{
internalType: 'bool',
name: '',
type: 'bool',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'triggerAssertError',
outputs: [],
stateMutability: 'pure',
type: 'function',
},
{
inputs: [],
name: 'triggerCustomError',
outputs: [],
stateMutability: 'pure',
type: 'function',
},
{
inputs: [],
name: 'triggerDivisionByZero',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'pure',
type: 'function',
},
{
inputs: [],
name: 'triggerOutOfBoundsError',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'pure',
type: 'function',
},
{
inputs: [],
name: 'triggerRequireError',
outputs: [],
stateMutability: 'pure',
type: 'function',
},
{
inputs: [],
name: 'triggerRevertError',
outputs: [],
stateMutability: 'pure',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: 'value',
type: 'uint256',
},
],
name: 'valueMatch',
outputs: [],
stateMutability: 'payable',
type: 'function',
},
] as const
34 changes: 0 additions & 34 deletions substrate/frame/revive/rpc/examples/js/abi/event.json

This file was deleted.

34 changes: 34 additions & 0 deletions substrate/frame/revive/rpc/examples/js/abi/event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export const abi = [
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'address',
name: 'sender',
type: 'address',
},
{
indexed: false,
internalType: 'uint256',
name: 'value',
type: 'uint256',
},
{
indexed: false,
internalType: 'string',
name: 'message',
type: 'string',
},
],
name: 'ExampleEvent',
type: 'event',
},
{
inputs: [],
name: 'triggerEvent',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
] as const
Loading
Loading