cartesi / openapi-interfaces

HTTP interfaces specified with OpenAPI.
Apache License 2.0
2 stars 7 forks source link

Make `value` argument of `/voucher` entry-point optional #21

Open guidanoli opened 1 month ago

guidanoli commented 1 month ago

Rationale

On SDK v1, vouchers had only two fields: destination and payload. On-chain, this triggers a CALL instruction. This instruction also takes a value as stack input, but we didn't specify it, so Solidity would pass zero as the default value to message calls.

On SDK v2, we introduced the value field to parameterize this stack input. In most cases, however, this field will still be zero. It will only be non-zero when there is some movement of Ether. The classic example is Ether withdrawals.

If this field were made obligatory in the HTTP API, application back-ends would have to adapt every call to the /voucher entry-point, just to pass the same value, zero. To make this change backwards-compatible, we believe that we can make this field optional, with zero being a sensible default.

Proposal

Make the value argument of the /voucher entry-point optional. The default value should be zero, just like before. If this change is agreed upon, an equivalent issue should be opened on machine-emulator-tools.

tuler commented 1 month ago

I support the change. It’s basically removal of line https://github.com/cartesi/openapi-interfaces/blob/9b9d6088d6e2f93c333d5500e868116d7e57ba91/rollup.yaml#L429

jplgarcia commented 1 month ago

Strong agree, but I would like to point that we also have to change the description of destination https://github.com/cartesi/openapi-interfaces/blob/9b9d6088d6e2f93c333d5500e868116d7e57ba91/rollup.yaml#L406

description: 20-byte address of the destination contract for which the payload will be sent.

Currently it specifiec it is the address of a contract and for ether withdrawals it can be the user who will be receiving the assets. Correct @guidanoli ?

guidanoli commented 1 month ago

Yes, destination can be any Ethereum account address. If the account has some code, we say it's a smart contract.

guidanoli commented 1 month ago

It’s basically removal of line https://github.com/cartesi/openapi-interfaces/blob/9b9d6088d6e2f93c333d5500e868116d7e57ba91/rollup.yaml#L429

Yes, and we should make it clear that zero is the default value.