marigold-dev / marigold-dev/chusai

Implement Withdraws

Open
#15 0 comments 0 reactions 1 assignee Claimed by @pecornilleau View on GitHub
layer-1:bridge
Dominant language
OCaml
Stars
6
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Withdraw in two parts:
- operation `Freeze (amount)`, parallel to `Deposit` which allow a user to specify that an amount of asset will be withdrawn
- endpoint `Withdraw (callback_address)` which allows a user to claim an amount of asset

When the operation `Freeze` is process, a lookup on the balance is done, if there is enough, then it is deduced and put into a `Frozen` account. If not, it is a noop.
When a block is sent, if it's level includes some `Freeze` operations, then their result is mentioned in the block. The fridge is part of the state, and as such, the bissection game does not need to be modified (agreeing on the hash of the state means agreeing on the state of the fridge).
When a block is finalized, the result of the included `Freeze` operations are processed, and the asset is prepared for the user.
When a user calls the `Withdraw` endpoint, then the assets in the fridge, prepared for him, are sent back.

The fridge:
Each block starts with an empty fridge. The initial state of the block is the root hash of the ledger + hash of the empty fridge.
During the executions of the operations, the fridge is filled by each `Freeze` request. When preparing a block, a representation of the fridge is included. It can be checked by comparing with hash of the fridge in the block.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.