The constraints on compute power a program can consume is limited only to its instruction count (#11717)

This commit is contained in:
Jack May
2020-08-21 15:31:19 -07:00
committed by GitHub
parent 418b483af6
commit 8d362f682b
17 changed files with 350 additions and 137 deletions

View File

@ -196,6 +196,16 @@ pub trait InvokeContext {
fn get_logger(&self) -> Rc<RefCell<dyn Logger>>;
/// Are cross program invocations supported
fn is_cross_program_supported(&self) -> bool;
/// Get this invocation's compute meter
fn get_compute_meter(&self) -> Rc<RefCell<dyn ComputeMeter>>;
}
/// Compute meter
pub trait ComputeMeter {
/// Consume compute units
fn consume(&mut self, amount: u64) -> Result<(), InstructionError>;
/// Get the number of remaining compute units
fn get_remaining(&self) -> u64;
}
/// Log messages

View File

@ -160,9 +160,13 @@ pub enum InstructionError {
#[error("Provided seeds do not result in a valid address")]
InvalidSeeds,
// Failed to reallocate account data of this length
/// Failed to reallocate account data of this length
#[error("Failed to reallocate account data")]
InvalidRealloc,
/// Computational budget exceeded
#[error("Computational budget exceeded")]
ComputationalBudgetExceeded,
}
#[derive(Debug, PartialEq, Clone)]