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

feat(flashbera): SendBundle backend #746

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 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
14 changes: 14 additions & 0 deletions cosmos/x/evm/plugins/txpool/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/gofrs/uuid"

"github.com/ethereum/go-ethereum/event"

"pkg.berachain.dev/polaris/cosmos/x/evm/plugins"
mempool "pkg.berachain.dev/polaris/cosmos/x/evm/plugins/txpool/mempool"
"pkg.berachain.dev/polaris/eth/common"
"pkg.berachain.dev/polaris/eth/core"
coretypes "pkg.berachain.dev/polaris/eth/core/types"
errorslib "pkg.berachain.dev/polaris/lib/errors"
Expand Down Expand Up @@ -123,4 +125,16 @@ func (p *plugin) SendPrivTx(signedTx *coretypes.Transaction) error {
return p.EthTxPool.Insert(sdk.Context{}.WithPriority(signedTx.GasPrice().Int64()), cosmosTx)
}

func (p *plugin) SendBundle(txs coretypes.Transactions, blockNumber int64, uuid uuid.UUID, signingAddress common.Address, minTimestamp uint64, maxTimestamp uint64, revertingTxHashes []common.Hash) error {
/*
Serialize the transactions to SdkTx

send the bundle to the skip auction mempool (ok what goes here?)

gg ez?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty much ya


*/
return nil
}

func (p *plugin) IsPlugin() {}
14 changes: 14 additions & 0 deletions eth/core/chain_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"context"
"math/big"

"github.com/gofrs/uuid"

"github.com/ethereum/go-ethereum/core/vm"

"pkg.berachain.dev/polaris/eth/common"
Expand All @@ -42,6 +44,10 @@ type ChainWriter interface {
Finalize(context.Context) error
// SendTx sends the given transaction to the tx pool.
SendTx(ctx context.Context, signedTx *types.Transaction) error
// SendPrivTx privately sends the given transaction to the tx pool.
SendPrivTx(ctx context.Context, signedPrivTx *types.Transaction) error
// SendBundle sends the given bundle to the tx pool.
SendBundle(ctx context.Context, txs types.Transactions, blockNumber int64, uuid uuid.UUID, signingAddress common.Address, minTimestamp uint64, maxTimestamp uint64, revertingTxHashes []common.Hash) error
}

// =========================================================================
Expand Down Expand Up @@ -183,3 +189,11 @@ func (bc *blockchain) Finalize(ctx context.Context) error {
func (bc *blockchain) SendTx(_ context.Context, signedTx *types.Transaction) error {
return bc.tp.SendTx(signedTx)
}

func (bc *blockchain) SendPrivTx(_ context.Context, signedPrivTx *types.Transaction) error {
return bc.tp.SendPrivTx(signedPrivTx)
}

func (bc *blockchain) SendBundle(_ context.Context, txs types.Transactions, blockNumber int64, uuid uuid.UUID, signingAddress common.Address, minTimestamp uint64, maxTimestamp uint64, revertingTxHashes []common.Hash) error {
return bc.tp.SendBundle(txs, blockNumber, uuid, signingAddress, minTimestamp, maxTimestamp, revertingTxHashes)
}
6 changes: 6 additions & 0 deletions eth/core/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ package core
import (
"math/big"

"github.com/gofrs/uuid"

"github.com/ethereum/go-ethereum/event"

"pkg.berachain.dev/polaris/eth/common"
Expand Down Expand Up @@ -129,6 +131,10 @@ type (
TxPoolPlugin interface {
// SendTx submits the tx to the transaction pool.
SendTx(tx *types.Transaction) error
// SendPrivTx sends a private transaction to the transaction pool.
SendPrivTx(tx *types.Transaction) error
// SendBundle sends a bundle of transactions to the transaction pool.
SendBundle(txs types.Transactions, blockNumber int64, uuid uuid.UUID, signingAddress common.Address, minTimestamp uint64, maxTimestamp uint64, revertingTxHashes []common.Hash) error
// Pending returns all pending transactions in the transaction pool.
Pending(bool) map[common.Address]types.Transactions
// Get returns the transaction from the pool with the given hash.
Expand Down
125 changes: 125 additions & 0 deletions eth/core/mock/txpool_plugin.mock.go

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

1 change: 1 addition & 0 deletions eth/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ replace github.com/ethereum/go-ethereum => github.com/berachain/polaris-geth v0.
require (
github.com/BurntSushi/toml v1.2.1
github.com/ethereum/go-ethereum v1.11.4
github.com/gofrs/uuid v3.3.0+incompatible
github.com/onsi/ginkgo/v2 v2.9.5
github.com/onsi/gomega v1.27.6
golang.org/x/text v0.9.0
Expand Down
1 change: 1 addition & 0 deletions eth/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6Wezm
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84=
github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4=
Expand Down
10 changes: 10 additions & 0 deletions eth/rpc/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"math/big"
"time"

"github.com/gofrs/uuid"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/consensus"
Expand Down Expand Up @@ -454,6 +456,14 @@ func (b *backend) SendTx(ctx context.Context, signedTx *types.Transaction) error
return b.chain.SendTx(ctx, signedTx)
}

func (b *backend) SendPrivTx(ctx context.Context, signedPrivTx *types.Transaction) error {
return b.chain.SendPrivTx(ctx, signedPrivTx)
}

func (b *backend) SendBundle(ctx context.Context, txs types.Transactions, blockNumber int64, uuid uuid.UUID, signingAddress common.Address, minTimestamp uint64, maxTimestamp uint64, revertingTxHashes []common.Hash) error {
return b.chain.SendBundle(ctx, txs, blockNumber, uuid, signingAddress, minTimestamp, maxTimestamp, revertingTxHashes)
}

func (b *backend) GetPoolTransactions() (types.Transactions, error) {
b.logger.Info("called eth.rpc.backend.GetPoolTransactions")
return b.chain.GetPoolTransactions()
Expand Down