From 7e9ce630c9e0728d99f8e5b203e9f6822610ebf0 Mon Sep 17 00:00:00 2001 From: jsvisa Date: Tue, 9 Sep 2025 15:24:53 +0800 Subject: [PATCH] improve --- eth/filters/api.go | 8 +++--- eth/filters/filter.go | 2 +- eth/filters/filter_system_test.go | 48 +++++++++++++++---------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/eth/filters/api.go b/eth/filters/api.go index 445fa54650..3b5a9ff0f5 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -53,14 +53,14 @@ var ( ) const ( + // The maximum number of addresses allowed in a filter criteria + maxAddresses = 1000 + // The maximum number of topic criteria allowed, vm.LOG4 - vm.LOG0 + maxTopics = 4 // maxTrackedBlocks is the number of block hashes that will be tracked by subscription. maxTrackedBlocks = 32 * 1024 - // maxTopics is the maximum number of topics that can be specified in a filter - maxTopics = 4 // maxSubTopics is the maximum number of sub-topics that can be specified in a single topic position maxSubTopics = 1000 - // maxAddresses is the maximum number of addresses that can be specified in a filter - maxAddresses = 1000 ) // filter is a helper struct that holds meta information over the filter type diff --git a/eth/filters/filter.go b/eth/filters/filter.go index 6d0dd321cc..1a9918d0ee 100644 --- a/eth/filters/filter.go +++ b/eth/filters/filter.go @@ -32,7 +32,7 @@ import ( "github.com/ethereum/go-ethereum/rpc" ) -// Filter can be used to retrieve and filter historical logs. +// Filter can be used to retrieve and filter logs. type Filter struct { sys *FilterSystem diff --git a/eth/filters/filter_system_test.go b/eth/filters/filter_system_test.go index 56dfffbebc..287116d08e 100644 --- a/eth/filters/filter_system_test.go +++ b/eth/filters/filter_system_test.go @@ -725,6 +725,30 @@ func (n *mockNotifier) Notify(id rpc.ID, data interface{}) error { return nil } +var ( + signer = types.HomesteadSigner{} + key, _ = crypto.GenerateKey() + addr = crypto.PubkeyToAddress(key.PublicKey) + addrHash = common.HexToHash(addr.Hex()) + contract = common.HexToAddress("0000000000000000000000000000000000031ec7") + // Transfer(address indexed from, address indexed to, uint256 value); + topic = common.HexToHash("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef") + genesisAlloc = core.GenesisAlloc{ + // // SPDX-License-Identifier: GPL-3.0 + // pragma solidity >=0.7.0 <0.9.0; + // + // contract Token { + // event Transfer(address indexed from, address indexed to, uint256 value); + // function transfer(address to, uint256 value) public returns (bool) { + // emit Transfer(msg.sender, to, value); + // return true; + // } + // } + contract: {Balance: big.NewInt(params.Ether), Code: common.FromHex("0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063a9059cbb14610030575b600080fd5b61004a6004803603810190610045919061016a565b610060565b60405161005791906101c5565b60405180910390f35b60008273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516100bf91906101ef565b60405180910390a36001905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610101826100d6565b9050919050565b610111816100f6565b811461011c57600080fd5b50565b60008135905061012e81610108565b92915050565b6000819050919050565b61014781610134565b811461015257600080fd5b50565b6000813590506101648161013e565b92915050565b60008060408385031215610181576101806100d1565b5b600061018f8582860161011f565b92505060206101a085828601610155565b9150509250929050565b60008115159050919050565b6101bf816101aa565b82525050565b60006020820190506101da60008301846101b6565b92915050565b6101e981610134565b82525050565b600060208201905061020460008301846101e0565b9291505056fea2646970667358221220b469033f4b77b9565ee84e0a2f04d496b18160d26034d54f9487e57788fd36d564736f6c63430008120033")}, + addr: {Balance: big.NewInt(params.Ether)}, + } +) + // TestLogsSubscription tests if a rpc subscription receives the correct logs func TestLogsSubscription(t *testing.T) { t.Parallel() @@ -894,30 +918,6 @@ func TestLogsSubscription(t *testing.T) { } } -var ( - signer = types.HomesteadSigner{} - key, _ = crypto.GenerateKey() - addr = crypto.PubkeyToAddress(key.PublicKey) - addrHash = common.HexToHash(addr.Hex()) - contract = common.HexToAddress("0000000000000000000000000000000000031ec7") - // Transfer(address indexed from, address indexed to, uint256 value); - topic = common.HexToHash("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef") - genesisAlloc = core.GenesisAlloc{ - // // SPDX-License-Identifier: GPL-3.0 - // pragma solidity >=0.7.0 <0.9.0; - // - // contract Token { - // event Transfer(address indexed from, address indexed to, uint256 value); - // function transfer(address to, uint256 value) public returns (bool) { - // emit Transfer(msg.sender, to, value); - // return true; - // } - // } - contract: {Balance: big.NewInt(params.Ether), Code: common.FromHex("0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063a9059cbb14610030575b600080fd5b61004a6004803603810190610045919061016a565b610060565b60405161005791906101c5565b60405180910390f35b60008273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516100bf91906101ef565b60405180910390a36001905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610101826100d6565b9050919050565b610111816100f6565b811461011c57600080fd5b50565b60008135905061012e81610108565b92915050565b6000819050919050565b61014781610134565b811461015257600080fd5b50565b6000813590506101648161013e565b92915050565b60008060408385031215610181576101806100d1565b5b600061018f8582860161011f565b92505060206101a085828601610155565b9150509250929050565b60008115159050919050565b6101bf816101aa565b82525050565b60006020820190506101da60008301846101b6565b92915050565b6101e981610134565b82525050565b600060208201905061020460008301846101e0565b9291505056fea2646970667358221220b469033f4b77b9565ee84e0a2f04d496b18160d26034d54f9487e57788fd36d564736f6c63430008120033")}, - addr: {Balance: big.NewInt(params.Ether)}, - } -) - func makeTx(to int, value int, b *core.BlockGen) *types.Transaction { // transfer(address to, uint256 value) data := fmt.Sprintf("0xa9059cbb%s%s", common.HexToHash(common.BigToAddress(big.NewInt(int64(to))).Hex()).String()[2:], common.BytesToHash([]byte{byte(value)}).String()[2:])