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

Error while deserializing EthFilterSpec #4826

Closed
elmattic opened this issue Oct 2, 2024 · 5 comments
Closed

Error while deserializing EthFilterSpec #4826

elmattic opened this issue Oct 2, 2024 · 5 comments
Assignees
Labels
Type: Bug Something isn't working

Comments

@elmattic
Copy link
Contributor

elmattic commented Oct 2, 2024

Describe the bug

We don't support deserializing of "topics" correctly.

To reproduce

Run Forest and this Curl command:

curl -X POST 'http://127.0.0.1:2345/rpc/v1' \
    -H 'Content-Type: application/json' \
    --data '{"jsonrpc":"2.0","id":1,"method":"Filecoin.EthGetLogs","params":[{"blockHash": "0xa158a536fe66e18b8cbf5c392384d840483f84732e2a2ed8d9fb68cedcffef54", "address": ["0x51e1f72b655528de2d4d88e70bd53774db8d0b0c"], "topics": ["0x90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15"]}]}'

Log output

You should see:

{"jsonrpc":"2.0","id":1,"error":{"code":-32602,"message":"error deserializing parameter","data":{"error":"invalid type: string \"0x90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15\", expected a sequence","index":0,"name":"eth_filter","type":"forest_filecoin::lotus_json::LotusJson<forest_filecoin::rpc::methods::eth::types::EthFilterSpec>"}}}

Expected behavior

We should be able to deserialize this type.

We should have complete test coverage.

Screenshots

Environment (please complete the following information):

  • OS: any
  • Branch: main or 551932e (to reproduce my test settings)

Other information and links

Note I have already fixed topics here to allow for null topics.

Spec:
https://github.com/filecoin-project/lotus/blob/master/chain/types/ethtypes/eth_types.go#L676-L688

@sudo-shashank
Copy link
Contributor

sudo-shashank commented Oct 3, 2024

@elmattic topics fields in EthFilterSpec is a collection of EthHashList which is a collection of EthHash

#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct EthHashList(pub Vec<EthHash>);
#[derive(Default, Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct EthTopicSpec(pub Vec<EthHashList>);

correct curl cmd:

curl -X POST 'http://127.0.0.1:2345/rpc/v1' \
    -H 'Content-Type: application/json' \
    --data '{"jsonrpc":"2.0","id":1,"method":"Filecoin.EthGetLogs","params":[{"blockHash": "0xa158a536fe66e18b8cbf5c392384d840483f84732e2a2ed8d9fb68cedcffef54", "address": ["0x51e1f72b655528de2d4d88e70bd53774db8d0b0c"], "topics": [["0x90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15"]]}]}'

@elmattic
Copy link
Contributor Author

elmattic commented Oct 3, 2024

Yes, that works, but a scalar is also possible instead of a list.

@elmattic
Copy link
Contributor Author

@sudo-shashank I've changed EthHashList in #4780 to ease the pain for the topic matcher.

@elmattic
Copy link
Contributor Author

elmattic commented Oct 17, 2024

Note that this new EthHashList should parse following topics:

"topics": [ null, ["0x..", "0x.."] ] is valid
"topics": [ "0x..", 0x.., ["0x..", "0x.."] ] is valid
"topics": [ "0x..", null, ["0x..", "0x.."] ] is valid
"topics": [ "0x."., null, ["0x..", "0x.."], null ] is valid

edit: fix answer

@sudo-shashank sudo-shashank moved this from Ready to In progress in Forest Backlog 🌲 Oct 22, 2024
@sudo-shashank
Copy link
Contributor

this issue has been fixed in #4780

@github-project-automation github-project-automation bot moved this from In progress to Done in Forest Backlog 🌲 Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants