forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correct implementation of srav (ethereum-optimism#245)
Existing implementation of SRAV had a bug where it would perform a shift with all bytes of the rs register when the spec says it should only be using the lower 5 bits of the register. Updates the implementation to reflect this, updates the existing test to use the same test vector as provided in the open mips tests, and adds fuzz tests that shows srav works as expected with rs values that have more than the lower 5 bits set.
- Loading branch information
1 parent
0d53d8c
commit 27a3f9f
Showing
11 changed files
with
98 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
############################################################################### | ||
# Description: | ||
# Tests that the 'srav' instruction properly only utilizes the lower 5 bits | ||
# of the rs register rather than using the entire 32 bits. | ||
# | ||
############################################################################### | ||
|
||
|
||
.section .test, "x" | ||
.balign 4 | ||
.set noreorder | ||
.global test | ||
.ent test | ||
test: | ||
lui $s0, 0xbfff # Load the base address 0xbffffff0 | ||
ori $s0, 0xfff0 | ||
ori $s1, $0, 1 # Prepare the 'done' status | ||
|
||
#### Test code start #### | ||
|
||
lui $t0, 0xdeaf # A = 0xdeafbeef | ||
ori $t0, 0xbeef | ||
ori $t1, $0, 0x2c | ||
srav $t2, $t0, $t1 # B = 0xdeafbeef >> (0x2c & 0x1f) = 0xdeadbeef >> 12 = 0xfffdeafb | ||
lui $t3, 0xfffd | ||
ori $t3, 0xeafb | ||
subu $t4, $t2, $t3 | ||
sltiu $v0, $t4, 1 | ||
|
||
#### Test code end #### | ||
|
||
sw $v0, 8($s0) # Set the test result | ||
sw $s1, 4($s0) # Set 'done' | ||
|
||
$done: | ||
jr $ra | ||
nop | ||
|
||
.end test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
packages/contracts-bedrock/snapshots/state-diff/Kontrol-31337.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
packages/contracts-bedrock/test/kontrol/proofs/utils/DeploymentSummaryCode.sol
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
packages/contracts-bedrock/test/kontrol/proofs/utils/DeploymentSummaryFaultProofsCode.sol
Large diffs are not rendered by default.
Oops, something went wrong.