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

NDEV-2620: Add executor_state: &impl Database parameter to EventListener::event method #273

Merged
merged 3 commits into from
Feb 16, 2024

Conversation

andreisilviudragnea
Copy link

@andreisilviudragnea andreisilviudragnea commented Feb 13, 2024

This PR changes signature of EventListener::event method from:

    fn event(&mut self, event: Event);

to:

    fn event(&mut self, executor_state: &impl Database, event: Event);

Most changes in this PR come from fixing the object safety error encountered while adding this parameter:

error[E0038]: the trait `EventListener` cannot be made into an object
   --> program/src/evm/mod.rs:167:13
    |
167 |     tracer: TracerTypeOpt,
    |             ^^^^^^^^^^^^^ `EventListener` cannot be made into an object
    |
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
   --> program/src/evm/tracing.rs:12:8
    |
11  | pub trait EventListener: Debug {
    |           ------------- this trait cannot be made into an object...
12  |     fn event(&mut self, executor_state: &impl Database, event: Event);
    |        ^^^^^ ...because method `event` has generic type parameters
    = help: consider moving `event` to another trait

Since executor_state: &impl Database is a generic type parameter, dynamic dispatch needs to be replaced with static dispatch, similar to #233.

The executor_state: &impl Database parameter is needed to intercept state changes in tracer implementations. It is passed as an explicit parameter in order to avoid wrapping executor_state: &impl Database into Rc<RefCell<>>.

@andreisilviudragnea andreisilviudragnea added the fullTestSuite Run OZ tests and part of dapps tests label Feb 13, 2024
Deniskore
Deniskore previously approved these changes Feb 14, 2024
@andreisilviudragnea andreisilviudragnea changed the base branch from NDEV-2555 to develop February 16, 2024 07:28
@andreisilviudragnea andreisilviudragnea dismissed stale reviews from stanislav-tkach and Deniskore February 16, 2024 07:28

The base branch was changed.

@andreisilviudragnea andreisilviudragnea added fullTestSuite Run OZ tests and part of dapps tests and removed fullTestSuite Run OZ tests and part of dapps tests labels Feb 16, 2024
@neonlabstech
Copy link

Dapps report

Cost report for "Aave" dApp

Action Fee Cost in $ Accounts TRx Estimated Gas Used Gas Used % of EG
Token mint 0.00228896 0.0030614954448 9 1 1164480 1144480 98.28
Token approve 0.00228896 0.0030614954448 9 1 1164480 1144480 98.28
Deposit to lending pool 0.0077856 0.010413278928 4 5 4761840 3892800 81.75
Borrow from lending pool 0.00508792 0.0068051184396 4 30 3737360 2543960 68.07
Repay 0.00049 0.00065537745 4 27 2586800 245000 9.47
Flashloan 0.00501792 0.0067114930896 4 28 7360480 2508960 34.09
Withdraw 7e-05 9.362534999999998e-05 4 5 1628080 35000 2.15
Liquidation 0.00335896 0.004492625794799999 4 57 4710320 1679480 35.66

Cost report for "Uniswap V3" dApp

Action Fee Cost in $ Accounts TRx Estimated Gas Used Gas Used % of EG
Token approve 0.00228896 0.0030614954448 9 1 1164480 1144480 98.28
NonfungiblePositionManager - Mint position 0.02730384 0.0365190225192 4 28 30739120 13651920 44.41
NonfungiblePositionManager - Increase liquidity 0.00044 0.0005885022 23 23 4364240 220000 5.04
NonfungiblePositionManager - Decrease Liquidity 0.00139808 0.0018699389903999999 17 1 4274240 699040 16.35
NonfungiblePositionManager - Collect Fees 0.00455792 0.0060962407896 20 1 3497360 2278960 65.16
NonfungiblePositionManager - Burn Liquidity Position 2e-05 2.67501e-05 15 1 3954560 10000 0.25
Direct swap 2e-05 2.67501e-05 17 1 1328400 10000 0.75
Burn transaction 0.00047936 0.0006411463968 11 1 739040 239680 32.43
Collect transaction 0.00228896 0.0030614954448 12 1 1633840 1144480 70.05

Cost report for "Saddle Finance" dApp

Action Fee Cost in $ Accounts TRx Estimated Gas Used Gas Used % of EG
Add liquidity 0.00229896 0.0030748704948 3 2 3181920 1149480 36.13
Swap DAI -> USDC 2e-05 2.67501e-05 21 1 1797760 10000 0.56
Swap USDC -> DAI 2e-05 2.67501e-05 21 1 1797760 10000 0.56
Remove liquidity 2e-05 2.67501e-05 23 1 1937440 10000 0.52
Add liquidity in 3 Tokens 0.00278896 0.0037302479448 4 30 4220640 1394480 33.04
Swap DAI -> USDC 3 pool 2e-05 2.67501e-05 21 1 1807760 10000 0.55
Swap USDC -> USDT 3 pool 2e-05 2.67501e-05 21 1 1807760 10000 0.55
Swap USDC -> DAI 3 pool 2e-05 2.67501e-05 21 1 1807760 10000 0.55
Remove liquidity 3 pool 3e-05 4.0125149999999996e-05 3 2 2646480 15000 0.57
Add liquidity in metapool 0.00285896 0.0038238732947999997 3 31 3271920 1429480 43.69
Swap SUSD -> LP metapool 2e-05 2.67501e-05 22 1 1807760 10000 0.55
Swap USDC -> SUSD metapool 0.00103 0.0013776301500000002 4 53 3775520 515000 13.64
Swap DAI -> USDT metapool 0.00056 0.0007490027999999999 4 29 3086160 280000 9.07
Remove liquidity in Metapool 2e-05 2.67501e-05 23 1 1937440 10000 0.52

@andreisilviudragnea andreisilviudragnea merged commit b730019 into develop Feb 16, 2024
4 of 8 checks passed
@andreisilviudragnea andreisilviudragnea deleted the NDEV-2620 branch February 16, 2024 11:36
anton-lisanin added a commit that referenced this pull request Feb 26, 2024
* Add Account Revision (#276)
* NDEV-2651 Remove syscall_stabs (#279)
* NDEV-2620: Add executor_state: &impl Database parameter to EventListener::event method (#273)
* add keys for Miro, DeBank/ Rabby and Alfie for devnet WL
---------

Co-authored-by: Semen Medvedev <[email protected]>
Co-authored-by: Miroslav Nedelchev <[email protected]>
Co-authored-by: Andrei Silviu Dragnea <[email protected]>
Co-authored-by: s-medvedev <[email protected]>
Co-authored-by: Kristina Nikolaeva <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fullTestSuite Run OZ tests and part of dapps tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants