0xPolygonMiden / miden-base

Core components of the Polygon Miden rollup
MIT License
70 stars 44 forks source link

Require transactions to refer to recent blocks #933

Open bobbinth opened 3 weeks ago

bobbinth commented 3 weeks ago

Currently, we have no restriction on how old a block referenced by a transaction needs to be (it could be a genesis block, for example). It may be beneficial to make this a bit more restrictive (and this is done in some other chains - e.g., Solana). For example, we could require that a transaction references a block which is within 256 blocks of the chain tip. This would be a global setting applicable to all transactions. Individual transactions would still be able to reduce this window via individual expiration settings as they can now.

igamigo commented 3 weeks ago

Is there any specific reason why we would not want to initialize the expiration delta to 256 instead of u32::MAX on the kernel prologue? I guess it could be be more "dynamic" by enforcing it on the node.

bobbinth commented 3 weeks ago

Good point! Though, we'd set the block expiration time to block_ref + 256 rather than the delta directly. I'll transfer this issue to miden-base.

bobbinth commented 2 weeks ago

One drawback to imposing this condition is that it would require a wallet to always sync with the chain before it can issue transactions. Most of the time, this could be fine, but there could be some use cases where this may be undesirable.

For example, I can imagine a kind of a "spend only" account. Such an account can be funded once. The state of this account could be loaded into an air-gapped device (e.g., something not connected to the internet). Then, this account can generate transactions which move assets out of the account (up until the balance is exhausted) without the need to ever be connected to the network. These transactions could be transmitted to the recipient, who is presumably connected to the internet and will be able to submit them to the network.

Requiring transactions to reference a recent block will make such "spend only" accounts impossible.