ethereum-optimism / ethereum-optimism/optimism

Most of OP constants are not used

Open
#13,440 1 comment 0 reactions 0 assignees View on GitHub
A-pkg-contracts-bedrock C-good first issue MT cannon - audit findings
Dominant language
Go
Stars
6.5k
Forks
4k
Avg merge
2d 15h
Merged PRs (30d)
145

Description

**Description**
Of all these OP constants defined, only OP_LOAD_DOUBLE_LEFT and OP_LOAD_DOUBLE_RIGHT are used, but only in some places. In others, the values 0x1A and 0x1B` are used directly.

**Recommendation**
At very least, OP_LOAD_DOUBLE_LEFT and OP_LOAD_DOUBLE_RIGHT should be used whenever possible.

But ideally, all opcodes should have constants to be used though the code, at least on == comparisons, as it would greatly improve the code readability. Even better if the constant names were the same as in the MIPS documentation, e.g. OP_LDR or OP_LDL.

[packages/contracts-bedrock/src/cannon/libraries/MIPS64Instructions.sol](https://cantina.xyz/code/4ea41142-4359-4f62-bfaa-a542172cab5d/packages/contracts-bedrock/src/cannon/libraries/MIPS64Instructions.sol#L9-L14)
uint32 internal constant OP_LOAD_LINKED = 0x30;
uint32 internal constant OP_STORE_CONDITIONAL = 0x38;
uint32 internal constant OP_LOAD_LINKED64 = 0x34;
uint32 internal constant OP_STORE_CONDITIONAL64 = 0x3C;
uint32 internal constant OP_LOAD_DOUBLE_LEFT = 0x1A;
uint32 internal constant OP_LOAD_DOUBLE_RIGHT = 0x1B;
[packages/contracts-bedrock/src/cannon/libraries/MIPS64Instructions.sol](https://cantina.xyz/code/4ea41142-4359-4f62-bfaa-a542172cab5d/packages/contracts-bedrock/src/cannon/libraries/MIPS64Instructions.sol#L98)
if (_args.opcode == 0x27 || _args.opcode == 0x1A || _args.opcode == 0x1B) {

Contributor guide

Open the contributing guide

Research direction

Start with packages/contracts-bedrock/src/cannon/libraries/MIPS64Instructions.sol, reviewing the opcode constants near lines 9–14 and the comparison near line 98. Trace other opcode comparisons in this file, then replace supported literals with constants and identify any missing constants needed for readability. Done means opcode comparisons consistently use named constants where applicable.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
blockchain
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.