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

Convert for to do while to save gas on multiple runs #10

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Arkay92
Copy link
Contributor

@Arkay92 Arkay92 commented Oct 18, 2022

No description provided.

@cygaar
Copy link
Collaborator

cygaar commented Oct 21, 2022

Can you rebase and post the gas difference before and after?

@sennett-lau
Copy link

It seems the commit does not pass the test, the following should be changed
line 53: i > tokenIds.length to i >= tokenIds.length
line 64: i > tokenIds.length to i < tokenIds.length
line 77: i > chipAddressesOld.length to i >= chipAddressesOld.length
line 97: i >chipAddressesOld.length to i < chipAddressesOld.length

I combined this idea with my PR with a gas difference before and after here

@Arkay92
Copy link
Contributor Author

Arkay92 commented Oct 23, 2022

[PASS] testGetTokenDataForChipSignature() (gas: 127921 -> 127892)
[PASS] testGetTokenDataForChipSignatureBlockNumTooOld() (gas: 122467 ->122438 )
[PASS] testGetTokenDataForChipSignatureInvalid() (gas: 131763 -> 131734)
[PASS] testGetTokenDataForChipSignatureInvalidBlockNumber() (gas: 122301 -> 122272)
[PASS] testIsChipSignatureForToken() (gas: 216704 -> 216675)
[PASS] testMintTokenWithChip() (gas: 176564 -> 176535)
[PASS] testSeedChipToTokenMapping() (gas: 115247 -> 115218)
[PASS] testSeedChipToTokenMappingExistingToken() (gas: 212294 -> 212240)
[PASS] testSeedChipToTokenMappingInvalidInput() (gas: 17178 -> 17178)
[PASS] testSupportsInterface() (gas: 7059 -> 7059)
[PASS] testTokenIdFor() (gas: 117084 -> 117056)
[PASS] testTokenIdMappedFor() (gas: 66778 -> 66750)
[PASS] testTransferTokenWithChip(bool) (runs: 256, μ: 211867, ~: 211785 -> runs: 256, μ: 211835, ~: 211756)
[PASS] testUpdateChips() (gas: 171052 -> 171002)
[PASS] testUpdateChipsInvalidInput() (gas: 16433 -> 16433)
[PASS] testUpdateChipsUnsetChip() (gas: 23430 -> 23405)

@Arkay92
Copy link
Contributor Author

Arkay92 commented Oct 24, 2022

After adding laubs unchecked to do while cut gas down significantly #13

[PASS] testGetTokenDataForChipSignature() (gas: 127921 -> 127752)
[PASS] testGetTokenDataForChipSignatureBlockNumTooOld() (gas: 122467 -> 122298)
[PASS] testGetTokenDataForChipSignatureInvalid() (gas: 131763 -> 131594)
[PASS] testGetTokenDataForChipSignatureInvalidBlockNumber() (gas: 122301 -> 122132)
[PASS] testIsChipSignatureForToken() (gas: 216704 -> 216535)
[PASS] testMintTokenWithChip() (gas: 176564 -> 176395)
[PASS] testSeedChipToTokenMapping() (gas: 115247 -> 115078)
[PASS] testSeedChipToTokenMappingExistingToken() (gas: 212100-> 212100)
[PASS] testSupportsInterface() (gas: 7059 -> 7059)
[PASS] testTokenIdFor() (gas: 117084 -> 116986)
[PASS] testTokenIdMappedFor() (gas: 66778 -> 66680)
[PASS] testTransferTokenWithChip(bool) (runs: 256, μ: 211881, ~: 211785 -> runs: 256, μ: 211706, ~: 211616)
[PASS] testUpdateChips() (gas: 171052 -> 170776)
[PASS] testUpdateChipsInvalidInput() (gas: 16433 -> 16433)
[PASS] testUpdateChipsUnsetChip() (gas: 23430 -> 23405)

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.

5 participants