From fbc4730a103d609c93358e41d765061601a8671d Mon Sep 17 00:00:00 2001 From: Minhyuk Kim Date: Tue, 10 Dec 2024 16:04:55 +0900 Subject: [PATCH] Hardcord state offset values to save gas and execution time --- rvsol/src/RISCV.sol | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/rvsol/src/RISCV.sol b/rvsol/src/RISCV.sol index 1bbb681..d75bed2 100644 --- a/rvsol/src/RISCV.sol +++ b/rvsol/src/RISCV.sol @@ -285,34 +285,44 @@ contract RISCV is IBigStepper { out := 0 } function stateOffsetPreimageKey() -> out { - out := add(stateOffsetMemRoot(), stateSizeMemRoot()) + out := 32 // 0 + 32 +// out := add(stateOffsetMemRoot(), stateSizeMemRoot()) } function stateOffsetPreimageOffset() -> out { - out := add(stateOffsetPreimageKey(), stateSizePreimageKey()) + out := 64 // 32 + 32 +// out := add(stateOffsetPreimageKey(), stateSizePreimageKey()) } function stateOffsetPC() -> out { - out := add(stateOffsetPreimageOffset(), stateSizePreimageOffset()) + out := 72 // 64 + 8 +// out := add(stateOffsetPreimageOffset(), stateSizePreimageOffset()) } function stateOffsetExitCode() -> out { - out := add(stateOffsetPC(), stateSizePC()) + out := 80 // 72 + 8 +// out := add(stateOffsetPC(), stateSizePC()) } function stateOffsetExited() -> out { - out := add(stateOffsetExitCode(), stateSizeExitCode()) + out := 81 // 80 + 1 +// out := add(stateOffsetExitCode(), stateSizeExitCode()) } function stateOffsetStep() -> out { - out := add(stateOffsetExited(), stateSizeExited()) + out := 82 // 81 + 1 +// out := add(stateOffsetExited(), stateSizeExited()) } function stateOffsetHeap() -> out { - out := add(stateOffsetStep(), stateSizeStep()) + out := 90 // 82 + 8 +// out := add(stateOffsetStep(), stateSizeStep()) } function stateOffsetLoadReservation() -> out { - out := add(stateOffsetHeap(), stateSizeHeap()) + out := 98 // 90 + 8 +// out := add(stateOffsetHeap(), stateSizeHeap()) } function stateOffsetRegisters() -> out { - out := add(stateOffsetLoadReservation(), stateSizeLoadReservation()) + out := 106 // 98 + 8 +// out := add(stateOffsetLoadReservation(), stateSizeLoadReservation()) } function stateSize() -> out { - out := add(stateOffsetRegisters(), stateSizeRegisters()) + out := 362 // 106 + 256 +// out := add(stateOffsetRegisters(), stateSizeRegisters()) } //