darwinia-network / darwinia-messages-sol

Darwinia cross-chain messages gateway and protocol for EVM developers 💌
MIT License
29 stars 8 forks source link

ScaleCodec decoding relayers is not correct #198

Closed cinlk closed 2 years ago

cinlk commented 2 years ago

the relayers bytes as follow come from feeMarket precompile calling 0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c10cc000808d24a072304e5a4cf436d3ef1f8a1353cc7e240b42446aadf7e6e4831e003c82b469000000000000000000000000d6117e0300000000000000000000008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48003c82b469000000000000000000000000d6117e030000000000000000000000f41d3260d736f5b3db8a6351766e97619ea35972546a5f850bbf0b27764abe0300743ba40b000000000000000000000000d6117e03000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Those bytes could be decoded correctly by rust confirmed form @AsceticBear, But ScaleCode couldn't find relayers.

boundless-forest commented 2 years ago
let bytes = hex2bytes_unchecked("0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c10cc000808d24a072304e5a4cf436d3ef1f8a1353cc7e240b42446aadf7e6e4831e003c82b469000000000000000000000000d6117e0300000000000000000000008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48003c82b469000000000000000000000000d6117e030000000000000000000000f41d3260d736f5b3db8a6351766e97619ea35972546a5f850bbf0b27764abe0300743ba40b000000000000000000000000d6117e03000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
ket mut eth_decode = abi_decode_bytes(&bytes).unwrap();

let final_result: Vec<Relayer<AccountId32, u128>> = Decode::decode(&mut eth_decode.as_slice()).unwrap();
println!("bear: --- final {:?}", final_result);
// bear: --- final [Relayer { id: c000808d24a072304e5a4cf436d3ef1f8a1353cc7e240b42446aadf7e6e4831e (5GQTCZhz...), collateral: 454000000000, fee: 15000000000 }, Relayer { id: 8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48 (5FHneW46...), collateral: 454000000000, fee: 15000000000 }, Relayer { id: f41d3260d736f5b3db8a6351766e97619ea35972546a5f850bbf0b27764abe03 (5HanDP7Y...), collateral: 50000000000, fee: 15000000000 }]
wuminzhe commented 2 years ago

https://github.com/darwinia-network/darwinia-messages-sol/pull/197

cinlk commented 2 years ago

197 solve input data encode problem. but this issue is that "ScaleCodec.decodeUintCompact" dose not work as excepted

wuminzhe commented 2 years ago

not the decodeUintCompact problem . the reason is that this precompile returns an abi-encoded data. @AsceticBear can we return non-abi-encoded data. I see the input data of precompile can be the non-abi-encoded data.

boundless-forest commented 2 years ago

It's doable to return non-ethabi data in the state-storage precompile in coing, but I am worried about it might break other applications using this precompile. What's the problem with the ethabi returned data here?

wuminzhe commented 2 years ago

It's doable to return non-ethabi data in the state-storage precompile in coing, but I am worried about it might break other applications using this precompile. What's the problem with the ethabi returned data here?

I prefer returning non-abi-encoded data, because this is redundant. but if worried about breaking the existing code, I will add a abi.decode in solidity.

https://github.com/darwinia-network/darwinia-messages-sol/issues/200

wuminzhe commented 2 years ago

keep abi encoded returning