1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2020 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(* The model for read accesses is the following:
cost(path_length, read_bytes) = 200_000 + 5000 * path_length + 2 * read_bytes
*)letread_access~path_length~read_bytes=letopenSaturation_reprinletbase_cost=safe_int(200_000+(5000*path_length))inGas_limit_repr.atomic_step_cost(addbase_cost(mul(safe_int2)(safe_intread_bytes)))(* The model for write accesses is the following:
cost(written_bytes) = 200_000 + 4 * written_bytes
*)letwrite_access~written_bytes=letopenSaturation_reprinGas_limit_repr.atomic_step_cost(add(safe_int200_000)(mul(safe_int4)(safe_intwritten_bytes)))letlist_key_values_step_cost=Saturation_repr.safe_int117letlist_key_values_intercept=Saturation_repr.safe_int470letlist_key_values_traverse~size=Saturation_repr.(addlist_key_values_intercept(mul(safe_intsize)list_key_values_step_cost))