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

Ergs comparision CI #194

Merged
merged 14 commits into from
Aug 26, 2024
Merged

Ergs comparision CI #194

merged 14 commits into from
Aug 26, 2024

Conversation

gianbelinche
Copy link
Contributor

@gianbelinche gianbelinche commented Aug 14, 2024

This PR adds a CI in order to test whether we are spending the same amount of ergs as the vm1.
This is done by using the benchmark-analyzer of the compiler tester with the interpreter tests
The idea is be the following:
Run:
cargo run --verbose --features lambda_vm --release --bin compiler-tester -- --path tests/solidity/complex/interpreter/test.json --mode 'Y+M3B3 0.8.26' --benchmark lambda_vm.json
Then run:
cargo run --verbose --release --bin compiler-tester -- --path tests/solidity/complex/interpreter/test.json --mode 'Y+M3B3 0.8.26' --benchmark vm1.json

This will generate 2 json files with data for each interpreter test, we care about ergs, running:
cargo run --release --bin benchmark-analyzer -- --reference vm1.json --candidate lambda_vm.json
Will output a table like this

╔═╡ Size (-%) ╞═════╡ EVMInterpreter M3B3 ╞═╗
║ Mean 0.000 ║
║ Best 0.000 ║
║ Worst 0.000 ║
║ Total 0.000 ║
╠═╡ Cycles (-%) ╞═══╡ EVMInterpreter M3B3 ╞═╣
║ Mean 4.834 ║
║ Best 7.022 ║
║ Worst -1.611 ║
║ Total 5.573 ║
╠═╡ Ergs (-%) ╞═════╡ EVMInterpreter M3B3 ╞═╣
║ Mean -3.166 ║
║ Best 0.000 ║
║ Worst -6.275 ║
║ Total -3.573 ║
╠═╡ Ergs/gas ╞══════╡ EVMInterpreter M3B3 ╞═╣
║ ADD 67.667 ║
║ MUL 39.400 ║
║ SUB 67.667 ║
.
.
.
║ SWAP16 66.000 ║
║ RETURN inf ║
║ REVERT inf ║
╠═╡ Ergs/gas (-%) ╞═╡ EVMInterpreter M3B3 ╞═╣
║ ADD 29.021 ║
║ MUL 31.119 ║
║ SUB 29.021 ║
.
.
.
║ SWAP16 38.700 ║
╚════════════════════════════════╝

We care about ergs/gas which indicates the relation between the ergs spent by the eravm and the gas spent by the interpreter, since the gas should be the same in both, this will tell us if the ergs spent is correct.

What we need to check is that there are no opcodes in ergs / gas % , since that means that both values of ergs/gas are the same.
Another way would be checking the colors in ergs/gas, if all opcodes have ergs/gas in grey then they are the same on both vms, however, on the pr comment colors are not showed.

This CI will automatically post a comment on the PR with the results, and it should be manually checked if that output is correct before merging

Related to lambdaclass/era-compiler-tester#16

Copy link

github-actions bot commented Aug 15, 2024

Ergs comparison results:

╔═╡ Size (-%) ╞════════════════╡ All M3B3 ╞═╗
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                                 NaN ║
╠═╡ Cycles (-%) ╞══════════════╡ All M3B3 ╞═╣
║ Mean                              100.000 ║
║ Best                              100.000 ║
║ Worst                               0.000 ║
║ Total                             100.000 ║
╠═╡ Ergs (-%) ╞════════════════╡ All M3B3 ╞═╣
║ Mean                              -36.382 ║
║ Best                               57.093 ║
║ Worst                             -1231745.705 ║
║ Total                             -106612.436 ║
╚═══════════════════════════════════════════╝

╔═╡ Size (-%) ╞════════════════╡ All MzB3 ╞═╗
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                                 NaN ║
╠═╡ Cycles (-%) ╞══════════════╡ All MzB3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                                 NaN ║
╠═╡ Ergs (-%) ╞════════════════╡ All MzB3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                                 NaN ║
╚═══════════════════════════════════════════╝

