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

Expand Deploy Acceptor #2081

Merged
merged 11 commits into from
Sep 22, 2021
Merged

Conversation

darthsiroftardis
Copy link
Contributor

@darthsiroftardis darthsiroftardis commented Sep 15, 2021

Co-authored-by: Ed Hastings ed@casperlabs.io

CHANGELOG:

  • Expanded the checks the DeployAcceptor makes on a single Deploy
    • Account related checks
      1. Checks if the AccountHashes associated with the Deploy are valid associated keys
      2. Checks if the Weight of the AccountHashes meet the threshold to perform a deployment
      3. Checks if the balance of the Account in the case of a Deploy received by from a Client is sufficient
    • ExecutableDeployItem
      1. Checks if the ExecutableDeployItem present in the session or payment fields are valid and present in the case of stored contracts and contract packages
  • Moved the cryptographic validity check of a Deploy to be the last step once all other prerequisites are met.
  • Expanded the test suite to cover the newly added checks

Closes #2085

Co-authored-by: Ed Hastings <ed@casperlabs.io>
@goral09
Copy link
Collaborator

goral09 commented Sep 16, 2021

Hey @darthsiroftardis, could you include in the description of the PR exactly how the checks were expanded? i.e. what was added/changed/removed.

@goral09 goral09 added the release blocker PR to be merged before releasing label Sep 16, 2021
@darthsiroftardis
Copy link
Contributor Author

@goral09 Yes, I am working on polishing the PR before I mark it ready, at that point I will amend the PR description

@goral09
Copy link
Collaborator

goral09 commented Sep 17, 2021

Checks if the ExecutableDeployItem present in the session or payment fields are valid and present in the case of stored contracts and contract packages

In the spirit of doing only the minimal set of required checks prior to accepting a deploy, I think we shouldn't be validating session code for correctness. Once we know that the deploy will pay for the execution, we should accept any deploy even incorrect.

) -> Self {
let session = ExecutableDeployItem::StoredVersionedContractByName {
name: "Test".to_string(),
version: Some(6u32),
Copy link
Contributor

Choose a reason for hiding this comment

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

version in session is Some, yet the function name says with_missing_contract_version_in_session..., maybe it's just a naming issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Naming issue, yes, its meant to be Some version that doesn't exist in a contract package

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed the tests around it

node/src/effect.rs Outdated Show resolved Hide resolved
@@ -707,7 +711,7 @@ impl Deploy {
/// * the body hash is correct (should be the hash of the body), and
/// * approvals are non empty, and
/// * all approvals are valid signatures of the deploy hash
pub fn is_valid(&mut self) -> Result<(), DeployValidationFailure> {
pub fn is_valid(&mut self) -> Result<(), DeployConfigurationFailure> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did we change the name? I think the Validation was more fitting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We changed it cause a lot of these errors raised when a Deploy is checked against a specified DeployConfig , which is why it felt more apropos to rename it ConfigurationFailure

Copy link
Collaborator

Choose a reason for hiding this comment

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

My understanding is that we're validating against config so it fails during validation phase.

node/src/types/deploy.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@goral09 goral09 left a comment

Choose a reason for hiding this comment

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

All of the effect_builder.immediately().event(...) constructs in deploy_acceptor.rs can be replaced with calls to the respective methods. It's not going to be bad for performance as it's we were just continuing a synchronous method call. Performance-wise it will actually be better as we won't be creating additional messages that have to be routed through the reactor.

}
}

fn verify_session_logic<REv: ReactorEventT>(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we should be verifying the session logic at all. If the deploy can be paid for we shouldn't really care whether deploy's creator made sure it can also be executed.

@darthsiroftardis
Copy link
Contributor Author

All of the effect_builder.immediately().event(...) constructs in deploy_acceptor.rs can be replaced with calls to the respective methods. It's not going to be bad for performance as it's we were just continuing a synchronous method call. Performance-wise it will actually be better as we won't be creating additional messages that have to be routed through the reactor.

Applied suggestion and removed most of the immediately().event calls

verification_start_timestamp: Timestamp,
) -> Effects<Event> {
let mut cloned_deploy = event_metadata.deploy().clone();
if let Err(deploy_configuration_failure) = cloned_deploy.is_valid() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure if everything that happens inside the is_valid method is actually more computationally expensive than all of this back-and-forth between deploy_acceptor, storage and EE. It's only the signature verification that could be expensive and I still wouldn't be sure that's true - if there's a single signature to verify (which is probably 99% of cases) it will be faster than creating dozens of events, calling various components etc.

@darthsiroftardis
Copy link
Contributor Author

bors try

@casperlabs-bors-ng
Copy link
Contributor

try

Build succeeded:

# Conflicts:
#	execution_engine/src/core/engine_state/executable_deploy_item.rs
@darthsiroftardis
Copy link
Contributor Author

bors r+

@casperlabs-bors-ng
Copy link
Contributor

Build succeeded:

@casperlabs-bors-ng casperlabs-bors-ng bot merged commit 8516aa6 into casper-network:dev Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release blocker PR to be merged before releasing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants