Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update cost estimator with contract compilation cost computations #4231

Merged
merged 23 commits into from
May 20, 2021

Conversation

olonho
Copy link
Contributor

@olonho olonho commented Apr 16, 2021

  • Implemented contract precompilation cost computation framework
  • Use contract precompilation measurements in cost computations

@olonho
Copy link
Contributor Author

olonho commented Apr 19, 2021

RuntimeConfig {
    storage_amount_per_byte: 90900000000000000000,
    transaction_costs: RuntimeFeesConfig {
        action_receipt_creation_config: Fee {
            send_sir: 173376187500,
            send_not_sir: 173376187500,
            execution: 173376187500,
        },
        data_receipt_creation_config: DataReceiptCreationConfig {
            base_cost: Fee {
                send_sir: 50927271643687,
                send_not_sir: 50927271643687,
                execution: 50927271643687,
            },
            cost_per_byte: Fee {
                send_sir: 4569950,
                send_not_sir: 4569950,
                execution: 4569950,
            },
        },
        action_creation_config: ActionCreationConfig {
            create_account_cost: Fee {
                send_sir: 29243687500,
                send_not_sir: 29243687500,
                execution: 29243687500,
            },
            deploy_contract_cost: Fee {
                send_sir: 56906312500,
                send_not_sir: 56906312500,
                execution: 105392087500,
            },
            deploy_contract_cost_per_byte: Fee {
                send_sir: 8298830,
                send_not_sir: 8298830,
                execution: 383710211,
            },
            function_call_cost: Fee {
                send_sir: 104694812500,
                send_not_sir: 104694812500,
                execution: 104694812500,
            },
            function_call_cost_per_byte: Fee {
                send_sir: 29290,
                send_not_sir: 29290,
                execution: 29290,
            },
            transfer_cost: Fee {
                send_sir: 24369687500,
                send_not_sir: 24369687500,
                execution: 24369687500,
            },
            stake_cost: Fee {
                send_sir: 65173750000,
                send_not_sir: 65173750000,
                execution: 65173750000,
            },
            add_key_cost: AccessKeyCreationConfig {
                full_access_cost: Fee {
                    send_sir: 35496000000,
                    send_not_sir: 35496000000,
                    execution: 35496000000,
                },
                function_call_cost: Fee {
                    send_sir: 35152312500,
                    send_not_sir: 35152312500,
                    execution: 35152312500,
                },
                function_call_cost_per_byte: Fee {
                    send_sir: 9514806,
                    send_not_sir: 9514806,
                    execution: 9514806,
                },
            },
            delete_key_cost: Fee {
                send_sir: 15966750000,
                send_not_sir: 15966750000,
                execution: 15966750000,
            },
            delete_account_cost: Fee {
                send_sir: 135998812500,
                send_not_sir: 135998812500,
                execution: 135998812500,
            },
        },
        storage_usage_config: StorageUsageConfig {
            num_bytes_account: 100,
            num_extra_bytes_record: 40,
        },
        burnt_gas_reward: Ratio {
            numer: 3,
            denom: 10,
        },
        pessimistic_gas_price_inflation_ratio: Ratio {
            numer: 103,
            denom: 100,
        },
    },
    wasm_config: VMConfig {
        ext_costs: ExtCostsConfig {
            base: 44684235,
            contract_compile_base: 0,
            contract_compile_bytes: 0,
            read_memory_base: 194420812,
            read_memory_byte: 1265103,
            write_memory_base: 246703825,
            write_memory_byte: 59739,
            read_register_base: 171131825,
            read_register_byte: 30540,
            write_register_base: 279066462,
            write_register_byte: 1265183,
            utf8_decoding_base: 361052000,
            utf8_decoding_byte: 88775511,
            utf16_decoding_base: 507523112,
            utf16_decoding_byte: 50157442,
            sha256_base: 931144137,
            sha256_byte: 9526572,
            keccak256_base: 1256387700,
            keccak256_byte: 7059051,
            keccak512_base: 1248904050,
            keccak512_byte: 12099318,
            log_base: 507523112,
            log_byte: 4103732,
            storage_write_base: 15049827500,
            storage_write_key_byte: 26151072,
            storage_write_value_byte: 1648812074,
            storage_write_evicted_byte: 2724356012,
            storage_read_base: 21667694625,
            storage_read_key_byte: 4668346894,
            storage_read_value_byte: 4429004858,
            storage_remove_base: 30519829500,
            storage_remove_key_byte: 5915845185,
            storage_remove_ret_value_byte: 5439146590,
            storage_has_key_base: 19529844875,
            storage_has_key_byte: 4264464051,
            storage_iter_create_prefix_base: 0,
            storage_iter_create_prefix_byte: 0,
            storage_iter_create_range_base: 0,
            storage_iter_create_from_byte: 0,
            storage_iter_create_to_byte: 0,
            storage_iter_next_base: 0,
            storage_iter_next_key_byte: 0,
            storage_iter_next_value_byte: 0,
            touching_trie_node: 6190769892,
            promise_and_base: 5290788315,
            promise_and_per_promise: 43239176,
            promise_return: 4674980542,
            validator_stake_base: 303944908800,
            validator_total_stake_base: 303944908800,
        },
        grow_mem_cost: 1,
        regular_op_cost: 593658,
        limit_config: VMLimitConfig {
            max_gas_burnt: 200000000000000,
            max_gas_burnt_view: 200000000000000,
            max_stack_height: 16384,
            initial_memory_pages: 1024,
            max_memory_pages: 2048,
            registers_memory_limit: 1073741824,
            max_register_size: 104857600,
            max_number_registers: 100,
            max_number_logs: 100,
            max_total_log_length: 16384,
            max_total_prepaid_gas: 300000000000000,
            max_actions_per_receipt: 100,
            max_number_bytes_method_names: 2000,
            max_length_method_name: 256,
            max_arguments_length: 4194304,
            max_length_returned_data: 4194304,
            max_contract_size: 4194304,
            max_length_storage_key: 4194304,
            max_length_storage_value: 4194304,
            max_promises_per_function_call_action: 1024,
            max_number_input_data_dependencies: 128,
        },
    },
    account_creation_config: AccountCreationConfig {
        min_allowed_top_level_account_length: 0,
        registrar_account_id: "registrar",
    },
}

