-
Notifications
You must be signed in to change notification settings - Fork 118
feat: Use standard RLP transactions #300
base: master
Are you sure you want to change the base?
Conversation
@@ -3,8 +3,6 @@ pragma solidity >0.5.0 <0.8.0; | |||
|
|||
/* Library Imports */ | |||
import { Lib_Bytes32Utils } from "../../libraries/utils/Lib_Bytes32Utils.sol"; | |||
import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files were unused, I removed them.
import { Lib_BytesUtils } from "../../libraries/utils/Lib_BytesUtils.sol"; | ||
import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; | ||
import { Lib_ECDSAUtils } from "../../libraries/utils/Lib_ECDSAUtils.sol"; | ||
import { Lib_EIP155Tx } from "../../libraries/codec/Lib_EIP155Tx.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file gets way simpler.
@@ -0,0 +1,111 @@ | |||
// SPDX-License-Identifier: MIT | |||
pragma solidity >0.5.0 <0.9.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pulled decoding logic into this file to make review easier. It's mostly the same as what was originally in OVM codec. We can confirm this with some careful review.
@@ -1,98 +0,0 @@ | |||
// SPDX-License-Identifier: MIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File is no longer needed.
@@ -1,95 +0,0 @@ | |||
// SPDX-License-Identifier: MIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use this in geth and we shouldn't use this in ethereumjs-vm
.
@@ -1,22 +1,4 @@ | |||
{ | |||
"tests": { | |||
"decompressEIP155Transaction": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests move to new eip155tx
library.
address to; | ||
uint256 value; | ||
bytes data; | ||
uint8 recoveryParam; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is basically just caching the recovery param so that it is only computed once instead of needing to compute it when calling sender
which is only called once and is always called. Might save gas to use it depending on how well packed this struct can be made
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Given a chain ID, the recovery param will never change. So it seems a bit easier to compute this once (we do actually end up computing this in two different places otherwise).
Overall good changes. The abi is changing, we need to make sure to not break everything when we publish these changes. Also we dont have hardhat deploy so there are no deployment artifacts in this repo so we need to be mindful about this change. |
TransactionType transactionType = _getTransactionType(Lib_BytesUtils.toUint8(msg.data, 0)); | ||
|
||
bytes32 r = Lib_BytesUtils.toBytes32(Lib_BytesUtils.slice(msg.data, 1, 32)); | ||
bytes32 s = Lib_BytesUtils.toBytes32(Lib_BytesUtils.slice(msg.data, 33, 32)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removes the calls to slice
which is good
The calldata size of using a RLP encoded tx is about ~250 gas more than using the custom serialization. Trading a bit of cost for simplicity, but its possible that the gas usage was decreased elsewhere in these changes. We really need automated gas metering in CI |
import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol"; | ||
import { Lib_SafeMathWrapper } from "../../libraries/wrappers/Lib_SafeMathWrapper.sol"; | ||
|
||
import { console } from "hardhat/console.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is WIP, but just noting to remove this
bytes memory _out | ||
) | ||
{ | ||
return writeBytes(abi.encodePacked(_in)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bytes32
isn't treated any differently from bytes
when it comes to RLP.
const message = serializeNativeTransaction(DEFAULT_EIP155_TX) | ||
const sig = await signNativeTransaction(wallet, DEFAULT_EIP155_TX) | ||
const transaction = DEFAULT_EIP155_TX | ||
const encodedTransaction = await wallet.signTransaction(transaction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests get way simpler.
@@ -0,0 +1,248 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using this test file as the source of these tests: https://github.com/ethereumjs/ethereumjs-tx/blob/master/test/ttTransactionTestEip155VitaliksTests.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't test hash
here, but sender
implicitly tests this under the hood so it should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Covers tests for decode
, encode
, and sender
.
"0x044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d", | ||
"0x01", | ||
"0x00", | ||
false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Format is:
[
"0x00", // nonce
"0x04a817c800", // gasPrice
"0x5208", // gasLimit
"0x3535353535353535353535353535353535353535", // to
"0x00", // value
"0x", // data
"0x25", // v
"0x044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d", // r
"0x044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d", // s
"0x01", // chainId
"0x00", // recoveryParam
false // isCreate
]
@@ -4,10 +4,16 @@ import { expect } from '../../setup' | |||
import { ethers } from 'hardhat' | |||
import { Contract, BigNumber } from 'ethers' | |||
|
|||
const bigNumberify = (arr) => { | |||
const bnRegex = /^\d+n$/gm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made this generally more reliable. Treat more things as big numbers so that equality checking is easier.
) | ||
const ovmREVERT: any = | ||
Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0] | ||
expect(decodeSolidityError(ovmREVERT._data)).to.equal( | ||
'Transaction chainId does not match expected OVM chainId.' | ||
'OVM_ECDSAContractAccount: Transaction was signed with the wrong chain ID.' | ||
) | ||
}) | ||
|
||
// TEMPORARY: Skip gas checks for minnet. | ||
it.skip(`should revert on insufficient gas`, async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skipped test has been modified. Should double check it still passes
Note that this change must be done in a way that is backwards compatible with the current ctc elements. From the point of view of geth, the old contract must be used when syncing the initial set of transactions. This makes me lean towards not changing the contract and adding a new one that is This means that geth needs the old serialization logic still and we need a way to selectively set |
CI Fails at:
|
Converting to draft until checks pass. |
Is this dead? |
Description
Updates our sequencer entrypoint and ECDSA contracts to use the standard RLP encoding that we're using in geth now.
Metadata
Fixes
Contributing Agreement