Skip to content

Commit

Permalink
Fix storage price following neo-project/neo#2692
Browse files Browse the repository at this point in the history
  • Loading branch information
ixje committed Apr 19, 2022
1 parent 444209b commit 786599a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions neo3/contracts/applicationengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def __init__(self,
self.notifications: List[Tuple[payloads.IVerifiable, types.UInt160, bytes, vm.ArrayStackItem]] = []
if self.snapshot is None or self.snapshot.persisting_block is None or self.snapshot.persisting_block.index == 0:
self.exec_fee_factor = contracts.PolicyContract().DEFAULT_EXEC_FEE_FACTOR
self.STORAGE_PRICE = contracts.PolicyContract().DEFAULT_STORAGE_PRICE
self.storage_price = contracts.PolicyContract().DEFAULT_STORAGE_PRICE
else:
self.exec_fee_factor = contracts.PolicyContract().get_exec_fee_factor(snapshot)
self.STORAGE_PRICE = contracts.PolicyContract().get_storage_price(snapshot)
self.storage_price = contracts.PolicyContract().get_storage_price(snapshot)

if isinstance(self.script_container, payloads.Transaction):
self.nonce_data = self.script_container.hash().to_array()[:16]
Expand Down
2 changes: 1 addition & 1 deletion neo3/contracts/interop/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def storage_put(engine: contracts.ApplicationEngine, context: storage.StorageCon
else:
new_data_len = (len(item.value) - 1) // 4 + 1 + len(value) - len(item.value)

engine.add_gas(new_data_len * engine.STORAGE_PRICE)
engine.add_gas(new_data_len * engine.storage_price)
item.value = value


Expand Down
4 changes: 2 additions & 2 deletions neo3/contracts/native/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def contract_create_with_data(self,
raise ValueError("Invalid NEF or manifest length")

engine.add_gas(
max(engine.STORAGE_PRICE * (nef_len + manifest_len), self.get_minimum_deployment_fee(engine.snapshot))
max(engine.storage_price * (nef_len + manifest_len), self.get_minimum_deployment_fee(engine.snapshot))
)

nef = contracts.NEF.deserialize_from_bytes(nef_file)
Expand Down Expand Up @@ -128,7 +128,7 @@ def contract_update_with_data(self,

nef_len = 0 if nef_file is None else len(nef_file)
manifest_len = 0 if manifest is None else len(manifest)
engine.add_gas(engine.STORAGE_PRICE * (nef_len + manifest_len))
engine.add_gas(engine.storage_price * (nef_len + manifest_len))

contract = engine.snapshot.contracts.try_get(engine.calling_scripthash, read_only=False)
if contract is None:
Expand Down
4 changes: 2 additions & 2 deletions neo3/contracts/native/nativecontract.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ def invoke(self, engine: contracts.ApplicationEngine, version: int) -> None:
raise ValueError(f"Method requires call flag: {method.required_flags} received: {flags}")

engine.add_gas(method.cpu_price
* contracts.PolicyContract().get_exec_fee_factor(engine.snapshot)
* engine.exec_fee_factor
+ method.storage_price
* contracts.PolicyContract().get_storage_price(engine.snapshot))
* engine.storage_price)

params: List[Any] = []
if method.add_engine:
Expand Down

0 comments on commit 786599a

Please sign in to comment.