Comments (6)
What is super bizarre is my tests with Address work fine. It is uint that specifically is giving strange results
even if there is an explanation for this , the documentation is highly insufficient and this is very confusing
from ethers-rs.
Okay i found another clue. It looks like in rust, Uint only matches JS if doing 'encode' and Address only matches if doing 'encodePacked' . The reference on JS is doing ' ethers.utils.solidityKeccak256 '. To my limited knowledge, that JS reference is doing encodePacked so i thought rust would also always be doing that. uh oh.
unfortunately, this means it is impossible for me to match hashes on a struct that has both an address and a uint. This seems like a bug... ?
from ethers-rs.
Okay i forked the code and changed it to this
'''
Uint(n) => {
/*
let mut buf = [0; 32];
n.to_big_endian(&mut buf);
let start = if in_array { 0 } else { 32 - ((n.bits() + 7) / 8) };
out.extend_from_slice(&buf[start..32]);
*/
let mut buf = [0; 32];
n.to_big_endian(&mut buf);
let start = 0;
out.extend_from_slice(&buf[start..32]);
}
'''
and now it works like a charm for me. Needs some investigation for sure !
from ethers-rs.
Btw im talking abt etherscore/src/abi/encode_packed having an issue here
from ethers-rs.
This is an unfortunate limitation of ethabi
tokens.
https://docs.rs/ethers/latest/ethers/abi/fn.encode_packed.html
Uint and Int tokens will be encoded using the least number of bits, so no padding will be added by default.
from ethers-rs.
Uhh so
- encodePacked isnt encodePacked? It means something different in rust versus javascript???
And 2 ) so there is absolutely no way to do solidityKeccak256(tokens[]) in rust yet ?
🤔 i feel like these are some serious problems as they relate to applications that want to use ECRecover with rust backend
from ethers-rs.
Related Issues (20)
- Abigen fails when foundry-evm is specified as a dependency in Cargo.toml
- Uint256 PercentagMath, WadRayMath
- `abi.encodePacked` for Uint
- Snowtrace is being discontinued HOT 1
- Incorrect subscription id HOT 4
- ethers-rs is being deprecated HOT 14
- Multiple issues with unsubscribe HOT 3
- `abigen` inline loading of ABI is failing HOT 1
- abi::encode_packed() returns incorrect value for U256s with leading zeroes HOT 1
- Sync supported Multicall chain deployments
- H256 and some of the other types truncate the string output like 0x13...141 which imo is horrible/frustrating HOT 5
- Implement encoding and signing for EIP-4844 transaction requests HOT 1
- is there a way to decode what is inside the CallFrame struct ?
- Support for other methods in subscribe (other than `eth_subscribe`)
- Container type for all of the contract's custom errors DO NOT GENERATE BY `abigen` for my contract's abi HOT 1
- Documentation is seriously outdated HOT 2
- Why this `as_aggregate_3_value` only available in `send` mode
- subscribe_full_pending_txs seems not working HOT 2
- NonceManagerMiddleware failures when running concurrently HOT 1
- 4844 rlp encoding not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ethers-rs.