|
| 1 | +package api |
| 2 | + |
| 3 | +import ( |
| 4 | + "time" |
| 5 | +) |
| 6 | + |
| 7 | +const ProtocolConfigMethod = "EXPERIMENTAL_protocol_config" |
| 8 | + |
| 9 | +type ProtocolConfigResult struct { |
| 10 | + ProtocolVersion int `json:"protocol_version"` |
| 11 | + GenesisTime time.Time `json:"genesis_time"` |
| 12 | + ChainID string `json:"chain_id"` |
| 13 | + GenesisHeight int `json:"genesis_height"` |
| 14 | + NumBlockProducerSeats int `json:"num_block_producer_seats"` |
| 15 | + NumBlockProducerSeatsPerShard []int `json:"num_block_producer_seats_per_shard"` |
| 16 | + AvgHiddenValidatorSeatsPerShard []int `json:"avg_hidden_validator_seats_per_shard"` |
| 17 | + DynamicResharding bool `json:"dynamic_resharding"` |
| 18 | + ProtocolUpgradeStakeThreshold []int `json:"protocol_upgrade_stake_threshold"` |
| 19 | + EpochLength int `json:"epoch_length"` |
| 20 | + GasLimit int64 `json:"gas_limit"` |
| 21 | + MinGasPrice string `json:"min_gas_price"` |
| 22 | + MaxGasPrice string `json:"max_gas_price"` |
| 23 | + BlockProducerKickoutThreshold int `json:"block_producer_kickout_threshold"` |
| 24 | + ChunkProducerKickoutThreshold int `json:"chunk_producer_kickout_threshold"` |
| 25 | + OnlineMinThreshold []int `json:"online_min_threshold"` |
| 26 | + OnlineMaxThreshold []int `json:"online_max_threshold"` |
| 27 | + GasPriceAdjustmentRate []int `json:"gas_price_adjustment_rate"` |
| 28 | + RuntimeConfig struct { |
| 29 | + StorageAmountPerByte string `json:"storage_amount_per_byte"` |
| 30 | + TransactionCosts struct { |
| 31 | + ActionReceiptCreationConfig struct { |
| 32 | + SendSir int64 `json:"send_sir"` |
| 33 | + SendNotSir int64 `json:"send_not_sir"` |
| 34 | + Execution int64 `json:"execution"` |
| 35 | + } `json:"action_receipt_creation_config"` |
| 36 | + DataReceiptCreationConfig struct { |
| 37 | + BaseCost struct { |
| 38 | + SendSir int64 `json:"send_sir"` |
| 39 | + SendNotSir int64 `json:"send_not_sir"` |
| 40 | + Execution int64 `json:"execution"` |
| 41 | + } `json:"base_cost"` |
| 42 | + CostPerByte struct { |
| 43 | + SendSir int `json:"send_sir"` |
| 44 | + SendNotSir int `json:"send_not_sir"` |
| 45 | + Execution int `json:"execution"` |
| 46 | + } `json:"cost_per_byte"` |
| 47 | + } `json:"data_receipt_creation_config"` |
| 48 | + ActionCreationConfig struct { |
| 49 | + CreateAccountCost struct { |
| 50 | + SendSir int64 `json:"send_sir"` |
| 51 | + SendNotSir int64 `json:"send_not_sir"` |
| 52 | + Execution int64 `json:"execution"` |
| 53 | + } `json:"create_account_cost"` |
| 54 | + DeployContractCost struct { |
| 55 | + SendSir int64 `json:"send_sir"` |
| 56 | + SendNotSir int64 `json:"send_not_sir"` |
| 57 | + Execution int64 `json:"execution"` |
| 58 | + } `json:"deploy_contract_cost"` |
| 59 | + DeployContractCostPerByte struct { |
| 60 | + SendSir int `json:"send_sir"` |
| 61 | + SendNotSir int `json:"send_not_sir"` |
| 62 | + Execution int `json:"execution"` |
| 63 | + } `json:"deploy_contract_cost_per_byte"` |
| 64 | + FunctionCallCost struct { |
| 65 | + SendSir int64 `json:"send_sir"` |
| 66 | + SendNotSir int64 `json:"send_not_sir"` |
| 67 | + Execution int64 `json:"execution"` |
| 68 | + } `json:"function_call_cost"` |
| 69 | + FunctionCallCostPerByte struct { |
| 70 | + SendSir int `json:"send_sir"` |
| 71 | + SendNotSir int `json:"send_not_sir"` |
| 72 | + Execution int `json:"execution"` |
| 73 | + } `json:"function_call_cost_per_byte"` |
| 74 | + TransferCost struct { |
| 75 | + SendSir int64 `json:"send_sir"` |
| 76 | + SendNotSir int64 `json:"send_not_sir"` |
| 77 | + Execution int64 `json:"execution"` |
| 78 | + } `json:"transfer_cost"` |
| 79 | + StakeCost struct { |
| 80 | + SendSir int64 `json:"send_sir"` |
| 81 | + SendNotSir int64 `json:"send_not_sir"` |
| 82 | + Execution int64 `json:"execution"` |
| 83 | + } `json:"stake_cost"` |
| 84 | + AddKeyCost struct { |
| 85 | + FullAccessCost struct { |
| 86 | + SendSir int64 `json:"send_sir"` |
| 87 | + SendNotSir int64 `json:"send_not_sir"` |
| 88 | + Execution int64 `json:"execution"` |
| 89 | + } `json:"full_access_cost"` |
| 90 | + FunctionCallCost struct { |
| 91 | + SendSir int64 `json:"send_sir"` |
| 92 | + SendNotSir int64 `json:"send_not_sir"` |
| 93 | + Execution int64 `json:"execution"` |
| 94 | + } `json:"function_call_cost"` |
| 95 | + FunctionCallCostPerByte struct { |
| 96 | + SendSir int `json:"send_sir"` |
| 97 | + SendNotSir int `json:"send_not_sir"` |
| 98 | + Execution int `json:"execution"` |
| 99 | + } `json:"function_call_cost_per_byte"` |
| 100 | + } `json:"add_key_cost"` |
| 101 | + DeleteKeyCost struct { |
| 102 | + SendSir int64 `json:"send_sir"` |
| 103 | + SendNotSir int64 `json:"send_not_sir"` |
| 104 | + Execution int64 `json:"execution"` |
| 105 | + } `json:"delete_key_cost"` |
| 106 | + DeleteAccountCost struct { |
| 107 | + SendSir int64 `json:"send_sir"` |
| 108 | + SendNotSir int64 `json:"send_not_sir"` |
| 109 | + Execution int64 `json:"execution"` |
| 110 | + } `json:"delete_account_cost"` |
| 111 | + } `json:"action_creation_config"` |
| 112 | + StorageUsageConfig struct { |
| 113 | + NumBytesAccount int `json:"num_bytes_account"` |
| 114 | + NumExtraBytesRecord int `json:"num_extra_bytes_record"` |
| 115 | + } `json:"storage_usage_config"` |
| 116 | + BurntGasReward []int `json:"burnt_gas_reward"` |
| 117 | + PessimisticGasPriceInflationRatio []int `json:"pessimistic_gas_price_inflation_ratio"` |
| 118 | + } `json:"transaction_costs"` |
| 119 | + WasmConfig struct { |
| 120 | + ExtCosts struct { |
| 121 | + Base int `json:"base"` |
| 122 | + ContractCompileBase int `json:"contract_compile_base"` |
| 123 | + ContractCompileBytes int `json:"contract_compile_bytes"` |
| 124 | + ReadMemoryBase int64 `json:"read_memory_base"` |
| 125 | + ReadMemoryByte int `json:"read_memory_byte"` |
| 126 | + WriteMemoryBase int64 `json:"write_memory_base"` |
| 127 | + WriteMemoryByte int `json:"write_memory_byte"` |
| 128 | + ReadRegisterBase int64 `json:"read_register_base"` |
| 129 | + ReadRegisterByte int `json:"read_register_byte"` |
| 130 | + WriteRegisterBase int64 `json:"write_register_base"` |
| 131 | + WriteRegisterByte int `json:"write_register_byte"` |
| 132 | + Utf8DecodingBase int64 `json:"utf8_decoding_base"` |
| 133 | + Utf8DecodingByte int `json:"utf8_decoding_byte"` |
| 134 | + Utf16DecodingBase int64 `json:"utf16_decoding_base"` |
| 135 | + Utf16DecodingByte int `json:"utf16_decoding_byte"` |
| 136 | + Sha256Base int64 `json:"sha256_base"` |
| 137 | + Sha256Byte int `json:"sha256_byte"` |
| 138 | + Keccak256Base int64 `json:"keccak256_base"` |
| 139 | + Keccak256Byte int `json:"keccak256_byte"` |
| 140 | + Keccak512Base int64 `json:"keccak512_base"` |
| 141 | + Keccak512Byte int `json:"keccak512_byte"` |
| 142 | + Ripemd160Base int `json:"ripemd160_base"` |
| 143 | + Ripemd160Block int `json:"ripemd160_block"` |
| 144 | + EcrecoverBase int64 `json:"ecrecover_base"` |
| 145 | + LogBase int64 `json:"log_base"` |
| 146 | + LogByte int `json:"log_byte"` |
| 147 | + StorageWriteBase int64 `json:"storage_write_base"` |
| 148 | + StorageWriteKeyByte int `json:"storage_write_key_byte"` |
| 149 | + StorageWriteValueByte int `json:"storage_write_value_byte"` |
| 150 | + StorageWriteEvictedByte int `json:"storage_write_evicted_byte"` |
| 151 | + StorageReadBase int64 `json:"storage_read_base"` |
| 152 | + StorageReadKeyByte int `json:"storage_read_key_byte"` |
| 153 | + StorageReadValueByte int `json:"storage_read_value_byte"` |
| 154 | + StorageRemoveBase int64 `json:"storage_remove_base"` |
| 155 | + StorageRemoveKeyByte int `json:"storage_remove_key_byte"` |
| 156 | + StorageRemoveRetValueByte int `json:"storage_remove_ret_value_byte"` |
| 157 | + StorageHasKeyBase int64 `json:"storage_has_key_base"` |
| 158 | + StorageHasKeyByte int `json:"storage_has_key_byte"` |
| 159 | + StorageIterCreatePrefixBase int `json:"storage_iter_create_prefix_base"` |
| 160 | + StorageIterCreatePrefixByte int `json:"storage_iter_create_prefix_byte"` |
| 161 | + StorageIterCreateRangeBase int `json:"storage_iter_create_range_base"` |
| 162 | + StorageIterCreateFromByte int `json:"storage_iter_create_from_byte"` |
| 163 | + StorageIterCreateToByte int `json:"storage_iter_create_to_byte"` |
| 164 | + StorageIterNextBase int `json:"storage_iter_next_base"` |
| 165 | + StorageIterNextKeyByte int `json:"storage_iter_next_key_byte"` |
| 166 | + StorageIterNextValueByte int `json:"storage_iter_next_value_byte"` |
| 167 | + TouchingTrieNode int64 `json:"touching_trie_node"` |
| 168 | + PromiseAndBase int `json:"promise_and_base"` |
| 169 | + PromiseAndPerPromise int `json:"promise_and_per_promise"` |
| 170 | + PromiseReturn int `json:"promise_return"` |
| 171 | + ValidatorStakeBase int64 `json:"validator_stake_base"` |
| 172 | + ValidatorTotalStakeBase int64 `json:"validator_total_stake_base"` |
| 173 | + } `json:"ext_costs"` |
| 174 | + GrowMemCost int `json:"grow_mem_cost"` |
| 175 | + RegularOpCost int `json:"regular_op_cost"` |
| 176 | + LimitConfig struct { |
| 177 | + MaxGasBurnt int64 `json:"max_gas_burnt"` |
| 178 | + MaxStackHeight int `json:"max_stack_height"` |
| 179 | + StackLimiterVersion int `json:"stack_limiter_version"` |
| 180 | + InitialMemoryPages int `json:"initial_memory_pages"` |
| 181 | + MaxMemoryPages int `json:"max_memory_pages"` |
| 182 | + RegistersMemoryLimit int `json:"registers_memory_limit"` |
| 183 | + MaxRegisterSize int `json:"max_register_size"` |
| 184 | + MaxNumberRegisters int `json:"max_number_registers"` |
| 185 | + MaxNumberLogs int `json:"max_number_logs"` |
| 186 | + MaxTotalLogLength int `json:"max_total_log_length"` |
| 187 | + MaxTotalPrepaidGas int64 `json:"max_total_prepaid_gas"` |
| 188 | + MaxActionsPerReceipt int `json:"max_actions_per_receipt"` |
| 189 | + MaxNumberBytesMethodNames int `json:"max_number_bytes_method_names"` |
| 190 | + MaxLengthMethodName int `json:"max_length_method_name"` |
| 191 | + MaxArgumentsLength int `json:"max_arguments_length"` |
| 192 | + MaxLengthReturnedData int `json:"max_length_returned_data"` |
| 193 | + MaxContractSize int `json:"max_contract_size"` |
| 194 | + MaxTransactionSize int `json:"max_transaction_size"` |
| 195 | + MaxLengthStorageKey int `json:"max_length_storage_key"` |
| 196 | + MaxLengthStorageValue int `json:"max_length_storage_value"` |
| 197 | + MaxPromisesPerFunctionCallAction int `json:"max_promises_per_function_call_action"` |
| 198 | + MaxNumberInputDataDependencies int `json:"max_number_input_data_dependencies"` |
| 199 | + MaxFunctionsNumberPerContract int `json:"max_functions_number_per_contract"` |
| 200 | + } `json:"limit_config"` |
| 201 | + } `json:"wasm_config"` |
| 202 | + AccountCreationConfig struct { |
| 203 | + MinAllowedTopLevelAccountLength int `json:"min_allowed_top_level_account_length"` |
| 204 | + RegistrarAccountID string `json:"registrar_account_id"` |
| 205 | + } `json:"account_creation_config"` |
| 206 | + } `json:"runtime_config"` |
| 207 | + TransactionValidityPeriod int `json:"transaction_validity_period"` |
| 208 | + ProtocolRewardRate []int `json:"protocol_reward_rate"` |
| 209 | + MaxInflationRate []int `json:"max_inflation_rate"` |
| 210 | + NumBlocksPerYear int `json:"num_blocks_per_year"` |
| 211 | + ProtocolTreasuryAccount string `json:"protocol_treasury_account"` |
| 212 | + FishermenThreshold string `json:"fishermen_threshold"` |
| 213 | + MinimumStakeDivisor int `json:"minimum_stake_divisor"` |
| 214 | +} |
| 215 | + |
| 216 | +func (c *Client) ProtocolConfig() (*ProtocolConfigResult, error) { |
| 217 | + var result *ProtocolConfigResult |
| 218 | + err := c.do(ProtocolConfigMethod, map[string]string{"finality": "final"}, &result) |
| 219 | + |
| 220 | + return result, err |
| 221 | +} |
0 commit comments