forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Original rebased prototype by proto, plus changes from Roberto: - encapsulate data <-> blob conversion code, add unit tests - update 4844 code to be compatible with latest beacon node api - remove stray file, include one more invalid blob test - appropriate fee bumping & blob fee estimation for blob transactions - misc other improvements
- Loading branch information
1 parent
8b39517
commit 5fcade6
Showing
33 changed files
with
1,171 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package op_e2e | ||
|
||
import ( | ||
"context" | ||
"math/big" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/ethereum-optimism/optimism/op-service/client" | ||
"github.com/ethereum-optimism/optimism/op-service/sources" | ||
"github.com/ethereum-optimism/optimism/op-service/testlog" | ||
"github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/log" | ||
"github.com/ethereum/go-ethereum/rpc" | ||
) | ||
|
||
// TestSystem4844E2E runs the SystemE2E test with 4844 enabled on L1, | ||
// and active on the rollup in the op-batcher and verifier. | ||
func TestSystem4844E2E(t *testing.T) { | ||
InitParallel(t) | ||
|
||
cfg := DefaultSystemConfig(t) | ||
genesisActivation := uint64(0) | ||
cfg.DeployConfig.L1CancunTimeOffset = &genesisActivation | ||
cfg.DeployConfig.L2BlobsUpgradeTimeOffset = &genesisActivation | ||
|
||
sys, err := cfg.Start(t) | ||
require.Nil(t, err, "Error starting up system") | ||
defer sys.Close() | ||
|
||
log := testlog.Logger(t, log.LvlInfo) | ||
log.Info("genesis", "l2", sys.RollupConfig.Genesis.L2, "l1", sys.RollupConfig.Genesis.L1, "l2_time", sys.RollupConfig.Genesis.L2Time) | ||
|
||
l1Client := sys.Clients["l1"] | ||
l2Seq := sys.Clients["sequencer"] | ||
l2Verif := sys.Clients["verifier"] | ||
|
||
// Transactor Account | ||
ethPrivKey := cfg.Secrets.Alice | ||
|
||
// Send Transaction & wait for success | ||
fromAddr := cfg.Secrets.Addresses().Alice | ||
log.Info("alice", "addr", fromAddr) | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) | ||
defer cancel() | ||
startBalance, err := l2Verif.BalanceAt(ctx, fromAddr, nil) | ||
require.Nil(t, err) | ||
|
||
// Send deposit transaction | ||
opts, err := bind.NewKeyedTransactorWithChainID(ethPrivKey, cfg.L1ChainIDBig()) | ||
require.Nil(t, err) | ||
mintAmount := big.NewInt(1_000_000_000_000) | ||
opts.Value = mintAmount | ||
SendDepositTx(t, cfg, l1Client, l2Verif, opts, func(l2Opts *DepositTxOpts) {}) | ||
|
||
// Confirm balance | ||
ctx, cancel = context.WithTimeout(context.Background(), 15*time.Second) | ||
defer cancel() | ||
endBalance, err := l2Verif.BalanceAt(ctx, fromAddr, nil) | ||
require.Nil(t, err) | ||
|
||
diff := new(big.Int) | ||
diff = diff.Sub(endBalance, startBalance) | ||
require.Equal(t, mintAmount, diff, "Did not get expected balance change") | ||
|
||
// Submit TX to L2 sequencer node | ||
receipt := SendL2Tx(t, cfg, l2Seq, ethPrivKey, func(opts *TxOpts) { | ||
opts.Value = big.NewInt(1_000_000_000) | ||
opts.Nonce = 1 // Already have deposit | ||
opts.ToAddr = &common.Address{0xff, 0xff} | ||
opts.VerifyOnClients(l2Verif) | ||
}) | ||
|
||
// Verify blocks match after batch submission on verifiers and sequencers | ||
verifBlock, err := l2Verif.BlockByNumber(context.Background(), receipt.BlockNumber) | ||
require.Nil(t, err) | ||
seqBlock, err := l2Seq.BlockByNumber(context.Background(), receipt.BlockNumber) | ||
require.Nil(t, err) | ||
require.Equal(t, verifBlock.NumberU64(), seqBlock.NumberU64(), "Verifier and sequencer blocks not the same after including a batch tx") | ||
require.Equal(t, verifBlock.ParentHash(), seqBlock.ParentHash(), "Verifier and sequencer blocks parent hashes not the same after including a batch tx") | ||
require.Equal(t, verifBlock.Hash(), seqBlock.Hash(), "Verifier and sequencer blocks not the same after including a batch tx") | ||
|
||
rollupRPCClient, err := rpc.DialContext(context.Background(), sys.RollupNodes["sequencer"].HTTPEndpoint()) | ||
require.Nil(t, err) | ||
rollupClient := sources.NewRollupClient(client.NewBaseRPCClient(rollupRPCClient)) | ||
// basic check that sync status works | ||
seqStatus, err := rollupClient.SyncStatus(context.Background()) | ||
require.Nil(t, err) | ||
require.LessOrEqual(t, seqBlock.NumberU64(), seqStatus.UnsafeL2.Number) | ||
// basic check that version endpoint works | ||
seqVersion, err := rollupClient.Version(context.Background()) | ||
require.Nil(t, err) | ||
require.NotEqual(t, "", seqVersion) | ||
|
||
// quick check that the batch submitter works | ||
for i := 0; i < 10; i++ { | ||
// wait for chain to be marked as "safe" (i.e. confirm batch-submission works) | ||
stat, err := rollupClient.SyncStatus(context.Background()) | ||
require.NoError(t, err) | ||
if stat.SafeL2.Number > 0 { | ||
return | ||
} | ||
time.Sleep(2 * time.Second) | ||
} | ||
t.Fatal("expected L2 to be batch-submitted and labeled as safe") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.