╔═╡ Size (-%) ╞═════╡ EVMInterpreter M3B3 ╞═╗
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                                 NaN ║
╠═╡ Cycles (-%) ╞═══╡ EVMInterpreter M3B3 ╞═╣
║ Mean                              100.000 ║
║ Best                              100.000 ║
║ Worst                               0.000 ║
║ Total                             100.000 ║
╠═╡ Ergs (-%) ╞═════╡ EVMInterpreter M3B3 ╞═╣
║ Mean                              -36.382 ║
║ Best                               57.093 ║
║ Worst                             -1231745.705 ║
║ Total                             -106612.436 ║
╠═╡ Ergs/gas ╞══════╡ EVMInterpreter M3B3 ╞═╣
║ ADD                                60.750 ║
║ MUL                                36.450 ║
║ SUB                                60.750 ║
║ DIV                                44.850 ║
║ SDIV                               59.250 ║
║ MOD                                43.650 ║
║ SMOD                               58.050 ║
║ ADDMOD                             34.156 ║
║ MULMOD                             34.156 ║
║ EXP                                 8.537 ║
║ SIGNEXTEND                         42.450 ║
║ LT                                 64.750 ║
║ GT                                 64.750 ║
║ SLT                                88.750 ║
║ SGT                                86.750 ║
║ EQ                                 64.750 ║
║ ISZERO                             56.417 ║
║ AND                                58.750 ║
║ OR                                 60.750 ║
║ XOR                                60.750 ║
║ NOT                                52.417 ║
║ BYTE                               66.750 ║
║ SHL                                64.750 ║
║ SHR                                62.750 ║
║ SAR                                80.750 ║
║ SGT                                86.750 ║
║ SHA3                               27.647 ║
║ ADDRESS                            81.000 ║
║ BALANCE                            34.496 ║
║ ORIGIN                            398.594 ║
║ CALLER                             81.000 ║
║ CALLVALUE                          81.000 ║
║ CALLDATALOAD                       54.750 ║
║ CALLDATASIZE                       81.125 ║
║ CALLDATACOPY                       66.231 ║
║ CODESIZE                           81.625 ║
║ CODECOPY                          142.241 ║
║ GASPRICE                          404.219 ║
║ EXTCODESIZE                         3.590 ║
║ EXTCODECOPY                         3.664 ║
║ RETURNDATASIZE                     76.500 ║
║ RETURNDATACOPY                     51.778 ║
║ EXTCODEHASH                         5.489 ║
║ BLOCKHASH                          49.197 ║
║ COINBASE                          401.594 ║
║ TIMESTAMP                         398.594 ║
║ NUMBER                            398.594 ║
║ PREVRANDAO                        398.594 ║
║ GASLIMIT                          404.594 ║
║ CHAINID                           398.594 ║
║ SELFBALANCE                       261.863 ║
║ BASEFEE                           395.594 ║
║ POP                                65.625 ║
║ MLOAD                              71.931 ║
║ MSTORE                             75.696 ║
║ MSTORE8                            83.539 ║
║ SLOAD                              14.891 ║
║ SSTORE                              4.039 ║
║ JUMP                               32.444 ║
║ JUMPI                              30.455 ║
║ PC                                 81.500 ║
║ MSIZE                              88.000 ║
║ GAS                                81.500 ║
║ JUMPDEST                          114.000 ║
║ PUSH0                              75.500 ║
║ PUSH1                              62.083 ║
║ PUSH2                              65.500 ║
║ PUSH4                              68.333 ║
║ PUSH5                              69.750 ║
║ PUSH6                              71.167 ║
║ PUSH7                              72.583 ║
║ PUSH8                              74.000 ║
║ PUSH9                              75.417 ║
║ PUSH10                             76.833 ║
║ PUSH11                             78.250 ║
║ PUSH12                             79.667 ║
║ PUSH13                             81.083 ║
║ PUSH14                             82.500 ║
║ PUSH15                             83.917 ║
║ PUSH16                             85.333 ║
║ PUSH17                             86.750 ║
║ PUSH18                             88.167 ║
║ PUSH19                             89.583 ║
║ PUSH20                             91.000 ║
║ PUSH21                             92.417 ║
║ PUSH22                             93.833 ║
║ PUSH23                             95.250 ║
║ PUSH24                             96.667 ║
║ PUSH25                             98.083 ║
║ PUSH26                             99.500 ║
║ PUSH27                            100.917 ║
║ PUSH28                            102.333 ║
║ PUSH29                            103.750 ║
║ PUSH30                            105.167 ║
║ PUSH31                            106.583 ║
║ PUSH32                            106.000 ║
║ DUP1                               54.417 ║
║ DUP2                               58.417 ║
║ DUP3                               58.417 ║
║ DUP4                               58.417 ║
║ DUP5                               58.417 ║
║ DUP6                               58.417 ║
║ DUP7                               58.417 ║
║ DUP8                               58.417 ║
║ DUP9                               56.417 ║
║ DUP10                              58.417 ║
║ DUP11                              58.417 ║
║ DUP12                              58.417 ║
║ DUP13                              58.417 ║
║ DUP14                              58.417 ║
║ DUP15                              58.417 ║
║ DUP16                              58.417 ║
║ SWAP1                              59.083 ║
║ SWAP2                              59.083 ║
║ SWAP3                              59.083 ║
║ SWAP4                              59.083 ║
║ SWAP5                              59.083 ║
║ SWAP6                              59.083 ║
║ SWAP7                              59.083 ║
║ SWAP8                              59.083 ║
║ SWAP9                              59.083 ║
║ SWAP10                             59.083 ║
║ SWAP11                             59.083 ║
║ SWAP12                             59.083 ║
║ SWAP13                             59.083 ║
║ SWAP14                             59.083 ║
║ SWAP15                             59.083 ║
║ SWAP16                             57.083 ║
║ CALL                             1104715.448 ║
║ STATICCALL                       1104715.407 ║
║ DELEGATECALL                     1104715.127 ║
║ CREATE                           48008.647 ║
║ CREATE2                          72403.622 ║
║ RETURN                              1.000 ║
║ REVERT                              1.000 ║
╠═╡ Ergs/gas (-%) ╞═╡ EVMInterpreter M3B3 ╞═╣
║ BALANCE                            53.121 ║
║ ORIGIN                             70.963 ║
║ GASPRICE                           70.673 ║
║ EXTCODESIZE                        29.684 ║
║ EXTCODECOPY                        29.233 ║
║ EXTCODEHASH                        33.981 ║
║ BLOCKHASH                          79.764 ║
║ COINBASE                           70.808 ║
║ TIMESTAMP                          70.963 ║
║ NUMBER                             70.963 ║
║ PREVRANDAO                         70.963 ║
║ GASLIMIT                           70.654 ║
║ CHAINID                            70.963 ║
║ SELFBALANCE                        59.692 ║
║ BASEFEE                            71.118 ║
║ SLOAD                              44.878 ║
║ SSTORE                             55.336 ║
║ CALL                             -1773771.281 ║
║ STATICCALL                       -1774934.371 ║
║ DELEGATECALL                     -1802608.140 ║
║ CREATE                           -874267.586 ║
║ CREATE2                          -934763.169 ║
╚═══════════════════════════════════════════╝

@jrchatruc jrchatruc marked this pull request as ready for review August 26, 2024 18:01
Copy link
Contributor

@MarcosNicolau MarcosNicolau left a comment

Choose a reason for hiding this comment

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

LGTM!

@gianbelinche gianbelinche merged commit b681380 into main Aug 26, 2024
188 checks passed
@gianbelinche gianbelinche deleted the ergs-calculation-ci branch August 26, 2024 21: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.

3 participants