Init.Exec and "Runtime" CIDs #482
Replies: 2 comments 2 replies
-
Interesting. Taking a step back, I think you might be hinting at a mechanism to define visibility of DAGs, e.g. exported/private DAGs, i.e. DAGs that can be integrated into the state tree vs DAGs that can't. The problem with this is that it breaks some guarantees in the receiver. Now it no longer has the guarantee that the received DAG can be unconditionally linked to from its state. Another scenario where a different flavour of this could be useful is when staging a batch of write operations on a data structure. Right now, I believe the HAMT and the AMT rehash at every write. It would be nicer if one could perform a batch insertion/deletion/update and avoid the cost of rehashing at every individual operation. One way of doing that would be to use "placeholder CIDs" or "reference CIDs" temporarily until the batch is committed, which is when real CIDs would be calculated. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've run into a few cases where I'd like to be able to create CIDs that are only valid at runtime. This can be useful for passing temporary datastructures between actors that will never be persisted into the state-tree. Otherwise, the user will need to create a real CID, and pay for the hashing.
One such example is the parameters to
Init.Exec
. At the moment, we've defined these parameters to be "raw bytes". However, we'd like to be able to pass more complex datastructures to constructors (e.g., ones containing CIDs/links).At the moment, we have two options:
InitParams::constuctor_params
a CID.Both of these have drawbacks:
ipld::put_block
on this value before calling the actor's constructor.One (somewhat crazy) solution would be to introduce a new fvm-specific "multihash code" for "ephemeral" CIDs (or even just an "application specific code". If the user calls
ipld::block_link
with this special multihash code, the FVM would assign a temporary ID to the block, and return a CID with that temporary ID as the digest (we can probably avoid a syscall here if we get cleaver). If the user then callsipld::block_link
with any other multihash code on a block containing one of these ephemeral CIDs, the FVM would reject the call.Unfortunately:
Honestly, in this case, the cost of hashing is likely minimal compared to everything else (we're creating a new actor). So maybe that's a viable solution?
Beta Was this translation helpful? Give feedback.
All reactions