ethereum-optimism / ethereum-optimism/optimism

Function `calculateSubWordMaskAndOffset` has undocumented precondition

Open
#13,437 0 comments 0 reactions 0 assignees View on GitHub
MT cannon - audit findings
Dominant language
Go
Stars
6.5k
Forks
4k
Avg merge
2d 15h
Merged PRs (30d)
145

Description

As per spearbit audit finding:

**Description**:
According to the function implementation, argument _vaddr must be aligned to _byteLength, which by itself must be a power of 2.

**Recommendation:**
Assuming a correct guest program, every usage seems to conform to these preconditions, but even so, these limitations warrants at least a docstring explaining them, on this function itself and others that simply forwards their arguments to it.

[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#L901-L904)
function calculateSubWordMaskAndOffset(
uint64 _vaddr,
uint64 _byteLength
)

Contributor guide

Open the contributing guide

Research direction

Read `packages/contracts-bedrock/src/cannon/libraries/MIPS64Instructions.sol` around `calculateSubWordMaskAndOffset` and identify other functions that forward arguments to it. Document that `_vaddr` must be aligned to `_byteLength` and that `_byteLength` must be a power of two, including those forwarding functions; done when these preconditions are stated in their docstrings.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
backend
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.