Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

RPC eth_getFilterChanges dose not work as expected with blockNumber filter #810

Open
@banishee

Description

@banishee

System info: [Include Ethermint commit, operating system name, and other relevant details]

  • branch dev

Steps to reproduce:

  1. Deploy a contract (make sure this contract will emit events), then get specific block height and contract address
  2. Enter the contract address, topic names and starting block height, then create a filter parameter
  3. Based on this filter parameter, try to call eth_getFilterChanges api to get logs.
  4. But the result log is null.

The test code is as follows:

func TestEth_GetFilterChanges_Addresses(t *testing.T) {
        // Deploy contract which will emit event in constructor function
	_, receipt := deployTestContract(t, hexAddr1, testContractKind)
	contractAddrHex := receipt["contractAddress"].(string)
	blockHeight := receipt["blockNumber"].(string)
	
        // Create filter
	param := make([]map[string]interface{}, 1)
	param[0] = make(map[string]interface{})
	param[0]["addresses"] = []string{contractAddrHex}
	param[0]["topics"] = []string{helloTopic, worldTopic}
	param[0]["fromBlock"] = blockHeight
	rpcRes := Call(t, "eth_newFilter", param)

	var ID string
	require.NoError(t, json.Unmarshal(rpcRes.Result, &ID))
	t.Logf("create filter focusing on contract %s successfully with ID %s\n", contractAddrHex, ID)

	// Based on this filter id, query the changed ethlogs
	changesRes := Call(t, "eth_getFilterChanges", []string{ID})

	var logs []ethtypes.Log
	require.NoError(t, json.Unmarshal(changesRes.Result, &logs))
	require.Equal(t, 1, len(logs))
}

The error output:

=== RUN   TestEth_GetFilterChanges_Addresses
    utils_test.go:143: 0x2CF4ea7dF75b513509d95946B43062E26bD88035 has deployed a contract 0xe786781cb7a89017c758570b8e1e223551f7b71a with tx hash 0xcf67e7385c067ee5616ce32f6992c55725238e5d7cf200f332b02b15bb80729c successfully
    rpc_test.go:1083: create filter focusing on contract 0xe786781cb7a89017c758570b8e1e223551f7b71a successfully with ID 0xb821364c629d465dd6357b34b1efb47
    rpc_test.go:1090: 
        	Error Trace:	rpc_test.go:1090
        	Error:      	Not equal: 
        	            	expected: 1
        	            	actual  : 0
        	Test:       	TestEth_GetFilterChanges_Addresses
--- FAIL: TestEth_GetFilterChanges_Addresses (8.06s)

Expected behavior: [What you expected to happen]

  • It should return a specific log

Actual behavior: [What actually happened]

  • Developers cannot use filter api to query events with specified conditions

Additional info: [Include gist of relevant config, logs, etc.]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions