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

[breaking][libra framework] add event on account creation #6156

Merged
merged 1 commit into from Sep 26, 2020

Conversation

sblackshear
Copy link
Contributor

  • New CreateAccountEvent struct that records the created address
  • Had to refactor LibraAccount::initialize() a bit to ensure that we can emit an event for the creation of LibraRoot
  • Had to refactor the event verification part of VM genesis since the number of events now depends on the # of created accounts
  • Added tests for each of the create_*_account functions
  • Added Rust wrapper for CreateAccountEvent

Comment on lines -201 to -222

assert(
!exists<AccountOperationsCapability>(CoreAddresses::LIBRA_ROOT_ADDRESS()),
Errors::already_published(EACCOUNT_OPERATIONS_CAPABILITY)
);
move_to(
lr_account,
AccountOperationsCapability {
limits_cap: AccountLimits::grant_mutation_capability(lr_account),
}
);

assert(
!exists<LibraWriteSetManager>(CoreAddresses::LIBRA_ROOT_ADDRESS()),
Errors::already_published(EWRITESET_MANAGER)
);
move_to(
lr_account,
LibraWriteSetManager {
upgrade_events: Event::new_event_handle<Self::UpgradeEvent>(lr_account),
}
);
Copy link
Contributor

@tzakian tzakian Sep 23, 2020

Choose a reason for hiding this comment

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

I feels odd for this to be in the in the create_libra_root_account function. What would you think of doing something like:

create_libra_root_account(...); // As before
emit_event<CreateAccountEvent>(....); // <- emit create account event for LR root account. 
<THIS CODE>
create_treasury_compliance_account(...);

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.

Unfortunately, this won't wok because emitting the event (which happens in create_libra_root_account) requires <THIS_CODE> to be run first, specifically, the AccountOperationsCapability part.

I actually felt good about moving this code into create_libra_root_account because the pattern we use elsewhere is to publish X role-specific resources in create_X_account. But certainly open to alternatives!

Copy link
Contributor

Choose a reason for hiding this comment

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

ahhh I see! For some reason I didn't see that the event emission is happening in make_account.

I'm fine with this as-is since I can't think of any other alternatives that wouldn't make the code more complicated.

/// Message for creation of a new account
struct CreateAccountEvent {
/// Address of the account that was created
created: address,
Copy link
Contributor

Choose a reason for hiding this comment

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

What would you think of also including the role id for the account created in this event?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I love it except that role id's will no longer be opaque. But I'm ok with that because they can already be read off-chain...

.iter()
.find(|e| e.key() == &NewEpochEvent::event_key())
.expect("Couldn't find NewEpochEvent");
assert_eq!(*new_epoch_event.key(), NewEpochEvent::event_key());
Copy link
Contributor

Choose a reason for hiding this comment

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

What would you think of adding an additional check that there's only one new epoch event?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very good idea, would not want to make that mistake (and it'd be easy to make!).

Copy link
Contributor

@tzakian tzakian left a comment

Choose a reason for hiding this comment

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

LGTM!

@MIRAI-bot
Copy link

[move-prover] Move Prover test (language/move-prover/cargo test) on commit 8877d8b did fail. See details.

@sblackshear
Copy link
Contributor Author

/canary

@bors-libra bors-libra moved this from In Review to Canary in bors Sep 24, 2020
bors-libra pushed a commit that referenced this pull request Sep 24, 2020
- New CreateAccountEvent struct that records the created address
- Had to refactor LibraAccount::initialize() a bit to ensure that we can emit an event for the creation of LibraRoot
- Had to refactor the event verification part of VM genesis since the number of events now depends on the # of created accounts
- Added tests for each of the create_*_account functions
- Added Rust wrapper for CreateAccountEvent

Previously, users saw only TYPE_MISMATCH, NUMBER_OF_TYPE_ARGUMENTS_MISMATCH, or LINKER_ERROR, which are not very descriptive

Closes: #6118
Closes: #6156
@github-actions
Copy link

Cluster Test Result

Cluster setup failed: `Nodes did not become healthy after deployment`
Logs: http://kibana.ct-0-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2020-09-24T14:56:15Z',to:'2020-09-24T15:07:56Z'))
Dashboard: http://grafana.ct-0-k8s-testnet.aws.hlw3truzy4ls.com/d/2XqUIhnWz/performance?from=1600959375000&to=1600960076000
Validator 1 logs: http://kibana.ct-0-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2020-09-24T14:56:15Z',to:'2020-09-24T15:07:56Z'))&_a=(columns:!(log),query:(language:kuery,query:'kubernetes.pod_name:"val-1"'),sort:!(!('@timestamp',desc)))

❗ Cluster Test failed - non-zero exit code for cti

Repro cmd:

./scripts/cti --tag land_441d1e4b --cluster-test-tag land_84eb8678 -E RUST_LOG=debug -E BATCH_SIZE=15 -E UPDATE_TO_TAG=land_84eb8678 --report report.json --suite land_blocking_compat

@bors-libra
Copy link
Contributor

💔 Test Failed - Build images and run cluster test

@bors-libra bors-libra moved this from Canary to In Review in bors Sep 24, 2020
@sblackshear
Copy link
Contributor Author

/canary

@bors-libra bors-libra moved this from In Review to Canary in bors Sep 24, 2020
bors-libra pushed a commit that referenced this pull request Sep 24, 2020
- New CreateAccountEvent struct that records the created address
- Had to refactor LibraAccount::initialize() a bit to ensure that we can emit an event for the creation of LibraRoot
- Had to refactor the event verification part of VM genesis since the number of events now depends on the # of created accounts
- Added tests for each of the create_*_account functions
- Added Rust wrapper for CreateAccountEvent

Previously, users saw only TYPE_MISMATCH, NUMBER_OF_TYPE_ARGUMENTS_MISMATCH, or LINKER_ERROR, which are not very descriptive

Closes: #6118
Closes: #6156
@github-actions
Copy link

Cluster Test Result

Cluster setup failed: `Nodes did not become healthy after deployment`
Logs: http://kibana.ct-2-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2020-09-24T17:31:21Z',to:'2020-09-24T17:48:43Z'))
Dashboard: http://grafana.ct-2-k8s-testnet.aws.hlw3truzy4ls.com/d/2XqUIhnWz/performance?from=1600968681000&to=1600969723000
Validator 1 logs: http://kibana.ct-2-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2020-09-24T17:31:21Z',to:'2020-09-24T17:48:43Z'))&_a=(columns:!(log),query:(language:kuery,query:'kubernetes.pod_name:"val-1"'),sort:!(!('@timestamp',desc)))

❗ Cluster Test failed - non-zero exit code for cti

Repro cmd:

./scripts/cti --tag land_a8205421 --cluster-test-tag land_9e51266c -E RUST_LOG=debug -E BATCH_SIZE=15 -E UPDATE_TO_TAG=land_9e51266c --report report.json --suite land_blocking_compat

@bors-libra
Copy link
Contributor

💔 Test Failed - Build images and run cluster test

@bors-libra bors-libra moved this from Canary to In Review in bors Sep 24, 2020
@sblackshear
Copy link
Contributor Author

/canary

bors-libra pushed a commit that referenced this pull request Sep 24, 2020
- New CreateAccountEvent struct that records the created address
- Had to refactor LibraAccount::initialize() a bit to ensure that we can emit an event for the creation of LibraRoot
- Had to refactor the event verification part of VM genesis since the number of events now depends on the # of created accounts
- Added tests for each of the create_*_account functions
- Added Rust wrapper for CreateAccountEvent

Previously, users saw only TYPE_MISMATCH, NUMBER_OF_TYPE_ARGUMENTS_MISMATCH, or LINKER_ERROR, which are not very descriptive

Closes: #6118
Closes: #6156
@bors-libra bors-libra moved this from In Review to Canary in bors Sep 24, 2020
@sblackshear
Copy link
Contributor Author

Ahh I forgot about that. Thanks!

@sblackshear
Copy link
Contributor Author

/canary

bors-libra pushed a commit that referenced this pull request Sep 25, 2020
- New CreateAccountEvent struct that records the created address
- Had to refactor LibraAccount::initialize() a bit to ensure that we can emit an event for the creation of LibraRoot
- Had to refactor the event verification part of VM genesis since the number of events now depends on the # of created accounts
- Added tests for each of the create_*_account functions
- Added Rust wrapper for CreateAccountEvent

Previously, users saw only TYPE_MISMATCH, NUMBER_OF_TYPE_ARGUMENTS_MISMATCH, or LINKER_ERROR, which are not very descriptive

