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
66e55e89
Commit
66e55e89
authored
Nov 30, 2020
by
Alina
Committed by
GitHub
Nov 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chainId check (#83)
* chainId check * test fix + cleanup
parent
fa3c557c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
1 deletion
+40
-1
OVM_ECDSAContractAccount.sol
...mistic-ethereum/OVM/accounts/OVM_ECDSAContractAccount.sol
+6
-0
mockOVM_ECDSAContractAccount.sol
...thereum/mockOVM/accounts/mockOVM_ECDSAContractAccount.sol
+6
-0
OVM_ECDSAContractAccount.spec.ts
...t/contracts/OVM/accounts/OVM_ECDSAContractAccount.spec.ts
+27
-0
encoding.ts
packages/contracts/test/helpers/codec/encoding.ts
+1
-1
No files found.
packages/contracts/contracts/optimistic-ethereum/OVM/accounts/OVM_ECDSAContractAccount.sol
View file @
66e55e89
...
@@ -64,6 +64,12 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
...
@@ -64,6 +64,12 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
Lib_OVMCodec.EIP155Transaction memory decodedTx = Lib_OVMCodec.decodeEIP155Transaction(_transaction, isEthSign);
Lib_OVMCodec.EIP155Transaction memory decodedTx = Lib_OVMCodec.decodeEIP155Transaction(_transaction, isEthSign);
// Need to make sure that the transaction chainId is correct.
Lib_SafeExecutionManagerWrapper.safeREQUIRE(
decodedTx.chainId == Lib_SafeExecutionManagerWrapper.safeCHAINID(),
"Transaction chainId does not match expected OVM chainId."
);
// Need to make sure that the transaction nonce is right.
// Need to make sure that the transaction nonce is right.
Lib_SafeExecutionManagerWrapper.safeREQUIRE(
Lib_SafeExecutionManagerWrapper.safeREQUIRE(
decodedTx.nonce == Lib_SafeExecutionManagerWrapper.safeGETNONCE(),
decodedTx.nonce == Lib_SafeExecutionManagerWrapper.safeGETNONCE(),
...
...
packages/contracts/contracts/optimistic-ethereum/mockOVM/accounts/mockOVM_ECDSAContractAccount.sol
View file @
66e55e89
...
@@ -46,6 +46,12 @@ contract mockOVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
...
@@ -46,6 +46,12 @@ contract mockOVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
bool isEthSign = _signatureType == Lib_OVMCodec.EOASignatureType.ETH_SIGNED_MESSAGE;
bool isEthSign = _signatureType == Lib_OVMCodec.EOASignatureType.ETH_SIGNED_MESSAGE;
Lib_OVMCodec.EIP155Transaction memory decodedTx = Lib_OVMCodec.decodeEIP155Transaction(_transaction, isEthSign);
Lib_OVMCodec.EIP155Transaction memory decodedTx = Lib_OVMCodec.decodeEIP155Transaction(_transaction, isEthSign);
// Need to make sure that the transaction chainId is correct.
Lib_SafeExecutionManagerWrapper.safeREQUIRE(
decodedTx.chainId == Lib_SafeExecutionManagerWrapper.safeCHAINID(),
"Transaction chainId does not match expected OVM chainId."
);
// Need to make sure that the transaction nonce is right.
// Need to make sure that the transaction nonce is right.
Lib_SafeExecutionManagerWrapper.safeREQUIRE(
Lib_SafeExecutionManagerWrapper.safeREQUIRE(
decodedTx.nonce == Lib_SafeExecutionManagerWrapper.safeGETNONCE(),
decodedTx.nonce == Lib_SafeExecutionManagerWrapper.safeGETNONCE(),
...
...
packages/contracts/test/contracts/OVM/accounts/OVM_ECDSAContractAccount.spec.ts
View file @
66e55e89
...
@@ -200,5 +200,32 @@ describe('OVM_ECDSAContractAccount', () => {
...
@@ -200,5 +200,32 @@ describe('OVM_ECDSAContractAccount', () => {
'
Transaction nonce does not match the expected nonce.
'
'
Transaction nonce does not match the expected nonce.
'
)
)
})
})
it
(
`should revert on incorrect chainId`
,
async
()
=>
{
const
alteredChainIdTx
=
{
...
DEFAULT_EIP155_TX
,
chainId
:
421
}
const
message
=
serializeNativeTransaction
(
alteredChainIdTx
)
const
sig
=
await
signNativeTransaction
(
wallet
,
alteredChainIdTx
)
await
callPrecompile
(
Helper_PrecompileCaller
,
OVM_ECDSAContractAccount
,
'
execute
'
,
[
message
,
0
,
//isEthSignedMessage
`0x
${
sig
.
v
}
`
,
//v
`0x
${
sig
.
r
}
`
,
//r
`0x
${
sig
.
s
}
`
,
//s
]
)
const
ovmREVERT
:
any
=
Mock__OVM_ExecutionManager
.
smocked
.
ovmREVERT
.
calls
[
0
]
expect
(
ethers
.
utils
.
toUtf8String
(
ovmREVERT
.
_data
)).
to
.
equal
(
'
Transaction chainId does not match expected OVM chainId.
'
)
})
})
})
})
})
packages/contracts/test/helpers/codec/encoding.ts
View file @
66e55e89
...
@@ -121,7 +121,7 @@ export const signNativeTransaction = async (
...
@@ -121,7 +121,7 @@ export const signNativeTransaction = async (
let
[
v
,
r
,
s
]
=
getSignedComponents
(
transactionSignature
).
map
((
component
)
=>
{
let
[
v
,
r
,
s
]
=
getSignedComponents
(
transactionSignature
).
map
((
component
)
=>
{
return
remove0x
(
component
)
return
remove0x
(
component
)
})
})
v
=
'
0
'
+
(
parseInt
(
v
,
16
)
-
420
*
2
-
8
-
27
)
v
=
'
0
'
+
(
parseInt
(
v
,
16
)
-
transaction
.
chainId
*
2
-
8
-
27
)
return
{
return
{
messageHash
,
messageHash
,
v
,
v
,
...
...
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