Skip to content

Conversation

gzeoneth
Copy link
Member

@gzeoneth gzeoneth commented Aug 29, 2022

Saves around (994171 - 962590) / 100 = 316 gas per recipient.

before

╭──────────────────────────────────────────────────────┬─────────────────┬────────┬────────┬────────┬─────────╮
│ src/RewardDistributor.sol:RewardDistributor contract ┆                 ┆        ┆        ┆        ┆         │
╞══════════════════════════════════════════════════════╪═════════════════╪════════╪════════╪════════╪═════════╡
│ Deployment Cost                                      ┆ Deployment Size ┆        ┆        ┆        ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ 500233                                               ┆ 5957            ┆        ┆        ┆        ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ Function Name                                        ┆ min             ┆ avg    ┆ median ┆ max    ┆ # calls │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ currentRecipientGroup                                ┆ 317             ┆ 317    ┆ 317    ┆ 317    ┆ 3       │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ distributeRewards                                    ┆ 685             ┆ 196154 ┆ 83833  ┆ 994171 ┆ 7       │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ owner                                                ┆ 290             ┆ 290    ┆ 290    ┆ 290    ┆ 1       │
╰──────────────────────────────────────────────────────┴─────────────────┴────────┴────────┴────────┴─────────╯

after

╭──────────────────────────────────────────────────────┬─────────────────┬────────┬────────┬────────┬─────────╮
│ src/RewardDistributor.sol:RewardDistributor contract ┆                 ┆        ┆        ┆        ┆         │
╞══════════════════════════════════════════════════════╪═════════════════╪════════╪════════╪════════╪═════════╡
│ Deployment Cost                                      ┆ Deployment Size ┆        ┆        ┆        ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ 375280                                               ┆ 5194            ┆        ┆        ┆        ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ Function Name                                        ┆ min             ┆ avg    ┆ median ┆ max    ┆ # calls │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ currentRecipientGroup                                ┆ 316             ┆ 316    ┆ 316    ┆ 316    ┆ 3       │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ distributeRewards                                    ┆ 627             ┆ 190873 ┆ 82469  ┆ 962590 ┆ 7       │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ owner                                                ┆ 315             ┆ 315    ┆ 315    ┆ 315    ┆ 1       │
╰──────────────────────────────────────────────────────┴─────────────────┴────────┴────────┴────────┴─────────╯

coverage

+---------------------------+-----------------+-----------------+---------------+---------------+
| File                      | % Lines         | % Statements    | % Branches    | % Funcs       |
+===============================================================================================+
| src/RewardDistributor.sol | 100.00% (28/28) | 100.00% (33/33) | 50.00% (7/14) | 100.00% (4/4) |
|---------------------------+-----------------+-----------------+---------------+---------------|
| Total                     | 100.00% (28/28) | 100.00% (33/33) | 50.00% (7/14) | 100.00% (4/4) |
+---------------------------+-----------------+-----------------+---------------+---------------+

@gzeoneth gzeoneth marked this pull request as ready for review August 29, 2022 11:27
@gzeoneth gzeoneth requested review from fredlacs and yahgwai August 29, 2022 11:27
@gzeoneth gzeoneth requested a review from fredlacs August 29, 2022 12:57
Base automatically changed from fred-docs to main August 29, 2022 14:30
@yahgwai yahgwai self-requested a review August 29, 2022 15:47
@gzeoneth gzeoneth merged commit 57c3b54 into main Aug 29, 2022
@gzeoneth gzeoneth deleted the gas-opt branch August 29, 2022 15:48
godzillaba added a commit that referenced this pull request Sep 4, 2025
* prettier

* eslint running

* package json format and lint commands

* tsconfig options

* update readme

* Formatting ci (#4)

* use node 18

* Test ci

* forge install

* test contract size

* test gas check

* add snapshot

* readme

* fix formatting

* upload all selectors

* test-sigs

* test-sigs ci

* build before test-sigs

* test-storage

* readme

* readme

* unit folder

* unit folder
godzillaba added a commit that referenced this pull request Sep 22, 2025
* first commit

* update readme

* package.json

* hardhat init

* foundry init

* Counter

* package.json

* sync compiler settings

* typo

* update readme

* Formatting (#3)

* prettier

* eslint running

* package json format and lint commands

* tsconfig options

* update readme

* Formatting ci (#4)

* use node 18

* Misc CI (#5)

* prettier

* eslint running

* package json format and lint commands

* tsconfig options

* update readme

* Formatting ci (#4)

* use node 18

* Test ci

* forge install

* test contract size

* test gas check

* add snapshot

* readme

* fix formatting

* upload all selectors

* test-sigs

* test-sigs ci

* build before test-sigs

* test-storage

* readme

* readme

* unit folder

* unit folder

* Fork tests (#7)

* fork tests

* fork tests

* unusded imports

* fork tests ci

* fmt

* gas snapshot

* match path in gas check

* ...

* bash scripts for unit and fork tests

* globstar

* globstar in package json

* multichain fork tests

* change exit code

* spacing

* update fork test job

* secrets

* secrets

* secrets

* ...

* e2e test (#8)

* e2e test

* fmt

* comment

* compile

* ignore lib

* localhost to 127

* forge install for lint

* setup-sdk

* compile before lint

* compile in e2e script

* ...

* prepare

* ...

* ethersv5

* install foundry in install-node job

* reinstall node modules every time

* ...

* readme

* ...

* custom fee l3

* always orbit, test both eth and custom fee

* format

* name job

* readme

* testSetup

* fmt

* ...

* Audit (#9)

* e2e test

* fmt

* comment

* compile

* ignore lib

* localhost to 127

* forge install for lint

* setup-sdk

* compile before lint

* compile in e2e script

* ...

* prepare

* ...

* ethersv5

* install foundry in install-node job

* reinstall node modules every time

* ...

* readme

* ...

* custom fee l3

* always orbit, test both eth and custom fee

* format

* name job

* readme

* testSetup

* fmt

* ...

* audit

* readme

* ci job

* ...

* readme

* minimal-publish (#10)

* minimal-publish

* fmt

* readme

* ...

* Update README.md

* publish.bash

* separate files for jobs (#12)

* separate files for jobs

* ...

* use v4

* update readme

* update readme

* fix: yarn and misc improvements (#13)

* chore: yarn fix

* ci: fix yarn install

* document disabling e2e (#14)

* disable script

* update readme and jobs

* update test-e2e.bash

* update readme

* ...

* fix: script path

* minimal-install

* Lighter e2e (#19)

* minimal-install

* lighter e2e

* update readme and comment out l3 jobs

* add gas snapshot to fix

* fix print contracts script (#20)

* error if no contracts found (#21)

* error if no contracts found

* rename jobs

* readme

* unused import

* improve inspect (#22)

* improve inspect

* comment

* Delete sample files script (#23)

* improve inspect

* delete-samples script

* comment

* test delete samples

* Revert "test delete samples"

This reverts commit 7d1e4b1ac2c3ebbb8c1a17d509ad4cfa3889efff.

* test delete samples 2

* Revert "test delete samples 2"

This reverts commit be7ae94e6572a320e69432fce54ab57b0e498032.

* fix bash scripts (#24)

* Unused errors checker (#26)

* Add action which checks if there are unused errors

* Rename step

* main

* Use main branch

---------

Co-authored-by: Henry <11198460+godzillaba@users.noreply.github.com>

* use hardhat-sizer (#29)

* move template scripts to their own dir (#28)

* move template scripts to their own dir

* fix

* simplify test scripts (#25)

* simplify test scripts

* update readme

* fix audit:ci

* Mocks + DoubleProvider (#30)

* simplify test-e2e.bash

* add v5 to v6 conversion functions and add a note

* return both versions of wallets and providers

* mocks

* move util to scripts/template

* ...

* getEnv fix

* Revert "getEnv fix"

This reverts commit f985a44684a070be3cc2b197ead5cfdde63a259c.

* double provider (#33)

* double provider

* inheritance

* better types

* ...

* update readme

* explicit formatter config (#34)

* uncomment e2e ci (#36)

* use stable foundry (#37)

* use stable foundry

* remove --pretty from inspect script

* uncomment e2e ci

* yarn fix

* use node v22, run `yarn upgrade`, fix tsconfig (#38)

* use stable foundry

* remove --pretty from inspect script

* uncomment e2e ci

* use node v22

* yarn fix

* fix major versions and yarn upgrade

* add node to types

* add mocha to types

* Bump arbitrum sdk (#39)

* use stable foundry

* remove --pretty from inspect script

* uncomment e2e ci

* use node v22

* yarn fix

* fix major versions and yarn upgrade

* add node to types

* remove submodule

* add mocha to types

* remove minimal-install script

* install arbitrum sdk package

* fix test-e2e.bash

* fix testSetup.ts

* use temporary testnode ref

* use release testnode

* remove sdk submodule

* fix: audit (#40)

* use stable foundry

* remove --pretty from inspect script

* uncomment e2e ci

* use node v22

* yarn fix

* fix major versions and yarn upgrade

* add node to types

* remove submodule

* add mocha to types

* remove minimal-install script

* install arbitrum sdk package

* fix test-e2e.bash

* fix testSetup.ts

* use temporary testnode ref

* fix audit

* audit GHSA-52f5-9888-hmc6

* undo workflow change

* import template

* install contract deps through npm and fix contract import paths

* fmt

* fix FundRouters.test.ts

* fmt

* install viem

* fix ChildToParentMessageRedeemer.ts

* lib.ts

* checkAndRouteFunds.ts

* bump ts, couple files

* add yargs, cli

* fix e2e tests

* no lint on build

* fix print-contracts script

* format

* fix

* fix lint

* include total supply in deployment of test token

* remove test token minting

* try fix tests

* fix tests

* use ha/traffic-flag branch of testnode

* Revert "use ha/traffic-flag branch of testnode"

This reverts commit 7d59c9f.

* audit fix

* remove publish helpers

* remove publish

---------

Co-authored-by: gzeon <h@arry.io>
Co-authored-by: gzeon <hng@offchainlabs.com>
Co-authored-by: Goran Vladika <goran.vladika@gmail.com>
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.

3 participants