@olonho
Copy link
Contributor Author

olonho commented Apr 19, 2021

Above costs are with Wasmer1 and precompilation, now recomputing the baseline with Wasmer0 and no precompilation on the same data/revision.

@olonho
Copy link
Contributor Author

olonho commented Apr 19, 2021

RuntimeConfig {
    storage_amount_per_byte: 90900000000000000000,
    transaction_costs: RuntimeFeesConfig {
        action_receipt_creation_config: Fee {
            send_sir: 170739187500,
            send_not_sir: 170739187500,
            execution: 170739187500,
        },
        data_receipt_creation_config: DataReceiptCreationConfig {
            base_cost: Fee {
                send_sir: 50756252803625,
                send_not_sir: 50756252803625,
                execution: 50756252803625,
            },
            cost_per_byte: Fee {
                send_sir: 14615009,
                send_not_sir: 14615009,
                execution: 14615009,
            },
        },
        action_creation_config: ActionCreationConfig {
            create_account_cost: Fee {
                send_sir: 31759375000,
                send_not_sir: 31759375000,
                execution: 31759375000,
            },
            deploy_contract_cost: Fee {
                send_sir: 51102312500,
                send_not_sir: 51102312500,
                execution: 99711737500,
            },
            deploy_contract_cost_per_byte: Fee {
                send_sir: 8268672,
                send_not_sir: 8268672,
                execution: 379984828,
            },
            function_call_cost: Fee {
                send_sir: 255151062500,
                send_not_sir: 255151062500,
                execution: 255151062500,
            },
            function_call_cost_per_byte: Fee {
                send_sir: 30092,
                send_not_sir: 30092,
                execution: 30092,
            },
            transfer_cost: Fee {
                send_sir: 28074625000,
                send_not_sir: 28074625000,
                execution: 28074625000,
            },
            stake_cost: Fee {
                send_sir: 62682750000,
                send_not_sir: 62682750000,
                execution: 62682750000,
            },
            add_key_cost: AccessKeyCreationConfig {
                full_access_cost: Fee {
                    send_sir: 36261375000,
                    send_not_sir: 36261375000,
                    execution: 36261375000,
                },
                function_call_cost: Fee {
                    send_sir: 37606250000,
                    send_not_sir: 37606250000,
                    execution: 37606250000,
                },
                function_call_cost_per_byte: Fee {
                    send_sir: 9764731,
                    send_not_sir: 9764731,
                    execution: 9764731,
                },
            },
            delete_key_cost: Fee {
                send_sir: 17345687500,
                send_not_sir: 17345687500,
                execution: 17345687500,
            },
            delete_account_cost: Fee {
                send_sir: 136139250000,
                send_not_sir: 136139250000,
                execution: 136139250000,
            },
        },
        storage_usage_config: StorageUsageConfig {
            num_bytes_account: 100,
            num_extra_bytes_record: 40,
        },
        burnt_gas_reward: Ratio {
            numer: 3,
            denom: 10,
        },
        pessimistic_gas_price_inflation_ratio: Ratio {
            numer: 103,
            denom: 100,
        },
    },
    wasm_config: VMConfig {
        ext_costs: ExtCostsConfig {
            base: 85575730,
            contract_compile_base: 0,
            contract_compile_bytes: 0,
            read_memory_base: 240204162,
            read_memory_byte: 1267152,
            write_memory_base: 298010700,
            write_memory_byte: 61637,
            read_register_base: 207826812,
            read_register_byte: 32264,
            write_register_base: 330162250,
            write_register_byte: 1267237,
            utf8_decoding_base: 414182237,
            utf8_decoding_byte: 97673738,
            utf16_decoding_base: 560067675,
            utf16_decoding_byte: 54606008,
            sha256_base: 984259937,
            sha256_byte: 9533435,
            keccak256_base: 1310902475,
            keccak256_byte: 7064304,
            keccak512_base: 1303771025,
            keccak512_byte: 12122541,
            log_base: 560067675,
            log_byte: 4109275,
            storage_write_base: 15024946500,
            storage_write_key_byte: 26148260,
            storage_write_value_byte: 1648179217,
            storage_write_evicted_byte: 3122044127,
            storage_read_base: 25393745625,
            storage_read_key_byte: 5460987367,
            storage_read_value_byte: 5223880062,
            storage_remove_base: 30885643250,
            storage_remove_key_byte: 5911200795,
            storage_remove_ret_value_byte: 5436148896,
            storage_has_key_base: 24060032250,
            storage_has_key_byte: 5056584417,
            storage_iter_create_prefix_base: 0,
            storage_iter_create_prefix_byte: 0,
            storage_iter_create_range_base: 0,
            storage_iter_create_from_byte: 0,
            storage_iter_create_to_byte: 0,
            storage_iter_next_base: 0,
            storage_iter_next_key_byte: 0,
            storage_iter_next_value_byte: 0,
            touching_trie_node: 7255355892,
            promise_and_base: 5364434505,
            promise_and_per_promise: 43246280,
            promise_return: 4737591733,
            validator_stake_base: 303944908800,
            validator_total_stake_base: 303944908800,
        },
        grow_mem_cost: 1,
        regular_op_cost: 1310745,
        limit_config: VMLimitConfig {
            max_gas_burnt: 200000000000000,
            max_gas_burnt_view: 200000000000000,
            max_stack_height: 16384,
            initial_memory_pages: 1024,
            max_memory_pages: 2048,
            registers_memory_limit: 1073741824,
            max_register_size: 104857600,
            max_number_registers: 100,
            max_number_logs: 100,
            max_total_log_length: 16384,
            max_total_prepaid_gas: 300000000000000,
            max_actions_per_receipt: 100,
            max_number_bytes_method_names: 2000,
            max_length_method_name: 256,
            max_arguments_length: 4194304,
            max_length_returned_data: 4194304,
            max_contract_size: 4194304,
            max_length_storage_key: 4194304,
            max_length_storage_value: 4194304,
            max_promises_per_function_call_action: 1024,
            max_number_input_data_dependencies: 128,
        },
    },
    account_creation_config: AccountCreationConfig {
        min_allowed_top_level_account_length: 0,
        registrar_account_id: "registrar",
    },
}

@olonho
Copy link
Contributor Author

olonho commented Apr 20, 2021

