Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

[account-address] Make display and hex outputs consistent #54

Conversation

gregnazario
Copy link
Collaborator

Motivation

Now, all default outputs should be 0xCAPS. Additionally, there is now a from_hex_fuzzy() which handles both 0x and non-0x inputs for the time being.

This is built as follows:

  1. from_hex -> Only hex characters, exact length
  2. from_hex_literal -> Only 0x with hex characters, with length extension
  3. from_hex_fuzzy -> Match either condition
  4. short_str_lossless -> With 0x, but drop leading 0s
  5. Drop the to_hex and to_hex_literal since we can now use Display or Debug using the proper formatter. Additionally to remove any confusion around it. All of are now consistent as upper case.

#53

@gregnazario
Copy link
Collaborator Author

@tnowacki lmk how this looks

@tnowacki
Copy link
Member

Overall it looks fine to me! but I imagine there might be some changes if you have tests to fix (they are all red, not sure if related, looks like it might not be). Just ping me again when things are passing :)

@gregnazario
Copy link
Collaborator Author

@tnowacki it looks like there is a compilation issue in addition to the tests failing, though the compilation issue doesn't look like it's due to me

@gregnazario gregnazario force-pushed the make-account-address-hex-consistent branch from 4684dca to 01e13bb Compare April 20, 2022 17:22
@gregnazario gregnazario force-pushed the make-account-address-hex-consistent branch from 01e13bb to b76efe2 Compare April 20, 2022 17:39
impl RawAddress {
pub fn parse(s: &str) -> Result<Self> {
if let Ok(addr) = parse_address_literal(s) {
if let Ok(addr) = AccountAddress::from_hex_fuzzy(s) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the same behavior. WIthout the 0x parses from a decimal value, and that should be the behavior for this, and all CLI tools, to match the source language

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parse_address_literal was already doing fuzzy matching. So, if that's the case I'm not making this any more wrong, but it was wrong in the first place

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This the wrong sort of fuzzy parsing though. It should be following the source languages convention: 0x is hex, otherwise decimal

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then again.... this is mostly for identifiers, so maybe we should just force the 0x

Should probably reserve the dec/hex parsing for args

@@ -66,7 +66,7 @@ move run` must be applied to a module inside `storage/`",

let signer_addresses = signers
.iter()
.map(|s| AccountAddress::from_hex_literal(s))
.map(|s| AccountAddress::from_hex_fuzzy(s))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should use the source language parsing here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I was surprised to not a see a change for other arg parsing. Have you looked at that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to scope down my stuff to AccountAddresses for now, we can come back and do other args later.

@@ -213,7 +213,10 @@ pub fn parse_addresses(tval: TV) -> Result<PM::AddressDeclarations> {
} else if addresses
.insert(
ident,
Some(parse_address_literal(entry_str).context("Invalid address")?),
Some(
AccountAddress::from_hex_fuzzy(entry_str)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these should not be fuzzy. We should force 0x for package addresses

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't we add a test for that on the last PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original one parse_address_literal was fuzzy, so I'm unsure there. I can switch it back.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make sure we add back the dropped in tests from #59, those should test this change here one way or another

@mkurnikov
Copy link
Contributor

Does this fix diem/move#141 ?

@tnowacki
Copy link
Member

Does this fix diem/move#141 ?

It should at least make it easier to fix :P, unsure right now if it fixes it or not

Copy link
Member

@tnowacki tnowacki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's switch the calls in manifest_parser to from_hex_literal. Requesting changes to make sure we get those tests back from the revert.

Thanks for all of this! It should have been done long ago

@gregnazario
Copy link
Collaborator Author

Let's switch the calls in manifest_parser to from_hex_literal. Requesting changes to make sure we get those tests back from the revert.

Thanks for all of this! It should have been done long ago

Sorry, been very distracted on other things, I'll probably come back on a pass through this in a week or two.

@gregnazario gregnazario force-pushed the make-account-address-hex-consistent branch 4 times, most recently from 0af42bc to 369402e Compare May 8, 2022 06:53
@gregnazario gregnazario force-pushed the make-account-address-hex-consistent branch from 369402e to d9ab787 Compare May 8, 2022 06:53
@tnowacki
Copy link
Member

tnowacki commented May 9, 2022

@gregnazario, ping me when you want another review! (looks like you are still working through some changes)

@gregnazario gregnazario closed this Aug 2, 2022
wrwg pushed a commit to wrwg/move-lang that referenced this pull request Feb 10, 2023
vgao1996 pushed a commit to vgao1996/move that referenced this pull request Feb 27, 2023
vgao1996 pushed a commit that referenced this pull request Feb 27, 2023
vgao1996 pushed a commit to vgao1996/move that referenced this pull request Feb 27, 2023
vgao1996 pushed a commit that referenced this pull request Feb 28, 2023
nkysg referenced this pull request in starcoinorg/move Feb 28, 2023
nkysg referenced this pull request in starcoinorg/move Feb 28, 2023
nkysg referenced this pull request in starcoinorg/move Feb 28, 2023
nkysg referenced this pull request in starcoinorg/move Feb 28, 2023
* Revert "[bytecode verifier] Meter type instantiations (#64)"

This reverts commit 803d4d1.

* Revert "[bytecode verifer] Adjust metering to decrease runtime of some tests. (#62)"

This reverts commit 459029f.

* Revert "[bytecode-verifier] Add metering logic and apply to absint based analysis (#58)"

This reverts commit 14d624d.

* Revert "copyloc-pop test (#54)"

This reverts commit 443c45a.

* Revert "[verifier] fix incorrect error code for per-module back edge limit check"

This reverts commit 1926f1a.

* Revert "[verifier] limit the number of back edges"

This reverts commit ef2f4d4.

* Revert "[language] add catch_unwind panic handling (move-language#750)"

This reverts commit b110827.
wrwg pushed a commit to wrwg/move-lang that referenced this pull request Mar 1, 2023
wrwg added a commit that referenced this pull request Mar 10, 2023
* [verifier] limit the number of back edges

* [verifier] fix incorrect error code for per-module back edge limit check

* copyloc-pop test (#54)

* [gas] allow natives to read the gas balance

* [bytecode-verifier] Add metering logic and apply to absint based analysis (#58)

This adds a simple meter to the bytecode verifier which counts the number of abstract operations performed and can enforce a limit. The meter is for now only connected to locals and reference analysis, but plumped to all phases of the verifier so they can easily make use of it.

A set of test cases have been added which exercise the new meter for a number of known pathological cases.

PR history:

- Add metering in type safety, to capture cost of very large types. This reduces timing of large_type_test to 1/4
- Adjusting max metering units upwards and adding a new sample which needs it
- Addressing reviewer comments
- Add links to security advisories, and verify that all are covered.
- Switching metering granularity from function to module.
- Adding non-linear growing penalty to using input refs x output refs relations (bicycles), for dealing better with `test_bicliques`. Adding printing size in benchmarks.

* [bytecode verifer] Adjust metering to decrease runtime of some tests. (#62)

Specifically the test below now runs in 1/2 of the time. This adjustment appeard useful because the overall time allocation had to be increased to 8000 million units in production. Adjusted this as the default here too.

```
--> test_merge_state: verification time: 59.414ms, result: CONSTRAINT_NOT_SATISFIED, size: 63kb
```

Also adjusts the default to what aptos uses now in production.

* [bytecode verifier] Meter type instantiations (#64)

Instead of just metering size of types on the operand stack, also meter size of type instantiations in calls and other places. This e.g. capture the size of types in calls like `f<T>()`, where the type does not appear on the operand stack.

---------

Co-authored-by: Victor Gao <vgao1996@gmail.com>
Co-authored-by: Teng Zhang <rahxephon89@163.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants