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
9d9bbc93
Unverified
Commit
9d9bbc93
authored
Jan 19, 2022
by
Mark Tyneway
Committed by
GitHub
Jan 19, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2011 from tuxcanfly/tux/replica-fwd
l2geth: forward tx to sequencer
parents
e67e8508
805a42cd
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
83 additions
and
5 deletions
+83
-5
replica.spec.ts
integration-tests/test/replica.spec.ts
+27
-0
main.go
l2geth/cmd/geth/main.go
+1
-0
usage.go
l2geth/cmd/geth/usage.go
+1
-0
flags.go
l2geth/cmd/utils/flags.go
+8
-0
api_backend.go
l2geth/eth/api_backend.go
+4
-0
api.go
l2geth/internal/ethapi/api.go
+33
-5
backend.go
l2geth/internal/ethapi/backend.go
+1
-0
api_backend.go
l2geth/les/api_backend.go
+4
-0
config.go
l2geth/rollup/config.go
+2
-0
docker-compose.yml
ops/docker-compose.yml
+2
-0
No files found.
integration-tests/test/replica.spec.ts
View file @
9d9bbc93
...
...
@@ -71,5 +71,32 @@ describe('Replica Tests', () => {
expect
(
sequencerBlock
.
stateRoot
).
to
.
deep
.
eq
(
replicaBlock
.
stateRoot
)
expect
(
sequencerBlock
.
hash
).
to
.
deep
.
eq
(
replicaBlock
.
hash
)
})
it
(
'
should forward tx to sequencer
'
,
async
()
=>
{
const
tx
=
{
...
defaultTransactionFactory
(),
nonce
:
await
env
.
l2Wallet
.
getTransactionCount
(),
gasPrice
:
await
gasPriceForL2
(
env
),
}
const
signed
=
await
env
.
l2Wallet
.
signTransaction
(
tx
)
const
result
=
await
env
.
replicaProvider
.
sendTransaction
(
signed
)
let
receipt
:
TransactionReceipt
while
(
!
receipt
)
{
receipt
=
await
env
.
replicaProvider
.
getTransactionReceipt
(
result
.
hash
)
await
sleep
(
200
)
}
const
sequencerBlock
=
(
await
env
.
l2Provider
.
getBlock
(
result
.
blockNumber
))
as
any
const
replicaBlock
=
(
await
env
.
replicaProvider
.
getBlock
(
result
.
blockNumber
))
as
any
expect
(
sequencerBlock
.
stateRoot
).
to
.
deep
.
eq
(
replicaBlock
.
stateRoot
)
expect
(
sequencerBlock
.
hash
).
to
.
deep
.
eq
(
replicaBlock
.
hash
)
})
})
})
l2geth/cmd/geth/main.go
View file @
9d9bbc93
...
...
@@ -163,6 +163,7 @@ var (
utils
.
RollupEnforceFeesFlag
,
utils
.
RollupFeeThresholdDownFlag
,
utils
.
RollupFeeThresholdUpFlag
,
utils
.
SequencerClientHttpFlag
,
}
rpcFlags
=
[]
cli
.
Flag
{
...
...
l2geth/cmd/geth/usage.go
View file @
9d9bbc93
...
...
@@ -77,6 +77,7 @@ var AppHelpFlagGroups = []flagGroup{
utils
.
RollupEnforceFeesFlag
,
utils
.
RollupFeeThresholdDownFlag
,
utils
.
RollupFeeThresholdUpFlag
,
utils
.
SequencerClientHttpFlag
,
},
},
{
...
...
l2geth/cmd/utils/flags.go
View file @
9d9bbc93
...
...
@@ -861,6 +861,11 @@ var (
Usage
:
"Allow txs with fees above the current fee up to this amount, must be > 1"
,
EnvVar
:
"ROLLUP_FEE_THRESHOLD_UP"
,
}
SequencerClientHttpFlag
=
cli
.
StringFlag
{
Name
:
"sequencer.clienthttp"
,
Usage
:
"HTTP endpoint for the sequencer client"
,
EnvVar
:
"SEQUENCER_CLIENT_HTTP"
,
}
)
// MakeDataDir retrieves the currently requested data directory, terminating
...
...
@@ -1137,6 +1142,9 @@ func setRollup(ctx *cli.Context, cfg *rollup.Config) {
val
:=
ctx
.
GlobalFloat64
(
RollupFeeThresholdUpFlag
.
Name
)
cfg
.
FeeThresholdUp
=
new
(
big
.
Float
)
.
SetFloat64
(
val
)
}
if
ctx
.
GlobalIsSet
(
SequencerClientHttpFlag
.
Name
)
{
cfg
.
SequencerClientHttp
=
ctx
.
GlobalString
(
SequencerClientHttpFlag
.
Name
)
}
}
// setLes configures the les server and ultra light client settings from the command line flags.
...
...
l2geth/eth/api_backend.go
View file @
9d9bbc93
...
...
@@ -136,6 +136,10 @@ func (b *EthAPIBackend) IngestTransactions(txs []*types.Transaction) error {
return
nil
}
func
(
b
*
EthAPIBackend
)
SequencerClientHttp
()
string
{
return
b
.
eth
.
config
.
Rollup
.
SequencerClientHttp
}
func
(
b
*
EthAPIBackend
)
HeaderByNumber
(
ctx
context
.
Context
,
number
rpc
.
BlockNumber
)
(
*
types
.
Header
,
error
)
{
// Pending block is only known by the miner
if
number
==
rpc
.
PendingBlockNumber
{
...
...
l2geth/internal/ethapi/api.go
View file @
9d9bbc93
...
...
@@ -40,6 +40,7 @@ import (
"github.com/ethereum-optimism/optimism/l2geth/core/types"
"github.com/ethereum-optimism/optimism/l2geth/core/vm"
"github.com/ethereum-optimism/optimism/l2geth/crypto"
"github.com/ethereum-optimism/optimism/l2geth/ethclient"
"github.com/ethereum-optimism/optimism/l2geth/log"
"github.com/ethereum-optimism/optimism/l2geth/p2p"
"github.com/ethereum-optimism/optimism/l2geth/params"
...
...
@@ -51,6 +52,12 @@ import (
var
errOVMUnsupported
=
errors
.
New
(
"OVM: Unsupported RPC Method"
)
const
(
// defaultDialTimeout is default duration the service will wait on
// startup to make a connection to either the L1 or L2 backends.
defaultDialTimeout
=
5
*
time
.
Second
)
// PublicEthereumAPI provides an API to access Ethereum related information.
// It offers only methods that operate on public data that is freely available to anyone.
type
PublicEthereumAPI
struct
{
...
...
@@ -1289,6 +1296,18 @@ func newRPCTransactionFromBlockHash(b *types.Block, hash common.Hash) *RPCTransa
return
nil
}
// dialSequencerClientWithTimeout attempts to dial the Sequencer using the
// provided URL. If the dial doesn't complete within defaultDialTimeout
// seconds, this method will return an error.
func
dialSequencerClientWithTimeout
(
ctx
context
.
Context
,
url
string
)
(
*
ethclient
.
Client
,
error
)
{
ctxt
,
cancel
:=
context
.
WithTimeout
(
ctx
,
defaultDialTimeout
)
defer
cancel
()
return
ethclient
.
DialContext
(
ctxt
,
url
)
}
// PublicTransactionPoolAPI exposes methods for the RPC interface
type
PublicTransactionPoolAPI
struct
{
b
Backend
...
...
@@ -1649,18 +1668,27 @@ func (s *PublicTransactionPoolAPI) FillTransaction(ctx context.Context, args Sen
// SendRawTransaction will add the signed transaction to the transaction pool.
// The sender is responsible for signing the transaction and using the correct nonce.
func
(
s
*
PublicTransactionPoolAPI
)
SendRawTransaction
(
ctx
context
.
Context
,
encodedTx
hexutil
.
Bytes
)
(
common
.
Hash
,
error
)
{
if
s
.
b
.
IsVerifier
()
{
return
common
.
Hash
{},
errors
.
New
(
"Cannot send raw transaction in verifier mode"
)
tx
:=
new
(
types
.
Transaction
)
if
err
:=
rlp
.
DecodeBytes
(
encodedTx
,
tx
);
err
!=
nil
{
return
common
.
Hash
{},
err
}
if
s
.
b
.
IsSyncing
()
{
return
common
.
Hash
{},
errors
.
New
(
"Cannot send raw transaction while syncing"
)
}
tx
:=
new
(
types
.
Transaction
)
if
err
:=
rlp
.
DecodeBytes
(
encodedTx
,
tx
);
err
!=
nil
{
if
s
.
b
.
IsVerifier
()
{
client
,
err
:=
dialSequencerClientWithTimeout
(
ctx
,
s
.
b
.
SequencerClientHttp
())
if
err
!=
nil
{
return
common
.
Hash
{},
err
}
err
=
client
.
SendTransaction
(
context
.
Background
(),
tx
)
if
err
!=
nil
{
return
common
.
Hash
{},
err
}
return
tx
.
Hash
(),
nil
}
// L1Timestamp and L1BlockNumber will be set right before execution
txMeta
:=
types
.
NewTransactionMeta
(
nil
,
0
,
nil
,
types
.
QueueOriginSequencer
,
nil
,
nil
,
encodedTx
)
tx
.
SetTransactionMeta
(
txMeta
)
...
...
l2geth/internal/ethapi/backend.go
View file @
9d9bbc93
...
...
@@ -96,6 +96,7 @@ type Backend interface {
SuggestL2GasPrice
(
context
.
Context
)
(
*
big
.
Int
,
error
)
SetL2GasPrice
(
context
.
Context
,
*
big
.
Int
)
error
IngestTransactions
([]
*
types
.
Transaction
)
error
SequencerClientHttp
()
string
}
func
GetAPIs
(
apiBackend
Backend
)
[]
rpc
.
API
{
...
...
l2geth/les/api_backend.go
View file @
9d9bbc93
...
...
@@ -86,6 +86,10 @@ func (b *LesApiBackend) IngestTransactions([]*types.Transaction) error {
panic
(
"not implemented"
)
}
func
(
b
*
LesApiBackend
)
SequencerClientHttp
()
string
{
return
b
.
eth
.
config
.
Rollup
.
SequencerClientHttp
}
func
(
b
*
LesApiBackend
)
HeaderByNumber
(
ctx
context
.
Context
,
number
rpc
.
BlockNumber
)
(
*
types
.
Header
,
error
)
{
if
number
==
rpc
.
LatestBlockNumber
||
number
==
rpc
.
PendingBlockNumber
{
return
b
.
eth
.
blockchain
.
CurrentHeader
(),
nil
...
...
l2geth/rollup/config.go
View file @
9d9bbc93
...
...
@@ -37,4 +37,6 @@ type Config struct {
// quoted and the transaction being executed
FeeThresholdDown
*
big
.
Float
FeeThresholdUp
*
big
.
Float
// HTTP endpoint of the sequencer
SequencerClientHttp
string
}
ops/docker-compose.yml
View file @
9d9bbc93
...
...
@@ -159,6 +159,7 @@ services:
replica
:
depends_on
:
-
dtl
-
l2geth
deploy
:
replicas
:
1
build
:
...
...
@@ -169,6 +170,7 @@ services:
-
./envs/geth.env
environment
:
ETH1_HTTP
:
http://l1_chain:8545
SEQUENCER_CLIENT_HTTP
:
http://l2geth:8545
ROLLUP_STATE_DUMP_PATH
:
http://deployer:8081/state-dump.latest.json
ROLLUP_CLIENT_HTTP
:
http://dtl:7878
ROLLUP_BACKEND
:
'
l2'
...
...
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