Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

test(proposer): change tests to send blob transactions #799

Merged
merged 7 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/docker/nodes/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ services:
- "8545"
entrypoint:
- anvil
- --chain-id
- "32301"
- --host
- "0.0.0.0"
- --hardfork
Expand Down
89 changes: 4 additions & 85 deletions proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"testing"
"time"

"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
Expand All @@ -22,7 +21,6 @@ import (
"github.com/taikoxyz/taiko-client/driver/chain_syncer/beaconsync"
"github.com/taikoxyz/taiko-client/driver/chain_syncer/blob"
"github.com/taikoxyz/taiko-client/driver/state"
txlistfetcher "github.com/taikoxyz/taiko-client/driver/txlist_fetcher"
"github.com/taikoxyz/taiko-client/internal/testutils"
"github.com/taikoxyz/taiko-client/internal/utils"
"github.com/taikoxyz/taiko-client/pkg/jwt"
Expand Down Expand Up @@ -87,6 +85,8 @@ func (s *ProposerTestSuite) SetupTest() {
MaxTierFeePriceBumps: 3,
ExtraData: "test",
L1BlockBuilderTip: common.Big0,
BlobAllowed: true,
ProposeBlockTxGasLimit: 10_000_000,
TxmgrConfigs: &txmgr.CLIConfig{
L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"),
NumConfirmations: 0,
Expand All @@ -108,36 +108,6 @@ func (s *ProposerTestSuite) SetupTest() {
s.cancel = cancel
}

func parseTxs(client *rpc.Client, event *bindings.TaikoL1ClientBlockProposed) (types.Transactions, error) {
tx, err := client.L1.TransactionInBlock(context.Background(), event.Raw.BlockHash, event.Raw.TxIndex)
if err != nil {
return nil, err
}

// Decode transactions list.
var txListDecoder txlistfetcher.TxListFetcher
if event.Meta.BlobUsed {
txListDecoder = txlistfetcher.NewBlobTxListFetcher(client.L1Beacon, rpc.NewBlobDataSource(
context.Background(),
client,
nil,
))
} else {
txListDecoder = new(txlistfetcher.CalldataFetcher)
}
txListBytes, err := txListDecoder.Fetch(context.Background(), tx, &event.Meta)
if err != nil {
return nil, err
}

txListBytes, err = utils.Decompress(txListBytes)
if err != nil {
return nil, err
}

var txs types.Transactions
return txs, rlp.DecodeBytes(txListBytes, &txs)
}
func (s *ProposerTestSuite) TestProposeTxLists() {
p := s.p
ctx := p.ctx
Expand Down Expand Up @@ -178,57 +148,16 @@ func (s *ProposerTestSuite) TestProposeTxLists() {
}

// trigger the error
candidate.Blobs = []*eth.Blob{}
candidate.GasLimit = 10000000
candidate.GasLimit = 10_000_000

txCandidates[i] = *candidate
}

var errors []error
for _, txCandidate := range txCandidates {
receipt, err := p.txmgr.Send(ctx, txCandidate)
s.Nil(err)
errors = append(errors, encoding.TryParsingCustomErrorFromReceipt(ctx, p.rpc.L1, p.proposerAddress, receipt))
}

// confirm errors handled
for _, err := range errors {
s.Equal("L1_BLOB_NOT_AVAILABLE", err.Error())
}
}

func (s *ProposerTestSuite) getLatestProposedTxs(
n int,
timeout time.Duration,
) (<-chan []types.Transactions, error) {
sink := make(chan *bindings.TaikoL1ClientBlockProposed)
sub, err := s.p.rpc.TaikoL1.WatchBlockProposed(nil, sink, nil, nil)
if err != nil {
return nil, err
s.Nil(encoding.TryParsingCustomErrorFromReceipt(ctx, p.rpc.L1, p.proposerAddress, receipt))
}

var resCh = make(chan []types.Transactions, 1)
go func() {
defer sub.Unsubscribe()

txLst := make([]types.Transactions, 0, n)
tick := time.After(timeout)
for len(txLst) < cap(txLst) {
select {
case event := <-sink:
txs, err := parseTxs(s.RPCClient, event)
if err != nil {
log.Error("failed to parse txs", "error", err)
}
txLst = append(txLst, txs)
case <-tick:
return
}
}
resCh <- txLst
}()

return resCh, nil
}

func (s *ProposerTestSuite) TestProposeOpNoEmptyBlock() {
Expand Down Expand Up @@ -260,13 +189,9 @@ func (s *ProposerTestSuite) TestProposeOpNoEmptyBlock() {
s.Nil(err)
s.Equal(true, len(preBuiltTxList) > 0)

txsCh, err := s.getLatestProposedTxs(len(preBuiltTxList), time.Minute)
s.Nil(err)

var (
blockMinGasLimit uint64 = math.MaxUint64
blockMinTxListBytes uint64 = math.MaxUint64
txLists = make([]types.Transactions, 0, len(preBuiltTxList))
)
for _, txs := range preBuiltTxList {
if txs.EstimatedGasUsed <= blockMinGasLimit {
Expand All @@ -279,7 +204,6 @@ func (s *ProposerTestSuite) TestProposeOpNoEmptyBlock() {
} else {
break
}
txLists = append(txLists, txs.TxList)
}

// Start proposer
Expand All @@ -289,11 +213,6 @@ func (s *ProposerTestSuite) TestProposeOpNoEmptyBlock() {
p.ProposeInterval = time.Second
p.MinProposingInternal = time.Minute
s.Nil(p.ProposeOp(context.Background()))

txs := <-txsCh
for i := 0; i < len(txLists); i++ {
s.Equal(txLists[i].Len(), txs[i].Len())
}
}

func (s *ProposerTestSuite) TestName() {
Expand Down
2 changes: 1 addition & 1 deletion proposer/transaction_builder/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (s *TransactionBuilderTestSuite) SetupTest() {
common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")),
common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")),
0,
10_000_000,
"test",
)
}
Expand Down
Loading