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
ec1bcd48
Commit
ec1bcd48
authored
Nov 18, 2021
by
kf
Committed by
Mark Tyneway
Nov 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update rollup client for unprotected tx support
parent
27452790
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
22 deletions
+27
-22
package.json
integration-tests/package.json
+1
-0
replica.spec.ts
integration-tests/test/replica.spec.ts
+5
-4
client.go
l2geth/rollup/client.go
+20
-13
eth-tx.ts
packages/data-transport-layer/src/utils/eth-tx.ts
+1
-5
No files found.
integration-tests/package.json
View file @
ec1bcd48
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
"@eth-optimism/contracts"
:
"0.5.4"
,
"@eth-optimism/contracts"
:
"0.5.4"
,
"@eth-optimism/core-utils"
:
"0.7.2"
,
"@eth-optimism/core-utils"
:
"0.7.2"
,
"@eth-optimism/message-relayer"
:
"0.2.4"
,
"@eth-optimism/message-relayer"
:
"0.2.4"
,
"@ethersproject/abstract-provider"
:
"^5.5.1"
,
"@ethersproject/providers"
:
"^5.4.5"
,
"@ethersproject/providers"
:
"^5.4.5"
,
"@ethersproject/transactions"
:
"^5.4.0"
,
"@ethersproject/transactions"
:
"^5.4.0"
,
"@nomiclabs/hardhat-ethers"
:
"^2.0.2"
,
"@nomiclabs/hardhat-ethers"
:
"^2.0.2"
,
...
...
integration-tests/test/replica.spec.ts
View file @
ec1bcd48
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
defaultTransactionFactory
,
gasPriceForL2
,
sleep
}
from
'
./shared/utils
'
import
{
defaultTransactionFactory
,
gasPriceForL2
,
sleep
}
from
'
./shared/utils
'
import
{
expect
}
from
'
chai
'
import
{
expect
}
from
'
chai
'
import
{
TransactionReceipt
}
from
'
@ethersproject/abstract-provider
'
describe
(
'
Replica Tests
'
,
()
=>
{
describe
(
'
Replica Tests
'
,
()
=>
{
let
env
:
OptimismEnv
let
env
:
OptimismEnv
...
@@ -12,10 +13,10 @@ describe('Replica Tests', () => {
...
@@ -12,10 +13,10 @@ describe('Replica Tests', () => {
describe
(
'
Matching blocks
'
,
()
=>
{
describe
(
'
Matching blocks
'
,
()
=>
{
it
(
'
should sync a transaction
'
,
async
()
=>
{
it
(
'
should sync a transaction
'
,
async
()
=>
{
const
tx
=
defaultTransactionFactory
()
const
tx
=
defaultTransactionFactory
()
tx
.
gasPrice
=
await
gasPriceForL2
()
tx
.
gasPrice
=
await
gasPriceForL2
(
env
)
const
result
=
await
env
.
l2Wallet
.
sendTransaction
(
tx
)
const
result
=
await
env
.
l2Wallet
.
sendTransaction
(
tx
)
let
receipt
let
receipt
:
TransactionReceipt
while
(
!
receipt
)
{
while
(
!
receipt
)
{
receipt
=
await
env
.
replicaProvider
.
getTransactionReceipt
(
result
.
hash
)
receipt
=
await
env
.
replicaProvider
.
getTransactionReceipt
(
result
.
hash
)
await
sleep
(
200
)
await
sleep
(
200
)
...
@@ -37,13 +38,13 @@ describe('Replica Tests', () => {
...
@@ -37,13 +38,13 @@ describe('Replica Tests', () => {
const
tx
=
{
const
tx
=
{
...
defaultTransactionFactory
(),
...
defaultTransactionFactory
(),
nonce
:
await
env
.
l2Wallet
.
getTransactionCount
(),
nonce
:
await
env
.
l2Wallet
.
getTransactionCount
(),
gasPrice
:
await
gasPriceForL2
(),
gasPrice
:
await
gasPriceForL2
(
env
),
chainId
:
null
,
// Disables EIP155 transaction signing.
chainId
:
null
,
// Disables EIP155 transaction signing.
}
}
const
signed
=
await
env
.
l2Wallet
.
signTransaction
(
tx
)
const
signed
=
await
env
.
l2Wallet
.
signTransaction
(
tx
)
const
result
=
await
env
.
l2Provider
.
sendTransaction
(
signed
)
const
result
=
await
env
.
l2Provider
.
sendTransaction
(
signed
)
let
receipt
let
receipt
:
TransactionReceipt
while
(
!
receipt
)
{
while
(
!
receipt
)
{
receipt
=
await
env
.
replicaProvider
.
getTransactionReceipt
(
result
.
hash
)
receipt
=
await
env
.
replicaProvider
.
getTransactionReceipt
(
result
.
hash
)
await
sleep
(
200
)
await
sleep
(
200
)
...
...
l2geth/rollup/client.go
View file @
ec1bcd48
...
@@ -135,7 +135,7 @@ type RollupClient interface {
...
@@ -135,7 +135,7 @@ type RollupClient interface {
// Client is an HTTP based RollupClient
// Client is an HTTP based RollupClient
type
Client
struct
{
type
Client
struct
{
client
*
resty
.
Client
client
*
resty
.
Client
signer
*
types
.
EIP155Signer
chainID
*
big
.
Int
}
}
// TransactionResponse represents the response from the remote server when
// TransactionResponse represents the response from the remote server when
...
@@ -166,11 +166,10 @@ func NewClient(url string, chainID *big.Int) *Client {
...
@@ -166,11 +166,10 @@ func NewClient(url string, chainID *big.Int) *Client {
}
}
return
nil
return
nil
})
})
signer
:=
types
.
NewEIP155Signer
(
chainID
)
return
&
Client
{
return
&
Client
{
client
:
client
,
client
:
client
,
signer
:
&
signer
,
chainID
:
chainID
,
}
}
}
}
...
@@ -322,7 +321,7 @@ func (c *Client) GetLatestTransactionBatchIndex() (*uint64, error) {
...
@@ -322,7 +321,7 @@ func (c *Client) GetLatestTransactionBatchIndex() (*uint64, error) {
// batchedTransactionToTransaction converts a transaction into a
// batchedTransactionToTransaction converts a transaction into a
// types.Transaction that can be consumed by the SyncService
// types.Transaction that can be consumed by the SyncService
func
batchedTransactionToTransaction
(
res
*
transaction
,
signer
*
types
.
EIP155Signer
)
(
*
types
.
Transaction
,
error
)
{
func
batchedTransactionToTransaction
(
res
*
transaction
,
chainID
*
big
.
Int
)
(
*
types
.
Transaction
,
error
)
{
// `nil` transactions are not found
// `nil` transactions are not found
if
res
==
nil
{
if
res
==
nil
{
return
nil
,
errElementNotFound
return
nil
,
errElementNotFound
...
@@ -373,7 +372,15 @@ func batchedTransactionToTransaction(res *transaction, signer *types.EIP155Signe
...
@@ -373,7 +372,15 @@ func batchedTransactionToTransaction(res *transaction, signer *types.EIP155Signe
sig
:=
make
([]
byte
,
crypto
.
SignatureLength
)
sig
:=
make
([]
byte
,
crypto
.
SignatureLength
)
copy
(
sig
[
32
-
len
(
r
)
:
32
],
r
)
copy
(
sig
[
32
-
len
(
r
)
:
32
],
r
)
copy
(
sig
[
64
-
len
(
s
)
:
64
],
s
)
copy
(
sig
[
64
-
len
(
s
)
:
64
],
s
)
var
signer
types
.
Signer
if
res
.
Decoded
.
Signature
.
V
==
27
||
res
.
Decoded
.
Signature
.
V
==
28
{
signer
=
types
.
HomesteadSigner
{}
sig
[
64
]
=
byte
(
res
.
Decoded
.
Signature
.
V
-
27
)
}
else
{
signer
=
types
.
NewEIP155Signer
(
chainID
)
sig
[
64
]
=
byte
(
res
.
Decoded
.
Signature
.
V
)
sig
[
64
]
=
byte
(
res
.
Decoded
.
Signature
.
V
)
}
tx
,
err
:=
tx
.
WithSignature
(
signer
,
sig
[
:
])
tx
,
err
:=
tx
.
WithSignature
(
signer
,
sig
[
:
])
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -431,7 +438,7 @@ func (c *Client) GetTransaction(index uint64, backend Backend) (*types.Transacti
...
@@ -431,7 +438,7 @@ func (c *Client) GetTransaction(index uint64, backend Backend) (*types.Transacti
if
!
ok
{
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"could not get tx with index %d"
,
index
)
return
nil
,
fmt
.
Errorf
(
"could not get tx with index %d"
,
index
)
}
}
return
batchedTransactionToTransaction
(
res
.
Transaction
,
c
.
signer
)
return
batchedTransactionToTransaction
(
res
.
Transaction
,
c
.
chainID
)
}
}
// GetLatestTransaction will get the latest transaction, meaning the transaction
// GetLatestTransaction will get the latest transaction, meaning the transaction
...
@@ -452,7 +459,7 @@ func (c *Client) GetLatestTransaction(backend Backend) (*types.Transaction, erro
...
@@ -452,7 +459,7 @@ func (c *Client) GetLatestTransaction(backend Backend) (*types.Transaction, erro
return
nil
,
errors
.
New
(
"Cannot get latest transaction"
)
return
nil
,
errors
.
New
(
"Cannot get latest transaction"
)
}
}
return
batchedTransactionToTransaction
(
res
.
Transaction
,
c
.
signer
)
return
batchedTransactionToTransaction
(
res
.
Transaction
,
c
.
chainID
)
}
}
// GetEthContext will return the EthContext by block number
// GetEthContext will return the EthContext by block number
...
@@ -564,7 +571,7 @@ func (c *Client) GetLatestTransactionBatch() (*Batch, []*types.Transaction, erro
...
@@ -564,7 +571,7 @@ func (c *Client) GetLatestTransactionBatch() (*Batch, []*types.Transaction, erro
if
!
ok
{
if
!
ok
{
return
nil
,
nil
,
fmt
.
Errorf
(
"Cannot parse transaction batch response"
)
return
nil
,
nil
,
fmt
.
Errorf
(
"Cannot parse transaction batch response"
)
}
}
return
parseTransactionBatchResponse
(
txBatch
,
c
.
signer
)
return
parseTransactionBatchResponse
(
txBatch
,
c
.
chainID
)
}
}
// GetTransactionBatch will return the transaction batch by batch index
// GetTransactionBatch will return the transaction batch by batch index
...
@@ -584,19 +591,19 @@ func (c *Client) GetTransactionBatch(index uint64) (*Batch, []*types.Transaction
...
@@ -584,19 +591,19 @@ func (c *Client) GetTransactionBatch(index uint64) (*Batch, []*types.Transaction
if
!
ok
{
if
!
ok
{
return
nil
,
nil
,
fmt
.
Errorf
(
"Cannot parse transaction batch response"
)
return
nil
,
nil
,
fmt
.
Errorf
(
"Cannot parse transaction batch response"
)
}
}
return
parseTransactionBatchResponse
(
txBatch
,
c
.
signer
)
return
parseTransactionBatchResponse
(
txBatch
,
c
.
chainID
)
}
}
// parseTransactionBatchResponse will turn a TransactionBatchResponse into a
// parseTransactionBatchResponse will turn a TransactionBatchResponse into a
// Batch and its corresponding types.Transactions
// Batch and its corresponding types.Transactions
func
parseTransactionBatchResponse
(
txBatch
*
TransactionBatchResponse
,
signer
*
types
.
EIP155Signer
)
(
*
Batch
,
[]
*
types
.
Transaction
,
error
)
{
func
parseTransactionBatchResponse
(
txBatch
*
TransactionBatchResponse
,
chainID
*
big
.
Int
)
(
*
Batch
,
[]
*
types
.
Transaction
,
error
)
{
if
txBatch
==
nil
||
txBatch
.
Batch
==
nil
{
if
txBatch
==
nil
||
txBatch
.
Batch
==
nil
{
return
nil
,
nil
,
errElementNotFound
return
nil
,
nil
,
errElementNotFound
}
}
batch
:=
txBatch
.
Batch
batch
:=
txBatch
.
Batch
txs
:=
make
([]
*
types
.
Transaction
,
len
(
txBatch
.
Transactions
))
txs
:=
make
([]
*
types
.
Transaction
,
len
(
txBatch
.
Transactions
))
for
i
,
tx
:=
range
txBatch
.
Transactions
{
for
i
,
tx
:=
range
txBatch
.
Transactions
{
transaction
,
err
:=
batchedTransactionToTransaction
(
tx
,
signer
)
transaction
,
err
:=
batchedTransactionToTransaction
(
tx
,
chainID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
fmt
.
Errorf
(
"Cannot parse transaction batch: %w"
,
err
)
return
nil
,
nil
,
fmt
.
Errorf
(
"Cannot parse transaction batch: %w"
,
err
)
}
}
...
...
packages/data-transport-layer/src/utils/eth-tx.ts
View file @
ec1bcd48
...
@@ -6,13 +6,9 @@ export const parseSignatureVParam = (
...
@@ -6,13 +6,9 @@ export const parseSignatureVParam = (
chainId
:
number
chainId
:
number
):
number
=>
{
):
number
=>
{
v
=
ethers
.
BigNumber
.
from
(
v
).
toNumber
()
v
=
ethers
.
BigNumber
.
from
(
v
).
toNumber
()
// Handle normalized v
if
(
v
===
0
||
v
===
1
)
{
return
v
}
// Handle unprotected transactions
// Handle unprotected transactions
if
(
v
===
27
||
v
===
28
)
{
if
(
v
===
27
||
v
===
28
)
{
return
v
-
27
return
v
}
}
// Handle EIP155 transactions
// Handle EIP155 transactions
return
v
-
2
*
chainId
-
35
return
v
-
2
*
chainId
-
35
...
...
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