Full difference between two (first - before Wasmer 1.0, second - after):

storage_amount_per_byte: first=90900000000000000000 second=90900000000000000000 second/first=1.00
action_receipt_creation_config: send_sir: first=170739187500 second=173376187500 second/first=1.02
action_receipt_creation_config: send_not_sir: first=170739187500 second=173376187500 second/first=1.02
action_receipt_creation_config: execution: first=170739187500 second=173376187500 second/first=1.02
base_cost: send_sir: first=50756252803625 second=50927271643687 second/first=1.00
base_cost: send_not_sir: first=50756252803625 second=50927271643687 second/first=1.00
base_cost: execution: first=50756252803625 second=50927271643687 second/first=1.00
cost_per_byte: send_sir: first=14615009 second=4569950 second/first=0.31
cost_per_byte: send_not_sir: first=14615009 second=4569950 second/first=0.31
cost_per_byte: execution: first=14615009 second=4569950 second/first=0.31
create_account_cost: send_sir: first=31759375000 second=29243687500 second/first=0.92
create_account_cost: send_not_sir: first=31759375000 second=29243687500 second/first=0.92
create_account_cost: execution: first=31759375000 second=29243687500 second/first=0.92
deploy_contract_cost: send_sir: first=51102312500 second=56906312500 second/first=1.11
deploy_contract_cost: send_not_sir: first=51102312500 second=56906312500 second/first=1.11
deploy_contract_cost: execution: first=99711737500 second=105392087500 second/first=1.06
deploy_contract_cost_per_byte: send_sir: first=8268672 second=8298830 second/first=1.00
deploy_contract_cost_per_byte: send_not_sir: first=8268672 second=8298830 second/first=1.00
deploy_contract_cost_per_byte: execution: first=379984828 second=383710211 second/first=1.01
function_call_cost: send_sir: first=37606250000 second=35152312500 second/first=0.93
function_call_cost: send_not_sir: first=37606250000 second=35152312500 second/first=0.93
function_call_cost: execution: first=37606250000 second=35152312500 second/first=0.93
function_call_cost_per_byte: send_sir: first=9764731 second=9514806 second/first=0.97
function_call_cost_per_byte: send_not_sir: first=9764731 second=9514806 second/first=0.97
function_call_cost_per_byte: execution: first=9764731 second=9514806 second/first=0.97
transfer_cost: send_sir: first=28074625000 second=24369687500 second/first=0.87
transfer_cost: send_not_sir: first=28074625000 second=24369687500 second/first=0.87
transfer_cost: execution: first=28074625000 second=24369687500 second/first=0.87
stake_cost: send_sir: first=62682750000 second=65173750000 second/first=1.04
stake_cost: send_not_sir: first=62682750000 second=65173750000 second/first=1.04
stake_cost: execution: first=62682750000 second=65173750000 second/first=1.04
full_access_cost: send_sir: first=36261375000 second=35496000000 second/first=0.98
full_access_cost: send_not_sir: first=36261375000 second=35496000000 second/first=0.98
full_access_cost: execution: first=36261375000 second=35496000000 second/first=0.98
delete_key_cost: send_sir: first=17345687500 second=15966750000 second/first=0.92
delete_key_cost: send_not_sir: first=17345687500 second=15966750000 second/first=0.92
delete_key_cost: execution: first=17345687500 second=15966750000 second/first=0.92
delete_account_cost: send_sir: first=136139250000 second=135998812500 second/first=1.00
delete_account_cost: send_not_sir: first=136139250000 second=135998812500 second/first=1.00
delete_account_cost: execution: first=136139250000 second=135998812500 second/first=1.00
storage_usage_config: num_bytes_account: first=100 second=100 second/first=1.00
storage_usage_config: num_extra_bytes_record: first=40 second=40 second/first=1.00
burnt_gas_reward: numer: first=3 second=3 second/first=1.00
burnt_gas_reward: denom: first=10 second=10 second/first=1.00
pessimistic_gas_price_inflation_ratio: numer: first=103 second=103 second/first=1.00
pessimistic_gas_price_inflation_ratio: denom: first=100 second=100 second/first=1.00
ext_costs: base: first=85575730 second=44684235 second/first=0.52
ext_costs: contract_compile_base: first=0 second=0 second/first=n/a
ext_costs: contract_compile_bytes: first=0 second=0 second/first=n/a
ext_costs: read_memory_base: first=240204162 second=194420812 second/first=0.81
ext_costs: read_memory_byte: first=1267152 second=1265103 second/first=1.00
ext_costs: write_memory_base: first=298010700 second=246703825 second/first=0.83
ext_costs: write_memory_byte: first=61637 second=59739 second/first=0.97
ext_costs: read_register_base: first=207826812 second=171131825 second/first=0.82
ext_costs: read_register_byte: first=32264 second=30540 second/first=0.95
ext_costs: write_register_base: first=330162250 second=279066462 second/first=0.85
ext_costs: write_register_byte: first=1267237 second=1265183 second/first=1.00
ext_costs: utf8_decoding_base: first=414182237 second=361052000 second/first=0.87
ext_costs: utf8_decoding_byte: first=97673738 second=88775511 second/first=0.91
ext_costs: utf16_decoding_base: first=560067675 second=507523112 second/first=0.91
ext_costs: utf16_decoding_byte: first=54606008 second=50157442 second/first=0.92
ext_costs: sha256_base: first=984259937 second=931144137 second/first=0.95
ext_costs: sha256_byte: first=9533435 second=9526572 second/first=1.00
ext_costs: keccak256_base: first=1310902475 second=1256387700 second/first=0.96
ext_costs: keccak256_byte: first=7064304 second=7059051 second/first=1.00
ext_costs: keccak512_base: first=1303771025 second=1248904050 second/first=0.96
ext_costs: keccak512_byte: first=12122541 second=12099318 second/first=1.00
ext_costs: log_base: first=560067675 second=507523112 second/first=0.91
ext_costs: log_byte: first=4109275 second=4103732 second/first=1.00
ext_costs: storage_write_base: first=15024946500 second=15049827500 second/first=1.00
ext_costs: storage_write_key_byte: first=26148260 second=26151072 second/first=1.00
ext_costs: storage_write_value_byte: first=1648179217 second=1648812074 second/first=1.00
ext_costs: storage_write_evicted_byte: first=3122044127 second=2724356012 second/first=0.87
ext_costs: storage_read_base: first=25393745625 second=21667694625 second/first=0.85
ext_costs: storage_read_key_byte: first=5460987367 second=4668346894 second/first=0.85
ext_costs: storage_read_value_byte: first=5223880062 second=4429004858 second/first=0.85
ext_costs: storage_remove_base: first=30885643250 second=30519829500 second/first=0.99
ext_costs: storage_remove_key_byte: first=5911200795 second=5915845185 second/first=1.00
ext_costs: storage_remove_ret_value_byte: first=5436148896 second=5439146590 second/first=1.00
ext_costs: storage_has_key_base: first=24060032250 second=19529844875 second/first=0.81
ext_costs: storage_has_key_byte: first=5056584417 second=4264464051 second/first=0.84
ext_costs: storage_iter_create_prefix_base: first=0 second=0 second/first=n/a
ext_costs: storage_iter_create_prefix_byte: first=0 second=0 second/first=n/a
ext_costs: storage_iter_create_range_base: first=0 second=0 second/first=n/a
ext_costs: storage_iter_create_from_byte: first=0 second=0 second/first=n/a
ext_costs: storage_iter_create_to_byte: first=0 second=0 second/first=n/a
ext_costs: storage_iter_next_base: first=0 second=0 second/first=n/a
ext_costs: storage_iter_next_key_byte: first=0 second=0 second/first=n/a
ext_costs: storage_iter_next_value_byte: first=0 second=0 second/first=n/a
ext_costs: touching_trie_node: first=7255355892 second=6190769892 second/first=0.85
ext_costs: promise_and_base: first=5364434505 second=5290788315 second/first=0.99
ext_costs: promise_and_per_promise: first=43246280 second=43239176 second/first=1.00
ext_costs: promise_return: first=4737591733 second=4674980542 second/first=0.99
ext_costs: validator_stake_base: first=303944908800 second=303944908800 second/first=1.00
ext_costs: validator_total_stake_base: first=303944908800 second=303944908800 second/first=1.00
ext_costs: grow_mem_cost: first=1 second=1 second/first=1.00
ext_costs: regular_op_cost: first=1310745 second=593658 second/first=0.45
limit_config: max_gas_burnt: first=200000000000000 second=200000000000000 second/first=1.00
limit_config: max_gas_burnt_view: first=200000000000000 second=200000000000000 second/first=1.00
limit_config: max_stack_height: first=16384 second=16384 second/first=1.00
limit_config: initial_memory_pages: first=1024 second=1024 second/first=1.00
limit_config: max_memory_pages: first=2048 second=2048 second/first=1.00
limit_config: registers_memory_limit: first=1073741824 second=1073741824 second/first=1.00
limit_config: max_register_size: first=104857600 second=104857600 second/first=1.00
limit_config: max_number_registers: first=100 second=100 second/first=1.00
limit_config: max_number_logs: first=100 second=100 second/first=1.00
limit_config: max_total_log_length: first=16384 second=16384 second/first=1.00
limit_config: max_total_prepaid_gas: first=300000000000000 second=300000000000000 second/first=1.00
limit_config: max_actions_per_receipt: first=100 second=100 second/first=1.00
limit_config: max_number_bytes_method_names: first=2000 second=2000 second/first=1.00
limit_config: max_length_method_name: first=256 second=256 second/first=1.00
limit_config: max_arguments_length: first=4194304 second=4194304 second/first=1.00
limit_config: max_length_returned_data: first=4194304 second=4194304 second/first=1.00
limit_config: max_contract_size: first=4194304 second=4194304 second/first=1.00
limit_config: max_length_storage_key: first=4194304 second=4194304 second/first=1.00
limit_config: max_length_storage_value: first=4194304 second=4194304 second/first=1.00
limit_config: max_promises_per_function_call_action: first=1024 second=1024 second/first=1.00
limit_config: max_number_input_data_dependencies: first=128 second=128 second/first=1.00
account_creation_config: min_allowed_top_level_account_length: first=0 second=0 second/first=n/a

Significant difference (>15%) is the following:

cost_per_byte: send_sir: first=14615009 second=4569950 second/first=0.31
cost_per_byte: send_not_sir: first=14615009 second=4569950 second/first=0.31
cost_per_byte: execution: first=14615009 second=4569950 second/first=0.31
transfer_cost: send_sir: first=28074625000 second=24369687500 second/first=0.87
transfer_cost: send_not_sir: first=28074625000 second=24369687500 second/first=0.87
transfer_cost: execution: first=28074625000 second=24369687500 second/first=0.87
ext_costs: base: first=85575730 second=44684235 second/first=0.52
ext_costs: read_memory_base: first=240204162 second=194420812 second/first=0.81
ext_costs: write_memory_base: first=298010700 second=246703825 second/first=0.83
ext_costs: read_register_base: first=207826812 second=171131825 second/first=0.82
ext_costs: write_register_base: first=330162250 second=279066462 second/first=0.85
ext_costs: storage_read_base: first=25393745625 second=21667694625 second/first=0.85
ext_costs: storage_read_key_byte: first=5460987367 second=4668346894 second/first=0.85
ext_costs: storage_read_value_byte: first=5223880062 second=4429004858 second/first=0.85
ext_costs: storage_has_key_base: first=24060032250 second=19529844875 second/first=0.81
ext_costs: storage_has_key_byte: first=5056584417 second=4264464051 second/first=0.84
ext_costs: touching_trie_node: first=7255355892 second=6190769892 second/first=0.85
ext_costs: regular_op_cost: first=1310745 second=593658 second/first=0.45

// File 341191, code 279965, data 56627.
let data = include_bytes!("../test-contract/res/lockup_contract.wasm");
let contract = ContractCode::new(data.to_vec(), None);
xs.push(data.len() as u64);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename data to bytes or file to avoid confusion with "data section" mentioned in comment?


// We multiply `b` by 5/4 to accommodate for the fact that test contracts are typically 80% code,
// so in the worst case it could grow to 100% and our costs are still properly estimate.
// (a, b * Ratio::new(5i128, 4i128))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think above math formula is correct, however, it doesn't make sense to do a lsm on varied portion of code section / size.
Assume you test with
x1 = file size of file1.wasm, which has 90% of code section, y1 = cost
x2 = file size of file2.wasm, which has 60% of code section, y2 = cost
...
Then what is does the y = mx + b means? it would give both errorneous estimation on both 90%-code and 60% code contract, and the est doesn't give you an upper bound. So i suggest do two set of least square method:
x1 = code size of file1.wasm, y = cost1
x2 = code size of file2.wasm, y = cost2
...
You get a cost = m1 * code_size + b1
Then do least square on: xi = code size of file_i.wasm, y = cost_i, and get cost = m2 * data_size + b2.
Then, cost = max(m1,m2)*file_size + max(b1,b2) should give an upper bound cost, no matter how many portion of the file is code or data

@olonho
Copy link
Contributor Author

olonho commented Apr 22, 2021

Computed costs in pure instructions for Wasmer0 and Wasmer1:

Wasmer0:
 base: 6091792574264458940/129237918379 (47136263.49505116) ~ 47M
 per_byte: 4347212535408344/129237918379(33637.28377812318) ~34K

Wasmer1:
  base: 14439573053720587770/129237918379 (111728610.57213445) ~112M
  per_byte: 4130846448485268/129237918379(31963.115007557204) ~32K

@olonho
Copy link
Contributor Author

olonho commented Apr 22, 2021

Cost in gas will be thus (*1M / 8)

Wasmer0:
 base: ~ 5Tg
 per_byte: ~4Mg

Wasmer1:
  base: ~14Tg
  per_byte: ~4Mg

It is pretty high, as accounts for both compilation and storage.

@olonho
Copy link
Contributor Author

olonho commented Apr 22, 2021

When replaced backing cache with no-op, results are following:

Wasmer0:
  base: 5506664310489610589/129237918379 (42608735.72987225) ~ 42M
  per_byte: 4245443038433149/129237918379(32849.82528102213) ~ 33K
Wasmer1:
  base: 9555420837327677218/129237918379 (73936666.2445435) ~ 74M
  per_byte:  4056295041526911/129237918379(31386.261032396993) ~ 31K

xs.push(data.len() as u64);
ys.push(measure_contract(vm_kind, gas_metric, &contract, cache));

// Least squares method.
Copy link
Contributor

@matklad matklad Apr 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Compute error estimation.
let mut error = 0i128;
for i in 0..n {
let expect = (a + b * (xs[i] as i128)).to_integer();
Copy link
Contributor

@matklad matklad Apr 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not quite correct -- we just forget about fractional part, but it obviously affects the error. What is the reason for doing calculations in intergers? I think linear regression fundamentally operates with fractions, so we either should do all the math in rationals, or in floats.

I can see merit in sticking to precise rationals in principle, but I think floats wold work better in practice in this context? At lest the error calculation should be done in floats.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking more about this, rationals do make sense here, error calculation is the only place where we lose precision, so it's probably better to change just this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error vector is computed in integers.

let diff = expect - (ys[i] as i128);
error = error + diff * diff;
}
println!("Error {}", (error as f64).sqrt() / (n as f64));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I think this should be (error as f64 / n as f64).sqrt(). RMSE is a root of MSE.

Comment on lines 190 to 185
let n = xs.len();
let n128 = n as i128;

let mut sum_prod = 0 as i128; // Sum of x * y.
for i in 0..n {
sum_prod = sum_prod + (xs[i] as i128) * (ys[i] as i128);
}

let mut sum_x = 0 as i128; // Sum of x.
for i in 0..n {
sum_x = sum_x + (xs[i] as i128);
}

let mut sum_y = 0 as i128; // Sum of y.
for i in 0..n {
sum_y = sum_y + (ys[i] as i128);
}

let mut sum_x_square = 0 as i128; // Sum of x^2.
for i in 0..n {
sum_x_square = sum_x_square + (xs[i] as i128) * (xs[i] as i128);
}

let b = Ratio::new(n128 * sum_prod - sum_x * sum_y, n128 * sum_x_square - sum_x * sum_x);
let a = Ratio::new(sum_y * b.denom() - b.numer() * sum_x, n128 * b.denom());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use a differently stated formula in my version, and I pen&paper confiremed that they are equivalent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this one denom is multiplied to both

let contract = ContractCode::new(data.to_vec(), None);
xs.push(data.len() as u64);
ys.push(measure_contract(vm_kind, gas_metric, &contract, cache));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: i'd split out fn least_squares(xs: &[], ys: &[]) -> (Ratio, Ratio) to keep pure math independent of wasm stuff. This will also allow us to write a unit-test that, if least_squeares is feed with a linear function, it exactly recovers coefficients with zero error. The math looks right, but its fiddly, a test would be a nice assuareance.

ys.push(measure_contract(vm_kind, gas_metric, &contract, cache));

// File 257516, code 203545, data 50419.
let data = include_bytes!("../test-contract/res/staking_pool.wasm");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the right approach to use "real world" contracts for estimation? My gut feeling is that it probably is not.

We should be estimating worst case, so we should prepare a synthetic contract that exercises this case. We should use real contracts to double-check that a synthetic worst-case is at least not better that real world code.

However, just using real world contracts feels like we are saying "look, we don't know what the worst-case is, but we assume that it's within a stone's throw of typical case, so let's just measure that".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think max(m1,m2) approach will give you upper bound even for unknown code-portion contract, proof is:

let cost = max(m1,m2)*file_size+max(b1,b2)
then cost>=m1*filesize+b1>m1*codesize+b1=cost est based on codesize
cost>=m2*filesize+b2>m2*datasize=cost est based on datasize

@ailisp
Copy link
Member

ailisp commented Apr 22, 2021

Looks like the compile base cost of wasmer1 significantly increased is a problem

@olonho
Copy link
Contributor Author

olonho commented Apr 26, 2021

Oh, we we running non-optimized builds, tested with optimized versions (empty cache):

Wasmer0 in a + b * x:  a = 1414809023277576285/129237918379 (10947321.35137415) b = 272473464240210/129237918379(2108.308982826239)
Wasmer1 in a + b * x: a = 1041433042948184523/129237918379 (8058262.280997927) b = 87682443254453/129237918379(678.4575638035084)

Which translates to

Wasmer0: 1_368_415_168_921  + 263_538_623 * len (1.3Tg + 264M * per byte)
Wasmer1: 1_007_282_785_125  + 84_807_195 * len (1Tg + 85M * per byte)

@olonho
Copy link
Contributor Author

olonho commented Apr 26, 2021

With storage cache:

Wasmer0 in a + b * x:  a = 2014125401455500852/129237918379 (15584632.023775911) b = 371953238142935/129237918379(2878.0503648484487)
Wasmer1 in a + b * x: a = 1448036759168112663/129237918379 (11204426.512980772) b = 174702018725521/129237918379(1351.7860773120321)

which transforms to

Wasmer0: 1_948_079_002_972 + 359_756_296 * len (2Tg + 360M * len)
Wasmer1:  1_400_553_314_123 + 168_973_260 * len (1.4Tg + 168 M * len)

@bowenwang1996
Copy link
Collaborator

@olonho does the new function call per byte cost include deserialization cost? It seems too cheap

@olonho
Copy link
Contributor Author

olonho commented May 5, 2021

Updated tests with validation logic ensuring that other contracts can be properly upper cost estimated by values obtained from measurements on other contracts.

Also run the actual cost estimation:

x = 139637 y = 437183613 error is 84591507
x = 157010 y = 501375143 error is 82908392
x = 218444 y = 687400005 error is 117924338
Wasmer0 using ICount: in a + b * x: a = 2501825558000565200/129237918379 (19358293.520820815) b = 465000715158455/129237918379(3598.020774327277) base = 2419786690102 per_byte = 449752596
test vm_estimator::test_compile_cost_icount ... test vm_estimator::test_compile_cost_icount has been running for over 60 seconds
x = 139637 y = 448685434 error is 97162120
x = 157010 y = 505940963 error is 105253490
x = 218444 y = 712766879 error is 129505766
Wasmer1 using ICount: in a + b * x: a = 5328779606236421815/258475836758 (20616161.54559752) b = 1944464916683195/516951673516(3761.405594178839) base = 2577020193199 per_byte = 470175699

So the costs we suggest to be:

Wasmer0: 2_419_786_690_102 + 449_636_411 * len (2.5Tg + 4.5Tg per 10K)
Wasmer1: 2_577_020_193_199 +  470_175_699 * len (2.6Tg + 4.7Tg per 10K)

@olonho
Copy link
Contributor Author

olonho commented May 10, 2021

@olonho does the new function call per byte cost include deserialization cost? It seems too cheap
Let me recompute the costs with the most current version.

@olonho olonho marked this pull request as ready for review May 10, 2021 09:33
@olonho olonho changed the title fix: update cost estimator docs and recompute fees (WIP) fix: update cost estimator with contract compilation cost computations May 10, 2021
@MaksymZavershynskyi
Copy link
Contributor

Updated tests with validation logic ensuring that other contracts can be properly upper cost estimated by values obtained from measurements on other contracts.

Also run the actual cost estimation:

x = 139637 y = 437183613 error is 84591507
x = 157010 y = 501375143 error is 82908392
x = 218444 y = 687400005 error is 117924338
Wasmer0 using ICount: in a + b * x: a = 2501825558000565200/129237918379 (19358293.520820815) b = 465000715158455/129237918379(3598.020774327277) base = 2419786690102 per_byte = 449752596
test vm_estimator::test_compile_cost_icount ... test vm_estimator::test_compile_cost_icount has been running for over 60 seconds
x = 139637 y = 448685434 error is 97162120
x = 157010 y = 505940963 error is 105253490
x = 218444 y = 712766879 error is 129505766
Wasmer1 using ICount: in a + b * x: a = 5328779606236421815/258475836758 (20616161.54559752) b = 1944464916683195/516951673516(3761.405594178839) base = 2577020193199 per_byte = 470175699

So the costs we suggest to be:

Wasmer0: 2_419_786_690_102 + 449_636_411 * len (2.5Tg + 4.5Tg per 10K)
Wasmer1: 2_577_020_193_199 +  470_175_699 * len (2.6Tg + 4.7Tg per 10K)

@ailisp @matklad @olonho do these numbers mean that Wasmer 1 is not faster than Wasmer 0?

Copy link
Collaborator

@bowenwang1996 bowenwang1996 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is my understanding correct that this PR does not actually change the cost?

@matklad
Copy link
Contributor

matklad commented May 11, 2021

do these numbers mean that Wasmer 1 is not faster than Wasmer 0?

@nearmax Yes, but it's important to understand what this cost is about. In a sense, a comparison between wasm versions is misleading in this case.

This is the cost for compiling the contract. At the moment, we don't have this cost at all. So the actual diff here is going from not charging this cost at all to starting charging it.

Compilation cost being the same for 1 and 0 being similar makes sense.

@olonho
Copy link
Contributor Author

olonho commented May 13, 2021

Updated costs table after rebase:

RuntimeConfig {
    storage_amount_per_byte: 90900000000000000000,
    transaction_costs: RuntimeFeesConfig {
        action_receipt_creation_config: Fee {
            send_sir: 169645937500,
            send_not_sir: 169645937500,
            execution: 169645937500,
        },
        data_receipt_creation_config: DataReceiptCreationConfig {
            base_cost: Fee {
                send_sir: 50832240920562,
                send_not_sir: 50832240920562,
                execution: 50832240920562,
            },
            cost_per_byte: Fee {
                send_sir: 4815853,
                send_not_sir: 4815853,
                execution: 4815853,
            },
        },
        action_creation_config: ActionCreationConfig {
            create_account_cost: Fee {
                send_sir: 31934187500,
                send_not_sir: 31934187500,
                execution: 31934187500,
            },
            deploy_contract_cost: Fee {
                send_sir: 57261750000,
                send_not_sir: 57261750000,
                execution: 57712241672,
            },
            deploy_contract_cost_per_byte: Fee {
                send_sir: 8289221,
                send_not_sir: 8289221,
                execution: 2326388733319,
            },
            function_call_cost: Fee {
                send_sir: 102482875000,
                send_not_sir: 102482875000,
                execution: 102482875000,
            },
            function_call_cost_per_byte: Fee {
                send_sir: 28342,
                send_not_sir: 28342,
                execution: 28342,
            },
            transfer_cost: Fee {
                send_sir: 28687937500,
                send_not_sir: 28687937500,
                execution: 28687937500,
            },
            stake_cost: Fee {
                send_sir: 62264562500,
                send_not_sir: 62264562500,
                execution: 62264562500,
            },
            add_key_cost: AccessKeyCreationConfig {
                full_access_cost: Fee {
                    send_sir: 33815562500,
                    send_not_sir: 33815562500,
                    execution: 33815562500,
                },
                function_call_cost: Fee {
                    send_sir: 30587000000,
                    send_not_sir: 30587000000,
                    execution: 30587000000,
                },
                function_call_cost_per_byte: Fee {
                    send_sir: 13081843,
                    send_not_sir: 13081843,
                    execution: 13081843,
                },
            },
            delete_key_cost: Fee {
                send_sir: 15477375000,
                send_not_sir: 15477375000,
                execution: 15477375000,
            },
            delete_account_cost: Fee {
                send_sir: 135690625000,
                send_not_sir: 135690625000,
                execution: 135690625000,
            },
        },
        storage_usage_config: StorageUsageConfig {
            num_bytes_account: 100,
            num_extra_bytes_record: 40,
        },
        burnt_gas_reward: Ratio {
            numer: 3,
            denom: 10,
        },
        pessimistic_gas_price_inflation_ratio: Ratio {
            numer: 103,
            denom: 100,
        },
    },
    wasm_config: VMConfig {
        ext_costs: ExtCostsConfig {
            base: 44701352,
            contract_compile_base: 0,
            contract_compile_bytes: 0,
            read_memory_base: 196042662,
            read_memory_byte: 1264948,
            write_memory_base: 248064412,
            write_memory_byte: 59741,
            read_register_base: 172883137,
            read_register_byte: 30385,
            write_register_base: 280904337,
            write_register_byte: 1265029,
            utf8_decoding_base: 362850075,
            utf8_decoding_byte: 88774321,
            utf16_decoding_base: 509307637,
            utf16_decoding_byte: 50160159,
            sha256_base: 932913037,
            sha256_byte: 9510602,
            keccak256_base: 1258105000,
            keccak256_byte: 7057793,
            keccak512_base: 1250641662,
            keccak512_byte: 12115779,
            log_base: 509307637,
            log_byte: 4104682,
            storage_write_base: 14178527125,
            storage_write_key_byte: 25987802,
            storage_write_value_byte: 1449390047,
            storage_write_evicted_byte: 2923647032,
            storage_read_base: 24489688500,
            storage_read_key_byte: 5064746680,
            storage_read_value_byte: 4826917589,
            storage_remove_base: 31313008500,
            storage_remove_key_byte: 5913348197,
            storage_remove_ret_value_byte: 5438339304,
            storage_has_key_base: 22190463375,
            storage_has_key_byte: 4659941850,
            storage_iter_create_prefix_base: 0,
            storage_iter_create_prefix_byte: 0,
            storage_iter_create_range_base: 0,
            storage_iter_create_from_byte: 0,
            storage_iter_create_to_byte: 0,
            storage_iter_next_base: 0,
            storage_iter_next_key_byte: 0,
            storage_iter_next_value_byte: 0,
            touching_trie_node: 6997053857,
            promise_and_base: 5330988756,
            promise_and_per_promise: 43235951,
            promise_return: 4714972507,
            validator_stake_base: 303944908800,
            validator_total_stake_base: 303944908800,
        },
        grow_mem_cost: 1,
        regular_op_cost: 594686,
        limit_config: VMLimitConfig {
            max_gas_burnt: 200000000000000,
            max_gas_burnt_view: 200000000000000,
            max_stack_height: 16384,
            initial_memory_pages: 1024,
            max_memory_pages: 2048,
            registers_memory_limit: 1073741824,
            max_register_size: 104857600,
            max_number_registers: 100,
            max_number_logs: 100,
            max_total_log_length: 16384,
            max_total_prepaid_gas: 300000000000000,
            max_actions_per_receipt: 100,
            max_number_bytes_method_names: 2000,
            max_length_method_name: 256,
            max_arguments_length: 4194304,
            max_length_returned_data: 4194304,
            max_contract_size: 4194304,
            max_length_storage_key: 4194304,
            max_length_storage_value: 4194304,
            max_promises_per_function_call_action: 1024,
            max_number_input_data_dependencies: 128,
        },
    },
    account_creation_config: AccountCreationConfig {
        min_allowed_top_level_account_length: 0,
        registrar_account_id: "registrar",
    },
}

@bowenwang1996
Copy link
Collaborator

bowenwang1996 commented May 13, 2021

@olonho function call execution cost is 100Ggas, which means we can execute 10000 no-op function calls per block. I thought reloading compiled contracts and deserialization would not allow us to do that many function calls.

@olonho
Copy link
Contributor Author

olonho commented May 14, 2021

Difference is now

./emu-cost/compare_costs.py --diff ./wasmer0_noprecomp.json wasmer1_precomp.json 
transaction_costs.data_receipt_creation_config.cost_per_byte.send_sir: first=14299940 second=4815853 second/first=0.34
transaction_costs.data_receipt_creation_config.cost_per_byte.send_not_sir: first=14299940 second=4815853 second/first=0.34
transaction_costs.data_receipt_creation_config.cost_per_byte.execution: first=14299940 second=4815853 second/first=0.34
transaction_costs.action_creation_config.function_call_cost.send_sir: first=257471687500 second=102482875000 second/first=0.40
transaction_costs.action_creation_config.function_call_cost.send_not_sir: first=257471687500 second=102482875000 second/first=0.40
transaction_costs.action_creation_config.function_call_cost.execution: first=257471687500 second=102482875000 second/first=0.40
wasm_config.ext_costs.base: first=85500164 second=44701352 second/first=0.52
wasm_config.regular_op_cost: first=1311973 second=594686 second/first=0.45

@bowenwang1996
Copy link
Collaborator

We need to perform additional experiments, but code measuring it is rather straightforward. I can repeat with explicit calls to 10K of noop methods in 10k different contracts.

@olonho The reason why I have doubts about this is that according to @ailisp it would take us a couple milliseconds to load and deserialize the compiled contracts, which means that we cannot fit 10k noop calls in one block.

@bowenwang1996
Copy link
Collaborator

@olonho also #4231 (comment) looks suspicious because the current function call cost is

function_call_cost: Fee {
                    send_sir: 2319861500000,
                    send_not_sir: 2319861500000,
                    execution: 2319861500000,
                }

which is an order of magnitude larger than the one you posted (wasmer0_noprecomp).

@olonho
Copy link
Contributor Author

olonho commented May 16, 2021

OK, as it's rather important, will create dedicated code similar to what we have for contract precomilation costs and report back the results.

@olonho
Copy link
Contributor Author

olonho commented May 17, 2021

Implemented (ddb4dbd) very explicit test allowing to measure time and icount metrics on many small distinct contracts.

Results are as following:

Wasmer0:
10_000 calls:  976_223_554  (   97_622 per call) Time,    976_223_554_000_000 gas (97_622_355_400 per call)
10_000 calls: 3_023_189_676 (  302_318 per call)  ICount  377_898_709_500_000 gas (37_789_870_950 per call)
Wasmer1:
10_000 calls: 1_046_110_217 (104_611 per call) Time, 1_046_110_217_000_000 gas (104_611_021_700 per call)
10_000 calls: 2_131_123_187 (213_112 per call) ICount, 266_390_398_375_000 gas ( 26_639_039_837 per call)

I.e when precompiled, invocation cost for the very small contract is 0.097 "Tgs", if counted as time on my machine, and 0.037Tg, i.e. 3x smaller when counted as instructions compared to counted as time.

When measuring 10K contracts following IO statistics applies:

insn 2797453613 read 8360346 written 143

i.e we read about 8M of data.

@bowenwang1996
Copy link
Collaborator

many small distinct contracts.

What's the reason for measuring only small contracts? In practice most of the deployed contracts are pretty large.

@olonho
Copy link
Contributor Author

olonho commented May 17, 2021

many small distinct contracts.

What's the reason for measuring only small contracts? In practice most of the deployed contracts are pretty large.

Fully makes sense, we can use larger contracts as well, it was just easier to write with smaller contract.

@olonho
Copy link
Contributor Author

olonho commented May 17, 2021

Also counted instruction counts and wall clock with independent tool, Linux perf, as function of number of contracts:

      1_000: 1.4G insn, 268M insn qemu, 0.15 sec
     10_000: 6.9G insn, 3G insn qemu, 0.84 sec
    100_000: 515G insn, 164G insn qemu, 62 sec
  1_000_000: 13T insn, 1200 sec

@olonho
Copy link
Contributor Author

olonho commented May 17, 2021

And Alex produced such an amazing plot
image
showing icount and wall clock correlation.

@olonho
Copy link
Contributor Author

olonho commented May 17, 2021

Our current cost model assumes CPU capable of executing 8 instructions per nanosecond, experiments with perf shows that on high end modern CPUs (Intel 4.2Ghz) it's about 10.2 instructions per nanosecond

1,291,676.43 msec task-clock:u              #    1.047 CPUs utilized          
                 0      context-switches:u        #    0.000 K/sec                  
                 0      cpu-migrations:u          #    0.000 K/sec                  
         7,104,242      page-faults:u             #    0.006 M/sec                  
 5,449,541,389,053      cycles:u                  #    4.219 GHz                    
     6,682,365,801      stalled-cycles-frontend:u #    0.12% frontend cycles idle   
    46,723,157,457      stalled-cycles-backend:u  #    0.86% backend cycles idle    
13,301,632,220,268      instructions:u            #    2.44  insn per cycle         
                                                  #    0.00  stalled cycles per insn
 2,493,519,263,200      branches:u                # 1930.452 M/sec                  
     2,482,036,399      branch-misses:u           #    0.10% of all branches        
    1233.828732261 seconds time elapsed
    1198.632118000 seconds user
      93.045689000 seconds sys

On lower end CPUs we could probably recalibrate our gas multiplier to assume 2-3 instructions per-nanosecond by decreasing divisor in ratio_to_gas.

@ailisp
Copy link
Member

ailisp commented May 17, 2021

On lower end CPUs we could probably recalibrate our gas multiplier to assume 2-3 instructions per-nanosecond by decreasing divisor in ratio_to_gas.

Cloud instances we and validators use to run mainnet node are usually low end (google cloud, aws gives you N vcpus, so they optimized for N by using majorly 5-10 yr old cpus :) ) Did you run the ins/nanosecond check on our cloud instances?

@olonho
Copy link
Contributor Author

olonho commented May 18, 2021

Per the very end of table in https://en.wikipedia.org/wiki/Instructions_per_second one could see

On lower end CPUs we could probably recalibrate our gas multiplier to assume 2-3 instructions per-nanosecond by decreasing divisor in ratio_to_gas.

Cloud instances we and validators use to run mainnet node are usually low end (google cloud, aws gives you N vcpus, so they optimized for N by using majorly 5-10 yr old cpus :) ) Did you run the ins/nanosecond check on our cloud instances?

Nope, actually just running perf stat on some test, i.e one of contract call tests above shall be sufficient. Could youplease help with that?

@@ -2434,6 +2434,7 @@ impl<'a> VMLogic<'a> {
}
}

// TODO: remove, as those costs are incorrectly computed, and we shall account it on deployment.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we create an issue (or link to an existing one) for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker> cargo run --release --package neard --features protocol_feature_evm,nightly_protocol_features --bin neard -- --home /tmp/data init --chain-id= --test-seed=alice.near --account-id=test.near --fast
docker> cargo run --release --package genesis-populate --bin genesis-populate -- --additional-accounts-num=200000 --home /tmp/data
docker> cargo run -j2 --release --package neard --features protocol_feature_evm --bin neard -- --home /tmp/data init --chain-id= --test-seed=alice.near --account-id=test.near --fast
docker> cargo run -j2 --release --package genesis-populate --features protocol_feature_evm --bin genesis-populate -- --additional-accounts-num=200000 --home /tmp/data
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need protocol_feature_evm?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do estimate EVM costs, and it was there before.

@EgorKulikov
Copy link
Contributor

LGTM, any specific reason behind 5/4 constant?

@olonho
Copy link
Contributor Author

olonho commented May 19, 2021

LGTM, any specific reason behind 5/4 constant?

In contracts above code takes 80% of Wasm size, so multiply for cases where 100% of contract is code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants