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

chore: update borsh and nearcore crate versions in SDK #639

Merged
merged 12 commits into from
Dec 2, 2021

Conversation

austinabell
Copy link
Contributor

  • Updates borsh to 0.9
  • Updates near-vm-logic and near-primitives-core to new version 0.10

Did not update near-sdk-sim because the dependencies needed were not released and this will be deprecated soon.

There seems to be a lot of new dependencies added for these, which isn't a huge issue but will increase compile times for tests. cc @miraclx if you're curious the diff on the SDK side from the releases :)

@austinabell
Copy link
Contributor Author

buildkite failing because rust version is too low to handle 2021 edition from new nearcore crate releases

Comment on lines 34 to 37
current_account_id: alice().as_str().parse().unwrap(),
signer_account_id: bob().as_str().parse().unwrap(),
signer_account_pk: vec![0u8; 32],
predecessor_account_id: bob().into(),
predecessor_account_id: bob().as_str().parse().unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it make more sense to implement two-way Froms for both AccountIds? Something like this:

impl From<near_vm_logic::types::AccountId> for AccountId {
    fn from(id: near_vm_logic::types::AccountId) -> Self {
        id.into()
    }
}

impl From<AccountId> for near_vm_logic::types::AccountId {
    fn from(id: AccountId) -> Self {
        id.into()
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because there is no direct conversion between the two. There is no ability to create a vm_logic AccountId without error checking. Can add a TryFrom impl for these, but that didn't seem like it would be worth it, given that it's just used internally and is basically the same amount of code.

if let Some(index) = receipt_indices.iter().find(|&&el| el >= self.receipts.len() as u64) {
return Err(HostError::InvalidReceiptIndex { receipt_index: *index }.into());
}
let res = self.receipts.len() as u64;
self.receipts.push(Receipt {
receipt_indices,
receiver_id: AccountId::new_unchecked(receiver_id),
receiver_id: AccountId::new_unchecked(String::from(receiver_id)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion above would also help to simplify this (and other changes in this file) to:

Suggested change
receiver_id: AccountId::new_unchecked(String::from(receiver_id)),
receiver_id: receiver_id.into(),

Copy link
Contributor Author

@austinabell austinabell Nov 29, 2021

Choose a reason for hiding this comment

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

This isn't a public-facing API, no one uses the vm_logic AccountId, and it's generally bad practice to have trait impls for only specific architectures (we cannot have the impl for wasm32-unknown-unknown). I'll consider making some change, though

@austinabell
Copy link
Contributor Author

commit for suggested change @itegulov 9e77d35 (#639). Not convinced this is better since just used internally, but I don't have a strong opinion so I'll just keep the change.

);
self.receipts
.get_mut(receipt_index as usize)
.unwrap()
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 we can just change this unwrap to yield an invalid receipt index instead for None

Suggested change
.unwrap()
.ok_or_else(|| HostError::InvalidReceiptIndex { receipt_index })?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point! I didn't change this in the update and this is just used for testing, but this might yield a better error

Copy link
Member

@ChaoticTempest ChaoticTempest left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants