Update the consumed compute units cost for hashing syscalls
This change prevents zero-cost computation of hash functions on
unbound number of zero-length slices of data. The cost for each slice
is at least equal to the base cost of a memory operation, but could be
more for longer slices.
(cherry picked from commit 0a3a18744f
)
This commit is contained in:
committed by
Dmitri Makarov
parent
f4f0b64af4
commit
023ab1c427
@ -36,6 +36,8 @@ pub struct ComputeBudget {
|
||||
pub sha256_base_cost: u64,
|
||||
/// Incremental number of units consumed by SHA256 (based on bytes)
|
||||
pub sha256_byte_cost: u64,
|
||||
/// Maximum number of slices hashed per syscall
|
||||
pub sha256_max_slices: u64,
|
||||
/// Maximum BPF to BPF call depth
|
||||
pub max_call_depth: usize,
|
||||
/// Size of a stack frame in bytes, must match the size specified in the LLVM BPF backend
|
||||
@ -82,6 +84,7 @@ impl ComputeBudget {
|
||||
max_invoke_depth: 4,
|
||||
sha256_base_cost: 85,
|
||||
sha256_byte_cost: 1,
|
||||
sha256_max_slices: 20_000,
|
||||
max_call_depth: 64,
|
||||
stack_frame_size: 4_096,
|
||||
log_pubkey_units: 100,
|
||||
|
Reference in New Issue
Block a user