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

feat(protocol): ProverPool gas optimizations #14062

Merged
merged 12 commits into from
Jun 28, 2023

Conversation

adaki2004
Copy link
Contributor

@adaki2004 adaki2004 commented Jun 27, 2023

Before optimization, gas test of the ProoverPool:
kép

@adaki2004
Copy link
Contributor Author

adaki2004 commented Jun 27, 2023

After 1st gas optimization commit, proposeBlock() reduced by 10% and verifyBlock() by 70%.
kép

@dantaik
Copy link
Contributor

dantaik commented Jun 27, 2023

Please run pnpm install to trigger lints, or manually run pnpm fmt:sol, and maybe also run pnpm lint:sol, to fix these issues:

❯ pnpm lint:sol

> @taiko/protocol@0.10.0 lint:sol /Users/d/Projects/taiko/taiko-mono/packages/protocol
> forge fmt && pnpm solhint 'contracts/**/*.sol' --fix


contracts/L1/ProverPool.sol
  376:5  warning  Function order is incorrect, private view function can not go after private pure function (line 357)  ordering

contracts/L1/ProverPool2.sol
   26:5   warning  Function order is incorrect, struct definition can not go after custom error definition (line 24)  ordering
   36:5   warning  Explicitly mark visibility of state                                                                state-visibility
   37:5   warning  Explicitly mark visibility of state                                                                state-visibility
   58:9   warning  Variable name must be in mixedCase                                                                 var-name-mixedcase
  126:9   warning  Provide an error message for require                                                               reason-string
  137:9   warning  Provide an error message for require                                                               reason-string
  144:13  warning  Provide an error message for require                                                               reason-string
  183:9   warning  Provide an error message for require                                                               reason-string

contracts/L1/TaikoL1.sol
  160:5  warning  Function order is incorrect, external  function can not go after public payable function (line 150)  ordering

✖ 10 problems (0 errors, 10 warnings)

@adaki2004
Copy link
Contributor Author

adaki2004 commented Jun 27, 2023

@dantaik applied some extra optimizations - and get rid of the calcWeight always on-the-fly (during proposeBlock()) via getting rid of the average fee per gas coming from the protocol.

Here we are now:
Intergation tests with protocol:
kép

Pure ProverPool:
kép

So far this is 15% on proposeBlock(), 75% on verifyBlock(). (And no change to proveBlock())

Other / next steps could be like data packing (as you did with Prover).

@@ -147,6 +147,7 @@ library TaikoData {
mapping(bytes32 txListHash => TxListInfo) txListInfo;
mapping(uint256 depositId_mode_ethDepositRingBufferSize => uint256)
ethDeposits;
mapping(address account => uint256 balance) taikoTokenBalances;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__gap should be changed to 42

packages/protocol/contracts/L1/ProverPool.sol Show resolved Hide resolved
@adaki2004
Copy link
Contributor Author

I created a draft explanation document about ProverPool2.sol.
You can access it here.
I mainly did it for client guys to have a visual representation how it would/could work, so to speed up the process of understanding the core concept.
Doc. is only available to taiko ppl.
I dont yet know if code works or lacks something, not tested also. ( @Brechtpd please check if something is missing - i know it lacks events and some unified custom errors so please take it with a grain of salt.)

@dantaik dantaik merged commit a47527d into alpha-4-base Jun 28, 2023
@dantaik dantaik deleted the alpha-4-base_stake_optimizations branch June 28, 2023 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants