optimism icon indicating copy to clipboard operation
optimism copied to clipboard

Most of OP constants are not used

Open BlocksOnAChain opened this issue 1 year ago • 1 comments

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 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 if (_args.opcode == 0x27 || _args.opcode == 0x1A || _args.opcode == 0x1B) {

BlocksOnAChain avatar Dec 17 '24 13:12 BlocksOnAChain

I think this is taken care of - if yes can we close this issue?

blockhunter270-boop avatar Dec 03 '25 18:12 blockhunter270-boop