js-ceramic icon indicating copy to clipboard operation
js-ceramic copied to clipboard

Optionally resolve commits under consensus conflict

Open m0ar opened this issue 1 year ago • 0 comments

Description

Implement backwards compatible, opt-in load behavior that enables returning commits that have been consensus-pruned from stream state.

Background

At @desci-labs, we have strong needs to maximize determinism in state resolution. One area where this could be improved is under the effects of late-publishing attacks, because if this is performed, nodes will stop resolving any pruned commitID. We would like to be able to optionally resolve these pruned commits, if the node has knowledge about it. This would allow us to build truly stable references to historical stream state, reducing the impact of late publishing attacks.

At the present time, this would require the node to have been alive and well during the attack. In a CIP-145 future, new nodes would automatically be made aware of these historical forks, and hence could resolve pruned commits even if they were not online at the time.

These two changes together make for a dramatically improved resilience against late-publishing attacks, as they would not be able to prevent resolution of previously valid state.

Technical Information

This is the function that loads streams at a CommitID, and it currently hard-codes throwOnConflict to true: https://github.com/ceramicnetwork/js-ceramic/blob/d2db9045403472b490a2a4ac268538532a19e759/packages/core/src/stream-loading/stream-loader.ts#L140

This can be made a function argument, threaded through the caller all the way up to the HTTP API. There, it can be added as a property in LoadOptions that can be passed from the HTTP client.

Thanks to @stbrody for suggesting an implementation path :cupcake:

Note that it is my intention to contribute the code for this enhancement, if there are no objections.

m0ar avatar Dec 07 '23 09:12 m0ar