Commit 6062bb6c authored by EvanJRichard's avatar EvanJRichard

Squash full eip4844-e2e-history into a single commit.

parent eef315e9
...@@ -138,7 +138,7 @@ func (f *fakePoS) Start() error { ...@@ -138,7 +138,7 @@ func (f *fakePoS) Start() error {
tim.Stop() tim.Stop()
return nil return nil
} }
envelope, err := f.engineAPI.GetPayloadV2(*res.PayloadID) envelope, err := f.engineAPI.GetPayloadV3(*res.PayloadID)
if err != nil { if err != nil {
f.log.Error("failed to finish building L1 block", "err", err) f.log.Error("failed to finish building L1 block", "err", err)
continue continue
...@@ -178,7 +178,7 @@ func (f *fakePoS) Start() error { ...@@ -178,7 +178,7 @@ func (f *fakePoS) Start() error {
continue continue
} }
} }
if _, err := f.engineAPI.ForkchoiceUpdatedV2(engine.ForkchoiceStateV1{ if _, err := f.engineAPI.ForkchoiceUpdatedV3(engine.ForkchoiceStateV1{
HeadBlockHash: envelope.ExecutionPayload.BlockHash, HeadBlockHash: envelope.ExecutionPayload.BlockHash,
SafeBlockHash: safe.Hash(), SafeBlockHash: safe.Hash(),
FinalizedBlockHash: finalized.Hash(), FinalizedBlockHash: finalized.Hash(),
......
package transactions
import (
"crypto/ecdsa"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto/kzg4844"
"github.com/holiman/uint256"
)
var (
emptyBlob = kzg4844.Blob{}
emptyBlobCommit, _ = kzg4844.BlobToCommitment(emptyBlob)
emptyBlobProof, _ = kzg4844.ComputeBlobProof(emptyBlob, emptyBlobCommit)
)
// with thanks to fjl
// https://github.com/ethereum/go-ethereum/commit/2a6beb6a39d7cb3c5906dd4465d65da6efcc73cd
func CreateEmptyBlobTx(key *ecdsa.PrivateKey, withSidecar bool, chainID uint64) *types.BlobTx {
sidecar := &types.BlobTxSidecar{
Blobs: []kzg4844.Blob{emptyBlob},
Commitments: []kzg4844.Commitment{emptyBlobCommit},
Proofs: []kzg4844.Proof{emptyBlobProof},
}
blobTx := &types.BlobTx{
ChainID: uint256.NewInt(chainID),
Nonce: 0,
GasTipCap: uint256.NewInt(2200000000000),
GasFeeCap: uint256.NewInt(5000000000000),
Gas: 25000,
To: common.Address{0x03, 0x04, 0x05},
Value: uint256.NewInt(99),
Data: make([]byte, 50),
BlobFeeCap: uint256.NewInt(150000000000),
BlobHashes: sidecar.BlobHashes(),
}
if withSidecar {
blobTx.Sidecar = sidecar
}
return blobTx
}
...@@ -31,6 +31,8 @@ import ( ...@@ -31,6 +31,8 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/bindings" "github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys" "github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-e2e/config" "github.com/ethereum-optimism/optimism/op-e2e/config"
gethutils "github.com/ethereum-optimism/optimism/op-e2e/e2eutils/geth"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/transactions"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum-optimism/optimism/op-node/metrics" "github.com/ethereum-optimism/optimism/op-node/metrics"
rollupNode "github.com/ethereum-optimism/optimism/op-node/node" rollupNode "github.com/ethereum-optimism/optimism/op-node/node"
...@@ -171,6 +173,56 @@ func TestSystemE2EDencunAtGenesis(t *testing.T) { ...@@ -171,6 +173,56 @@ func TestSystemE2EDencunAtGenesis(t *testing.T) {
require.NotNil(t, head.ExcessBlobGas(), "L1 is building dencun blocks since genesis") require.NotNil(t, head.ExcessBlobGas(), "L1 is building dencun blocks since genesis")
} }
// TestSystemE2EDencunAtGenesis tests if L2 finalizes when blobs are present on L1
func TestSystemE2EDencunAtGenesisWithBlobs(t *testing.T) {
InitParallel(t)
cfg := DefaultSystemConfig(t)
//cancun is on from genesis:
genesisActivation := uint64(0)
cfg.DeployConfig.L1CancunTimeOffset = &genesisActivation // i.e. turn cancun on at genesis time + 0
sys, err := cfg.Start(t)
require.Nil(t, err, "Error starting up system")
defer sys.Close()
// send a blob-containing txn on l1
ethPrivKey := sys.cfg.Secrets.Alice
txData := transactions.CreateEmptyBlobTx(ethPrivKey, true, sys.cfg.L1ChainIDBig().Uint64())
tx := types.MustSignNewTx(ethPrivKey, types.LatestSignerForChainID(cfg.L1ChainIDBig()), txData)
// send blob-containing txn
sendCtx, sendCancel := context.WithTimeout(context.Background(), 15*time.Second)
defer sendCancel()
l1Client := sys.Clients["l1"]
err = l1Client.SendTransaction(sendCtx, tx)
require.NoError(t, err, "Sending L1 empty blob tx")
// Wait for transaction on L1
_, err = geth.WaitForTransaction(tx.Hash(), l1Client, 30*time.Duration(cfg.DeployConfig.L1BlockTime)*time.Second)
require.Nil(t, err, "Waiting for blob tx on L1")
// end sending blob-contraining txns on l1
l2Seq := sys.Clients["sequencer"]
head, err := l1Client.BlockByNumber(context.Background(), big.NewInt(0))
require.Nil(t, err, "Getting current head on L1")
// Wait enough time for L1 to finalize and L2 to confirm its data in finalized L1 blocks: about 14 blocks
const finalizedDistance = 14
finalizedBlockNumber := head.NumberU64() + finalizedDistance
finalizedBlockBigInt := new(big.Int).SetUint64(finalizedBlockNumber)
finalizationTimeout := 30 * time.Duration(cfg.DeployConfig.L1BlockTime) * time.Second
_, err = gethutils.WaitForBlockToBeFinalized(finalizedBlockBigInt, l1Client, finalizationTimeout)
require.Nil(t, err, "Waiting for finalized L1 block")
// fetch the finalized head of geth
finalizeCtx, finalizeCancel := context.WithTimeout(context.Background(), 1*time.Second)
defer finalizeCancel()
l2Finalized, err := l2Seq.BlockByNumber(finalizeCtx, big.NewInt(int64(rpc.FinalizedBlockNumber)))
require.NoError(t, err)
require.NotZerof(t, l2Finalized.NumberU64(), "must have finalized L2 block")
}
// TestSystemE2E sets up a L1 Geth node, a rollup node, and a L2 geth node and then confirms that L1 deposits are reflected on L2. // TestSystemE2E sets up a L1 Geth node, a rollup node, and a L2 geth node and then confirms that L1 deposits are reflected on L2.
// All nodes are run in process (but are the full nodes, not mocked or stubbed). // All nodes are run in process (but are the full nodes, not mocked or stubbed).
func TestSystemE2E(t *testing.T) { func TestSystemE2E(t *testing.T) {
......
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