-
Notifications
You must be signed in to change notification settings - Fork 21
Fold revert-on-reject into the generated step code #98
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
base: main
Are you sure you want to change the base?
Changes from all commits
f6ac168
91d4f0c
d6da51f
331e86e
e60f6eb
f12646b
260f837
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| fef8844a306d83eef9c30828986645f2b0ff149654490b0f7d47ec2883bcb693 downloads/machine-emulator-tests-data.deb | ||
| bc7a0cc14724167c2826967eaf62feb6a2c902b2b45a73f3c684e1c5ceaa8f69 downloads/uarch-riscv-tests-json-logs.tar.gz | ||
| 28fd67825be2bf53188326065a06f9a5019f7bd07426d21f6053f34e8652fb3e downloads/machine-emulator-tests-data.deb | ||
| f7d22eacba7c9df62fa6dfa63fe75bdc387f6c7a98f20606bcfd0b01a851830c downloads/uarch-riscv-tests-json-logs.tar.gz |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,17 +31,34 @@ library SendCmioResponse { | |
|
|
||
| function sendCmioResponse( | ||
| AccessLogs.Context memory a, | ||
| bytes32 revertRootHash, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At this point, in every valid call, We'd likely need to change the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remember that send_cmio_response was supposed to work with other generic IO requests. I am not sure what the deal there would be. So it makes sense to leave the argument there, I think. |
||
| uint16 reason, | ||
| bytes32 dataHash, | ||
| uint32 dataLength | ||
| ) internal pure { | ||
| // This function cannot fail. When a failure is detected, the operation is a no-op instead, | ||
| // so the honest party can always log and prove the resulting state transition. | ||
| // A response to a machine that is not waiting on a manual yield is a no-op. | ||
| if (!EmulatorCompat.readIflagsY(a)) { | ||
| EmulatorCompat.throwRuntimeError(a, "iflags.Y is not set"); | ||
| return; | ||
| } | ||
| if (reason == EmulatorConstants.HTIF_YIELD_REASON_ADVANCE_STATE) { | ||
| // Advance-state responses are the input boundary of the rollups flow. They only apply to a | ||
| // machine waiting for an input on an rx-accepted manual yield. Sending one to a machine that | ||
| // yielded manual with any other reason (e.g., rejected an input or threw an exception) is a no-op. | ||
| uint64 tohost = EmulatorCompat.readHtifTohost(a); | ||
| if (!EmulatorCompat.isYieldedManualWith( | ||
| tohost, | ||
| EmulatorConstants.HTIF_YIELD_MANUAL_REASON_RX_ACCEPTED | ||
| )) { | ||
| return; | ||
| } | ||
| } | ||
| // A zero length data is a valid response. We just skip writing to the rx buffer. | ||
| uint32 writeLengthLog2Size = 0; | ||
| if (dataLength > 0) { | ||
| // Find the write length: the smallest power of 2 that is >= dataLength and >= tree leaf size | ||
| uint32 writeLengthLog2Size = EmulatorCompat.uint32Log2(dataLength); | ||
| writeLengthLog2Size = EmulatorCompat.uint32Log2(dataLength); | ||
| if ( | ||
| writeLengthLog2Size < EmulatorConstants.HASH_TREE_LOG2_WORD_SIZE | ||
| ) { | ||
|
|
@@ -53,14 +70,17 @@ library SendCmioResponse { | |
| ) { | ||
| writeLengthLog2Size += 1; | ||
| } | ||
| // A response with data that does not fit in the rx buffer is a no-op | ||
| if ( | ||
| writeLengthLog2Size | ||
| > EmulatorConstants.AR_CMIO_RX_BUFFER_LOG2_SIZE | ||
| ) { | ||
| EmulatorCompat.throwRuntimeError( | ||
| a, "CMIO response data is too large" | ||
| ); | ||
| return; | ||
| } | ||
| } | ||
| // Record the machine root hash to revert to in case the response is eventually rejected | ||
| EmulatorCompat.writeRevertRootHash(a, revertRootHash); | ||
| if (dataLength > 0) { | ||
| a.writeRegion( | ||
| Memory.regionFromPhysicalAddress( | ||
| EmulatorConstants.AR_CMIO_RX_BUFFER_START | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