-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat: Calculate ccm gas limit #3935
Conversation
PRO-799 Set correct CCM Gas Limit
albert said in PRO-161:
|
* origin/main: Fix: Correct Select Median Implementation (#3934) fix: independent witnessing startup (#3913) 🍒 cherry-pick: changes in release for CI and chainspec (#3933) refactor: Re-arrange Chains traits for better composability (#3912) fix: log error when we try to transfer *more* than we have fetched (#3930) chore: add checks and increase timeout (#3928) Add `bind_redeem_address` to CLI (#3908) 🍒 cherry-pick: add missing prod dockerfiles (#3926) chore: skip localnet specific tests in devnet 🤫 (#3919) fix: broadcast success should be witnessable after a rotation (#3921) # Conflicts: # state-chain/chains/src/eth/api.rs # state-chain/runtime/src/chainflip.rs
Codecov Report
@@ Coverage Diff @@
## main #3935 +/- ##
======================================
Coverage 72% 72%
======================================
Files 366 366
Lines 57384 57530 +146
Branches 57384 57530 +146
======================================
+ Hits 41442 41577 +135
- Misses 13851 13862 +11
Partials 2091 2091
... and 4 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I am currently testing this changes (running against #3887 test). So far it isn't working but I'm debugging, it might well be a test issue. |
Changed GasUnit type to u128 to avoid downcasting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can simplify the PR a lot by focusing on the single use case at hand: ccm gas limits on Ethereum.
I appreciate the desire to generalise this to other chains, but right now I feel like this adds complexity with little benefit (see my comments).
While it does make sense that we don't need any of that for BTC/DOT... I'd really push for this implementation to be reusable for other EVM chains (e.g. Arbitrum). Cross-chain messaging is a must have in any EVM chain we add. Not sure if this changes anything for this PR, just thought it is worth mentioning. |
…ansaction, instead after CCM. Added an integration test to test the gas limit calculation logic
@dandanlen @albert-llimos
I think this satisfies both conditions:
Please take a look and let me know your thoughts |
@@ -868,25 +870,28 @@ impl<T: Config<I>, I: 'static> EgressApi<T::TargetChain> for Pallet<T, I> { | |||
asset: TargetChainAsset<T, I>, | |||
amount: TargetChainAmount<T, I>, | |||
destination_address: TargetChainAccount<T, I>, | |||
maybe_message: Option<CcmDepositMetadata>, | |||
maybe_message: Option<(CcmDepositMetadata, TargetChainAmount<T, I>)>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable will need to be renamed.
* chore: mainnet version of ccm gaslimit test * chore: restore localnet * chore: rename * chore: fix lint * chore: check gasUsed * chore: working PoC * chore: small fix * chore: update to v0.8.0 * chore: commit full test * chore: some added swaps * chore: shuffle .run.sh order * chore: working test * chore: finalized gaslimit_ccm test * feat: changes to gaslimit logic * chore: lint * chore: fix test and cleanup * chore: trigger ci * chore: ci on push * chore: avoid clone * chore: fix tests * chore: try adding delay * chore: add delay at the end of gasLimit test * chore: cleanup test * chore: more cleanup --------- Co-authored-by: Daniel <daniel@chainflip.io>
access_list: AccessList::default(), | ||
from: Some(client.address()), | ||
nonce: None, | ||
}); | ||
|
||
let estimated_gas = client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better here to change estimate_gas to take the Eip1559 instead of introduce the generic typed transaction here, and then needing the into(). @kylezs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ethers-rs estimate_gas call takes a TypedTransaction, so we'd be putting into an EIP1559 type and then pulling it back out. I think this is ok. The signature's of the underlying rpc types ensure they're correct... ideally the ethers interface would allow for what you're suggesting though ofc
Misunderstood what Alastair was suggesting initially, I agree, adding the wrapping with Typed::EIP1559 inside estimate gas would be a bit nicer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it would be a bit nicer but but the ethers api makes it a bit awkward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only thing there is that we then can't use the set_gas
after the gas estimation, which is very clean. I don't have much of an opinion though.
@@ -1,6 +1,6 @@ | |||
[env] | |||
CF_ETH_CONTRACT_ABI_ROOT = { value = "eth-contract-abis", relative = true } | |||
CF_ETH_CONTRACT_ABI_TAG = "perseverance-0.9-rc6" | |||
CF_ETH_CONTRACT_ABI_TAG = "v0.8.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit confusing... looks like we downgraded the contracts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I understand, but any follow-up tags can't be named perseverance-0.9-xyz as perseverance contracts have been deployed and will not changed. That would be even more confusing/wrong. So the best option to me seems going back to the normal tags and we launch mainnet with v1.0.0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about 0.10.0
?
Any objections to merging this as-is without changing the rpc api? (@kylezs @AlastairHolmes ) |
I'll do it, it'll take 3 minutes |
PRO-797 Use integrity test in TestRunner
Right now, for example, if you use the helper methods like There is a hook, IntegrityTest See:
We already have the other hooks. It should be possible to use this too. This would allow us to always test pallet invariants in every test run. |
FYI I have added the change already |
Co-authored-by: Daniel <daniel@chainflip.io> Co-authored-by: Albert Llimos <53186777+albert-llimos@users.noreply.github.com> Co-authored-by: albert <allimos3@gmail.com> Co-authored-by: Alastair Holmes <holmes.alastair@outlook.com>
Co-authored-by: Daniel <daniel@chainflip.io> Co-authored-by: Albert Llimos <53186777+albert-llimos@users.noreply.github.com> Co-authored-by: albert <allimos3@gmail.com> Co-authored-by: Alastair Holmes <holmes.alastair@outlook.com>
Co-authored-by: Daniel <daniel@chainflip.io> Co-authored-by: Albert Llimos <53186777+albert-llimos@users.noreply.github.com> Co-authored-by: albert <allimos3@gmail.com> Co-authored-by: Alastair Holmes <holmes.alastair@outlook.com>
Co-authored-by: Daniel <daniel@chainflip.io> Co-authored-by: Albert Llimos <53186777+albert-llimos@users.noreply.github.com> Co-authored-by: albert <allimos3@gmail.com> Co-authored-by: Alastair Holmes <holmes.alastair@outlook.com>
Pull Request
Closes: PRO-799
Checklist
Please conduct a thorough self-review before opening the PR.
Summary
CCM messages now calculate a "gas_limit", which is used when building the Ethereum Transaction.
gas_limit = gas_budget / (base_gas_price * multiplier + priority_fee)
where gas_budget is the amount of currency used for gas (after swaps are done if needed)
base_gas_price and priority_fee is obtained from EthereumChainTracking
the multiplier is defined through the Config
If any calculation causes an error (e.g. Gas price not set, gas price is 0, overflow etc.), a default gas_limit is used instead.
Currently, the Multiplier is set to 2 and the default gas limit is 400_000.