-
-
Notifications
You must be signed in to change notification settings - Fork 107
Closed
Labels
A-contractsArea: Contract runtime, SDK, and executionArea: Contract runtime, SDK, and executionT-featureType: New functionality requestType: New functionality request
Description
/// Verify that the state is valid, given the parameters. This will be used before a peer
/// caches a new State.
fn validate_state(parameters : &[u8], state : &[u8]) -> bool;
/// Verify that a delta is valid - at least as much as possible. The goal is to prevent DDoS of
/// a contract by sending a large number of invalid delta updates. This allows peers
/// to verify a delta before forwarding it.
fn validate_delta(parameters : &[u8], delta : &[u8]) -> bool;
enum UpdateResult {
VALID_UPDATED, VALID_NO_CHANGE, INVALID,
}
/// Update the state to account for the state_delta, assuming it is valid
fn update_state(parameters : &[u8], state : &mut Vec<u8>, state_delta : &[u8]) -> UpdateResult;
/// Generate a concise summary of a state that can be used to create deltas
/// relative to this state. This allows flexible and efficient state synchronization between peers.
fn summarize_state(parameters : &[u8], state : &[u8]) -> [u8]; // Returns state summary
/// Generate a state_delta using a state_summary from the current state. Tthis along with
/// summarize_state() allows flexible and efficient state synchronization between peers.
fn get_state_delta(parameters : &[u8], state : &[u8], state_summary : &[u8]) -> [u8]; // Returns state delta
fn update_state_summary(parameters : &[u8], state_summary : &mut Vec<u8>) -> UpdateResult;
struct Related {
contract_hash : [u8],
parameters : [u8],
}
/// Get other contracts that should also be updated with this state_delta
fn get_related_contracts(parameters : &[u8], state : &[u8], state_delta : &[u8])
-> Vec<Related>;Note that the Related struct implies the following approach to generating a contract hash:
contract_hash = hash(hash(contract_wasm) + parameters)
The reason is so that a contract_hash can be created with only a hash of the contract_wasm, not the entire contract_wasm. This should reduce contract sizes.
ZaneH
Metadata
Metadata
Assignees
Labels
A-contractsArea: Contract runtime, SDK, and executionArea: Contract runtime, SDK, and executionT-featureType: New functionality requestType: New functionality request