Skip to content
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 blockHash filter #811

Open
banishee opened this issue Feb 17, 2021 · 1 comment
Open
Labels
rpc Ethereum JSON-RPC related issues and PRs Status: On Ice Type: User Reported

Comments

@banishee
Copy link

banishee commented Feb 17, 2021

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

Steps to reproduce:

  1. Deploy a contract (make sure this contract will emit events), then get specific block hash and contract address
  2. Enter the contract address, topic names and block hash, 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)
	blockHash := receipt["blockHash"].(string)
	contractAddrHex := receipt["contractAddress"].(string)
	
        // Create filter
	param := make([]map[string]interface{}, 1)
	param[0] = make(map[string]interface{})
	param[0]["blockHash"] = blockHash
	param[0]["addresses"] = []string{contractAddrHex}
	param[0]["topics"] = []string{helloTopic, worldTopic}
	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 in the block with block hash %s successfully with ID %s\n", contractAddrHex, blockHash, 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_BlockHash
    utils_test.go:143: 0x2CF4ea7dF75b513509d95946B43062E26bD88035 has deployed a contract 0x82d796c59dcf67192f5ca11182ccfdb827a8eb2d with tx hash 0xf8df01e47a4964920c89a1bc9872fff75108803bb368f0967d52ad81e7f539f0 successfully
    rpc_test.go:1109: create filter focusing on contract 0x82d796c59dcf67192f5ca11182ccfdb827a8eb2d in the block with block hash 0xb5239e45133f8cc0c58e73b2675291e7290af492882c5c12a0c69ad39960ca95 successfully with ID 0x2b5917acbbe7d014feacd4978069fb2e
    rpc_test.go:1116: 
        	Error Trace:	rpc_test.go:1116
        	Error:      	Not equal: 
        	            	expected: 1
        	            	actual  : 0
        	Test:       	TestEth_GetFilterChanges_BlockHash
--- FAIL: TestEth_GetFilterChanges_BlockHash (6.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.]

@github-actions
Copy link

github-actions bot commented Apr 4, 2021

This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the stale stale PRs that will be closed if no further action occurs label Apr 4, 2021
@araskachoi araskachoi reopened this Apr 12, 2021
@araskachoi araskachoi reopened this May 10, 2021
@araskachoi araskachoi added rpc Ethereum JSON-RPC related issues and PRs Status: On Ice Type: User Reported labels May 10, 2021
@github-actions github-actions bot removed the stale stale PRs that will be closed if no further action occurs label May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
rpc Ethereum JSON-RPC related issues and PRs Status: On Ice Type: User Reported
Projects
None yet
Development

No branches or pull requests

2 participants