Skip to content

Commit

Permalink
Merge branch 'mempool-feed-stage' into merge/v1.13.14
Browse files Browse the repository at this point in the history
  • Loading branch information
lukanus authored Mar 4, 2024
2 parents 4571b7e + 148f358 commit 3537f04
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v2
- name: Build geth
run: |
cd cmd/geth && /opt/go/1.19.5/bin/go build
cd cmd/geth && /opt/go/1.21.0/bin/go build
tar -czvf geth-$(basename ${GITHUB_REF})-linux-arm64.tar.gz geth
echo $(md5sum geth | awk '{print $1}') > geth-$(basename ${GITHUB_REF})-linux-arm64.tar.gz.md5
- name: Upload geth to release page
Expand Down
2 changes: 1 addition & 1 deletion cmd/utils/history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func TestHistoryImportAndExport(t *testing.T) {
db2.Close()
})

genesis.MustCommit(db2, triedb.NewDatabase(db, triedb.HashDefaults))
genesis.MustCommit(db2, triedb.NewDatabase(db, triedb.HashDefaults))
imported, err := core.NewBlockChain(db2, nil, genesis, nil, ethash.NewFaker(), vm.Config{}, nil, nil)
if err != nil {
t.Fatalf("unable to initialize chain: %v", err)
Expand Down
37 changes: 35 additions & 2 deletions core/txpool/blobpool/blobpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ type blobTxMeta struct {
evictionExecTip *uint256.Int // Worst gas tip across all previous nonces
evictionExecFeeJumps float64 // Worst base fee (converted to fee jumps) across all previous nonces
evictionBlobFeeJumps float64 // Worse blob fee (converted to fee jumps) across all previous nonces

// -------- BLOCKNATIVE MODIFICATION START -------------
blobHashes []common.Hash
// -------- BLOCKNATIVE MODIFICATION STOP -------------
}

// newBlobTxMeta retrieves the indexed metadata fields from a blob transaction
Expand All @@ -122,6 +126,10 @@ func newBlobTxMeta(id uint64, size uint32, tx *types.Transaction) *blobTxMeta {
blobFeeCap: uint256.MustFromBig(tx.BlobGasFeeCap()),
execGas: tx.Gas(),
blobGas: tx.BlobGas(),

// -------- BLOCKNATIVE MODIFICATION START -------------
blobHashes: tx.BlobHashes(),
// -------- BLOCKNATIVE MODIFICATION STOP -------------
}
meta.basefeeJumps = dynamicFeeJumps(meta.execFeeCap)
meta.blobfeeJumps = dynamicFeeJumps(meta.blobFeeCap)
Expand Down Expand Up @@ -1624,7 +1632,33 @@ func (p *BlobPool) Stats() (int, int) {
// For the blob pool, this method will return nothing for now.
// TODO(karalabe): Abstract out the returned metadata.
func (p *BlobPool) Content() (map[common.Address][]*types.Transaction, map[common.Address][]*types.Transaction) {
return make(map[common.Address][]*types.Transaction), make(map[common.Address][]*types.Transaction)

// -------- BLOCKNATIVE MODIFICATION START -------------

pending := make(map[common.Address][]*types.Transaction)
p.lock.RLock()
defer p.lock.RUnlock()

for addr, txs := range p.index {
var lazies []*types.Transaction
for _, tx := range txs {
lazies = append(lazies, types.NewTx(&types.BlobTx{
Gas: tx.execGas,
BlobFeeCap: tx.blobFeeCap,
Nonce: tx.nonce,
GasFeeCap: tx.execFeeCap,
GasTipCap: tx.execTipCap,
BlobHashes: tx.blobHashes,
}))
}
if len(lazies) > 0 {
pending[addr] = lazies
}

}

return pending, make(map[common.Address][]*types.Transaction)
// -------- BLOCKNATIVE MODIFICATION STOP --------------
}

// ContentFrom retrieves the data content of the transaction pool, returning the
Expand Down Expand Up @@ -1652,7 +1686,6 @@ func (p *BlobPool) Status(hash common.Hash) txpool.TxStatus {
return txpool.TxStatusUnknown
}


// SubscribeDropTxsEvent registers a subscription of core.DropTxsEvent and
// starts sending event to the given channel.
func (pool *BlobPool) SubscribeDropTxsEvent(ch chan<- core.DropTxsEvent) event.Subscription {
Expand Down
4 changes: 2 additions & 2 deletions core/txpool/blobpool/blobpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ func TestOpenDrops(t *testing.T) {

id, _ := store.Put(blob)
filled[id] = struct{}{}
}
// Insert a sequence of transactions with partially passed nonces to verify
}
// Insert a sequence of transactions with partially passed nonces to verify
// that the included part of the set will get dropped (case 4).
var (
overlapper, _ = crypto.GenerateKey()
Expand Down
3 changes: 2 additions & 1 deletion eth/tracers/blocknative/decoder/calldata.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package decoder

import (
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"math/big"
)

func decodeCallData(sender common.Address, contract *Contract, input []byte) (*CallData, error) {
Expand Down
12 changes: 12 additions & 0 deletions eth/tracers/blocknative/decoder/evm_caller.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ func evmCallMethodDecimals(evmCall evmCallFn, addr common.Address) (uint8, error

// evmCallMethodTokenURI decodes the tokenURI of an asset from the EVM.
func evmCallMethodTokenURI(evmCall evmCallFn, addr common.Address, tokenID *big.Int) (string, error) {
if tokenID == nil {
return "", fmt.Errorf("tokenID is nil")
}

tokenIDBytes := tokenID.Bytes()
if len(tokenIDBytes) > 32 {
return "", fmt.Errorf("tokenID is too large")
Expand All @@ -99,6 +103,10 @@ func evmCallMethodTokenURI(evmCall evmCallFn, addr common.Address, tokenID *big.

// evmCallMethodURI decodes the URI of an asset from the EVM.
func evmCallMethodURI(evmCall evmCallFn, addr common.Address, tokenID *big.Int) (string, error) {
if tokenID == nil {
return "", fmt.Errorf("tokenID is nil")
}

tokenIDBytes := common.LeftPadBytes(tokenID.Bytes(), 32)
input := append(methodIDURI, tokenIDBytes...)
return callAndDecodeString(evmCall, addr, input)
Expand All @@ -113,6 +121,10 @@ func evmCallMethodBalanceOf(evmCall evmCallFn, addr common.Address, owner common

// evmCallMethodBalanceOf2 decodes the balance of an asset from the EVM.
func evmCallMethodBalanceOf2(evmCall evmCallFn, addr common.Address, owner common.Address, tokenID *big.Int) (*big.Int, error) {
if tokenID == nil {
return nil, fmt.Errorf("tokenID is nil")
}

tokenIDBytes := common.LeftPadBytes(tokenID.Bytes(), 32)
ownerBytes := common.LeftPadBytes(owner.Bytes(), 32)
input := append(methodIDBalanceOf2, ownerBytes...)
Expand Down
4 changes: 2 additions & 2 deletions eth/tracers/blocknative/decoder/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"

"github.com/ethereum/go-ethereum/common"
)

Expand Down Expand Up @@ -82,7 +83,7 @@ var methodSignatures = map[string]string{
type MethodID []byte

func (m MethodID) Is(other MethodID) bool {
return bytes.Compare(m, other) == 0
return bytes.Equal(m, other)
}

func (m MethodID) String() string {
Expand Down Expand Up @@ -113,7 +114,6 @@ func (m *MethodID) UnmarshalJSON(b []byte) error {
}

if len(b) > methodIDEncodedLen {
fmt.Println("sdfasdfasdf:", len(b), string(b), b)
return ErrMethodIDTooLong
}

Expand Down
6 changes: 3 additions & 3 deletions internal/ethapi/transaction_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (args *TransactionArgs) data() []byte {
return nil
}

// setDefaults fills in default values for unspecified tx fields.
// setDefaults fills in default values for unspecified tx fields.
func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend, skipGasEstimation bool) error {
if err := args.setBlobTxSidecar(ctx, b); err != nil {
return err
Expand Down Expand Up @@ -135,7 +135,7 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend, skipGas
return errors.New(`contract creation without any data provided`)
}
}

if args.Gas == nil {
if skipGasEstimation { // Skip gas usage estimation if a precise gas limit is not critical, e.g., in non-transaction calls.
gas := hexutil.Uint64(b.RPCGasCap())
Expand Down Expand Up @@ -211,7 +211,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) erro
}
return nil // No need to set anything, user already set MaxFeePerGas and MaxPriorityFeePerGas
}

// Sanity check the non-EIP-1559 fee parameters.
isLondon := b.ChainConfig().IsLondon(head.Number)
if args.GasPrice != nil && !eip1559ParamsSet {
Expand Down
2 changes: 1 addition & 1 deletion miner/ordering.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func newTransactionsByPriceAndNonce(signer types.Signer, txs map[common.Address]
}
}

// Peek returns the next transaction by price.
// Peek returns the next transaction by price.
func (t *transactionsByPriceAndNonce) Peek() (*txpool.LazyTransaction, *uint256.Int) {
if len(t.heads) == 0 {
return nil, nil
Expand Down
17 changes: 14 additions & 3 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ type worker struct {
mu sync.RWMutex // The lock used to protect the coinbase and extra fields
coinbase common.Address
extra []byte
tip *uint256.Int // Minimum tip needed for non-local transaction to include them
tip *uint256.Int // Minimum tip needed for non-local transaction to include them

pendingMu sync.RWMutex
pendingTasks map[common.Hash]*task
Expand Down Expand Up @@ -333,7 +333,7 @@ func (w *worker) setExtra(extra []byte) {
// setGasTip sets the minimum miner tip needed to include a non-local transaction.
func (w *worker) setGasTip(tip *big.Int) {
w.mu.Lock()
defer w.mu.Unlock()
defer w.mu.Unlock()
w.tip = uint256.MustFromBig(tip)
}

Expand Down Expand Up @@ -864,6 +864,11 @@ func (w *worker) commitTransactions(env *environment, plainTxs, blobTxs *transac
txs.Pop()
continue
}
// If we don't receive enough tip for the next transaction, skip the account
if tip.Cmp(minTip) < 0 {
log.Trace("Not enough tip for transaction", "hash", ltx.Hash, "tip", tip, "needed", minTip)
break // If the next-best is too low, surely no better will be available
}
// Transaction seems to fit, pull it up from the pool
tx := ltx.Resolve()
if tx == nil {
Expand Down Expand Up @@ -1056,7 +1061,13 @@ func (w *worker) fillTransactions(interrupt *atomic.Int32, env *environment) err
localBlobTxs[account] = txs
}
}
// Fill the block with all available pending transactions.
// Fill the block with all available pending transactions.

// w.mu.RLock()
// tip := w.tip
// w.mu.RUnlock()


if len(localPlainTxs) > 0 || len(localBlobTxs) > 0 {
plainTxs := newTransactionsByPriceAndNonce(env.signer, localPlainTxs, env.header.BaseFee)
blobTxs := newTransactionsByPriceAndNonce(env.signer, localBlobTxs, env.header.BaseFee)
Expand Down
4 changes: 2 additions & 2 deletions params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (

const (
VersionMajor = 1 // Major version component of the current release
VersionMinor = 13 // Minor version component of the current release
VersionPatch = 14 // Patch version component of the current release
VersionMinor = 13 // Minor version component of the current release
VersionPatch = 14 // Patch version component of the current release
VersionMeta = "stable" // Version metadata to append to the version string
)

Expand Down

0 comments on commit 3537f04

Please sign in to comment.