linera-protocol
linera-protocol copied to clipboard
Decide if reentrancy can be allowed for certain VMs
Or certain apps? This could conceivably be part of the application description
Reentrancy is used in some DeFi applications for Flash loans. The code for the provider will look like this:
function flashLoan(address receiver, uint256 amount, bytes calldata data) external {
uint256 balanceBefore = address(this).balance;
(bool ok, ) = receiver.call{ value: amount }(
abi.encodeWithSignature("executeOperation(uint256,bytes)", amount, data)
);
require(ok, "callback failed");
require(address(this).balance >= balanceBefore + fee, "loan not repaid");
}
So, you call your lending protocol (Uniswap, Morpho, etc.) with your callback information, and it does a reentrant call on your contract and checks that it went correctly. The operation is done completely or not at all.
Or certain apps? This could conceivably be part of the application description
Yes, technically it should be very easy to have two Ethereum VM configurations: one with reentrancy and one without.