Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
148cb966
Commit
148cb966
authored
Nov 17, 2020
by
ben-chain
Committed by
GitHub
Nov 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove msg.sender from all SafeEM calls (#68)
parent
d85d00fa
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
17 additions
and
89 deletions
+17
-89
OVM_ECDSAContractAccount.sol
...mistic-ethereum/OVM/accounts/OVM_ECDSAContractAccount.sol
+4
-10
OVM_ProxyEOA.sol
...ntracts/optimistic-ethereum/OVM/accounts/OVM_ProxyEOA.sol
+1
-6
OVM_ProxySequencerEntrypoint.sol
...ethereum/OVM/precompiles/OVM_ProxySequencerEntrypoint.sol
+1
-8
OVM_SequencerEntrypoint.sol
...stic-ethereum/OVM/precompiles/OVM_SequencerEntrypoint.sol
+2
-4
Lib_SafeExecutionManagerWrapper.sol
...um/libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol
+6
-53
mockOVM_ECDSAContractAccount.sol
...thereum/mockOVM/accounts/mockOVM_ECDSAContractAccount.sol
+2
-7
ovmCREATEEOA.spec.ts
...s/OVM/execution/OVM_ExecutionManager/ovmCREATEEOA.spec.ts
+1
-1
No files found.
packages/contracts/contracts/optimistic-ethereum/OVM/accounts/OVM_ECDSAContractAccount.sol
View file @
148cb966
...
...
@@ -45,7 +45,6 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
bytes memory _returndata
)
{
address ovmExecutionManager = msg.sender;
bool isEthSign = _signatureType == Lib_OVMCodec.EOASignatureType.ETH_SIGNED_MESSAGE;
// Address of this contract within the ovm (ovmADDRESS) should be the same as the
...
...
@@ -53,14 +52,13 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
// account abstraction even though the user isn't a contract.
// Need to make sure that the transaction nonce is right and bump it if so.
Lib_SafeExecutionManagerWrapper.safeREQUIRE(
msg.sender,
Lib_ECDSAUtils.recover(
_transaction,
isEthSign,
_v,
_r,
_s
) == Lib_SafeExecutionManagerWrapper.safeADDRESS(
ovmExecutionManager
),
) == Lib_SafeExecutionManagerWrapper.safeADDRESS(),
"Signature provided for EOA transaction execution is invalid."
);
...
...
@@ -68,16 +66,14 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
// Need to make sure that the transaction nonce is right.
Lib_SafeExecutionManagerWrapper.safeREQUIRE(
msg.sender,
decodedTx.nonce == Lib_SafeExecutionManagerWrapper.safeGETNONCE(ovmExecutionManager),
decodedTx.nonce == Lib_SafeExecutionManagerWrapper.safeGETNONCE(),
"Transaction nonce does not match the expected nonce."
);
// Transfer fee to relayer.
address relayer = Lib_SafeExecutionManagerWrapper.safeCALLER(
ovmExecutionManager
);
address relayer = Lib_SafeExecutionManagerWrapper.safeCALLER();
uint256 fee = decodedTx.gasLimit * decodedTx.gasPrice;
Lib_SafeExecutionManagerWrapper.safeCALL(
ovmExecutionManager,
gasleft(),
ETH_ERC20_ADDRESS,
abi.encodeWithSignature("transfer(address,uint256)", relayer, fee)
...
...
@@ -86,7 +82,6 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
// Contract creations are signalled by sending a transaction to the zero address.
if (decodedTx.to == address(0)) {
address created = Lib_SafeExecutionManagerWrapper.safeCREATE(
ovmExecutionManager,
decodedTx.gasLimit - 2000,
decodedTx.data
);
...
...
@@ -98,10 +93,9 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
// We only want to bump the nonce for `ovmCALL` because `ovmCREATE` automatically bumps
// the nonce of the calling account. Normally an EOA would bump the nonce for both
// cases, but since this is a contract we'd end up bumping the nonce twice.
Lib_SafeExecutionManagerWrapper.safeSETNONCE(
ovmExecutionManager,
decodedTx.nonce + 1);
Lib_SafeExecutionManagerWrapper.safeSETNONCE(decodedTx.nonce + 1);
return Lib_SafeExecutionManagerWrapper.safeCALL(
ovmExecutionManager,
decodedTx.gasLimit,
decodedTx.to,
decodedTx.data
...
...
packages/contracts/contracts/optimistic-ethereum/OVM/accounts/OVM_ProxyEOA.sol
View file @
148cb966
...
...
@@ -30,7 +30,6 @@ contract OVM_ProxyEOA {
external
{
(bool success, bytes memory returndata) = Lib_SafeExecutionManagerWrapper.safeDELEGATECALL(
msg.sender,
gasleft(),
getImplementation(),
msg.data
...
...
@@ -42,7 +41,6 @@ contract OVM_ProxyEOA {
}
} else {
Lib_SafeExecutionManagerWrapper.safeREVERT(
msg.sender,
string(returndata)
);
}
...
...
@@ -59,8 +57,7 @@ contract OVM_ProxyEOA {
external
{
Lib_SafeExecutionManagerWrapper.safeREQUIRE(
msg.sender,
Lib_SafeExecutionManagerWrapper.safeADDRESS(msg.sender) == Lib_SafeExecutionManagerWrapper.safeCALLER(msg.sender),
Lib_SafeExecutionManagerWrapper.safeADDRESS() == Lib_SafeExecutionManagerWrapper.safeCALLER(),
"EOAs can only upgrade their own EOA implementation"
);
...
...
@@ -75,7 +72,6 @@ contract OVM_ProxyEOA {
{
return address(uint160(uint256(
Lib_SafeExecutionManagerWrapper.safeSLOAD(
msg.sender,
bytes32(uint256(0))
)
)));
...
...
@@ -91,7 +87,6 @@ contract OVM_ProxyEOA {
internal
{
Lib_SafeExecutionManagerWrapper.safeSSTORE(
msg.sender,
bytes32(uint256(0)),
bytes32(uint256(uint160(_implementation)))
);
...
...
packages/contracts/contracts/optimistic-ethereum/OVM/precompiles/OVM_ProxySequencerEntrypoint.sol
View file @
148cb966
...
...
@@ -16,7 +16,6 @@ contract OVM_ProxySequencerEntrypoint {
external
{
Lib_SafeExecutionManagerWrapper.safeDELEGATECALL(
msg.sender,
gasleft(),
_getImplementation(),
msg.data
...
...
@@ -35,7 +34,6 @@ contract OVM_ProxySequencerEntrypoint {
external
{
Lib_SafeExecutionManagerWrapper.safeREQUIRE(
msg.sender,
_getOwner() == address(0),
"ProxySequencerEntrypoint has already been inited"
);
...
...
@@ -49,8 +47,7 @@ contract OVM_ProxySequencerEntrypoint {
external
{
Lib_SafeExecutionManagerWrapper.safeREQUIRE(
msg.sender,
_getOwner() == Lib_SafeExecutionManagerWrapper.safeCALLER(msg.sender),
_getOwner() == Lib_SafeExecutionManagerWrapper.safeCALLER(),
"Only owner can upgrade the Entrypoint"
);
...
...
@@ -68,7 +65,6 @@ contract OVM_ProxySequencerEntrypoint {
internal
{
Lib_SafeExecutionManagerWrapper.safeSSTORE(
msg.sender,
bytes32(uint256(0)),
bytes32(uint256(uint160(_implementation)))
);
...
...
@@ -82,7 +78,6 @@ contract OVM_ProxySequencerEntrypoint {
{
return address(uint160(uint256(
Lib_SafeExecutionManagerWrapper.safeSLOAD(
msg.sender,
bytes32(uint256(0))
)
)));
...
...
@@ -94,7 +89,6 @@ contract OVM_ProxySequencerEntrypoint {
internal
{
Lib_SafeExecutionManagerWrapper.safeSSTORE(
msg.sender,
bytes32(uint256(1)),
bytes32(uint256(uint160(_owner)))
);
...
...
@@ -108,7 +102,6 @@ contract OVM_ProxySequencerEntrypoint {
{
return address(uint160(uint256(
Lib_SafeExecutionManagerWrapper.safeSLOAD(
msg.sender,
bytes32(uint256(1))
)
)));
...
...
packages/contracts/contracts/optimistic-ethereum/OVM/precompiles/OVM_SequencerEntrypoint.sol
View file @
148cb966
...
...
@@ -63,10 +63,10 @@ contract OVM_SequencerEntrypoint {
s
);
if (Lib_SafeExecutionManagerWrapper.safeEXTCODESIZE(
msg.sender,
target) == 0) {
if (Lib_SafeExecutionManagerWrapper.safeEXTCODESIZE(target) == 0) {
// ProxyEOA has not yet been deployed for this EOA.
bytes32 messageHash = Lib_ECDSAUtils.getMessageHash(encodedTx, isEthSignedMessage);
Lib_SafeExecutionManagerWrapper.safeCREATEEOA(m
sg.sender, m
essageHash, uint8(v), r, s);
Lib_SafeExecutionManagerWrapper.safeCREATEEOA(messageHash, uint8(v), r, s);
}
// ProxyEOA has been deployed for this EOA, continue to CALL.
...
...
@@ -80,7 +80,6 @@ contract OVM_SequencerEntrypoint {
);
Lib_SafeExecutionManagerWrapper.safeCALL(
msg.sender,
gasleft(),
target,
callbytes
...
...
@@ -111,7 +110,6 @@ contract OVM_SequencerEntrypoint {
return TransactionType.ETH_SIGNED_MESSAGE;
} else {
Lib_SafeExecutionManagerWrapper.safeREVERT(
msg.sender,
"Transaction type must be 0 or 2"
);
}
...
...
packages/contracts/contracts/optimistic-ethereum/libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol
View file @
148cb966
This diff is collapsed.
Click to expand it.
packages/contracts/contracts/optimistic-ethereum/mockOVM/accounts/mockOVM_ECDSAContractAccount.sol
View file @
148cb966
...
...
@@ -43,21 +43,18 @@ contract mockOVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
bytes memory _returndata
)
{
address ovmExecutionManager = msg.sender;
bool isEthSign = _signatureType == Lib_OVMCodec.EOASignatureType.ETH_SIGNED_MESSAGE;
Lib_OVMCodec.EIP155Transaction memory decodedTx = Lib_OVMCodec.decodeEIP155Transaction(_transaction, isEthSign);
// Need to make sure that the transaction nonce is right.
Lib_SafeExecutionManagerWrapper.safeREQUIRE(
msg.sender,
decodedTx.nonce == Lib_SafeExecutionManagerWrapper.safeGETNONCE(ovmExecutionManager),
decodedTx.nonce == Lib_SafeExecutionManagerWrapper.safeGETNONCE(),
"Transaction nonce does not match the expected nonce."
);
// Contract creations are signalled by sending a transaction to the zero address.
if (decodedTx.to == address(0)) {
address created = Lib_SafeExecutionManagerWrapper.safeCREATE(
ovmExecutionManager,
decodedTx.gasLimit,
decodedTx.data
);
...
...
@@ -68,10 +65,9 @@ contract mockOVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
// We only want to bump the nonce for `ovmCALL` because `ovmCREATE` automatically bumps
// the nonce of the calling account. Normally an EOA would bump the nonce for both
// cases, but since this is a contract we'd end up bumping the nonce twice.
Lib_SafeExecutionManagerWrapper.safeSETNONCE(
ovmExecutionManager,
decodedTx.nonce + 1);
Lib_SafeExecutionManagerWrapper.safeSETNONCE(decodedTx.nonce + 1);
return Lib_SafeExecutionManagerWrapper.safeCALL(
ovmExecutionManager,
decodedTx.gasLimit,
decodedTx.to,
decodedTx.data
...
...
@@ -91,7 +87,6 @@ contract mockOVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
)
{
return Lib_SafeExecutionManagerWrapper.safeCALL(
msg.sender,
_gasLimit,
_to,
_data
...
...
packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmCREATEEOA.spec.ts
View file @
148cb966
...
...
@@ -65,7 +65,7 @@ const test_ovmCREATEEOA: TestDefinition = {
address
:
'
0x17ec8597ff92C3F44523bDc65BF0f1bE632917ff
'
,
},
expectedReturnStatus
:
true
,
expectedReturnValue
:
16
38
,
expectedReturnValue
:
16
19
,
},
],
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment