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

refactor: move type aliases from deps #415

Merged
merged 6 commits into from
May 15, 2021
Merged

Conversation

austinabell
Copy link
Contributor

  • Moves type aliases to the crate to have more control over semver breaking changes
  • Remove wildcard exports from other crates (easier to maintain)
  • Change references to the crate re-exports for easier updates

There should be no change to the API from this PR. I will note that there is a PromiseIndex in the two crates where it is a u64 in near_vm_types and usize in near_primatives_core but I kept the type alias that showed up in cargo docs (u64).

cc @matklad, was this what you had in mind for the first part of this? I can probably exclude the primitives and vm_logic types for wasm env with these changes. I will do that now and link to this

Copy link
Contributor

@willemneal willemneal left a comment

Choose a reason for hiding this comment

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

+1 for making types a module!

Copy link
Contributor

@matklad matklad left a comment

Choose a reason for hiding this comment

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

Looks good for me as is, I'd probably do wasm32 exclusion separately.

I suggest compiling https://github.com/near/core-contracts with this PR, to smoke test that this is as compatible as we think.

/// Account identifier. Provides access to user's state.
pub type AccountId = String;
/// Hash used by a struct implementing the Merkle tree.
pub type MerkleHash = CryptoHash;
Copy link
Contributor

Choose a reason for hiding this comment

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

So this is going to be a tough one. SDK defines a simple CryptoHash

image

But this MerkleHash is also public :-(

Can we quickly grep existing contracts to see if they use MerkleHash? Just to understand what leeway we have with changing that?

Although it seems that porting primitives-code CryptoHash and Digest won't be hard, just annoying.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I don't see a need for it to be exposed, but I was just trying to keep the API exactly as it was for now. I'll try to look to find any examples of using MerkleHash, but I doubt there would be any references to it through the SDK.

Copy link
Contributor

Choose a reason for hiding this comment

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

but I doubt there would be any references to it through the SDK.

I meant grepping extenral contracts, like near/core-contracts.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also headsup here -- CrypoHash definition in nearcore master branch is slightly different from the one used here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but I doubt there would be any references to it through the SDK.

I meant grepping extenral contracts, like near/core-contracts.

Yeah, what I meant by that is that I doubt people reference that type through the SDK because there is no connection with the SDK.

Also headsup here -- CrypoHash definition in nearcore master branch is slightly different from the one used here.

Yeah this is an overridden type, there are a few of these, and I'm not quite sure why yet

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think MerkleHash is used anywhere by the contracts. At least I'm not aware of one

@@ -0,0 +1,45 @@
use near_primitives_core::hash::CryptoHash;

pub use near_primitives_core::runtime::fees::RuntimeFeesConfig;
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be restricted to non-wasm32 as well, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, was going to do in follow up PR, but can make that change now (was being cautious to avoid removing if needed)

@mikedotexe mikedotexe merged commit 58bcd0d into master May 15, 2021
@mikedotexe mikedotexe deleted the austin/migrate_typedefs branch May 15, 2021 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants