From 4fc26f3772432ea293c5ce36e5e5f0bdba21c56f Mon Sep 17 00:00:00 2001 From: Michael de Hoog Date: Fri, 1 Sep 2023 11:28:02 -1000 Subject: [PATCH 1/2] Revert "Merge pull request #120 from ethereum-optimism/jg/fix_tests" This reverts commit a74d56b0c5dd14e9fff75f410a22415df0d1eeb9, reversing changes made to 88c9fa398246c3d215c5575f9e97689fb0dfe5bf. --- ethclient/gethclient/gethclient_test.go | 2 +- graphql/graphql_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ethclient/gethclient/gethclient_test.go b/ethclient/gethclient/gethclient_test.go index b830a07e4e..296d328484 100644 --- a/ethclient/gethclient/gethclient_test.go +++ b/ethclient/gethclient/gethclient_test.go @@ -60,7 +60,7 @@ func newTestBackend(t *testing.T) (*node.Node, []*types.Block) { if err != nil { t.Fatalf("can't create new ethereum service: %v", err) } - filterSystem := filters.NewFilterSystem(ethservice.APIBackend, filters.Config{AllowPendingTxs: true}) + filterSystem := filters.NewFilterSystem(ethservice.APIBackend, filters.Config{}) n.RegisterAPIs([]rpc.API{{ Namespace: "eth", Service: filters.NewFilterAPI(filterSystem, false), diff --git a/graphql/graphql_test.go b/graphql/graphql_test.go index 358015481f..0efee51a66 100644 --- a/graphql/graphql_test.go +++ b/graphql/graphql_test.go @@ -397,7 +397,7 @@ func newGQLService(t *testing.T, stack *node.Node, gspec *core.Genesis, genBlock t.Fatalf("could not create import blocks: %v", err) } // Set up handler - filterSystem := filters.NewFilterSystem(ethBackend.APIBackend, filters.Config{AllowPendingTxs: true}) + filterSystem := filters.NewFilterSystem(ethBackend.APIBackend, filters.Config{}) handler, err := newHandler(stack, ethBackend.APIBackend, filterSystem, []string{}, []string{}) if err != nil { t.Fatalf("could not create graphql service: %v", err) From 20753a13600a0d422c5e3516cc7f145594954682 Mon Sep 17 00:00:00 2001 From: Michael de Hoog Date: Fri, 1 Sep 2023 11:29:24 -1000 Subject: [PATCH 2/2] Revert "Merge pull request #118 from mdehoog/disable-pending-txpool-access" This reverts commit 88c9fa398246c3d215c5575f9e97689fb0dfe5bf, reversing changes made to bb04c5fa2ded81eb5d05889ae556bbeeeaf4ec0d. --- cmd/geth/main.go | 1 - cmd/utils/flags.go | 9 +-------- eth/ethconfig/config.go | 1 - eth/filters/api.go | 14 ++------------ eth/filters/filter_system.go | 2 -- eth/filters/filter_system_test.go | 16 +++------------- 6 files changed, 6 insertions(+), 37 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 2df6c63b55..6cf2fd57ff 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -146,7 +146,6 @@ var ( utils.RollupHistoricalRPCTimeoutFlag, utils.RollupDisableTxPoolGossipFlag, utils.RollupComputePendingBlock, - utils.RollupAllowPendingTxFilters, configFileFlag, }, utils.NetworkFlags, utils.DatabasePathFlags) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 16744c8193..f374c99556 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -893,11 +893,6 @@ var ( Usage: "By default the pending block equals the latest block to save resources and not leak txs from the tx-pool, this flag enables computing of the pending block from the tx-pool instead.", Category: flags.RollupCategory, } - RollupAllowPendingTxFilters = &cli.BoolFlag{ - Name: "rollup.allowpendingtxfilters", - Usage: "By default 'eth_subscribe' with 'NewPendingTransaction' and 'eth_newPendingTransactionFilter' are disabled to prevent leaking txs from the tx-pool.", - Category: flags.RollupCategory, - } // Metrics flags MetricsEnabledFlag = &cli.BoolFlag{ @@ -1844,7 +1839,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { } cfg.RollupDisableTxPoolGossip = ctx.Bool(RollupDisableTxPoolGossipFlag.Name) cfg.RollupDisableTxPoolAdmission = cfg.RollupSequencerHTTP != "" && !ctx.Bool(RollupEnableTxPoolAdmissionFlag.Name) - cfg.RollupAllowPendingTxFilters = ctx.Bool(RollupAllowPendingTxFilters.Name) // Override any default configs for hard coded networks. switch { case ctx.Bool(MainnetFlag.Name): @@ -2037,8 +2031,7 @@ func RegisterGraphQLService(stack *node.Node, backend ethapi.Backend, filterSyst func RegisterFilterAPI(stack *node.Node, backend ethapi.Backend, ethcfg *ethconfig.Config) *filters.FilterSystem { isLightClient := ethcfg.SyncMode == downloader.LightSync filterSystem := filters.NewFilterSystem(backend, filters.Config{ - LogCacheSize: ethcfg.FilterLogCacheSize, - AllowPendingTxs: ethcfg.RollupAllowPendingTxFilters, + LogCacheSize: ethcfg.FilterLogCacheSize, }) stack.RegisterAPIs([]rpc.API{{ Namespace: "eth", diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index c1b0e2ec56..2a7746a193 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -173,7 +173,6 @@ type Config struct { RollupHistoricalRPCTimeout time.Duration RollupDisableTxPoolGossip bool RollupDisableTxPoolAdmission bool - RollupAllowPendingTxFilters bool } // CreateConsensusEngine creates a consensus engine for the given chain config. diff --git a/eth/filters/api.go b/eth/filters/api.go index c00c02273d..cc08b442e8 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -36,8 +36,6 @@ import ( var ( errInvalidTopic = errors.New("invalid topic(s)") errFilterNotFound = errors.New("filter not found") - // errPendingDisabled is returned from NewPendingTransaction* when access to the mempool is not allowed - errPendingDisabled = errors.New("pending tx filters are disabled") ) // filter is a helper struct that holds meta information over the filter type @@ -111,11 +109,7 @@ func (api *FilterAPI) timeoutLoop(timeout time.Duration) { // // It is part of the filter package because this filter can be used through the // `eth_getFilterChanges` polling method that is also used for log filters. -func (api *FilterAPI) NewPendingTransactionFilter(fullTx *bool) (rpc.ID, error) { - if !api.sys.cfg.AllowPendingTxs { - return "", errPendingDisabled - } - +func (api *FilterAPI) NewPendingTransactionFilter(fullTx *bool) rpc.ID { var ( pendingTxs = make(chan []*types.Transaction) pendingTxSub = api.events.SubscribePendingTxs(pendingTxs) @@ -143,17 +137,13 @@ func (api *FilterAPI) NewPendingTransactionFilter(fullTx *bool) (rpc.ID, error) } }() - return pendingTxSub.ID, nil + return pendingTxSub.ID } // NewPendingTransactions creates a subscription that is triggered each time a // transaction enters the transaction pool. If fullTx is true the full tx is // sent to the client, otherwise the hash is sent. func (api *FilterAPI) NewPendingTransactions(ctx context.Context, fullTx *bool) (*rpc.Subscription, error) { - if !api.sys.cfg.AllowPendingTxs { - return &rpc.Subscription{}, errPendingDisabled - } - notifier, supported := rpc.NotifierFromContext(ctx) if !supported { return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported diff --git a/eth/filters/filter_system.go b/eth/filters/filter_system.go index 4e833e2556..1768681c17 100644 --- a/eth/filters/filter_system.go +++ b/eth/filters/filter_system.go @@ -44,8 +44,6 @@ import ( type Config struct { LogCacheSize int // maximum number of cached blocks (default: 32) Timeout time.Duration // how long filters stay active (default: 5min) - // allow filtering or subscriptions to new pending txs: - AllowPendingTxs bool } func (cfg Config) withDefaults() Config { diff --git a/eth/filters/filter_system_test.go b/eth/filters/filter_system_test.go index 97fd9752b6..ae0c83eb29 100644 --- a/eth/filters/filter_system_test.go +++ b/eth/filters/filter_system_test.go @@ -180,7 +180,6 @@ func (b *testBackend) ServiceFilter(ctx context.Context, session *bloombits.Matc func newTestFilterSystem(t testing.TB, db ethdb.Database, cfg Config) (*testBackend, *FilterSystem) { backend := &testBackend{db: db} - cfg.AllowPendingTxs = true sys := NewFilterSystem(backend, cfg) return backend, sys } @@ -264,10 +263,7 @@ func TestPendingTxFilter(t *testing.T) { hashes []common.Hash ) - fid0, err := api.NewPendingTransactionFilter(nil) - if err != nil { - t.Fatalf("Unable to create filter: %v", err) - } + fid0 := api.NewPendingTransactionFilter(nil) time.Sleep(1 * time.Second) backend.txFeed.Send(core.NewTxsEvent{Txs: transactions}) @@ -324,10 +320,7 @@ func TestPendingTxFilterFullTx(t *testing.T) { ) fullTx := true - fid0, err := api.NewPendingTransactionFilter(&fullTx) - if err != nil { - t.Fatalf("Unable to create filter: %v", err) - } + fid0 := api.NewPendingTransactionFilter(&fullTx) time.Sleep(1 * time.Second) backend.txFeed.Send(core.NewTxsEvent{Txs: transactions}) @@ -922,10 +915,7 @@ func TestPendingTxFilterDeadlock(t *testing.T) { // timeout either in 100ms or 200ms fids := make([]rpc.ID, 20) for i := 0; i < len(fids); i++ { - fid, err := api.NewPendingTransactionFilter(nil) - if err != nil { - t.Fatalf("Unable to create filter: %v", err) - } + fid := api.NewPendingTransactionFilter(nil) fids[i] = fid // Wait for at least one tx to arrive in filter for {