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

bug: Determine the chain type only by chain id #150

Open
0xOutOfGas opened this issue Sep 26, 2022 · 0 comments
Open

bug: Determine the chain type only by chain id #150

0xOutOfGas opened this issue Sep 26, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@0xOutOfGas
Copy link

Description: In module ChainId, determining whether the chain is dev, test, halley, proxima, barnard, and main type is not enough. The custom chain may be configured from a dev template with the main id. The wrong logic may cause an incorrect impact to VMConfig for calculating maximum_number_of_gas_units.
Code Location: sources/ChainId.move, line 45

// In ChainId.move
public fun is_dev(): bool acquires ChainId {
    get() == DEV_CHAIN_ID
}
public fun is_test(): bool acquires ChainId {
    get() == TEST_CHAIN_ID
}
public fun is_halley(): bool acquires ChainId {
    get() == HALLEY_CHAIN_ID
}
public fun is_proxima(): bool acquires ChainId {
    get() == PROXIMA_CHAIN_ID
}
public fun is_barnard(): bool acquires ChainId {
    get() == BARNARD_CHAIN_ID
}
public fun is_main(): bool acquires ChainId {
    get() == MAIN_CHAIN_ID
}

// In VMConfig.move
public fun gas_constants(): GasConstants {
    let min_price_per_gas_unit: u64 = if (ChainId::is_test()) { 0 }  else { 1 };
    let maximum_number_of_gas_units: u64 = 40000000;//must less than base_block_gas_limit

    if (ChainId::is_test() || ChainId::is_dev() || ChainId::is_halley()) {
        maximum_number_of_gas_units = maximum_number_of_gas_units * 10
    };
    GasConstants {
        global_memory_per_byte_cost: 4,
        global_memory_per_byte_write_cost: 9,
        min_transaction_gas_units: 600,
        large_transaction_cutoff: 600,
        instrinsic_gas_per_byte: 8,
        maximum_number_of_gas_units,
        min_price_per_gas_unit,
        max_price_per_gas_unit: 10000,
        max_transaction_size_in_bytes: 1024 * 128,
        gas_unit_scaling_factor: 1,
        default_account_size: 800,
    }
}
@0xOutOfGas 0xOutOfGas added the bug Something isn't working label Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant