Problem: latest parity/scale-codec failed to compile (CRO-161) #120#133
Problem: latest parity/scale-codec failed to compile (CRO-161) #120#133tomtau merged 3 commits intocrypto-com:masterfrom
Conversation
devashishdxt
left a comment
There was a problem hiding this comment.
A few comments:
- There's a compilation error in tests. You'll have to change
usizetou64in tests as well. - Run
cargo fmtandcargo clippybefore pushing your code. This will properly format your code and also warn you about non-idiomatic Rust code. Current CI has lint and formatting checks in place so, build won't succeed without properly formatted code.
client-core/src/transaction_builder/default_transaction_builder.rs
Outdated
Show resolved
Hide resolved
thanks |
tomtau
left a comment
There was a problem hiding this comment.
I think the basic fix looks OK, but needs a few small changes.
In addition to @devashishdxt suggestions here (cargo fmt, cargo clippy, cargo test): #133 (review)
It'd be good to follow the patch convention for commit / pull request message: https://rfc.zeromq.org/spec:42/C4/#23-patch-requirements
Here, it could be, for example:
Problem: latest parity/scale-codec fails to compile (CRO-161) #120
Solution: converted usize fields (in datatypes that use scale-codec) to u64
bb5f011 to
a76ea27
Compare
Codecov Report
@@ Coverage Diff @@
## master #133 +/- ##
=========================================
Coverage ? 79.29%
=========================================
Files ? 77
Lines ? 6971
Branches ? 0
=========================================
Hits ? 5528
Misses ? 1443
Partials ? 0
|
|
LGTM. Wait for @tomtau to approve before merging. |
tomtau
left a comment
There was a problem hiding this comment.
Reviewed 20 of 20 files at r1.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @leejw51crypto)
chain-abci/src/app/validate_tx.rs, line 72 at r1 (raw file):
let min_fee = state .fee_policy .calculate_fee(_req.tx().len() as u64)
I think calculate_fee could keep usize? it's a function, so no effect on parity/scale codec encoding
chain-abci/src/storage/tx.rs, line 158 at r1 (raw file):
match txo { Ok(Some(v)) => { let bv = BitVec::from_bytes(&v).get(txin.index as usize);
perhaps create a casted value in the beginning:
let input_index = txin.index as usize;
and then use this later instead of all the casts?
BitVec::from_bytes(&v).get(input_index);
...
if input_index >= outputs.len() {
...
let txout = &outputs[input_index];
?
chain-core/src/init/address.rs, line 27 at r1 (raw file):
/// Keccak-256 crypto hash length in bytes pub const KECCAK256_BYTES: u64 = 32;
is it necessary to change this constant's type? I think it's only used in defining the array sizes?
chain-core/src/tx/fee/mod.rs, line 70 at r1 (raw file):
pub enum MilliError { /// An invalid length of parts (should be 2) InvalidPartsLength(u64),
MilliError doesn't seem to need Encode/Decode, so I think it could be kept as usize?
chain-core/src/tx/fee/mod.rs, line 154 at r1 (raw file):
} pub fn estimate(&self, sz: u64) -> Result<Fee, CoinError> {
I think calculate_fee / estimate could keep usize? They are functions, so no effect on parity/scale codec encoding
client-core/src/service/root_hash_service.rs, line 114 at r1 (raw file):
} fn combinations(public_keys: Vec<PublicKey>, n: u64) -> Result<Vec<RawPubkey>> {
does n need to be u64 here? @devashishdxt
client-core/src/wallet/default_wallet_client.rs, line 677 at r1 (raw file):
as mentioned:
I think
calculate_fee/estimatecould keep usize? They are functions, so no effect on parity/scale codec encoding
client-rpc/src/wallet_rpc.rs, line 259 at r1 (raw file):
I think
calculate_fee/estimatecould keep usize? They are functions, so no effect on parity/scale codec encoding
There was a problem hiding this comment.
@leejw51crypto looks good, just three small requests before merging it:
- upstream master changed, so just sync up with that (
git pull origin master+ resolve conflicts) - usize can be kept where it's not related to binary encoding/serialisation (i.e. the fee algorithm function arguments + error data types that don't implement binary serialization)
- if there's a block of code where one value needs to be re-casted multiple times, it could be recasted once
let recasted_val = original_val as ...;and then used in those places
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @leejw51crypto)
|
Since we are making this change only to support encoding and decoding of |
do you mean to keep |
Yes. This will also help with error handling and avoiding integer overflows. Since Rust does not perform any overflow checks in release mode, I think manually implementing |
There were two cases where
For the latter one, it'll require more thought case-by-case (or datatype-by-datatype), so I'll delay that for now -- the simplest solution for the problem here ("latest parity/scale-codec failed to compile") is to keep using auto-derived implementations. |
|
ok, got it |
Bumps [quickcheck](https://github.com/BurntSushi/quickcheck) from 0.8.3 to 0.8.5. - [Release notes](https://github.com/BurntSushi/quickcheck/releases) - [Commits](BurntSushi/quickcheck@0.8.3...0.8.5) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Problem: latest parity/scale-codec failed to compile (CRO-161) crypto-com#120 Solution: converted usize fields (in datatypes that use scale-codec) to u64
|
seems upstream merge attempt brought back old code? https://github.com/crypto-com/chain/pull/133/files#diff-38d25694877d43825df8be4ab3c0a683 |
791ac43 to
c9a7e8b
Compare
|
merged with latest master |
Solution: converted usize fields (in datatypes that use scale-codec) to u64
This change is