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

Commit

Permalink
feat(proposer): remove poolContentSplitter in proposer (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Feb 28, 2023
1 parent e124fbb commit e26c831
Show file tree
Hide file tree
Showing 20 changed files with 253 additions and 938 deletions.
2 changes: 1 addition & 1 deletion bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16993cdb081b831420c7e86d981afd11726197d1
20fac4c7430c633c1b1418baf11be16ac342fb3d
2 changes: 1 addition & 1 deletion bindings/encoding/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ var (
},
{
Name: "circuits",
Type: "uint16[]",
Type: "uint16",
},
}
)
Expand Down
2 changes: 1 addition & 1 deletion bindings/encoding/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type TaikoL1Evidence struct {
Header BlockHeader
Prover common.Address
Proofs [][]byte
Circuits []uint16
Circuits uint16
}

// FromGethHeader converts a GETH *types.Header to *BlockHeader.
Expand Down
413 changes: 90 additions & 323 deletions bindings/gen_taiko_l1.go

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions bindings/gen_taiko_l2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 24 additions & 63 deletions pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"math/big"
"sort"
"time"

ethereum "github.com/ethereum/go-ethereum"
Expand Down Expand Up @@ -160,72 +159,34 @@ func (c *Client) WaitL1Origin(ctx context.Context, blockID *big.Int) (*rawdb.L1O
}
}

// PoolContent represents a response body of a `txpool_content` RPC call.
type PoolContent map[common.Address]map[string]*types.Transaction

// Len returns the number of transactions in the PoolContent.
func (pc PoolContent) Len() int {
len := 0
for _, pendingTxs := range pc {
for range pendingTxs {
len += 1
}
// GetPoolContent fetches the transactions list from L2 execution engine's transactions pool with given
// upper limit.
func (c *Client) GetPoolContent(
ctx context.Context,
maxTransactionsPerBlock *big.Int,
blockMaxGasLimit *big.Int,
maxBytesPerTxList *big.Int,
minTxGasLimit *big.Int,
locals []common.Address,
) ([]types.Transactions, error) {
var localsArg []string
for _, local := range locals {
localsArg = append(localsArg, local.Hex())
}

return len
}

// ToTxsByPriceAndNonce creates a transaction set that can retrieve price sorted transactions in a nonce-honouring way.
func (pc PoolContent) ToTxsByPriceAndNonce(
chainID *big.Int,
localAddresses []common.Address,
) (
locals *types.TransactionsByPriceAndNonce,
remotes *types.TransactionsByPriceAndNonce,
) {
var (
allTxs = map[common.Address]types.Transactions{}
localTxs = map[common.Address]types.Transactions{}
remoteTxs = map[common.Address]types.Transactions{}
var result []types.Transactions
err := c.L2RawRPC.CallContext(
ctx,
&result,
"taiko_txPoolContent",
maxTransactionsPerBlock.Uint64(),
blockMaxGasLimit.Uint64(),
maxBytesPerTxList.Uint64(),
minTxGasLimit.Uint64(),
localsArg,
)

for address, txsWithNonce := range pc {
idx := 0
for _, tx := range txsWithNonce {
allTxs[address] = append(allTxs[address], tx)
idx += 1

if idx == len(txsWithNonce) {
sort.Sort(types.TxByNonce(allTxs[address]))
}
}
}

for address, txs := range allTxs {
out:
for _, tx := range txs {
for _, localAddress := range localAddresses {
if address == localAddress {
localTxs[address] = append(localTxs[address], tx)
continue out
}
}
remoteTxs[address] = append(remoteTxs[address], tx)
}
}

return types.NewTransactionsByPriceAndNonce(types.LatestSignerForChainID(chainID), localTxs, nil),
types.NewTransactionsByPriceAndNonce(types.LatestSignerForChainID(chainID), remoteTxs, nil)
}

// L2PoolContent fetches the transaction pool content from a L2 execution engine.
func (c *Client) L2PoolContent(ctx context.Context) (pending PoolContent, queued PoolContent, err error) {
var res map[string]PoolContent
if err := c.L2RawRPC.CallContext(ctx, &res, "txpool_content"); err != nil {
return nil, nil, err
}

return res["pending"], res["queued"], nil
return result, err
}

// L2AccountNonce fetches the nonce of the given L2 account at a specified height.
Expand Down
Loading

0 comments on commit e26c831

Please sign in to comment.