Commit 9cd9a28c authored by ben-chain's avatar ben-chain Committed by GitHub

Use less common slot for EOA implementation (#69)

* set EOA implementation slot to deaddeaddead....

* fix tests
parent 148cb966
...@@ -11,6 +11,8 @@ import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_Sa ...@@ -11,6 +11,8 @@ import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_Sa
*/ */
contract OVM_ProxyEOA { contract OVM_ProxyEOA {
bytes32 constant IMPLEMENTATION_KEY = 0xdeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead;
/*************** /***************
* Constructor * * Constructor *
***************/ ***************/
...@@ -72,7 +74,7 @@ contract OVM_ProxyEOA { ...@@ -72,7 +74,7 @@ contract OVM_ProxyEOA {
{ {
return address(uint160(uint256( return address(uint160(uint256(
Lib_SafeExecutionManagerWrapper.safeSLOAD( Lib_SafeExecutionManagerWrapper.safeSLOAD(
bytes32(uint256(0)) IMPLEMENTATION_KEY
) )
))); )));
} }
...@@ -87,7 +89,7 @@ contract OVM_ProxyEOA { ...@@ -87,7 +89,7 @@ contract OVM_ProxyEOA {
internal internal
{ {
Lib_SafeExecutionManagerWrapper.safeSSTORE( Lib_SafeExecutionManagerWrapper.safeSSTORE(
bytes32(uint256(0)), IMPLEMENTATION_KEY,
bytes32(uint256(uint160(_implementation))) bytes32(uint256(uint160(_implementation)))
); );
} }
......
...@@ -100,6 +100,7 @@ describe('OVM_ProxyEOA', () => { ...@@ -100,6 +100,7 @@ describe('OVM_ProxyEOA', () => {
}) })
}) })
describe('upgrade()', () => { describe('upgrade()', () => {
const implSlotKey = '0xdeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead'
it(`should upgrade the proxy implementation`, async () => { it(`should upgrade the proxy implementation`, async () => {
const newImpl = `0x${'81'.repeat(20)}` const newImpl = `0x${'81'.repeat(20)}`
const newImplBytes32 = addrToBytes32(newImpl) const newImplBytes32 = addrToBytes32(newImpl)
...@@ -108,7 +109,7 @@ describe('OVM_ProxyEOA', () => { ...@@ -108,7 +109,7 @@ describe('OVM_ProxyEOA', () => {
]) ])
const ovmSSTORE: any = const ovmSSTORE: any =
Mock__OVM_ExecutionManager.smocked.ovmSSTORE.calls[0] 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) expect(ovmSSTORE._value).to.equal(newImplBytes32)
}) })
it(`should not allow upgrade of the proxy implementation by another account`, async () => { it(`should not allow upgrade of the proxy implementation by another account`, async () => {
......
...@@ -65,7 +65,7 @@ const test_ovmCREATEEOA: TestDefinition = { ...@@ -65,7 +65,7 @@ const test_ovmCREATEEOA: TestDefinition = {
address: '0x17ec8597ff92C3F44523bDc65BF0f1bE632917ff', address: '0x17ec8597ff92C3F44523bDc65BF0f1bE632917ff',
}, },
expectedReturnStatus: true, expectedReturnStatus: true,
expectedReturnValue: 1619, expectedReturnValue: 1682,
}, },
], ],
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment