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

Update env to include delete-im, remove-EnvVal changes #794

Merged
merged 4 commits into from
Dec 14, 2022

Conversation

jayz22
Copy link
Contributor

@jayz22 jayz22 commented Dec 13, 2022

What

Update env to include delete-im, remove-EnvVal changes

Why

[TODO: Why this change is being made. Include any context required to understand the why.]

Known limitations

[TODO or N/A]

Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

Small suggestions inline, otherwise lgtm.

I would consider getting rid of the EnvVal and EnvObj types. The goal was in part to get rid of unnecessary concepts, but this PR seems to attempt to maintain those two concepts, which I think are unnecessary and I regret adding them. Because they just make one more thing to learn when navigating this code.

soroban-sdk/src/accounts.rs Outdated Show resolved Hide resolved
soroban-sdk/src/accounts.rs Show resolved Hide resolved
soroban-sdk/src/env.rs Outdated Show resolved Hide resolved
@jayz22
Copy link
Contributor Author

jayz22 commented Dec 13, 2022

I would consider getting rid of the EnvVal and EnvObj types.

I would love so as well. I already removed EnvVal.
However, when I replace EnvObj (replacing with Env + Object) for Map and Vec:
pub struct Map<K, V>(Env, Object, PhantomData<K>, PhantomData<V>);
repr(transparent) was giving me problem "transparent struct needs at most one non-zero-sized field, but has 2". Is it ok that we remove repr(transparent)?

@leighmcculloch
Copy link
Member

Is it ok that we remove repr(transparent)?

I think yes. The attributes guarantees that the ABI of the inner value and struct are the same, so that you could transmute between them. More details here. We only need it on types that cross extern/exported functions, and the only types we have that do that are RawVal and Object. So it is critical that we keep it on those types, but other types no.

@jayz22 jayz22 marked this pull request as ready for review December 14, 2022 02:51
Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

🎉 👏🏻

@@ -111,16 +113,21 @@ impl PartialOrd for AccountId {

impl Ord for AccountId {
fn cmp(&self, other: &Self) -> core::cmp::Ordering {
self.0.cmp(&other.0)
self.env.check_same_env(&other.env);
Copy link
Member

Choose a reason for hiding this comment

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

Good call to add this check.

@leighmcculloch leighmcculloch enabled auto-merge (squash) December 14, 2022 06:36
@leighmcculloch leighmcculloch merged commit 14eea96 into stellar:main Dec 14, 2022
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.

2 participants