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

[Bug Report] state.list_resource resource_types filter do not work use short address. #3612

Closed
jolestar opened this issue Aug 4, 2022 · 6 comments · Fixed by #3615
Closed
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@jolestar
Copy link
Member

jolestar commented Aug 4, 2022

Bug Report

Starcoin version:

latest

Current behavior:

curl 'http://halley.seed.starcoin.org/' \
  -H 'content-type: application/json' \
  --data-raw '{"jsonrpc":"2.0","method":"state.list_resource","params":["0x4783d08fb16990bd35d83f3e23bf93b8",{"decode":true,"resource_types":["0x1::Account::Balance"]}],"id":0}'

{"jsonrpc":"2.0","result":{"resources":{}},"id":0}


curl 'http://halley.seed.starcoin.org/' \
  -H 'content-type: application/json' \
  --data-raw '{"jsonrpc":"2.0","method":"state.list_resource","params":["0x0000000000000000000000000a550c18",{"decode":true,"resource_types":["0x00000000000000000000000000000001::Account::Balance"]}],"id":0}'


{"jsonrpc":"2.0","result":{"resources":{"0x00000000000000000000000000000001::Account::Balance<0x00000000000000000000000000000001::STC::STC>":{"json":{"token":{"value":159256800000000000}},"raw":"0x00c0104037cb35020000000000000000"}}},"id":0}

Expected behavior:

"resource_types":["0x1::Account::Balance"] == "resource_types":["0x00000000000000000000000000000001::Account::Balance"]}]

Steps to reproduce:

Related code:

let struct_tag = StructTag::decode(k.as_slice()).unwrap();
let resource_type_address_module_name_str = format!(
"{}::{}::{}",
struct_tag.address, struct_tag.module, struct_tag.name
);
resource_types_set
.as_ref()
.unwrap()
.contains(&resource_type_address_module_name_str)

Other information:

@jolestar jolestar added bug Something isn't working help wanted Extra attention is needed labels Aug 4, 2022
@jolestar
Copy link
Member Author

jolestar commented Aug 4, 2022

@jiangying000 #3586 这个实现好像有点问题

@YouNeedWork
Copy link
Contributor

working on it

@jiangying000
Copy link
Collaborator

jiangying000 commented Aug 4, 2022

@jiangying000 #3586 这个实现好像有点问题

当时想的是先实现最严格的Addr::Module::StructTag完全版字符串的匹配,后续根据实际需求做修改

resource_types内部实现改一下就可以支持各类级别的筛选,短地址0x1,支持仅地址0x005c80,支持模块0x5588::Abc,支持带泛型0x1::22bc::XXY<A,B>,应该都是改下都可以了

当时没想到要手打地址的场景😂,以为就是前端调api的时候写死在代码里面的

@jolestar
Copy link
Member Author

jolestar commented Aug 4, 2022

@YusongWang 你要做的话,和 @jiangying000 沟通一下想法

@YouNeedWork
Copy link
Contributor

@jiangying000 #3615 看下这里。只对address进行了匹配。看了你说的,估计你做的方法应该更普遍合适一些,可以转给你做。

@jolestar
Copy link
Member Author

jolestar commented Aug 4, 2022

@jiangying000 #3586 这个实现好像有点问题

当时想的是先实现最严格的Addr::Module::StructTag完全版字符串的匹配,后续根据实际需求做修改

resource_types内部实现改一下就可以支持各类级别的筛选,短地址0x1,支持仅地址0x005c80,支持模块0x5588::Abc,支持带泛型0x1::22bc::XXY<A,B>,应该都是改下都可以了

当时没想到要手打地址的场景😂,以为就是前端调api的时候写死在代码里面的

感觉需要解析一下地址,通过解析后的类型去比较,而不是字符串匹配,可以和 #3614 的方案一起考虑下。
最关键的场景就是不带泛型参数的统配过滤

@jolestar jolestar linked a pull request Aug 11, 2022 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants