-
Notifications
You must be signed in to change notification settings - Fork 809
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
Initialize LastCallee*
of CallContext
#298
Initialize LastCallee*
of CallContext
#298
Conversation
c84f32f
to
e9d94e0
Compare
@@ -166,12 +163,20 @@ impl<F: FieldExt> ExecutionGadget<F> for BeginTxGadget<F> { | |||
), | |||
(CallContextFieldTag::Value, tx_value.expr()), | |||
(CallContextFieldTag::IsStatic, 0.expr()), | |||
(CallContextFieldTag::LastCalleeId, 0.expr()), |
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.
want to know why call last callee in begin_tx ?
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.
To avoid a malicious prover set these fields to read arbitrary call's memory, we need to make sure it's initilized to 0
properly
1ec98b0
to
7d398d7
Compare
df8d1ae
to
189b340
Compare
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.
LGTM!
I have a question though:
LastCallee* rows are always READ right?
But in the same call, we can have different values of LastCallee.
Imagine the following situation
Begin CALL 1
Begin CALL 2
End CALL 2
Begin CALL 3
End CALL 3
End Call 1
I imagine that the LastCalleeId rows for callId = 1 (in rw_table
) will be:
0 rwc | 1 isWrite | 2 Key0 (Tag) | 3 callId | 5 Key3 | 7 Value0 |
---|---|---|---|---|---|
1 | false | CallContext | 1 | LastCalleeId | 0 |
2 | false | CallContext | 1 | LastCalleeId | 2 |
3 | false | CallContext | 1 | LastCalleeId | 3 |
Is this right? If that's the case, then these rows don't follow the READ constraint, because for the same set of keys, the value is changing. Am I missing something?
Fields
There is also implemented in privacy-scaling-explorations/zkevm-specs#100 and the writes are here |
Thanks! This resolves my doubt. I had the misunderstanding that LastCalleeId* rows where never WRITE. |
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.
LGTM thanks !
@@ -652,6 +652,12 @@ pub enum CallContextField { | |||
IsPersistent, | |||
/// IsStatic | |||
IsStatic, | |||
/// LastCalleeId | |||
LastCalleeId, |
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.
just thinking how about if we only record LastCalleeId
without LastCalleeReturnDataOffset
LastCalleeReturnDataOffset
? then we can look up those two items by LastCalleeId
as already have ReturnDataOffset
ReturnDataOffset
, something missing ?
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.
Fields LastCalleeReturnData*
are decided by the callee's step which halts.
Fields ReturnData*
are decided by the caller's step which triggers the call, to ask callee to copy the ReturnData
to the specified range.
So they are for different purposes.
Should we update and merge this @han0110 ? |
a99b432
to
ace926d
Compare
ace926d
to
e0cbfd9
Compare
Co-authored-by: Zhang Zhuo <mycinbrin@gmail.com>
This PR is once #278, and aims to initialize last callee's information of
CallContext
inBeginTx
.For spec, see privacy-scaling-explorations/zkevm-specs#99.
It depends on #292.