-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a lifting pass that, where possible, discovers accesses to portions of a word smaller than the entire word. This allows the analyser to discover the size of types in many cases, but is also the precursor work to supporting packed encodings into single storage slots. In addition the codebase is now explicit about the byte ordering it is constructed with, and maintains the "stored as little-endian" invariant explicitly. It also adds a test for packed encodings that is not yet properly supported by the analyser, but is necessary for phase one of the packed-encoding work.
- Loading branch information
1 parent
5e9be2d
commit b8584bf
Showing
41 changed files
with
3,726 additions
and
1,048 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
contract BytecodeExample { | ||
|
||
// This one is only used in a storage slot, so should be indistinguishable | ||
// from a packed encoding (done so we force it) | ||
struct StructOne { | ||
uint64 one; | ||
uint128 two; | ||
} | ||
|
||
// This one we use in a dynamic array as well | ||
struct StructTwo { | ||
address addr; | ||
bool isEnabled; | ||
} | ||
|
||
// This struct is just used directly. | ||
StructOne internal data; | ||
|
||
// Here we create a connection between a dynamic array and a storage slot. | ||
// We should be able to infer a struct type for the slot. | ||
StructTwo internal current; | ||
StructTwo[] public history; | ||
|
||
function set_data(uint64 one, uint128 two) public { | ||
data.one = one; | ||
data.two = two; | ||
} | ||
|
||
// Updates the current and adds the old one to the history | ||
function new_current(address addr, bool isEnabled) public { | ||
history.push(current); | ||
current.addr = addr; | ||
current.isEnabled = isEnabled; | ||
} | ||
|
||
// A getter for the current | ||
function get_current() public view returns (StructTwo memory) { | ||
return current; | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.