Gas.t.sol
64 lines · sha256 09126d52ca38828895e6e7f3592d866f1c394e6d9dfeb10268ddf672387d7267 · Raw
| 1 | // SPDX-License-Identifier: MIT |
| 2 | pragma solidity ^0.8.26; |
| 3 | |
| 4 | import {KibbleBase} from "./utils/KibbleBase.sol"; |
| 5 | import {console} from "forge-std/console.sol"; |
| 6 | |
| 7 | /// @notice Steady-state gas figures (mining live, warm system), printed with -vv. |
| 8 | contract GasTest is KibbleBase { |
| 9 | function test_gas_steadyState() public { |
| 10 | _launch(10_000); |
| 11 | _buy(bob, 10); |
| 12 | _power(bob, 10e18); |
| 13 | _on(bob, 10); |
| 14 | _roll(500); |
| 15 | miner.checkpoint(); |
| 16 | |
| 17 | _roll(10); |
| 18 | vm.deal(carol, 10e18); |
| 19 | vm.prank(carol); |
| 20 | uint256 g = gasleft(); |
| 21 | miner.buyRigs{value: 10e18}(10); |
| 22 | console.log("buyRigs (after block 0, zap)", g - gasleft()); |
| 23 | |
| 24 | _roll(10); |
| 25 | vm.deal(carol, 1e18); |
| 26 | vm.prank(carol); |
| 27 | g = gasleft(); |
| 28 | miner.depositPower{value: 1e18}(); |
| 29 | console.log("depositPower (rigs off)", g - gasleft()); |
| 30 | |
| 31 | _roll(10); |
| 32 | vm.prank(carol); |
| 33 | g = gasleft(); |
| 34 | miner.setRigsOn(10); |
| 35 | console.log("setRigsOn (switch on)", g - gasleft()); |
| 36 | |
| 37 | _roll(10); |
| 38 | vm.prank(bob); |
| 39 | g = gasleft(); |
| 40 | miner.setRigsOn(5); |
| 41 | console.log("setRigsOn (change count)", g - gasleft()); |
| 42 | |
| 43 | _roll(10); |
| 44 | vm.prank(bob); |
| 45 | g = gasleft(); |
| 46 | miner.claim(); |
| 47 | console.log("claim", g - gasleft()); |
| 48 | |
| 49 | _roll(10); |
| 50 | g = gasleft(); |
| 51 | miner.checkpoint(); |
| 52 | console.log("checkpoint (no bucket)", g - gasleft()); |
| 53 | |
| 54 | _roll(200_000); // carol, bob, alice tanks run dry |
| 55 | g = gasleft(); |
| 56 | miner.checkpoint(); |
| 57 | console.log("checkpoint (3 buckets)", g - gasleft()); |
| 58 | |
| 59 | g = gasleft(); |
| 60 | miner.flushBurn(); |
| 61 | console.log("flushBurn", g - gasleft()); |
| 62 | } |
| 63 | } |
| 64 |