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

precompiled: adjust the gas cost of consortium precompiled contract #376

Merged
merged 2 commits into from
Dec 29, 2023

Conversation

minh-bq
Copy link
Collaborator

@minh-bq minh-bq commented Nov 7, 2023

This commit adds the benchmarks and calculated gas cost from the benchmarks to
validator sorting, pick validator set and verify double sign proof precompiled
contracts. Ethereum aims for 30 mgas/s when setting gas cost for precompiled
contracts, we aims for 60 mgas/s.

Benchmark results:

BenchmarkConsortiumValidatorSorting/validator-sort-Gas=2310-8             548737             20101 ns/op              2310 gas/op              114.9 mgas/s        11616 B/op        224 allocs/op
BenchmarkConsortiumValidatorSorting/validator-sort-Gas=9780-8             205410             66083 ns/op              9780 gas/op              148.0 mgas/s        49280 B/op        852 allocs/op
BenchmarkConsortiumVerifyHeaders/verify-headers-Gas=21000-8                48445            232612 ns/op             21000 gas/op               90.27 mgas/s       53043 B/op        477 allocs/op
BenchmarkConsortiumPickValidatorSet/pick-validator-set-Gas=3540-8         377305             32748 ns/op              3540 gas/op              108.1 mgas/s        19775 B/op        299 allocs/op
BenchmarkConsortiumPickValidatorSet/pick-validator-set-Gas=14790-8        113479            129076 ns/op             14790 gas/op              114.6 mgas/s        76689 B/op       1092 allocs/op

@minh-bq minh-bq requested review from DNK90 and andicrypt November 7, 2023 09:47
@minh-bq minh-bq force-pushed the fix/precompiled-gas branch 4 times, most recently from 915a221 to 60542f6 Compare November 14, 2023 11:04
@minh-bq minh-bq force-pushed the fix/precompiled-gas branch 2 times, most recently from ea76b97 to 1f870a8 Compare November 30, 2023 09:44
Currently, every time the precompiled contract is called, the contract ABI is
unmarshalled even though the ABI is unchanged. This commit moves the contract ABI
unmarshal to init to save the computation. This commit also optimizes the
SortableValidators.Less to reduce the memory allocation.
This commit adds the benchmarks and calculated gas cost from the benchmarks to
validator sorting, pick validator set and verify double sign proof precompiled
contracts. Ethereum aims for 30 mgas/s when setting gas cost for precompiled
contracts, we aims for 60 mgas/s.

Benchmark results:

BenchmarkConsortiumValidatorSorting/validator-sort-Gas=2310-8             548737             20101 ns/op              2310 gas/op              114.9 mgas/s        11616 B/op        224 allocs/op
BenchmarkConsortiumValidatorSorting/validator-sort-Gas=9780-8             205410             66083 ns/op              9780 gas/op              148.0 mgas/s        49280 B/op        852 allocs/op
BenchmarkConsortiumVerifyHeaders/verify-headers-Gas=21000-8                48445            232612 ns/op             21000 gas/op               90.27 mgas/s       53043 B/op        477 allocs/op
BenchmarkConsortiumPickValidatorSet/pick-validator-set-Gas=3540-8         377305             32748 ns/op              3540 gas/op              108.1 mgas/s        19775 B/op        299 allocs/op
BenchmarkConsortiumPickValidatorSet/pick-validator-set-Gas=14790-8        113479            129076 ns/op             14790 gas/op              114.6 mgas/s        76689 B/op       1092 allocs/op
@minh-bq minh-bq force-pushed the fix/precompiled-gas branch from 1f870a8 to 5874958 Compare December 4, 2023 03:36
@minh-bq minh-bq merged commit 95e3707 into axieinfinity:master Dec 29, 2023
1 check passed
@minh-bq minh-bq deleted the fix/precompiled-gas branch December 29, 2023 10:26
minh-bq added a commit to minh-bq/ronin that referenced this pull request Feb 20, 2024
…xieinfinity#376)

* precompiled: move contract ABI unmarshal to init

Currently, every time the precompiled contract is called, the contract ABI is
unmarshalled even though the ABI is unchanged. This commit moves the contract ABI
unmarshal to init to save the computation. This commit also optimizes the
SortableValidators.Less to reduce the memory allocation.

* precompiled: adjust the gas cost of consortium precompiled contract

This commit adds the benchmarks and calculated gas cost from the benchmarks to
validator sorting, pick validator set and verify double sign proof precompiled
contracts. Ethereum aims for 30 mgas/s when setting gas cost for precompiled
contracts, we aims for 60 mgas/s.

Benchmark results:

BenchmarkConsortiumValidatorSorting/validator-sort-Gas=2310-8             548737             20101 ns/op              2310 gas/op              114.9 mgas/s        11616 B/op        224 allocs/op
BenchmarkConsortiumValidatorSorting/validator-sort-Gas=9780-8             205410             66083 ns/op              9780 gas/op              148.0 mgas/s        49280 B/op        852 allocs/op
BenchmarkConsortiumVerifyHeaders/verify-headers-Gas=21000-8                48445            232612 ns/op             21000 gas/op               90.27 mgas/s       53043 B/op        477 allocs/op
BenchmarkConsortiumPickValidatorSet/pick-validator-set-Gas=3540-8         377305             32748 ns/op              3540 gas/op              108.1 mgas/s        19775 B/op        299 allocs/op
BenchmarkConsortiumPickValidatorSet/pick-validator-set-Gas=14790-8        113479            129076 ns/op             14790 gas/op              114.6 mgas/s        76689 B/op       1092 allocs/op
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