-
Notifications
You must be signed in to change notification settings - Fork 1.2k
pallet_revive: Add dry-run timestamp override support #10191
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
Changes from 25 commits
da1baf8
bd927ad
b75f9ff
c4ea78f
de1a294
3ec16d5
ae99522
0db67ae
8d39a29
fa6888b
0b9825f
e107143
e4a3dae
4b353ed
fa5d203
2fd4af1
d9f24fe
1d1170f
8ca05c5
aa531f9
71ff4fb
e1a46e5
de9475c
7b77659
2e6c186
fd0746f
68bb7ff
73c7bcf
239edb3
056c19d
d5b5a0b
906f12e
82c5714
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| title: 'pallet_revive: Add dry-run timestamp override support' | ||
| doc: | ||
| - audience: Runtime User | ||
| description: |- | ||
| # Description | ||
|
|
||
| This PR updates `pallet-revive` to **support overriding the block timestamp during dry-run calls**. | ||
| The dry-run execution now uses the following configuration for `eth_estimateGas` and `eth_call` when the block tag is `pending`: | ||
|
|
||
| ```text | ||
| block.timestamp = max(rpc_timestamp, latest_block.timestamp + 1) | ||
| block.number = latest_block.number + 1 | ||
| ``` | ||
|
|
||
| Fixes [#153](https://github.com/paritytech/contract-issues/issues/153), [#205](https://github.com/paritytech/contract-issues/issues/205) | ||
|
|
||
| ## Integration | ||
|
|
||
| Downstream projects using the `ReviveApi::eth_transact` runtime API should either provide a `timestamp` or pass `None`. | ||
|
|
||
| ## Review Notes | ||
| - Added dry run timestamp to `ExecConfig`. | ||
| - Added a new parameter to `ReviveApi::eth_transact` for passing the current RPC timestamp. | ||
| - `eth_estimateGas` defaults to the `pending` block tag. | ||
| - `eth_estimateGas` and `eth_call` with `pending` block tag will dry run the transaction with the block timestamp set to `max(rpc_timestamp, latest_block.timestamp + 1)` and block number set to `latest_block.number + 1`. | ||
| crates: | ||
| - name: pallet-revive-eth-rpc | ||
| bump: major | ||
| - name: pallet-revive | ||
| bump: major |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,9 +145,10 @@ impl EthRpcServer for EthRpcServerImpl { | |
| block: Option<BlockNumberOrTag>, | ||
| ) -> RpcResult<U256> { | ||
| log::trace!(target: LOG_TARGET, "estimate_gas transaction={transaction:?} block={block:?}"); | ||
| let hash = self.client.block_hash_for_tag(block.unwrap_or_default().into()).await?; | ||
| let block = block.unwrap_or_default(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK this defaults to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PG and I tried this test here and it seems that geth is defaulting to |
||
| let hash = self.client.block_hash_for_tag(block.clone().into()).await?; | ||
| let runtime_api = self.client.runtime_api(hash); | ||
| let dry_run = runtime_api.dry_run(transaction).await?; | ||
| let dry_run = runtime_api.dry_run(transaction, block.into()).await?; | ||
| log::trace!(target: LOG_TARGET, "estimate_gas result={dry_run:?}"); | ||
| Ok(dry_run.eth_gas) | ||
| } | ||
|
|
@@ -157,9 +158,10 @@ impl EthRpcServer for EthRpcServerImpl { | |
| transaction: GenericTransaction, | ||
| block: Option<BlockNumberOrTagOrHash>, | ||
| ) -> RpcResult<Bytes> { | ||
| let hash = self.client.block_hash_for_tag(block.unwrap_or_default()).await?; | ||
| let block = block.unwrap_or_default(); | ||
| let hash = self.client.block_hash_for_tag(block.clone()).await?; | ||
| let runtime_api = self.client.runtime_api(hash); | ||
| let dry_run = runtime_api.dry_run(transaction).await?; | ||
| let dry_run = runtime_api.dry_run(transaction, block).await?; | ||
| Ok(dry_run.data.into()) | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.