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

feat-2.0 to dev #5038

Merged
merged 3,111 commits into from
Dec 21, 2024
Merged

feat-2.0 to dev #5038

merged 3,111 commits into from
Dec 21, 2024

Conversation

EdHastingsCasperAssociation
Copy link
Collaborator

This PR merges the 2.0 feature branch to the dev branch.

Maciej Wójcik and others added 30 commits November 5, 2024 10:03
4949: Adding checks on GetRequest::Record check to make sure that we don't … r=zajko a=zajko

…pass empty key fetches to lmdb storage (which results in a non-recoverable crash). Also changed DataReader and VersionedDatabases to reflect the same check.


Co-authored-by: Jakub Zajkowski <[email protected]>
…at-2.0-clean-up

# Conflicts:
#	execution_engine_testing/tests/src/test/explorer/faucet.rs
 Conflicts:
	Cargo.lock
	execution_engine/src/engine_state/mod.rs
	execution_engine/src/engine_state/wasm_v1.rs
	node/src/components/contract_runtime/operations.rs
	node/src/types/transaction/meta_transaction.rs
	node/src/types/transaction/meta_transaction/meta_transaction_v1.rs
	storage/src/global_state.rs
	storage/src/global_state/state/mod.rs
	storage/src/tracking_copy/error.rs
	storage/src/tracking_copy/tests.rs
	types/src/addressable_entity/entry_points.rs
	types/src/lib.rs
	types/src/stored_value.rs
	types/src/system/auction/seigniorage_recipient.rs
	types/src/transaction/transaction_v1/arg_handling.rs
4943: Add catch up & shutdown mode r=EdHastingsCasperAssociation a=wojcik91

Added a mode to sync global state and shut down the node.

As discussed followed a simple approach - at the point when node would switch from CatchUp to KeepUp instead shut it down.

Closes #4799


Co-authored-by: Maciej Wójcik <[email protected]>
 Conflicts:
	binary_port/Cargo.toml
* Changed `seigniorage_recipients`, `total_supply`, `round_seigniorage_rate` to handle the situation where `state_hash` provided to them point to a pre-condor state
* Strip ae from gs requests
4934: Misc cleanups r=EdHastingsCasperAssociation a=EdHastingsCasperAssociation

This PR cleans up a few things, re-enables some tests, fixes a minor bug. A few tests need to be looked at by SME's.

Co-authored-by: Ed Hastings <[email protected]>
Co-authored-by: Karan Dhareshwar <[email protected]>
Co-authored-by: edhastings <[email protected]>
 Conflicts:
	execution_engine/src/runtime_context/mod.rs
	execution_engine_testing/tests/src/test/contract_api/add_contract_version.rs
	types/src/addressable_entity.rs
	types/src/execution/transform_kind.rs
	types/src/stored_value.rs
	types/src/transaction/deploy.rs
4953: Fixing issues with the node upgrading from 1.5.8 to 2.0.0 r=EdHastingsCasperAssociation a=zajko

* Removing enable_addressable_entity from config
* Changed `seigniorage_recipients`, `total_supply`, `round_seigniorage_rate` to handle the situation where `state_hash` provided to them point to a pre-condor state
* Strip ae from gs requests

Co-authored-by: Jakub Zajkowski <[email protected]>
Co-authored-by: Karan Dhareshwar <[email protected]>

Co-authored-by: Jakub Zajkowski <[email protected]>
 Conflicts:
	node/src/components/contract_runtime/error.rs
	storage/src/global_state/state/mod.rs
4948: Host functions for signature verification and Secp256k1 PK Recovery r=igor-casper a=igor-casper

Addresses the #4940 feature request by adding the following host functions:

- `casper_recover_secp256k1` - recovers a Secp256k1 public key from a signed message and a signature over that message
- `casper_verify_signature` - verifies the signature of the given message against the given public key

Example usage
```rs
#![no_std]
#![no_main]

extern crate alloc;
use alloc::string::String;
use casper_contract::{
    contract_api::{cryptography, runtime},
    unwrap_or_revert::UnwrapOrRevert,
};
use casper_types::{
    bytesrepr::{Bytes, FromBytes},
    PublicKey, Signature,
};

#[no_mangle]
pub extern "C" fn call() {
    let message: String = runtime::get_named_arg("message");
    let signature_bytes: Bytes = runtime::get_named_arg("signature_bytes");
    let recovery_id: u8 = runtime::get_named_arg("recovery_id");
    let (signature, _) = Signature::from_bytes(&signature_bytes).unwrap();
    
    // PK recovery
    let recovered_pk = cryptography::recover_secp256k1(
        message.as_bytes(),
        &signature,
        recovery_id
    ).unwrap_or_revert();

    // Signature verification
    let verify_result = cryptography::verify_signature(
        message.as_bytes(),
        &signature,
        &recovered_pk
    );

    assert!(verify_result.is_ok());
}
```

Co-authored-by: igor-casper <[email protected]>
Co-authored-by: igor-casper <[email protected]>
4806: VM2 MVP r=mpapierski a=mpapierski

This massive PR adds an MVP new smart contract execution engine based on wasmer.

This aims to address some long-standing issues with the current engine as well as improve developers' experience:

- `URef` once granted is forever and can't be reclaimed. The new engine does not support these.
- As a consequence purses are not exposed to the user (purses == special urefs)
- There were ~53 host functions in old execution engine. The new engine aims to be thoughtful when adding new host functions.
- Often there were inefficiencies when passing the data from host to wasm and back
- Isolation of implementation details from the Wasm SDK
- Encouraged high-level code (think of `struct Contract`, `trait SharedBehavior`), low-level also possible and is easy to explain
- When going high-level users shouldn't be concerned with low details (no more `no_mangle`, `pub extern "C"`, e
- Introduces missing features
  - payable entrypoints
  - contract schemas
  - unit testing

And more

Example contract:

```rust
#[casper(contract_state)]
struct Counter {
  count: u64
}


#[casper]
impl Counter {
  #[casper(constructor)]
  pub fn new(initial_value: u64) {
    Self {
      count: initial_value
    }
  }
  pub fn counter_inc(&mut self) {
    self.count += 1;
  }
  pub fn counter_get(&self) -> u64 {
    self.count
  }
}

#[cfg(test)]
mod tests {
  #[test]
  fn counter_works() {
    let mut counter = Counter::default();
    let before = counter.counter_get();
    counter.counter_inc();
    let after = counter.counter_get();
    assert!(after > before);
  }
}
```

There's self-contained example contract located here https://github.com/mpapierski/vm2-flipper/ that currently pulls the deps through git. There will be more self-contained example contracts as the time goes.

In general, smart contract developers from similar backgrounds should feel productive early on.

Another benefit of the new engine is that it brings us closer in performance to other leading blockchains, has a smaller footprint, and is easier to maintain and explain to the users.

This PR lays the foundation for the MVP new engine at the core level, but at the same time allows you to spin up nctl network and start write smart contracts, and execute contracts with the new runtime target.

Co-authored-by: Michał Papierski <[email protected]>
…d two new config properties for the binary port: keepalive_check_interval, keepalive_no_activity_timeout. From now on if a binary port connection is not used for a configured period of time it will be closed on the node side. Introduced a binary request variant BinaryRequest::KeepAliveRequest so that clients that want to keep the connection alive can use this low-overhead way to do that.
Jakub Zajkowski and others added 9 commits December 17, 2024 23:21
5037: Added missing error code for situation when we can't associate a tran… r=zajko a=zajko

action lane with a transaction.

This PR will have an effect on casper-client-rs and casper-sidecar.

Co-authored-by: Jakub Zajkowski <[email protected]>
5040: Added missing error codes for InvalidDeploy errors r=zajko a=zajko

This PR will affect casper-sidecar.

Co-authored-by: Jakub Zajkowski <[email protected]>
… in StoredValue::SmartContract, applying minor code fixes
@darthsiroftardis
Copy link
Contributor

Approving based on the code changes. However, I think we need to update the CHANGELOG for the storage crate, the diff implies that its the changelog from the hashing crate that got moved, but it hasn't been updated to reflect the functionality in the storage crate. I think we can capture that as part of a separate PR

Jakub Zajkowski and others added 12 commits December 20, 2024 00:21
Cover call contract acnd call versioned contract
5045: Custom Payment QoL r=EdHastingsCasperAssociation a=EdHastingsCasperAssociation

This PR adds a guardrail to improve quality of life for custom payment use case.


Co-authored-by: Ed Hastings <[email protected]>
Co-authored-by: Michał Papierski <[email protected]>
Co-authored-by: edhastings <[email protected]>
5046: Execution engine changelog r=EdHastingsCasperAssociation a=zajko

Backfilling execution_engine backlog. Fixing json serialization issue in StoredValue::SmartContract, applying minor code fixes

Co-authored-by: Jakub Zajkowski <[email protected]>
5041: Remove 0_9_0 chainspec r=EdHastingsCasperAssociation a=darthsiroftardis

Remove of old chainspecs that were used for testing that aren't required anymire
Removal of unnecessary fields and added comments to the added `enable_addressable_entity` field

Co-authored-by: Karan Dhareshwar <[email protected]>
Co-authored-by: edhastings <[email protected]>
5048: GH-5039: Tweak costs and chainspec settings r=EdHastingsCasperAssociation a=EdHastingsCasperAssociation

Closes #5039 

This PR adds a gas charge for calling a non-existing system contract entry point. Additionally, some charges for incorrectly charged system contract entrypoints are raised significantly (10k motes -> 2.5 CSPR or more depending on complexity).

This PR changes fee_handling and refund_handling to be consistent with 1.5.x settings (refund 99% and pay to proposer)

#5047 


Co-authored-by: Michał Papierski <[email protected]>
Co-authored-by: Ed Hastings <[email protected]>
@EdHastingsCasperAssociation
Copy link
Collaborator Author

bors r+

Copy link
Contributor

Build succeeded:

@casperlabs-bors-ng casperlabs-bors-ng bot merged commit 18955ae into dev Dec 21, 2024
8 checks passed
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.

7 participants