Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Incorret storage slot index reported #70

Closed
2xic opened this issue Sep 8, 2023 · 0 comments · Fixed by #71
Closed

[BUG] Incorret storage slot index reported #70

2xic opened this issue Sep 8, 2023 · 0 comments · Fixed by #71
Assignees
Labels
bug Something isn't working

Comments

@2xic
Copy link
Collaborator

2xic commented Sep 8, 2023

Describe the Bug

Slot is incorrectly reported (looks like a cutoff)

To Reproduce

Tried to run it with a beefed up config, but still having the same results.

Config { 
	gas_limit: 30000000, 
	maximum_iterations_per_opcode: 10000,
 	maximum_forks_per_fork_target: 10000, 
	value_size_limit: 10000,
	single_memory_operation_size_limit: 10000 
}

Example contract ( or any https://eips.ethereum.org/EIPS/eip-1967 like contract )

contract ExampleContract {
   // bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1))
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    constructor() {
        writeSlot(_IMPLEMENTATION_SLOT, 0x6bf5ed59dE0E19999d264746843FF931c0133090);
    }

    function implementation() public view returns (address) {
        return readSlot(_IMPLEMENTATION_SLOT);
    }

    function writeSlot(bytes32 slot, address value) public {
        assembly {
            sstore(slot, value)
        }
    }

    function readSlot(bytes32 slot) public view returns (address r) {
        assembly {
            r := sload(slot)
        }
    }
}

Bytecode

608060405234801561001057600080fd5b50600436106100415760003560e01c80635c60da1b14610046578063b06cb8991461006a578063e8e834a91461007e575b600080fd5b61004e610090565b6040516001600160a01b03909116815260200160405180910390f35b61007c6100783660046100bf565b9055565b005b61004e61008c3660046100fb565b5490565b60006100ba7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b905090565b600080604083850312156100d257600080fd5b8235915060208301356001600160a01b03811681146100f057600080fd5b809150509250929050565b60006020828403121561010d57600080fd5b503591905056fea2646970667358221220d65a69a7da4e10e131d4d9d13cf5abd64991e0201c1d86b2c4cb0c4aef279e1764736f6c63430008090033

Output from the sla

[
  {
    "index": 2351945876927687612, // 0x20a3ca505d382bbc in hex
    "offset": 0,
    "type": {
      "bytes": {
        "length": 20
      }
    }
  }
]

Comparing it we can see it looks like a cutoff of the value
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc
................................................0x20a3ca505d382bbc

Expected Behaviour

Expected to see 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc as the slot index

@2xic 2xic added the bug Something isn't working label Sep 8, 2023
@2xic 2xic changed the title [BUG] Incorret slot reported [BUG] Incorret storage slot index reported Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants