Open
Description
Component
Forge
Have you ensured that all of these are up to date?
- Foundry
- Foundryup
What version of Foundry are you on?
forge Version: 1.0.0-v1.0.0
What version of Foundryup are you on?
foundryup: 1.1.0
What command(s) is the bug in?
forge test
Operating System
None
Describe the bug
I used the below snippet to emit events:
event Exchange(bytes swapResult);
function emitExchange(
address pool,
address tokenIn,
address tokenOut,
uint256 amountIn,
uint256 amountOut
) internal {
assembly ("memory-safe") {
// Get a pointer to some free memory.
let fmp := mload(0x40)
// Write the data into memory in reverse order because we are packing it into 92 bytes.
// We will use 32 + 20 + 20 + 16 + 16 = 104 bytes of memory.
mstore(add(fmp, 72), amountOut) // 104 - 32 = 72
mstore(add(fmp, 56), amountIn) // 72 - 16 = 56
mstore(add(fmp, 40), tokenOut) // 56 - 16 = 40
mstore(add(fmp, 20), tokenIn) // 40 - 20 = 20
mstore(fmp, pool) // 20 - 20 = 0
// Emit the event.
// The actual data is starting from fmp + 12
log1(add(fmp, 12), 92, EXCHANGE_EVENT_SELECTOR)
// Now clean the memory we used
mstore(fmp, 0)
mstore(add(fmp, 0x20), 0)
mstore(add(fmp, 0x40), 0)
mstore(add(fmp, 0x60), 0)
}
}
When running tests, instead of showing emit Exchange(...)
, it showed:

And for some places, it showed:

I checked the logs from the test transaction using vm.recordLogs
and confirmed that all the logs are correct.
Metadata
Metadata
Assignees
Type
Projects
Status
Backlog