You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using my example above, how can I reconstruct setId=1 and rootData=[ {cid: 'baf1', rawSize: 64}, {cid: 'bafy2', rawSize: 256 } ] from the firstAdded field reported by the RootsAdded event?
I think you need to add at least setId field to the event payload.
If we can assume that addRoots() will map individual roots to root ids that are in sequence (i.e. firstRoot, firstRoot+1, ... firstRoot+N-1), then the combination of setId and firstRoot allows the observer to iterate over all roots. The remaining question is how to know when to stop the iteration (what was the length of the rootData array).
If my reasoning is correct, then we need to change the event signature to the following one:
(1)
I don't understand why is firstAdded indexed - how do you envision the client queries that will use this index? It makes sense to me to look up events linked to a specific root set (via setId). I struggle to find a use case for looking up the events using the firstAdded value. (If I wanted to look up the event by root id, then how would I go from a particular root id to the "firstAdded" value emitted when the root was aded?)
(2)
I find the name "firstAdded" very confusing, it does not tell me how to interpret the value. Something like idOfTheFirstRootAdded is easier to understand, but also rather verbose.
Then I can run the following code to reconstruct the root CIDs & sizes that were added to the proof set:
for(letrootId=firstRootId;rootId<=lastRootId;rootId++){constcid=rootCids[setId][rootId]constsize=rootLeafCounts[setId][rootId]*LEAF_SIZE// add {rootId, cid, size} to our view of roots}
Alternatively, can we model the RootsAdded event after RootsRemoved event that provides an array of root ids? I think that's the most elegant solution. (But I understand it could be more expensive on the gas fees.)
Let's say somebody calls scheduleRemovals() with the following arguments:
setId=1
rootIds = [10, 20]
How can a party observing PDP state learn:
Which setId+rootId pairs were removed?
When exactly are these roots considered as no longer covered by PDP proof? Is it when the removal is scheduled or when the roots are actually removed at the start of the next proving period?
The text was updated successfully, but these errors were encountered:
I imagine we will need to filter which root-sets we watch for changes, e.g. to watch only root-sets created by Storacha.
A possible solution is to use the root-set owner address as the filter (e.g. watch only root-sets owned by one of Storacha wallet addresses).
We need two features to enable that:
When a new root-set is created, get the information about the owner.
When an owner is changed, get a notification (event) about that.
The first requirement can be met with the current PDPVerifier version by calling getProofSetOwner in the handler for the event ProofSetCreated.
It would be more ergonomic for the consumers if ProofSetCreated included the owner in the payload. IMO, it makes sense to index this field, so that consumers can filter ProofSetCreated events using the owner address.
Hello from the Spark team 👋
I reviewed the docs and the PDPVerifier contract to understand how can Spark maintain a list of Root CIDs that are covered by PDP checks.
I found the following four events - I think they cover all state changes relevant to us 👍🏻
pdp/src/PDPVerifier.sol
Lines 31 to 34 in 19993af
I can imagine how a PDP observer can use
ProofSetCreated
andProofSetDeleted
events to maintain a view of all active proof sets 👍🏻However, I don't understand how we can maintain a view of all active roots.
Question 1: observing when roots are added to a root-set
pdp/contracts/src/PDPVerifier.sol
Lines 280 to 282 in 14fd1c9
Let's say somebody calls
addRoots()
with the following arguments:The event
RootsAdded
provides onlyfirstAdded
argument, which seems to be therootId
index into the three per-proof-set mappings:pdp/src/PDPVerifier.sol
Lines 323 to 325 in 19993af
Using my example above, how can I reconstruct
setId=1
androotData=[ {cid: 'baf1', rawSize: 64}, {cid: 'bafy2', rawSize: 256 } ]
from thefirstAdded
field reported by theRootsAdded
event?I think you need to add at least
setId
field to the event payload.If we can assume that
addRoots()
will map individual roots to root ids that are in sequence (i.e.firstRoot
,firstRoot+1
, ...firstRoot+N-1
), then the combination ofsetId
andfirstRoot
allows the observer to iterate over all roots. The remaining question is how to know when to stop the iteration (what was the length of therootData
array).If my reasoning is correct, then we need to change the event signature to the following one:
While thinking about this more:
(1)
I don't understand why is
firstAdded
indexed - how do you envision the client queries that will use this index? It makes sense to me to look up events linked to a specific root set (viasetId
). I struggle to find a use case for looking up the events using the firstAdded value. (If I wanted to look up the event by root id, then how would I go from a particular root id to the "firstAdded" value emitted when the root was aded?)Proposal:
(2)
I find the name "firstAdded" very confusing, it does not tell me how to interpret the value. Something like
idOfTheFirstRootAdded
is easier to understand, but also rather verbose.Here is a suggestion that works well for me:
Then I can run the following code to reconstruct the root CIDs & sizes that were added to the proof set:
Alternatively, can we model the
RootsAdded
event afterRootsRemoved
event that provides an array of root ids? I think that's the most elegant solution. (But I understand it could be more expensive on the gas fees.)Question 2: observing when roots are removed from a root-set
pdp/contracts/src/PDPVerifier.sol
Lines 329 to 331 in 14fd1c9
This is similar to the previous question.
First, the event
RootsRemoved
does not seem to be emitted at all. Huh?? There is only one source code line containing the stringRootsRemoved
:https://github.com/search?q=repo%3AFilOzone%2Fpdp%20RootsRemoved&type=code
Let's say somebody calls
scheduleRemovals()
with the following arguments:How can a party observing PDP state learn:
The text was updated successfully, but these errors were encountered: