Skip to content

Commit

Permalink
Use less common slot for EOA implementation (#69)
Browse files Browse the repository at this point in the history
* set EOA implementation slot to deaddeaddead....

* fix tests
  • Loading branch information
ben-chain authored Nov 18, 2020
1 parent 148cb96 commit 9cd9a28
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_Sa
*/
contract OVM_ProxyEOA {

bytes32 constant IMPLEMENTATION_KEY = 0xdeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead;

/***************
* Constructor *
***************/
Expand Down Expand Up @@ -72,7 +74,7 @@ contract OVM_ProxyEOA {
{
return address(uint160(uint256(
Lib_SafeExecutionManagerWrapper.safeSLOAD(
bytes32(uint256(0))
IMPLEMENTATION_KEY
)
)));
}
Expand All @@ -87,7 +89,7 @@ contract OVM_ProxyEOA {
internal
{
Lib_SafeExecutionManagerWrapper.safeSSTORE(
bytes32(uint256(0)),
IMPLEMENTATION_KEY,
bytes32(uint256(uint160(_implementation)))
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ describe('OVM_ProxyEOA', () => {
})
})
describe('upgrade()', () => {
const implSlotKey = '0xdeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead'
it(`should upgrade the proxy implementation`, async () => {
const newImpl = `0x${'81'.repeat(20)}`
const newImplBytes32 = addrToBytes32(newImpl)
Expand All @@ -108,7 +109,7 @@ describe('OVM_ProxyEOA', () => {
])
const ovmSSTORE: any =
Mock__OVM_ExecutionManager.smocked.ovmSSTORE.calls[0]
expect(ovmSSTORE._key).to.equal(`0x${'00'.repeat(32)}`)
expect(ovmSSTORE._key).to.equal(implSlotKey)
expect(ovmSSTORE._value).to.equal(newImplBytes32)
})
it(`should not allow upgrade of the proxy implementation by another account`, async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const test_ovmCREATEEOA: TestDefinition = {
address: '0x17ec8597ff92C3F44523bDc65BF0f1bE632917ff',
},
expectedReturnStatus: true,
expectedReturnValue: 1619,
expectedReturnValue: 1682,
},
],
},
Expand Down

0 comments on commit 9cd9a28

Please sign in to comment.