mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Have the Batch event encode the amount of results
Necessary to distinguish a bitvec with 1 results from a bitvec with 7 results.
This commit is contained in:
@@ -27,14 +27,17 @@ interface IRouterWithoutCollisions {
|
|||||||
/// @notice Emitted when a batch of `OutInstruction`s occurs
|
/// @notice Emitted when a batch of `OutInstruction`s occurs
|
||||||
/// @param nonce The nonce consumed to execute this batch of transactions
|
/// @param nonce The nonce consumed to execute this batch of transactions
|
||||||
/// @param messageHash The hash of the message signed for the executed batch
|
/// @param messageHash The hash of the message signed for the executed batch
|
||||||
|
/// @param resultsLength The length of the results bitvec (represented as bytes)
|
||||||
/**
|
/**
|
||||||
* @param results The result of each `OutInstruction` executed. This is a bitmask with true
|
* @param results The result of each `OutInstruction` executed. This is a bitvec with true
|
||||||
* representing success and false representing failure. The high bit (1 << 7) in the first byte
|
* representing success and false representing failure. The low bit in the first byte is used
|
||||||
* is used for the first `OutInstruction`, before the next bit, and so on, before the next byte.
|
* for the first `OutInstruction`, before the next bit, and so on, before the next byte. An
|
||||||
* An `OutInstruction` is considered as having succeeded if the call transferring ETH doesn't
|
* `OutInstruction` is considered as having succeeded if the call transferring ETH doesn't fail,
|
||||||
* fail, the ERC20 transfer doesn't fail, and any executed code doesn't revert.
|
* the ERC20 transfer doesn't fail, and any executed code doesn't revert.
|
||||||
*/
|
*/
|
||||||
event Batch(uint256 indexed nonce, bytes32 indexed messageHash, bytes results);
|
event Batch(
|
||||||
|
uint256 indexed nonce, bytes32 indexed messageHash, uint256 resultsLength, bytes results
|
||||||
|
);
|
||||||
|
|
||||||
/// @notice Emitted when `escapeHatch` is invoked
|
/// @notice Emitted when `escapeHatch` is invoked
|
||||||
/// @param escapeTo The address to escape to
|
/// @param escapeTo The address to escape to
|
||||||
|
|||||||
@@ -376,14 +376,13 @@ contract Router is IRouterWithoutCollisions {
|
|||||||
*/
|
*/
|
||||||
function transferOut(address to, address coin, uint256 amount) private returns (bool success) {
|
function transferOut(address to, address coin, uint256 amount) private returns (bool success) {
|
||||||
if (coin == address(0)) {
|
if (coin == address(0)) {
|
||||||
// Enough gas to service the transfer and a minimal amount of logic
|
|
||||||
uint256 _gas = 5_000;
|
|
||||||
// This uses assembly to prevent return bombs
|
// This uses assembly to prevent return bombs
|
||||||
// slither-disable-next-line assembly
|
// slither-disable-next-line assembly
|
||||||
assembly {
|
assembly {
|
||||||
success :=
|
success :=
|
||||||
call(
|
call(
|
||||||
_gas,
|
// explicit gas
|
||||||
|
0,
|
||||||
to,
|
to,
|
||||||
amount,
|
amount,
|
||||||
// calldata
|
// calldata
|
||||||
@@ -512,7 +511,7 @@ contract Router is IRouterWithoutCollisions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
results[i / 8] |= bytes1(uint8(1 << (7 - (i % 8))));
|
results[i / 8] |= bytes1(uint8(1 << (i % 8)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -521,7 +520,7 @@ contract Router is IRouterWithoutCollisions {
|
|||||||
|
|
||||||
This is an effect after interactions yet we have a reentrancy guard making this safe.
|
This is an effect after interactions yet we have a reentrancy guard making this safe.
|
||||||
*/
|
*/
|
||||||
emit Batch(nonceUsed, message, results);
|
emit Batch(nonceUsed, message, outs.length, results);
|
||||||
|
|
||||||
// Transfer the fee to the relayer
|
// Transfer the fee to the relayer
|
||||||
transferOut(msg.sender, coin, fee);
|
transferOut(msg.sender, coin, fee);
|
||||||
|
|||||||
Reference in New Issue
Block a user