Commit c00b59eb authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge branch 'develop' into feat/output-tx-calldata

parents 5af9b7b2 1aa2944d
package op_batcher
package batcher
import (
"time"
......
package op_batcher
package batcher
import (
"context"
......@@ -12,7 +12,6 @@ import (
"time"
hdwallet "github.com/ethereum-optimism/go-ethereum-hdwallet"
"github.com/ethereum-optimism/optimism/op-batcher/sequencer"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-proposer/txmgr"
"github.com/ethereum/go-ethereum/accounts"
......@@ -27,7 +26,7 @@ import (
type BatchSubmitter struct {
txMgr *TransactionManager
addr common.Address
cfg sequencer.Config
cfg DriverConfig
wg sync.WaitGroup
done chan struct{}
log log.Logger
......@@ -141,7 +140,7 @@ func NewBatchSubmitterWithSigner(cfg Config, addr common.Address, signer SignerF
SafeAbortNonceTooLowCount: cfg.SafeAbortNonceTooLowCount,
}
batcherCfg := sequencer.Config{
batcherCfg := DriverConfig{
Log: l,
Name: "Batch Submitter",
L1Client: l1Client,
......
package sequencer
package batcher
import (
"math/big"
......@@ -11,7 +11,7 @@ import (
"github.com/ethereum/go-ethereum/log"
)
type Config struct {
type DriverConfig struct {
Log log.Logger
Name string
......
package op_batcher
package batcher
import (
"context"
......
package op_batcher
package batcher
import (
"context"
......
......@@ -6,7 +6,7 @@ import (
"github.com/urfave/cli"
batcher "github.com/ethereum-optimism/optimism/op-batcher"
"github.com/ethereum-optimism/optimism/op-batcher/batcher"
"github.com/ethereum-optimism/optimism/op-batcher/flags"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum/go-ethereum/log"
......
......@@ -226,6 +226,7 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m
"height", bedrockHeader.Number,
"root", bedrockHeader.Root.String(),
"hash", bedrockHeader.Hash().String(),
"timestamp", bedrockHeader.Time,
)
return res, nil
......
......@@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-proposer/drivers/l2output"
"github.com/ethereum-optimism/optimism/op-proposer/proposer"
opcrypto "github.com/ethereum-optimism/optimism/op-service/crypto"
)
......@@ -24,7 +24,7 @@ type ProposerCfg struct {
type L2Proposer struct {
log log.Logger
l1 *ethclient.Client
driver *l2output.Driver
driver *proposer.Driver
address common.Address
lastTx common.Hash
}
......@@ -32,7 +32,7 @@ type L2Proposer struct {
func NewL2Proposer(t Testing, log log.Logger, cfg *ProposerCfg, l1 *ethclient.Client, rollupCl *sources.RollupClient) *L2Proposer {
chainID, err := l1.ChainID(t.Ctx())
require.NoError(t, err)
dr, err := l2output.NewDriver(l2output.Config{
dr, err := proposer.NewDriver(proposer.DriverConfig{
Log: log,
Name: "proposer",
L1Client: l1,
......
package actions
import (
"math/rand"
"path"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
......@@ -21,6 +23,10 @@ func setupReorgTest(t Testing) (*e2eutils.SetupData, *L1Miner, *L2Sequencer, *L2
dp := e2eutils.MakeDeployParams(t, defaultRollupTestParams)
sd := e2eutils.Setup(t, dp, defaultAlloc)
log := testlog.Logger(t, log.LvlDebug)
return setupReorgTestActors(t, dp, sd, log)
}
func setupReorgTestActors(t Testing, dp *e2eutils.DeployParams, sd *e2eutils.SetupData, log log.Logger) (*e2eutils.SetupData, *L1Miner, *L2Sequencer, *L2Engine, *L2Verifier, *L2Engine, *L2Batcher) {
miner, seqEngine, sequencer := setupSequencerTest(t, sd, log)
miner.ActL1SetFeeRecipient(common.Address{'A'})
sequencer.ActL2PipelineFull(t)
......@@ -357,3 +363,115 @@ func TestRestartOpGeth(gt *testing.T) {
require.Equal(t, statusBeforeRestart.UnsafeL2, sequencer.L2Unsafe(), "expecting to keep same unsafe head upon restart")
require.Equal(t, statusBeforeRestart.SafeL2, sequencer.L2Safe(), "expecting the safe block to catch up to what it was before shutdown after syncing from L1, and not be stuck at the finalized block")
}
// TestConflictingL2Blocks tests that a second copy of the sequencer stack cannot introduce an alternative
// L2 block (compared to something already secured by the first sequencer):
// the alt block is not synced by the verifier, in unsafe and safe sync modes.
func TestConflictingL2Blocks(gt *testing.T) {
t := NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, defaultRollupTestParams)
sd := e2eutils.Setup(t, dp, defaultAlloc)
log := testlog.Logger(t, log.LvlDebug)
sd, miner, sequencer, seqEng, verifier, _, batcher := setupReorgTestActors(t, dp, sd, log)
// Extra setup: a full alternative sequencer, sequencer engine, and batcher
jwtPath := e2eutils.WriteDefaultJWT(t)
altSeqEng := NewL2Engine(t, log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath)
altSeqEngCl, err := sources.NewEngineClient(altSeqEng.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg))
require.NoError(t, err)
l1F, err := sources.NewL1Client(miner.RPCClient(), log, nil, sources.L1ClientDefaultConfig(sd.RollupCfg, false))
require.NoError(t, err)
altSequencer := NewL2Sequencer(t, log, l1F, altSeqEngCl, sd.RollupCfg, 0)
altBatcher := NewL2Batcher(log, sd.RollupCfg, &BatcherCfg{
MinL1TxSize: 0,
MaxL1TxSize: 128_000,
BatcherKey: dp.Secrets.Batcher,
}, altSequencer.RollupClient(), miner.EthClient(), altSeqEng.EthClient())
// And set up user Alice, using the alternative sequencer endpoint
l2Cl := altSeqEng.EthClient()
addresses := e2eutils.CollectAddresses(sd, dp)
l2UserEnv := &BasicUserEnv[*L2Bindings]{
EthCl: l2Cl,
Signer: types.LatestSigner(sd.L2Cfg.Config),
AddressCorpora: addresses,
Bindings: NewL2Bindings(t, l2Cl, altSeqEng.GethClient()),
}
alice := NewCrossLayerUser(log, dp.Secrets.Alice, rand.New(rand.NewSource(1234)))
alice.L2.SetUserEnv(l2UserEnv)
sequencer.ActL2PipelineFull(t)
verifier.ActL2PipelineFull(t)
altSequencer.ActL2PipelineFull(t)
// build empty L1 block
miner.ActEmptyBlock(t)
// Create L2 blocks, and reference the L1 head as origin
sequencer.ActL1HeadSignal(t)
sequencer.ActBuildToL1Head(t)
// submit all new L2 blocks
batcher.ActSubmitAll(t)
// new L1 block with L2 batch
miner.ActL1StartBlock(12)(t)
miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t)
miner.ActL1EndBlock(t)
// verifier picks up the L2 chain that was submitted
verifier.ActL1HeadSignal(t)
verifier.ActL2PipelineFull(t)
verifierHead := verifier.L2Unsafe()
require.Equal(t, verifier.L2Safe(), sequencer.L2Unsafe(), "verifier syncs from sequencer via L1")
require.Equal(t, verifier.L2Safe(), verifierHead, "verifier head is the same as that what was derived from L1")
require.NotEqual(t, sequencer.L2Safe(), sequencer.L2Unsafe(), "sequencer has not processed L1 yet")
require.Less(t, altSequencer.L2Unsafe().L1Origin.Number, sequencer.L2Unsafe().L1Origin.Number, "alt-sequencer is behind")
// produce a conflicting L2 block with the alt sequencer:
// a new unsafe block that should not replace the existing safe block at the same height
altSequencer.ActL2StartBlock(t)
// include tx to force the L2 block to really be different than the previous empty block
alice.L2.ActResetTxOpts(t)
alice.L2.ActSetTxToAddr(&dp.Addresses.Bob)(t)
alice.L2.ActMakeTx(t)
altSeqEng.ActL2IncludeTx(alice.Address())(t)
altSequencer.ActL2EndBlock(t)
conflictBlock := seqEng.l2Chain.GetBlockByNumber(altSequencer.L2Unsafe().Number)
require.NotEqual(t, conflictBlock.Hash(), altSequencer.L2Unsafe().Hash, "alt sequencer has built a conflicting block")
// give the unsafe block to the verifier, and see if it reorgs because of any unsafe inputs
head, err := altSeqEngCl.PayloadByLabel(t.Ctx(), eth.Unsafe)
require.NoError(t, err)
verifier.ActL2UnsafeGossipReceive(head)
// make sure verifier has processed everything
verifier.ActL2PipelineFull(t)
// check if verifier is still following safe chain
require.Equal(t, verifier.L2Unsafe(), verifierHead, "verifier must not accept the unsafe payload that orphans the safe payload")
// now submit it to L1, and see if the verifier respects the inclusion order and preserves the original block
altBatcher.ActSubmitAll(t)
// include it in L1
miner.ActL1StartBlock(12)(t)
miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t)
miner.ActL1EndBlock(t)
l1Number := miner.l1Chain.CurrentHeader().Number.Uint64()
// show latest L1 block with new batch data to verifier, and make it sync.
verifier.ActL1HeadSignal(t)
verifier.ActL2PipelineFull(t)
require.Equal(t, verifier.SyncStatus().CurrentL1.Number, l1Number, "verifier has synced all new L1 blocks")
require.Equal(t, verifier.L2Unsafe(), verifierHead, "verifier sticks to first included L2 block")
// Now make the alt sequencer aware of the L1 chain and derive the L2 chain like the verifier;
// it should reorg out its conflicting blocks to get back in harmony with the verifier.
altSequencer.ActL1HeadSignal(t)
altSequencer.ActL2PipelineFull(t)
require.Equal(t, verifier.L2Unsafe(), altSequencer.L2Unsafe(), "alt-sequencer gets back in harmony with verifier by reorging out its conflicting data")
require.Equal(t, sequencer.L2Unsafe(), altSequencer.L2Unsafe(), "and gets back in harmony with original sequencer")
}
......@@ -2,6 +2,10 @@ module github.com/ethereum-optimism/optimism/op-e2e
go 1.18
replace github.com/ethereum-optimism/optimism/op-batcher v0.10.4 => ./../op-batcher
replace github.com/ethereum-optimism/optimism/op-proposer v0.10.4 => ./../op-proposer
require (
github.com/docker/docker v20.10.21+incompatible
github.com/docker/go-connections v0.4.0
......
......@@ -159,16 +159,12 @@ github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 h1:RWHKLhCrQThMfch+QJ1Z
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3/go.mod h1:QziizLAiF0KqyLdNJYD7O5cpDlaFMNZzlxYNcWsJUxs=
github.com/ethereum-optimism/op-geth v0.0.0-20221216190603-60b51d600468 h1:7KgjBYDji5AKi42eRYI+n8Gs+ZJVilSASL3WBu82c3M=
github.com/ethereum-optimism/op-geth v0.0.0-20221216190603-60b51d600468/go.mod h1:p0Yox74PhYlq1HvijrCBCD9A3cI7rXco7hT6KrQr+rY=
github.com/ethereum-optimism/optimism/op-batcher v0.10.4 h1:qLCdvVMgVja2AGbkKKG7xNW8nm+3C5rz4xagQ3Cg0sw=
github.com/ethereum-optimism/optimism/op-batcher v0.10.4/go.mod h1:a19oViWrL7dy1pPSIa2Dgsv8o97HOzVtKx+m2J5qQqY=
github.com/ethereum-optimism/optimism/op-bindings v0.10.4 h1:CFn4+t0FUrBG5DmkKyYrLbGmzHWLdLv8QdUnlklvozc=
github.com/ethereum-optimism/optimism/op-bindings v0.10.4/go.mod h1:philKV8erP02ggjk2mRIdvJd2ZjMzpmqu0+zwwzKmNw=
github.com/ethereum-optimism/optimism/op-chain-ops v0.10.4 h1:10/BrNfcobBNuaIQQAUcDblzLCtNeGMhGvqHdzhENKk=
github.com/ethereum-optimism/optimism/op-chain-ops v0.10.4/go.mod h1:AIajN/ydQj57npQeqP0hcax3lhjix5brpEgw0KpvI/A=
github.com/ethereum-optimism/optimism/op-node v0.10.4 h1:ZXqfrFKgb6W4ZLbkfO9NlgaQ1djBCCPzNGbd6TgehVI=
github.com/ethereum-optimism/optimism/op-node v0.10.4/go.mod h1:avOLjMLxzB5QB7HmiLlpNkyS93QVHdr0AttRdfYGX3Y=
github.com/ethereum-optimism/optimism/op-proposer v0.10.4 h1:X81vdig8CeiDrhPjQjCOc/eDBlOLcakppy+F4Sngk0E=
github.com/ethereum-optimism/optimism/op-proposer v0.10.4/go.mod h1:2WlzvnX23uOfgMsTF2UKKLb0PT9AqQOIm6OgtWTn1TQ=
github.com/ethereum-optimism/optimism/op-service v0.10.4 h1:WKqNyOBkdJ0ZdlGiDPROZMaWfYxpsYjA5Anb0Bkl5m4=
github.com/ethereum-optimism/optimism/op-service v0.10.4/go.mod h1:7INvNCJGwVgNT4gz9Yupx7PAEJeu+F/JtHKv1fOr+9Q=
github.com/fjl/memsize v0.0.1 h1:+zhkb+dhUgx0/e+M8sF0QqiouvMQUiKR+QYvdxIOKcQ=
......
......@@ -11,8 +11,8 @@ import (
"testing"
"time"
bss "github.com/ethereum-optimism/optimism/op-batcher"
l2os "github.com/ethereum-optimism/optimism/op-proposer"
bss "github.com/ethereum-optimism/optimism/op-batcher/batcher"
l2os "github.com/ethereum-optimism/optimism/op-proposer/proposer"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
"github.com/docker/docker/api/types"
......
......@@ -22,7 +22,7 @@ import (
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
"github.com/stretchr/testify/require"
bss "github.com/ethereum-optimism/optimism/op-batcher"
bss "github.com/ethereum-optimism/optimism/op-batcher/batcher"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
......@@ -33,7 +33,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup/driver"
"github.com/ethereum-optimism/optimism/op-node/testlog"
l2os "github.com/ethereum-optimism/optimism/op-proposer"
l2os "github.com/ethereum-optimism/optimism/op-proposer/proposer"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
)
......
......@@ -6,8 +6,8 @@ import (
"github.com/urfave/cli"
proposer "github.com/ethereum-optimism/optimism/op-proposer"
"github.com/ethereum-optimism/optimism/op-proposer/flags"
"github.com/ethereum-optimism/optimism/op-proposer/proposer"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum/go-ethereum/log"
)
......@@ -26,8 +26,7 @@ func main() {
app.Version = fmt.Sprintf("%s-%s-%s", Version, GitCommit, GitDate)
app.Name = "op-proposer"
app.Usage = "L2Output Submitter"
app.Description = "Service for generating and submitting L2 Output " +
"checkpoints to the L2OutputOracle contract"
app.Description = "Service for generating and submitting L2 Output checkpoints to the L2OutputOracle contract"
app.Action = proposer.Main(Version)
err := app.Run(os.Args)
......
package op_proposer
package proposer
import (
"time"
......
package l2output
package proposer
import (
"context"
......@@ -22,7 +22,7 @@ import (
var bigOne = big.NewInt(1)
var supportedL2OutputVersion = eth.Bytes32{}
type Config struct {
type DriverConfig struct {
Log log.Logger
Name string
......@@ -48,14 +48,14 @@ type Config struct {
}
type Driver struct {
cfg Config
cfg DriverConfig
l2ooContract *bindings.L2OutputOracle
rawL2ooContract *bind.BoundContract
walletAddr common.Address
l log.Logger
}
func NewDriver(cfg Config) (*Driver, error) {
func NewDriver(cfg DriverConfig) (*Driver, error) {
l2ooContract, err := bindings.NewL2OutputOracle(cfg.L2OOAddr, cfg.L1Client)
if err != nil {
return nil, err
......
package op_proposer
package proposer
import (
"context"
......@@ -25,7 +25,6 @@ import (
"github.com/ethereum-optimism/optimism/op-node/client"
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-proposer/drivers/l2output"
"github.com/ethereum-optimism/optimism/op-proposer/txmgr"
opcrypto "github.com/ethereum-optimism/optimism/op-service/crypto"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
......@@ -210,7 +209,7 @@ func NewL2OutputSubmitterWithSigner(
SafeAbortNonceTooLowCount: cfg.SafeAbortNonceTooLowCount,
}
l2OutputDriver, err := l2output.NewDriver(l2output.Config{
l2OutputDriver, err := NewDriver(DriverConfig{
Log: l,
Name: "L2Output Submitter",
L1Client: l1Client,
......
package op_proposer
package proposer
import (
"context"
......@@ -13,9 +13,9 @@ import (
"github.com/ethereum/go-ethereum/log"
)
// Driver is an interface for creating and submitting transactions for a
// DriverInterface is an interface for creating and submitting transactions for a
// specific contract.
type Driver interface {
type DriverInterface interface {
// Name is an identifier used to prefix logs for a particular service.
Name() string
......@@ -53,7 +53,7 @@ type Driver interface {
type ServiceConfig struct {
Log log.Logger
Context context.Context
Driver Driver
Driver DriverInterface
PollInterval time.Duration
L1Client *ethclient.Client
TxManagerConfig txmgr.Config
......
......@@ -687,7 +687,7 @@ represented by an [expanded version][expanded-payload] of the [`PayloadAttribute
which includes the additional `transactions` and `noTxPool` fields.
[expanded-payload]: exec-engine.md#extended-payloadattributesv1
[eth-payload]: https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md#payloadattributesv1
[eth-payload]: https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#payloadattributesv1
## Deriving the Transaction List
......@@ -861,7 +861,7 @@ The following JSON-RPC methods are part of the [execution engine API][exec-engin
The execution payload is an object of type [`ExecutionPayloadV1`][eth-payload].
[eth-payload]: https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md#executionpayloadv1
[eth-payload]: https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#executionpayloadv1
------------------------------------------------------------------------------------------------------------------------
......
......@@ -798,7 +798,7 @@ In these specifications, "execution engine" always refer to the L2 execution eng
[Solidity events]: https://docs.soliditylang.org/en/latest/contracts.html?highlight=events#events
[nano-header]: https://github.com/norswap/nanoeth/blob/cc5d94a349c90627024f3cd629a2d830008fec72/src/com/norswap/nanoeth/blocks/BlockHeader.java#L22-L156
[yellow]: https://ethereum.github.io/yellowpaper/paper.pdf
[engine-api]: https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md#PayloadAttributesV1
[engine-api]: https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#PayloadAttributesV1
[merge]: https://ethereum.org/en/eth2/merge/
[mempool]: https://www.quicknode.com/guides/defi/how-to-access-ethereum-mempool
[L1 consensus layer]: https://github.com/ethereum/consensus-specs/#readme
......
......@@ -64,7 +64,7 @@ a 32 byte hash corresponding to the [L2 output root](./proposals.md#l2-output-co
The input and return types here are as defined by the [engine API specs][engine-structures]).
[engine-structures]: https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md#structures
[engine-structures]: https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#structures
- method: `optimism_outputAtBlock`
- params:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment