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] adjust fee dry-run calculation #6393

Merged
merged 33 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b8fca6a
Revive fixes
pgherveou Nov 6, 2024
dd7fe75
Add context in build.rs
pgherveou Nov 6, 2024
06481e0
Fixes
pgherveou Nov 6, 2024
e5ea069
fixes
pgherveou Nov 6, 2024
4c0cd4b
fix
pgherveou Nov 6, 2024
175cc1a
wip
pgherveou Nov 6, 2024
c60f840
Fix typo
pgherveou Nov 7, 2024
5f6eef3
err message
pgherveou Nov 7, 2024
844dcf3
Update from pgherveou running command 'prdoc --audience runtime_dev -…
actions-user Nov 7, 2024
623a1a7
Bump ah westend
pgherveou Nov 8, 2024
8844b16
Fix dry run
pgherveou Nov 8, 2024
2aca171
Extract revert message
pgherveou Nov 8, 2024
7409ccc
fix
pgherveou Nov 8, 2024
f3603e4
fix
pgherveou Nov 8, 2024
3b3d113
fix formattting
pgherveou Nov 8, 2024
b17d31c
add nice error
pgherveou Nov 8, 2024
a5a1a41
Merge branch 'pg/subxt_038' into pg/revive-fixes
pgherveou Nov 8, 2024
18c4a72
clippy
pgherveou Nov 8, 2024
79036e1
Fix hash / receipt
pgherveou Nov 9, 2024
4608073
Support logs in receipts
pgherveou Nov 9, 2024
2067833
fmt
pgherveou Nov 9, 2024
c2096c7
fix lint
pgherveou Nov 9, 2024
30b1745
Merge branch 'master' into pg/revive-fixes
pgherveou Nov 11, 2024
ccdd2c9
Update js examples to run with geth
pgherveou Nov 11, 2024
0fa4c7b
Add tests for logs and revert
pgherveou Nov 11, 2024
556a6ea
update
pgherveou Nov 11, 2024
cfa5b30
fix clippy
pgherveou Nov 11, 2024
8833aca
fix clippy
pgherveou Nov 11, 2024
c265992
fix
pgherveou Nov 11, 2024
1b119b6
fix clippy
pgherveou Nov 11, 2024
a4f8e73
use ethabi
pgherveou Nov 11, 2024
814229f
Add test for invalid transaction
pgherveou Nov 11, 2024
8dcfe61
Align subxt version
pgherveou Nov 12, 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
Prev Previous commit
Next Next commit
fixes
  • Loading branch information
pgherveou committed Nov 6, 2024
commit e5ea069b4d2e19b65805a3a010ccf5a8cb1317d9
14 changes: 1 addition & 13 deletions substrate/frame/revive/rpc/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,6 @@ bun src/script.ts

### Configure MetaMask

See the doc [here](https://contracts.polkadot.io/connect-to-asset-hub) for more
See the doc [here](https://contracts.polkadot.io/work-with-a-local-node#metemask-configuration) for more
information on how to configure MetaMask.

#### Import Dev account

You will need to import the following account, endowed with some balance at genesis, to interact with the chain.
See [this guide][import-account] for more info on how to import an account.

- Account: `0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac`
- Private Key: `5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133`

[MetaMask]: https://metamask.io
[add-network]: https://support.metamask.io/networks-and-sidechains/managing-networks/how-to-add-a-custom-network-rpc/#adding-a-network-manually
[import-account]: https://support.metamask.io/managing-my-wallet/accounts-and-addresses/how-to-import-an-account/
[reset-account]: https://support.metamask.io/managing-my-wallet/resetting-deleting-and-restoring/how-to-clear-your-account-activity-reset-account
13 changes: 3 additions & 10 deletions substrate/frame/revive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1332,27 +1332,19 @@ where
},
};

// Use a big enough gas price to ensure that the encoded size is large enough.
let gas: BalanceOf<T> =
(pallet_transaction_payment::Pallet::<T>::weight_to_fee(Weight::MAX) /
GAS_PRICE.into())
.into();

// Get the encoded size of the transaction.
let mut tx = TransactionLegacyUnsigned {
value: value.into().saturating_mul(T::NativeToEthRatio::get().into()),
input: input.into(),
nonce: nonce.into(),
chain_id: Some(T::ChainId::get().into()),
gas_price: GAS_PRICE.into(),
gas: gas.into(),
to: dest,
..Default::default()
};

// The transaction fees depend on the extrinsic's length, which in turn is influenced by
// the encoded length of the gas limit specified in the transaction.
// We iteratively compute the fee by adjusting the gas until the fee stabilizes.
// the encoded length of the gas limit specified in the transaction (tx.gas).
// We iteratively compute the fee by adjusting tx.gas until the fee stabilizes.
// with a maximum of 3 iterations to avoid an infinite loop.
for _ in 0..3 {
let eth_dispatch_call = crate::Call::<T>::eth_transact {
Expand All @@ -1369,6 +1361,7 @@ where
.into();

if fee == result.fee {
log::trace!(target: LOG_TARGET, "bare_eth_call: encoded_len: {encoded_len:?} fee: {fee:?}");
break;
}
result.fee = fee;
Expand Down
Loading