Closes: #6118
Closes: #6156
@bors-libra bors-libra moved this from In Review to Canary in bors Sep 25, 2020
@github-actions
Copy link

Cluster Test Result

all up : 1008 TPS, 4485 ms latency, 5350 ms p99 latency, no expired txns
Logs: http://kibana.ct-0-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2020-09-25T03:01:28Z',to:'2020-09-25T03:12:59Z'))
Dashboard: http://grafana.ct-0-k8s-testnet.aws.hlw3truzy4ls.com/d/2XqUIhnWz/performance?from=1601002888000&to=1601003579000
Validator 1 logs: http://kibana.ct-0-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2020-09-25T03:01:28Z',to:'2020-09-25T03:12:59Z'))&_a=(columns:!(log),query:(language:kuery,query:'kubernetes.pod_name:"val-1"'),sort:!(!('@timestamp',desc)))

Repro cmd:

./scripts/cti --tag land_2b06201d -E RUST_LOG=debug --report report.json --suite land_blocking

🎉 Land-blocking cluster test passed! 👌

@bors-libra bors-libra moved this from Canary to In Review in bors Sep 25, 2020
@bors-libra
Copy link
Contributor

☀️ Canary successful

@sblackshear
Copy link
Contributor Author

/land

@bors-libra bors-libra moved this from In Review to Queued in bors Sep 25, 2020
@bors-libra
Copy link
Contributor

🔒 Merge Conflict

@bors-libra bors-libra moved this from Queued to In Review in bors Sep 25, 2020
@sblackshear
Copy link
Contributor Author

/land

@bors-libra bors-libra moved this from In Review to Queued in bors Sep 25, 2020
@MIRAI-bot
Copy link

[move-prover] Move Prover test (language/move-prover/cargo test) on commit d2c6376 did fail. See details.

@sblackshear
Copy link
Contributor Author

/cancel

@bors-libra bors-libra moved this from Queued to In Review in bors Sep 25, 2020
@sblackshear sblackshear force-pushed the create_account_event branch 2 times, most recently from 437f9d7 to b49195c Compare September 26, 2020 01:20
@sblackshear
Copy link
Contributor Author

/land

@bors-libra bors-libra moved this from In Review to Queued in bors Sep 26, 2020
@MIRAI-bot
Copy link

[move-prover] Move Prover test (language/move-prover/cargo test) on commit 437f9d7 did fail. See details.

- New CreateAccountEvent struct that records the created address
- Had to refactor LibraAccount::initialize() a bit to ensure that we can emit an event for the creation of LibraRoot
- Had to refactor the event verification part of VM genesis since the number of events now depends on the # of created accounts
- Added tests for each of the create_*_account functions
- Added Rust wrapper for CreateAccountEvent

Previously, users saw only TYPE_MISMATCH, NUMBER_OF_TYPE_ARGUMENTS_MISMATCH, or LINKER_ERROR, which are not very descriptive

Closes: diem#6118
Closes: diem#6156
@bors-libra bors-libra moved this from Queued to Testing in bors Sep 26, 2020
@github-actions
Copy link

Cluster Test Result

all up : 1001 TPS, 4519 ms latency, 5500 ms p99 latency, no expired txns
Logs: http://kibana.ct-2-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2020-09-26T05:48:16Z',to:'2020-09-26T06:04:42Z'))
Dashboard: http://grafana.ct-2-k8s-testnet.aws.hlw3truzy4ls.com/d/2XqUIhnWz/performance?from=1601099296000&to=1601100282000
Validator 1 logs: http://kibana.ct-2-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2020-09-26T05:48:16Z',to:'2020-09-26T06:04:42Z'))&_a=(columns:!(log),query:(language:kuery,query:'kubernetes.pod_name:"val-1"'),sort:!(!('@timestamp',desc)))

Repro cmd:

./scripts/cti --tag land_6726e579 -E RUST_LOG=debug --report report.json --suite land_blocking

🎉 Land-blocking cluster test passed! 👌

@bors-libra bors-libra removed this from Testing in bors Sep 26, 2020
@bors-libra bors-libra merged commit 6726e57 into diem:master Sep 26, 2020
@xli xli mentioned this pull request Sep 30, 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 cla-signed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants