Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc filter issues #669

Closed
3 tasks
debris opened this issue Apr 8, 2015 · 8 comments
Closed
3 tasks

rpc filter issues #669

debris opened this issue Apr 8, 2015 · 8 comments
Labels

Comments

@debris
Copy link
Contributor

debris commented Apr 8, 2015

Tested on mac 10.9, 7c0a18e

Note

You can use eth-event-tests repository to reproduce these issues faster

overview

I've been playing with go rpc filters recently, and found few issues:

address_issue

  • Filtering events, by passing an address does not work. Scenario:
    • create contract
    • mine
    • call contract function, which triggers an event
    • call to eth_getLogs returns empty array

request:

{
  "jsonrpc": "2.0",
  "method": "eth_getLogs",
  "params": [
    {
      "fromBlock": "0x0",
      "address": "0xfa606d6c3737862698a00c5b76679c87561be7b8"
    }
  ],
  "id": 1
}

response:

{
    "id": 1,
    "jsonrpc": "2.0",
    "result": []
}

mining_issue

  • When node is not mining, events are 'not saved'. Scenario:
    • create contract
    • mine
    • stop mining
    • call contract function, which triggers an event
    • call contract function, which triggers an event
    • start mining
    • call to eth_getLogs returns empty array

earliest_issue

  • Minor issue. Passing earliest as fromBlock doesn't work, but it should. See wiki
@tgerring
Copy link
Contributor

tgerring commented Apr 8, 2015

@debris Please split these into discrete issues so they can be addressed.

For example, addressing your 3rd point, can you describe how you determine this? I have a unit test that appears to disagree with you at

go-ethereum/rpc/args_test.go

Lines 1370 to 1391 in 6284604

func TestBlockFilterArgsWords(t *testing.T) {
input := `[{
"fromBlock": "latest",
"toBlock": "pending"
}]`
expected := new(BlockFilterArgs)
expected.Earliest = -1
expected.Latest = -2
args := new(BlockFilterArgs)
if err := json.Unmarshal([]byte(input), &args); err != nil {
t.Error(err)
}
if expected.Earliest != args.Earliest {
t.Errorf("Earliest shoud be %#v but is %#v", expected.Earliest, args.Earliest)
}
if expected.Latest != args.Latest {
t.Errorf("Latest shoud be %#v but is %#v", expected.Latest, args.Latest)
}
}

@frozeman frozeman added the RPC label Apr 8, 2015
@tgerring
Copy link
Contributor

tgerring commented Apr 8, 2015

For issue 1, " Filtering events, by passing an address does not work."

It seems that passing an address works fine. Unit tests here:

go-ethereum/rpc/args_test.go

Lines 1258 to 1368 in 6284604

func TestBlockFilterArgs(t *testing.T) {
input := `[{
"fromBlock": "0x1",
"toBlock": "0x2",
"limit": "0x3",
"offset": "0x0",
"address": "0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8",
"topics":
[
["0xAA", "0xBB"],
["0xCC", "0xDD"]
]
}]`
expected := new(BlockFilterArgs)
expected.Earliest = 1
expected.Latest = 2
expected.Max = 3
expected.Skip = 0
expected.Address = []string{"0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8"}
expected.Topics = [][]string{
[]string{"0xAA", "0xBB"},
[]string{"0xCC", "0xDD"},
}
args := new(BlockFilterArgs)
if err := json.Unmarshal([]byte(input), &args); err != nil {
t.Error(err)
}
if expected.Earliest != args.Earliest {
t.Errorf("Earliest shoud be %#v but is %#v", expected.Earliest, args.Earliest)
}
if expected.Latest != args.Latest {
t.Errorf("Latest shoud be %#v but is %#v", expected.Latest, args.Latest)
}
if expected.Max != args.Max {
t.Errorf("Max shoud be %#v but is %#v", expected.Max, args.Max)
}
if expected.Skip != args.Skip {
t.Errorf("Skip shoud be %#v but is %#v", expected.Skip, args.Skip)
}
if expected.Address[0] != args.Address[0] {
t.Errorf("Address shoud be %#v but is %#v", expected.Address, args.Address)
}
if expected.Topics[0][0] != args.Topics[0][0] {
t.Errorf("Topics shoud be %#v but is %#v", expected.Topics, args.Topics)
}
if expected.Topics[0][1] != args.Topics[0][1] {
t.Errorf("Topics shoud be %#v but is %#v", expected.Topics, args.Topics)
}
if expected.Topics[1][0] != args.Topics[1][0] {
t.Errorf("Topics shoud be %#v but is %#v", expected.Topics, args.Topics)
}
if expected.Topics[1][1] != args.Topics[1][1] {
t.Errorf("Topics shoud be %#v but is %#v", expected.Topics, args.Topics)
}
}
func TestBlockFilterArgsDefaults(t *testing.T) {
input := `[{
"address": ["0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8"],
"topics": ["0xAA","0xBB"]
}]`
expected := new(BlockFilterArgs)
expected.Earliest = -1
expected.Latest = -1
expected.Max = 100
expected.Skip = 0
expected.Address = []string{"0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8"}
expected.Topics = [][]string{[]string{"0xAA"}, []string{"0xBB"}}
args := new(BlockFilterArgs)
if err := json.Unmarshal([]byte(input), &args); err != nil {
t.Error(err)
}
if expected.Earliest != args.Earliest {
t.Errorf("Earliest shoud be %#v but is %#v", expected.Earliest, args.Earliest)
}
if expected.Latest != args.Latest {
t.Errorf("Latest shoud be %#v but is %#v", expected.Latest, args.Latest)
}
if expected.Max != args.Max {
t.Errorf("Max shoud be %#v but is %#v", expected.Max, args.Max)
}
if expected.Skip != args.Skip {
t.Errorf("Skip shoud be %#v but is %#v", expected.Skip, args.Skip)
}
if expected.Address[0] != args.Address[0] {
t.Errorf("Address shoud be %#v but is %#v", expected.Address, args.Address)
}
if expected.Topics[0][0] != args.Topics[0][0] {
t.Errorf("Topics shoud be %#v but is %#v", expected.Topics, args.Topics)
}
if expected.Topics[1][0] != args.Topics[1][0] {
t.Errorf("Topics shoud be %#v but is %#v", expected.Topics, args.Topics)
}
}

Is the issue that the address isn't being respected when registering or filtering the logs?

@debris
Copy link
Contributor Author

debris commented Apr 8, 2015

@tgerring ok, I will split

@debris
Copy link
Contributor Author

debris commented Apr 8, 2015

IS the issue that the address isn't being respected when registering or filtering the logs?

yes

@frozeman
Copy link
Contributor

frozeman commented Apr 8, 2015

the address issue is a duplicate of #629

@debris
Copy link
Contributor Author

debris commented Apr 8, 2015

the address issue is a duplicate of #629

yes, i will not split this one

@debris
Copy link
Contributor Author

debris commented Apr 8, 2015

For example, addressing your 3rd point, can you describe how you determine this? I have a unit test that appears to disagree with you at

go-ethereum/rpc/args_test.go

Lines 1370 to 1391 in 6284604

func TestBlockFilterArgsWords(t *testing.T) {
input := `[{
"fromBlock": "latest",
"toBlock": "pending"
}]`
expected := new(BlockFilterArgs)
expected.Earliest = -1
expected.Latest = -2
args := new(BlockFilterArgs)
if err := json.Unmarshal([]byte(input), &args); err != nil {
t.Error(err)
}
if expected.Earliest != args.Earliest {
t.Errorf("Earliest shoud be %#v but is %#v", expected.Earliest, args.Earliest)
}
if expected.Latest != args.Latest {
t.Errorf("Latest shoud be %#v but is %#v", expected.Latest, args.Latest)
}
}

@tgerring I've pulled latest develop and it's working. Thanks

@debris
Copy link
Contributor Author

debris commented Apr 8, 2015

I will close this issue and create new only for 2nd.

@debris debris closed this as completed Apr 8, 2015
jpeletier pushed a commit to epiclabs-io/go-ethereum that referenced this issue Jun 8, 2018
tony-ricciardi pushed a commit to tony-ricciardi/go-ethereum that referenced this issue Jan 20, 2022
s1na pushed a commit to s1na/go-ethereum that referenced this issue Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants