@@ -17,6 +17,7 @@ public sealed class ManagementContract : NativeContract
1717 public override int Id => 0 ;
1818 public override uint ActiveBlockIndex => 0 ;
1919
20+ private const byte Prefix_MinimumDeploymentFee = 20 ;
2021 private const byte Prefix_NextAvailableId = 15 ;
2122 private const byte Prefix_Contract = 8 ;
2223
@@ -28,6 +29,11 @@ private int GetNextAvailableId(StoreView snapshot)
2829 return value ;
2930 }
3031
32+ internal override void Initialize ( ApplicationEngine engine )
33+ {
34+ engine . Snapshot . Storages . Add ( CreateStorageKey ( Prefix_MinimumDeploymentFee ) , new StorageItem ( 100_00000000 ) ) ;
35+ }
36+
3137 internal override void OnPersist ( ApplicationEngine engine )
3238 {
3339 foreach ( NativeContract contract in Contracts )
@@ -45,6 +51,20 @@ internal override void OnPersist(ApplicationEngine engine)
4551 }
4652 }
4753
54+ [ ContractMethod ( 0_01000000 , CallFlags . ReadStates ) ]
55+ private long GetMinimumDeploymentFee ( StoreView snapshot )
56+ {
57+ return ( long ) ( BigInteger ) snapshot . Storages [ CreateStorageKey ( Prefix_MinimumDeploymentFee ) ] ;
58+ }
59+
60+ [ ContractMethod ( 0_03000000 , CallFlags . WriteStates ) ]
61+ private void SetMinimumDeploymentFee ( ApplicationEngine engine , BigInteger value )
62+ {
63+ if ( value < 0 ) throw new ArgumentOutOfRangeException ( nameof ( value ) ) ;
64+ if ( ! CheckCommittee ( engine ) ) throw new InvalidOperationException ( ) ;
65+ engine . Snapshot . Storages . GetAndChange ( CreateStorageKey ( Prefix_MinimumDeploymentFee ) ) . Set ( value ) ;
66+ }
67+
4868 [ ContractMethod ( 0_01000000 , CallFlags . ReadStates ) ]
4969 public ContractState GetContract ( StoreView snapshot , UInt160 hash )
5070 {
@@ -67,7 +87,10 @@ private ContractState Deploy(ApplicationEngine engine, byte[] nefFile, byte[] ma
6787 if ( manifest . Length == 0 || manifest . Length > ContractManifest . MaxLength )
6888 throw new ArgumentException ( $ "Invalid Manifest Length: { manifest . Length } ") ;
6989
70- engine . AddGas ( engine . StoragePrice * ( nefFile . Length + manifest . Length ) ) ;
90+ engine . AddGas ( Math . Max (
91+ engine . StoragePrice * ( nefFile . Length + manifest . Length ) ,
92+ GetMinimumDeploymentFee ( engine . Snapshot )
93+ ) ) ;
7194
7295 NefFile nef = nefFile . AsSerializable < NefFile > ( ) ;
7396 UInt160 hash = Helper . GetContractHash ( tx . Sender , nef . Script ) ;
0 commit comments