Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

Commit

Permalink
fix comment on message memory layout
Browse files Browse the repository at this point in the history
  • Loading branch information
snd committed Feb 27, 2018
1 parent 5a91157 commit 8ffc166
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contracts/bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ library Message {
// offset 84: 32 bytes :: bytes32 - transaction hash
// offset 116: 32 bytes :: uint256 (big endian) - home gas price

// bytes 1 to 32 are 0 because message length is stored as little endian.
// mload always reads 32 bytes.
// if mload reads an address it only interprets the last 20 bytes as the address.
// so we can and have to start reading recipient at offset 20 instead of 32.
// if we were to read at 32 the address would contain part of value and be corrupted.
// when reading from offset 20 mload will read 12 zero bytes followed
// when reading from offset 20 mload will ignore 12 bytes followed
// by the 20 recipient address bytes and correctly convert it into an address.
// this saves some storage/gas over the alternative solution
// which is padding address to 32 bytes and reading recipient at offset 32.
Expand Down

0 comments on commit 8ffc166

Please sign in to comment.