Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve todos in the codebase #90

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

mininny
Copy link
Collaborator

@mininny mininny commented Oct 17, 2024

This PR cleans up some TODOs in the codebase.

@mininny mininny force-pushed the feature/mininny/resolve-todos branch from d87e934 to c26f8bb Compare October 17, 2024 22:12
@mininny mininny force-pushed the feature/mininny/resolve-todos branch from c26f8bb to 5d087c3 Compare October 18, 2024 03:56
@codecov-commenter
Copy link

codecov-commenter commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 69.73684% with 23 lines in your changes missing coverage. Please review.

Project coverage is 60.33%. Comparing base (e1a5b01) to head (22f0c71).
Report is 16 commits behind head on master.

Files with missing lines Patch % Lines
rvgo/slow/vm.go 65.71% 8 Missing and 4 partials ⚠️
rvgo/fast/vm.go 80.55% 4 Missing and 3 partials ⚠️
rvgo/fast/instrumented.go 0.00% 1 Missing and 1 partial ⚠️
rvgo/scripts/go-ffi/differential-testing.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #90      +/-   ##
==========================================
- Coverage   60.84%   60.33%   -0.51%     
==========================================
  Files          26       26              
  Lines        3833     3787      -46     
==========================================
- Hits         2332     2285      -47     
+ Misses       1385     1378       -7     
- Partials      116      124       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -628,7 +628,7 @@ contract RISCV_Test is CommonTest {

function test_lrw_succeeds() public {
bytes32 value = hex"1e0acbdd44d41d85";
uint64 addr = 0x233f3d38d3ce666b;
uint64 addr = 0x233f3d38d3ce6668;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These random addresses in tests were not properly aligned for the call to succeed. I modified them to be aligned in 4 bytes.

@mininny mininny marked this pull request as ready for review October 18, 2024 15:48
@mininny mininny requested a review from ImTei October 18, 2024 17:59
@@ -200,21 +199,6 @@ func (m *Memory) SetUnaligned(addr uint64, dat []byte) {
if d == len(dat) {
return // if all the data fitted in the page, we're done
}

// continue to remaining part
Copy link
Member

@clabby clabby Oct 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're removing the ability to do unaligned writes across page boundaries, can we also add a check at the top of SetAligned that the write is 8-byte aligned?

I see that in the VM, we check for 4-byte alignment, but it is possible to read over multiple pages if we're writing full double words and only enforcing 4-byte alignment.

rvgo/fast/vm.go Outdated Show resolved Hide resolved
rvgo/fast/memory.go Outdated Show resolved Hide resolved
@@ -894,7 +875,9 @@ func (inst *InstrumentedState) riscvStep() (outErr error) {
revertWithCode(riscv.ErrBadAMOSize, fmt.Errorf("bad AMO size: %d", size))
}
addr := getRegister(rs1)
// TODO check if addr is aligned
if addr&3 != 0 { // quick addr alignment check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See other comment on removing the ability to write across multiple pages in SetAligned.

rvgo/slow/vm.go Outdated
@@ -132,11 +128,11 @@ func Step(calldata []byte, po PreimageOracle) (stateHash common.Hash, outErr err
}

proofContentOffset := shortToU64(uint16(stateContentOffset) + paddedStateSize + 32)
// TODO: validate abi offset values?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please :D

Cannon does this as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to look at where cannon does this, but can't find it since I"m not familiar with the codebase :( Could you please give me quick pointer on where to look?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah for sure! Apologies for the late response. Here are the calldata layout checks cannon does: https://github.com/ethereum-optimism/optimism/blob/85248727fe59498ed62788eca8d9c5849cfa5074/packages/contracts-bedrock/src/cannon/MIPS.sol#L216-L231

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It's fixed in eb34592

rvgo/slow/vm.go Outdated Show resolved Hide resolved
rvsol/src/RISCV.sol Outdated Show resolved Hide resolved
rvgo/fast/vm.go Outdated Show resolved Hide resolved
@mininny mininny force-pushed the feature/mininny/resolve-todos branch from eb34592 to 22f0c71 Compare October 22, 2024 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants