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

[libra framework] Separate freezing out into separate module, add freezing to VASPs #4937

Closed
wants to merge 1 commit into from

Conversation

tzakian
Copy link
Contributor

@tzakian tzakian commented Jul 7, 2020

This pulls account freezing out into its own module. The idea being that this module provides the "atomic semantics" of what it means for an account to be frozen. Other modules (e.g., VASP) can then use these semantics to provide a more semantically rich version of "freezing" e.g., if the parent account is frozen all of the child accounts are frozen, but if the child account is frozen then only that account is viewed as frozen.

Additionally, the libra root account, and TC account cannot be frozen. This is ensured in the AccountFreezing module

Won't land until all spec changes have passed.

@tzakian tzakian requested review from sblackshear and wrwg July 7, 2020 20:34
@tzakian tzakian added the breaking Any changes that will require restarting the testnet label Jul 7, 2020
@thefallentree
Copy link
Contributor

instead of removing is_frozen attribute, can you add logic to implement that in the view ? Otherwise we would need an new API for it again.

@tzakian
Copy link
Contributor Author

tzakian commented Jul 7, 2020

Shouldn't be an issue to implement in the view. I'll update.

Copy link
Contributor

@sblackshear sblackshear left a comment

Choose a reason for hiding this comment

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

Looks great to me from the Move perspective! The only thing I'm wondering is whether moving the freeze/unfreeze events to a new module is going to create churn for AOS (@moeziniaf?)

let initiator_address = Signer::address_of(account);
// The libra root account and TC cannot be frozen
assert(frozen_address != CoreAddresses::LIBRA_ROOT_ADDRESS(), ECANNOT_FREEZE_LIBRA_ROOT);
assert(frozen_address != CoreAddresses::TREASURY_COMPLIANCE_ADDRESS(), ECANNOT_FREEZE_TC);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to check an address or a role here (thinking of a future where there are multiple TC addresses...). Same question for the previous line, though perhaps less important given that there is supposed to be only one LR account...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question! I would like a role check here, however all of the role check functions take a &signer whereas we only have an address at this point. So we could update the has_role_* functions to take an address argument instead of a &signer, but doing that does make those functions a bit more "loose" in a sense (since you no longer have the direct connection to authority over the account), but I don't think it would be too bad.

@@ -260,6 +261,15 @@ module VASP {
}
}

/// A VASP account is frozen if itself is frozen, or if its parent account is frozen.
public fun is_frozen(addr: address): bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!!!!

@@ -970,7 +887,8 @@ module LibraAccount {
// Verify that the transaction sender's account exists
assert(exists_at(transaction_sender), EPROLOGUE_ACCOUNT_DNE);

assert(!account_is_frozen(transaction_sender), EPROLOGUE_ACCOUNT_FROZEN);
assert(!AccountFreezing::account_is_frozen(transaction_sender), EPROLOGUE_ACCOUNT_FROZEN);
assert(!VASP::is_frozen(transaction_sender), EPROLOGUE_ACCOUNT_FROZEN);
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth adding a comment explaining why there's a separate check for VASPs.

@moeziniaf
Copy link
Contributor

Looks great to me from the Move perspective! The only thing I'm wondering is whether moving the freeze/unfreeze events to a new module is going to create churn for AOS (@moeziniaf?)

Thanks! I believe we're just tailing the chain for Preburn events right now so doesn't seem to be an issue from our end

@bors-libra
Copy link
Contributor

☔ The latest upstream changes (presumably e3710c1) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Contributor

@moeziniaf moeziniaf left a comment

Choose a reason for hiding this comment

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

Looks like a helpful refactor!

Comment on lines +268 to +267
AccountFreezing::account_is_frozen(parent_address(addr)) ||
AccountFreezing::account_is_frozen(addr)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@tzakian
Copy link
Contributor Author

tzakian commented Jul 8, 2020

@bors-libra r=sblackshear

@bors-libra
Copy link
Contributor

📌 Commit 636f59d has been approved by sblackshear

@bors-libra
Copy link
Contributor

⌛ Testing commit 636f59d with merge 03f7efe...

@github-actions
Copy link

github-actions bot commented Jul 8, 2020

Cluster Test Result

all up : 1034 TPS, 4383 ms latency, 5400 ms p99 latency, no expired txns

Repro cmd:

./scripts/cti --tag land_03f7efeb --run bench

@bors-libra
Copy link
Contributor

☀️ Test successful - checks-actions_land_blocking_test, checks-circle_commit_workflow
Approved by: sblackshear
Pushing 03f7efe to master...

@bors-libra bors-libra closed this in 03f7efe Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Any changes that will require restarting the testnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants