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

feat: Regression based modelling of gas prices #1470

Draft
wants to merge 46 commits into
base: master
Choose a base branch
from

Conversation

@bvrooman bvrooman marked this pull request as ready for review November 9, 2023 06:00
@bvrooman
Copy link
Contributor Author

bvrooman commented Nov 9, 2023

There are some outstanding issues that I will address presently. But the PR is ready for a first round of reviews. I will do a new VM release with required cost changes and integrate. I will also upgrade the Rust version, as well as other tangential changes, in separate PRs.

@bvrooman bvrooman self-assigned this Nov 9, 2023
benches/Cargo.toml Outdated Show resolved Hide resolved
Copy link
Collaborator

@xgreenx xgreenx left a comment

Choose a reason for hiding this comment

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

I'm curious about which values this change produces =)

crates/client/src/client/schema/chain.rs Outdated Show resolved Hide resolved
Comment on lines 571 to 589
// let iter = dependent_groups.into_iter().map(|(name, x_y)| {
// groups.remove(&name);
// let samples = x_y
// .iter()
// .map(|(x, y)| Sample {
// throughput: *x,
// time: *y,
// })
// .collect();
// let (_, dep_per_unit) = dependent_cost(&name, x_y);
// (
// name,
// Cost::DependentAll {
// samples,
// dep_per_unit,
// },
// )
// });
// costs.0.extend(iter);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess we need it back?=D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this section because it is unclear to me how this will be used going forward, or if we still use it in our current benchmark process. This code is designed not to be used when generating formatted output (e.g., -f rust) so we don't use it, and it is just unmaintained code after this point.

benches/src/bin/collect.rs Outdated Show resolved Hide resolved
benches/src/bin/collect.rs Outdated Show resolved Hide resolved
benches/src/bin/collect.rs Outdated Show resolved Hide resolved
{"reason":"benchmark-complete","id":"heavy_linear_data/heavy_linear_data_185","report_directory":"","iteration_count":[6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6],"measured_values":[55714042.0,54896000.0,55015291.0,55095708.0,55018917.0,55020875.0,54908792.0,54936167.0,54970125.0,55080583.0,54948167.0,55095292.0,55393000.0,55279833.0,55010792.0,55016583.0,54984125.0,55012709.0,54935584.0,55172292.0,55543042.0,55029459.0,54946959.0,54942792.0,55126791.0,54935041.0,54917625.0,55026000.0,55069875.0,54997583.0,55205584.0,55421917.0,55346708.0,55232042.0,54969000.0,55059833.0,54971417.0,54848042.0,54877625.0,55566125.0,55103250.0,55003375.0,55409333.0,55449291.0,55392042.0,55404458.0,55311291.0,55321000.0,55670375.0,55461542.0,56462000.0,55392166.0,55321667.0,55147667.0,55463375.0,55245041.0,55172375.0,55742042.0,55565375.0,55189459.0,55113834.0,55475458.0,55111875.0,55436625.0,55212625.0,57094375.0,55924416.0,55196708.0,55400375.0,55524083.0,55094292.0,55128000.0,55102417.0,55113458.0,55236000.0,55517125.0,55054375.0,55751417.0,55315250.0,55158167.0,55152750.0,55191750.0,55219542.0,55443542.0,55162000.0,55597833.0,55071792.0,55375708.0,54958292.0,55178334.0,55170542.0,55368625.0,55534709.0,55088875.0,54997542.0,55102125.0,55702292.0,55162875.0,55101666.0,55190791.0],"unit":"ns","throughput":[{"per_iteration":185,"unit":"elements"}],"typical":{"estimate":9207496.534999998,"lower_bound":9197684.215625,"upper_bound":9218661.255291665,"unit":"ns"},"mean":{"estimate":9207496.534999998,"lower_bound":9197684.215625,"upper_bound":9218661.255291665,"unit":"ns"},"median":{"estimate":9194451.416666668,"lower_bound":9184725.666666668,"upper_bound":9202104.166666666,"unit":"ns"},"median_abs_dev":{"estimate":39443.33679974263,"lower_bound":27824.44790601684,"upper_bound":51020.96308294587,"unit":"ns"},"slope":null,"change":null}
{"reason":"benchmark-complete","id":"heavy_linear_data/heavy_linear_data_190","report_directory":"","iteration_count":[6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6],"measured_values":[57077542.0,56851500.0,57018583.0,56813250.0,56926584.0,57041167.0,56497625.0,56643208.0,56921625.0,56655500.0,56659708.0,56791666.0,56761333.0,56852583.0,56490583.0,56646209.0,56857417.0,56793708.0,56544709.0,57413875.0,57080625.0,56769375.0,56917750.0,56650583.0,56925250.0,56648250.0,56467458.0,56610042.0,57026834.0,56431084.0,56417917.0,56650125.0,56446834.0,56368417.0,56393042.0,56416125.0,56408834.0,57134500.0,56738541.0,56401500.0,56622209.0,56421750.0,56367125.0,57772875.0,56516375.0,56390083.0,56498416.0,56482542.0,56584875.0,56347750.0,56429000.0,56576916.0,56376417.0,56404333.0,56621000.0,56770750.0,57085917.0,56455417.0,56533416.0,56363209.0,56572416.0,56413542.0,56428959.0,56632500.0,56376875.0,56402750.0,56371208.0,56374875.0,56439000.0,56430292.0,56374625.0,56548250.0,56414458.0,56853666.0,56798375.0,56641875.0,56549083.0,56597125.0,56498292.0,56348959.0,56575625.0,56373875.0,56434666.0,56498916.0,56383125.0,56583292.0,56549375.0,56334458.0,56568250.0,56680417.0,56743209.0,56712917.0,56397625.0,57310000.0,56480708.0,56634000.0,56736458.0,56550542.0,56515375.0,56615416.0],"unit":"ns","throughput":[{"per_iteration":190,"unit":"elements"}],"typical":{"estimate":9437545.35,"lower_bound":9429535.613666669,"upper_bound":9446134.492124997,"unit":"ns"},"mean":{"estimate":9437545.35,"lower_bound":9429535.613666669,"upper_bound":9446134.492124997,"unit":"ns"},"median":{"estimate":9428388.833333332,"lower_bound":9416486.0,"upper_bound":9437451.333333332,"unit":"ns"},"median_abs_dev":{"estimate":38310.75396984677,"lower_bound":27268.47291588737,"upper_bound":46727.59757041885,"unit":"ns"},"slope":null,"change":null}
{"reason":"benchmark-complete","id":"heavy_linear_data/heavy_linear_data_195","report_directory":"","iteration_count":[6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6],"measured_values":[57754250.0,57607958.0,57583167.0,57624083.0,57630666.0,57630958.0,57657750.0,57624833.0,57745500.0,57611916.0,57601375.0,57619083.0,58621000.0,61597792.0,58071666.0,58331541.0,58337875.0,57682500.0,57619084.0,58932792.0,57607667.0,57612708.0,57728416.0,57774166.0,57658458.0,57577250.0,57744958.0,57645584.0,57608833.0,57588250.0,57647458.0,58584625.0,58205416.0,57677500.0,57600875.0,57582000.0,57632250.0,57618084.0,57571292.0,57579125.0,57674875.0,57631750.0,57770041.0,57749208.0,57630792.0,57638334.0,57580083.0,57645666.0,57685041.0,58183291.0,58154167.0,57612000.0,57831709.0,57664584.0,57700917.0,57651875.0,57602709.0,57842208.0,58066125.0,57589375.0,57769083.0,57612500.0,57685875.0,57624875.0,57603625.0,57865833.0,57731084.0,57597417.0,58373709.0,57765375.0,57661500.0,57623667.0,57625625.0,57596625.0,57625541.0,57732333.0,57599292.0,57615542.0,57787917.0,59978791.0,57647333.0,57576458.0,58583667.0,58738709.0,57706167.0,57842750.0,57913833.0,58346959.0,57692792.0,57606833.0,57660958.0,57630708.0,57817166.0,57663583.0,57634500.0,57678333.0,57646125.0,57647083.0,57633833.0,57625959.0],"unit":"ns","throughput":[{"per_iteration":195,"unit":"elements"}],"typical":{"estimate":9638009.020000005,"lower_bound":9623148.483083338,"upper_bound":9656712.016041663,"unit":"ns"},"mean":{"estimate":9638009.020000005,"lower_bound":9623148.483083338,"upper_bound":9656712.016041663,"unit":"ns"},"median":{"estimate":9608277.75,"lower_bound":9605375.0,"upper_bound":9613333.333333332,"unit":"ns"},"median_abs_dev":{"estimate":11768.013741076453,"lower_bound":7855.429321788251,"upper_bound":18326.54182463838,"unit":"ns"},"slope":null,"change":null}
{"reason":"group-complete","group_name":"heavy_linear_data","benchmarks":["heavy_linear_data/heavy_linear_data_0","heavy_linear_data/heavy_linear_data_5","heavy_linear_data/heavy_linear_data_10","heavy_linear_data/heavy_linear_data_15","heavy_linear_data/heavy_linear_data_20","heavy_linear_data/heavy_linear_data_25","heavy_linear_data/heavy_linear_data_30","heavy_linear_data/heavy_linear_data_35","heavy_linear_data/heavy_linear_data_40","heavy_linear_data/heavy_linear_data_45","heavy_linear_data/heavy_linear_data_50","heavy_linear_data/heavy_linear_data_55","heavy_linear_data/heavy_linear_data_60","heavy_linear_data/heavy_linear_data_65","heavy_linear_data/heavy_linear_data_70","heavy_linear_data/heavy_linear_data_75","heavy_linear_data/heavy_linear_data_80","heavy_linear_data/heavy_linear_data_85","heavy_linear_data/heavy_linear_data_90","heavy_linear_data/heavy_linear_data_95","heavy_linear_data/heavy_linear_data_100","heavy_linear_data/heavy_linear_data_105","heavy_linear_data/heavy_linear_data_110","heavy_linear_data/heavy_linear_data_115","heavy_linear_data/heavy_linear_data_120","heavy_linear_data/heavy_linear_data_125","heavy_linear_data/heavy_linear_data_130","heavy_linear_data/heavy_linear_data_135","heavy_linear_data/heavy_linear_data_140","heavy_linear_data/heavy_linear_data_145","heavy_linear_data/heavy_linear_data_150","heavy_linear_data/heavy_linear_data_155","heavy_linear_data/heavy_linear_data_160","heavy_linear_data/heavy_linear_data_165","heavy_linear_data/heavy_linear_data_170","heavy_linear_data/heavy_linear_data_175","heavy_linear_data/heavy_linear_data_180","heavy_linear_data/heavy_linear_data_185","heavy_linear_data/heavy_linear_data_190","heavy_linear_data/heavy_linear_data_195"],"report_directory":""}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need so huge input=D?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In general, the more data we have during function estimation, the more accurate it will be. In these tests, we see if we can determine an appropriate function from the data set, and the estimation process is sensitive to the quality of the data. Because these tests are pretty strict, (i.e, we test for exact values for slope and intercept) we need to provide enough data to achieve that accuracy.

@bvrooman bvrooman changed the title feat: Separate light heavy gas costs feat: Separate light and heavy gas costs Nov 13, 2023
@bvrooman
Copy link
Contributor Author

Given the current PR, and the data provided here, collect gives us the following:

use super::*;
/// File generated by fuel-core: benches/src/collect/state.rs:197. With the following git hash
pub const GIT: &str = "856f763cc042e78e6aa215e60614827b0e6cb812";
pub fn default_gas_costs() -> GasCostsValues {
    GasCostsValues {
        add: 1,
        addi: 1,
        aloc: 1,
        and: 1,
        andi: 1,
        bal: 832,
        bhei: 1,
        bhsh: 1,
        burn: 73630,
        cb: 1,
        cfei: 1,
        cfsi: 1,
        croo: 173,
        div: 1,
        divi: 1,
        eck1: 3849,
        ecr1: 51685,
        ed19: 3783,
        eq: 1,
        exp: 1,
        expi: 1,
        flag: 1,
        gm: 1,
        gt: 1,
        gtf: 1,
        ji: 1,
        jmp: 1,
        jne: 1,
        jnei: 1,
        jnzi: 1,
        jmpf: 1,
        jmpb: 1,
        jnzf: 1,
        jnzb: 1,
        jnef: 1,
        jneb: 1,
        lb: 1,
        log: 1503,
        lt: 1,
        lw: 1,
        mint: 58278,
        mlog: 2,
        state_root: DependentCost::HeavyOperation {
            base: 0,
            gas_per_unit: 186,
        },
        modi: 1,
        mod_op: 1,
        movi: 1,
        mroo: 4,
        mul: 1,
        muli: 1,
        mldv: 1,
        noop: 1,
        not: 1,
        or: 1,
        ori: 1,
        poph: 1,
        popl: 1,
        pshh: 1,
        pshl: 1,
        move_op: 1,
        ret: 1687,
        sb: 1,
        sll: 1,
        slli: 1,
        srl: 1,
        srli: 1,
        srw: 41,
        sub: 1,
        subi: 1,
        sw: 1,
        sww: 1253,
        time: 1,
        tr: 120175,
        tro: 72174,
        wdcm: 1,
        wqcm: 2,
        wdop: 2,
        wqop: 2,
        wdml: 2,
        wqml: 3,
        wddv: 5,
        wqdv: 9,
        wdmd: 11,
        wqmd: 19,
        wdam: 9,
        wqam: 11,
        wdmm: 14,
        wqmm: 14,
        xor: 1,
        xori: 1,
        call: DependentCost::LightOperation {
            base: 11852,
            units_per_gas: 11,
        },
        ccp: DependentCost::LightOperation {
            base: 137,
            units_per_gas: 31,
        },
        csiz: DependentCost::LightOperation {
            base: 150,
            units_per_gas: 57,
        },
        k256: DependentCost::LightOperation {
            base: 23,
            units_per_gas: 3,
        },
        ldc: DependentCost::LightOperation {
            base: 142,
            units_per_gas: 32,
        },
        logd: DependentCost::LightOperation {
            base: 1575,
            units_per_gas: 2,
        },
        mcl: DependentCost::LightOperation {
            base: 0,
            units_per_gas: 538,
        },
        mcli: DependentCost::LightOperation {
            base: 0,
            units_per_gas: 548,
        },
        mcp: DependentCost::LightOperation {
            base: 0,
            units_per_gas: 448,
        },
        mcpi: DependentCost::LightOperation {
            base: 2,
            units_per_gas: 1824,
        },
        meq: DependentCost::LightOperation {
            base: 1,
            units_per_gas: 1104,
        },
        rvrt: 1742,
        s256: DependentCost::LightOperation {
            base: 10,
            units_per_gas: 3,
        },
        scwq: DependentCost::HeavyOperation {
            base: 1,
            gas_per_unit: 0,
        },
        smo: DependentCost::LightOperation {
            base: 71020,
            units_per_gas: 2,
        },
        srwq: DependentCost::LightOperation {
            base: 0,
            units_per_gas: 1,
        },
        swwq: DependentCost::HeavyOperation {
            base: 1,
            gas_per_unit: 0,
        },
        contract_root: DependentCost::LightOperation {
            base: 0,
            units_per_gas: 3,
        },
        retd: DependentCost::LightOperation {
            base: 1583,
            units_per_gas: 2,
        },
    }
}

Note that scwq and swwq were not included:

Warning the following keys were not set by this bench:
["jmpb", "jmpf", "jneb", "jnef", "jnzb", "jnzf", "mldv", "poph", "popl", "pshh", "pshl", "scwq", "swwq"]

@bvrooman bvrooman requested a review from a team November 13, 2023 12:04
xgreenx added a commit that referenced this pull request Nov 14, 2023
This PR is a subset of #1470.
It contains only the changes required for fuel-core crates and
chainspec, including upgrading to `fuel-vm` v0.41.

---------

Co-authored-by: xgreenx <xgreenx9999@gmail.com>

const UNIT_COEF: f64 = 100.0;

fn busy<R>(coefficient: f64, rng: &mut R)
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious why you went with something that warms the CPU here. From what I'm reading I assume this is meant to be some arbitrary process. I would usually choose to do a sleep--or better something that mocks time. Maybe it's a constraint from criterion?

Also, I think a more descriptive name might be useful here. I inferred the use from the lack of output--it might be nice to name it something like consume_cpu_resources or do_arbitrary_work or something like that.

MitchTurner
MitchTurner previously approved these changes Nov 16, 2023
Copy link
Member

@MitchTurner MitchTurner left a comment

Choose a reason for hiding this comment

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

This looks great. Just had one clarifying question.

Copy link
Collaborator

@xgreenx xgreenx left a comment

Choose a reason for hiding this comment

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

I like the idea of this change, it looks great=)

I want to block the merging of this PR until we have stable results from the collect binary that we can use in production.

Right now it doesn't return prices for sequential opcodes.

@bvrooman
Copy link
Contributor Author

bvrooman commented Nov 16, 2023

I like the idea of this change, it looks great=)

I want to block the merging of this PR until we have stable results from the collect binary that we can use in production.

Right now it doesn't return prices for sequential opcodes.

Can you clarify which sequential opcodes are not returned by this version of collect please? I can investigate that.

Edit: If you're referring to the fact that the above results do not include scwq and swwq, it's simply because the benchmark data I used to generate the prices did not include them. They were generated from this data as provided on Slack.

@bvrooman
Copy link
Contributor Author

Updated prices:

use super::*;
/// File generated by fuel-core: benches/src/collect/state.rs:197. With the following git hash
pub const GIT: &str = "12c044d226407e230b7653251dd381e15f5f5462";
pub fn default_gas_costs() -> GasCostsValues {
    GasCostsValues {
        add: 1,
        addi: 1,
        aloc: 0,
        and: 1,
        andi: 1,
        bal: 40,
        bhei: 1,
        bhsh: 1,
        burn: 27737,
        cb: 1,
        cfei: 1,
        cfsi: 1,
        croo: 39,
        div: 1,
        divi: 1,
        eck1: 3106,
        ecr1: 42737,
        ed19: 2896,
        eq: 1,
        exp: 1,
        expi: 1,
        flag: 0,
        gm: 1,
        gt: 1,
        gtf: 1,
        ji: 1,
        jmp: 1,
        jne: 1,
        jnei: 1,
        jnzi: 1,
        jmpf: 1,
        jmpb: 1,
        jnzf: 1,
        jnzb: 1,
        jnef: 1,
        jneb: 1,
        lb: 1,
        log: 86,
        lt: 1,
        lw: 1,
        mint: 25514,
        mlog: 1,
        state_root: DependentCost::HeavyOperation {
            base: 0,
            gas_per_unit: 161,
        },
        modi: 1,
        mod_op: 1,
        movi: 1,
        mroo: 3,
        mul: 1,
        muli: 1,
        mldv: 3,
        noop: 1,
        not: 1,
        or: 1,
        ori: 1,
        poph: 2,
        popl: 2,
        pshh: 2,
        pshl: 2,
        move_op: 1,
        ret: 126,
        sb: 1,
        sll: 1,
        slli: 1,
        srl: 1,
        srli: 1,
        srw: 223,
        sub: 1,
        subi: 1,
        sw: 1,
        sww: 26246,
        time: 75,
        tr: 38924,
        tro: 26755,
        wdcm: 1,
        wqcm: 2,
        wdop: 2,
        wqop: 2,
        wdml: 2,
        wqml: 3,
        wddv: 4,
        wqdv: 5,
        wdmd: 9,
        wqmd: 16,
        wdam: 8,
        wqam: 10,
        wdmm: 9,
        wqmm: 9,
        xor: 1,
        xori: 1,
        call: DependentCost::LightOperation {
            base: 16160,
            units_per_gas: 60,
        },
        ccp: DependentCost::LightOperation {
            base: 20,
            units_per_gas: 23,
        },
        csiz: DependentCost::LightOperation {
            base: 28,
            units_per_gas: 300,
        },
        k256: DependentCost::LightOperation {
            base: 27,
            units_per_gas: 4,
        },
        ldc: DependentCost::LightOperation {
            base: 18,
            units_per_gas: 73,
        },
        logd: DependentCost::LightOperation {
            base: 124,
            units_per_gas: 3,
        },
        mcl: DependentCost::LightOperation {
            base: 0,
            units_per_gas: 639,
        },
        mcli: DependentCost::LightOperation {
            base: 0,
            units_per_gas: 639,
        },
        mcp: DependentCost::LightOperation {
            base: 1,
            units_per_gas: 523,
        },
        mcpi: DependentCost::HeavyOperation {
            base: 2,
            gas_per_unit: 0,
        },
        meq: DependentCost::LightOperation {
            base: 1,
            units_per_gas: 1349,
        },
        rvrt: 126,
        s256: DependentCost::LightOperation {
            base: 20,
            units_per_gas: 3,
        },
        scwq: DependentCost::HeavyOperation {
            base: 2093854,
            gas_per_unit: 21099,
        },
        smo: DependentCost::LightOperation {
            base: 26672,
            units_per_gas: 3,
        },
        srwq: DependentCost::HeavyOperation {
            base: 410,
            gas_per_unit: 19,
        },
        swwq: DependentCost::HeavyOperation {
            base: 1503569,
            gas_per_unit: 20088,
        },
        contract_root: DependentCost::LightOperation {
            base: 0,
            units_per_gas: 3,
        },
        retd: DependentCost::LightOperation {
            base: 145,
            units_per_gas: 3,
        },
    }
}

bvrooman added a commit that referenced this pull request Nov 24, 2023
## Version 0.21.0

This release focuses on preparing `fuel-core` for the mainnet
environment.
- Most of the changes improved the security and stability of the node.
- The gas model was reworked to cover all aspects of execution.
- The benchmarking system was significantly enhanced, covering worst
scenarios.
- A new set of benchmarks was added to track the accuracy of gas prices.
- Optimized heavy operations and removed/replaced exploitable
functionality.

Besides that, there are more concrete changes:
- Unified naming conventions for all CLI arguments. Added dependencies
between related fields to avoid misconfiguration in case of missing
arguments. Added `--debug` flag that enables additional functionality
like a debugger.
- Improved telemetry to cover the internal work of services and added
support for the Pyroscope, allowing it to generate real-time flamegraphs
to track performance.
- Improved stability of the P2P layer and adjusted the updating of
reputation. The speed of block synchronization was significantly
increased.
- The node is more stable and resilient. Improved DoS resistance and
resource management. Fixed critical bugs during state transition.
- Reworked the `Mint` transaction to accumulate the fee from block
production inside the contract defined by the block producer.

FuelVM received a lot of safety and stability improvements:
- The audit helped identify some bugs and errors that have been
successfully fixed.
- Updated the gas price model to charge for resources used during the
transaction lifecycle.
- Added `no_std` and 32 bit system support. This opens doors for fraud
proving in the future.
- Removed the `ChainId` from the `PredicateId` calculation, allowing the
use of predicates cross-chain.
- Improvements in the performance of some storage-related opcodes.
- Support the `ECAL` instruction that allows adding custom functionality
to the VM. It can be used to create unique rollups or advanced indexers
in the future.
- Support of [transaction
policies](https://github.com/FuelLabs/fuel-vm/blob/master/CHANGELOG.md#version-0420)
provides additional safety for the user.
It also allows the implementation of a multi-dimensional price model in
the future, making the transaction execution cheaper and allowing more
transactions that don't affect storage.
- Refactored errors, returning more detailed errors to the user,
simplifying debugging.

### Added

- [#1503](#1503): Add `gtf`
opcode sanity check.
- [#1502](#1502): Added price
benchmark for `vm_initialization`.
- [#1501](#1501): Add a CLI
command for generating a fee collection contract.
- [#1492](#1492): Support
backward iteration in the RocksDB. It allows backward queries that were
not allowed before.
- [#1490](#1490): Add push and
pop benchmarks.
- [#1485](#1485): Prepare rc
release of fuel core v0.21
- [#1476](#1453): Add the
majority of the "other" benchmarks for contract opcodes.
- [#1473](#1473): Expose
fuel-core version as a constant
- [#1469](#1469): Added
support of bloom filter for RocksDB tables and increased the block
cache.
- [#1465](#1465): Improvements
for keygen cli and crates
- [#1642](#1462): Added
benchmark to measure the performance of contract state and contract ID
calculation; use for gas costing.
- [#1457](#1457): Fixing
incorrect measurement for fast(µs) opcodes.
- [#1456](#1456): Added
flushing of the RocksDB during a graceful shutdown.
- [#1456](#1456): Added more
logs to track the service lifecycle.
- [#1453](#1453): Add the
majority of the "sanity" benchmarks for contract opcodes.
- [#1452](#1452): Added
benchmark to measure the performance of contract root calculation when
utilizing the maximum contract size; used for gas costing of contract
root during predicate owner validation.
- [#1449](#1449): Fix coin
pagination in e2e test client.
- [#1447](#1447): Add timeout
for continuous e2e tests
- [#1444](#1444): Add "sanity"
benchmarks for memory opcodes.
- [#1437](#1437): Add some
transaction throughput tests for basic transfers.
- [#1436](#1436): Add a github
action to continuously test beta-4.
- [#1433](#1433): Add "sanity"
benchmarks for flow opcodes.
- [#1432](#1432): Add a new
`--api-request-timeout` argument to control TTL for GraphQL requests.
- [#1430](#1430): Add "sanity"
benchmarks for crypto opcodes.
- [#1426](#1426) Split keygen
into a create and a binary.
- [#1419](#1419): Add
additional "sanity" benchmarks for arithmetic op code instructions.
- [#1411](#1411): Added WASM
and `no_std` compatibility.
- [#1405](#1405): Use correct
names for service metrics.
- [#1400](#1400): Add releasy
beta to fuel-core so that new commits to fuel-core master triggers
fuels-rs.
- [#1371](#1371): Add new
client function for querying the `MessageStatus` for a specific message
(by `Nonce`).
- [#1356](#1356): Add peer
reputation reporting to heartbeat code.
- [#1355](#1355): Added new
metrics related to block importing, such as tps, sync delays etc.
- [#1339](#1339): Adds
`baseAssetId` to `FeeParameters` in the GraphQL API.
- [#1331](#1331): Add peer
reputation reporting to block import code.
- [#1324](#1324): Added
pyroscope profiling to fuel-core, intended to be used by a secondary
docker image that has debug symbols enabled.
- [#1309](#1309): Add
documentation for running debug builds with CLion and Visual Studio
Code.
- [#1308](#1308): Add support
for loading .env files when compiling with the `env` feature. This
allows users to conveniently supply CLI arguments in a secure and
IDE-agnostic way.
- [#1304](#1304): Implemented
`submit_and_await_commit_with_receipts` method for `FuelClient`.
- [#1286](#1286): Include
readable names for test cases where missing.
- [#1274](#1274): Added tests
to benchmark block synchronization.
- [#1263](#1263): Add gas
benchmarks for `ED19` and `ECR1` instructions.

### Changed

- [#1512](#1512): Internally
simplify merkle_contract_state_range.
- [#1507](#1507): Updated
chain configuration to be ready for beta 5 network. It includes opcode
prices from the latest benchmark and contract for the block producer.
- [#1477](#1477): Upgraded the
Rust version used in CI and containers to 1.73.0. Also includes
associated Clippy changes.
- [#1469](#1469): Replaced
usage of `MemoryTransactionView` by `Checkpoint` database in the
benchmarks.
- [#1468](#1468): Bumped
version of the `fuel-vm` to `v0.40.0`. It brings some breaking changes
into consensus parameters API because of changes in the underlying
types.
- [#1466](#1466): Handling
overflows during arithmetic operations.
- [#1460](#1460): Change
tracking branch from main to master for releasy tests.
- [#1454](#1454): Update gas
benchmarks for opcodes that append receipts.
- [#1440](#1440): Don't report
reserved nodes that send invalid transactions.
- [#1439](#1439): Reduced
memory BMT consumption during creation of the header.
- [#1434](#1434): Continue
gossiping transactions to reserved peers regardless of gossiping
reputation score.
- [#1408](#1408): Update gas
benchmarks for storage opcodes to use a pre-populated database to get
more accurate worst-case costs.
- [#1399](#1399): The Relayer
now queries Ethereum for its latest finalized block instead of using a
configurable "finalization period" to presume finality.
- [#1397](#1397): Improved
keygen. Created a crate to be included from forc plugins and upgraded
internal library to drop requirement of protoc to build
- [#1395](#1395): Add
DependentCost benchmarks for `k256`, `s256` and `mcpi` instructions.
- [#1393](#1393): Increase
heartbeat timeout from `2` to `60` seconds, as suggested in [this
issue](#1330).
- [#1392](#1392): Fixed an
overflow in `message_proof`.
- [#1390](#1390): Up the
`ethers` version to `2` to fix an issue with `tungstenite`.
- [#1383](#1383): Disallow
usage of `log` crate internally in favor of `tracing` crate.
- [#1380](#1380): Add
preliminary, hard-coded config values for heartbeat peer reputation,
removing `todo`.
- [#1377](#1377): Remove
`DiscoveryEvent` and use `KademliaEvent` directly in
`DiscoveryBehavior`.
- [#1366](#1366): Improve
caching during docker builds in CI by replacing gha
- [#1358](#1358): Upgraded the
Rust version used in CI to 1.72.0. Also includes associated Clippy
changes.
- [#1349](#1349): Updated
peer-to-peer transactions API to support multiple blocks in a single
request, and updated block synchronization to request multiple blocks
based on the configured range of headers.
- [#1342](#1342): Add error
handling for P2P requests to return `None` to requester and log error.
- [#1318](#1318): Modified
block synchronization to use asynchronous task execution when retrieving
block headers.
- [#1314](#1314): Removed
`types::ConsensusParameters` in favour of `fuel_tx:ConsensusParameters`.
- [#1302](#1302): Removed the
usage of flake and building of the bridge contract ABI.
It simplifies the maintenance and updating of the events, requiring only
putting the event definition into the codebase of the relayer.
- [#1293](#1293):
Parallelized the `estimate_predicates` endpoint to utilize all available
threads.
- [#1270](#1270): Modify the
way block headers are retrieved from peers to be done in batches.

#### Breaking
- [#1506](#1506): Added
validation of the coin's fields during block production and validation.
Before, it was possible to submit a transaction that didn't match the
coin's values in the database, allowing printing/using unavailable
assets.
- [#1491](#1491): Removed
unused request and response variants from the Gossipsub implementation,
as well as related definitions and tests. Specifically, this removes
gossiping of `ConsensusVote` and `NewBlock` events.
- [#1472](#1472): Upgraded
`fuel-vm` to `v0.42.0`. It introduces transaction policies that changes
layout of the transaction. FOr more information check the
[v0.42.0](FuelLabs/fuel-vm#635) release.
- [#1470](#1470): Divide
`DependentCost` into "light" and "heavy" operations.
- [#1464](#1464): Avoid
possible truncation of higher bits. It may invalidate the code that
truncated higher bits causing different behavior on 32-bit vs. 64-bit
systems. The change affects some endpoints that now require lesser
integers.
- [#1432](#1432): All
subscriptions and requests have a TTL now. So each subscription
lifecycle is limited in time. If the subscription is closed because of
TTL, it means that you subscribed after your transaction had been
dropped by the network.
- [#1407](#1407): The
recipient is a `ContractId` instead of `Address`. The block producer
should deploy its contract to receive the transaction fee. The collected
fee is zero until the recipient contract is set.
- [#1407](#1407): The `Mint`
transaction is reworked with new fields to support the account-base
model. It affects serialization and deserialization of the transaction
and also affects GraphQL schema.
- [#1407](#1407): The `Mint`
transaction is the last transaction in the block instead of the first.
- [#1374](#1374): Renamed
`base_chain_height` to `da_height` and return current relayer height
instead of latest Fuel block height.
- [#1367](#1367): Update to
the latest version of fuel-vm.
- [#1363](#1363): Change
message_proof api to take `nonce` instead of `message_id`
- [#1355](#1355): Removed the
`metrics` feature flag from the fuel-core crate, and metrics are now
included by default.
- [#1339](#1339): Added a new
required field called `base_asset_id` to the `FeeParameters` definition
in `ConsensusParameters`, as well as default values for `base_asset_id`
in the `beta` and `dev` chain specifications.
- [#1322](#1322):
The `debug` flag is added to the CLI. The flag should be used for local
development only. Enabling debug mode:
      - Allows GraphQL Endpoints to arbitrarily advance blocks.
      - Enables debugger GraphQL Endpoints.
      - Allows setting `utxo_validation` to `false`.
- [#1318](#1318): Removed the
`--sync-max-header-batch-requests` CLI argument, and renamed
`--sync-max-get-txns` to `--sync-block-stream-buffer-size` to better
represent the current behavior in the import.
- [#1290](#1290): Standardize
CLI args to use `-` instead of `_`.
- [#1279](#1279): Added a new
CLI flag to enable the Relayer service `--enable-relayer`, and disabled
the Relayer service by default. When supplying the `--enable-relayer`
flag, the `--relayer` argument becomes mandatory, and omitting it is an
error. Similarly, providing a `--relayer` argument without the
`--enable-relayer` flag is an error. Lastly, providing the `--keypair`
or `--network` arguments will also produce an error if the
`--enable-p2p` flag is not set.
- [#1262](#1262): The
`ConsensusParameters` aggregates all configuration data related to the
consensus. It contains many fields that are segregated by the usage. The
API of some functions was affected to use lesser types instead the whole
`ConsensusParameters`. It is a huge breaking change requiring
repetitively monotonically updating all places that use the
`ConsensusParameters`. But during updating, consider that maybe you can
use lesser types. Usage of them may simplify signatures of methods and
make them more user-friendly and transparent.

### Removed

#### Breaking
- [#1484](#1484): Removed
`--network` CLI argument. Now the name of the network is fetched form
chain configuration.
- [#1399](#1399): Removed
`relayer-da-finalization` parameter from the relayer CLI.
- [#1338](#1338): Updated
GraphQL client to use `DependentCost` for `k256`, `mcpi`, `s256`,
`scwq`, `swwq` opcodes.
- [#1322](#1322): The
`manual_blocks_enabled` flag is removed from the CLI. The analog is a
`debug` flag.

## What's Changed
* Added changelog in the same way as we did for `fuel-vm` by @xgreenx in
#1287
* Decompose consensus params struct by @MitchTurner in
#1262
* Replace all instances of `_` in CLI `long` arguments with `-` by
@MitchTurner in #1290
* [rpc] Parallelise estimate_predicates endpoint by @YusongWang in
#1293
* Add readable test names to test cases by @MitchTurner in
#1286
* ED19 and ECR1 benchmarks by @Dentosal in
#1263
* feat: Add `enable-relayer` flag to `fuel-core` CLI by @bvrooman in
#1279
* Small nits found during deploying and benchmarking by @xgreenx in
#1303
* Implemented `submit_and_await_commit_with_receipts` method by @xgreenx
in #1304
* Removed the usage of flake and building of the bridge contract ABI by
@xgreenx in #1302
* Download range of headers during syncing by @MitchTurner in
#1270
* feat: Enable .env file loading using `env` feature by @bvrooman in
#1308
* chore: Remove types::ConsensusParameters by @bvrooman in
#1314
* docs: Debugging instructions using IDEs by @bvrooman in
#1309
* test: Block Import benchmarks and test helpers by @bvrooman in
#1274
* Fix audit CI for `webpki` by @xgreenx in
#1319
* chore: Single buffer block sync by @bvrooman in
#1318
* Run unit tests without default features only for specific crates by
@xgreenx in #1321
* Added support for `debug` CLI flag. by @xgreenx in
#1322
* Report Peers that give bad Block Info by @MitchTurner in
#1331
* Pyroscope profiling by @Voxelot in
#1324
* Add error handling for P2P requests to return `None` to requester and
log error by @MitchTurner in
#1342
* Importer Metrics by @Voxelot in
#1355
* chore: Upgrade to Rust 1.72.0 in CI by @bvrooman in
#1358
* chore: Upgrade `fuel-vm` to 0.37.0 by @bvrooman in
#1338
* docs: remove stale schema by @calldelegation in
#1362
* Replace message_id with nonce in `MessageProof` query by @MitchTurner
in #1363
* feat: Configurable base asset by @bvrooman in
#1339
* avoid gha caching for docker builds by @Voxelot in
#1366
* Add tracking for peer heartbeats by @MitchTurner in
#1356
* docs: fix broken link in README by @PaulRBerg in
#1357
* Use right level of error for `.env` file and duplicated service by
@xgreenx in #1372
* Add query and handling for `MessageStatus` by @MitchTurner in
#1371
* Renamed `base_chain_height` to `da_height` and return current relayer
height instead of latest Fuel block height by @xgreenx in
#1374
* Remove `DiscoveryEvent` and use `KademliaEvent` instead by
@MitchTurner in #1377
* Remove todo from code and provide some preliminary peer review config
values by @MitchTurner in
#1380
* Clippy lint to disallow logging crate macros in favor of tracing by
@Dentosal in #1383
* fuel-vm nostd update by @Dentosal in
#1367
* Up the `ethers` version to `2` to fix an issue with `tungstenite` by
@xgreenx in #1390
* Increase heartbeat timeout to one minute by @Dentosal in
#1393
* feat: batch transactions import by @bvrooman in
#1349
* Fix an interger overflow in message_proof when looking beyond genesis
by @Dentosal in #1392
* Improve keygen by @cr-fuel in
#1397
* Benchmark {k256, s256, mcpi} opcodes using DependentCost by @Dentosal
in #1395
* Use correct names for service metrics by @xgreenx in
#1405
* feat: Retrieve finalized blocks from Ethereum by @bvrooman in
#1399
* Updated CI to run `cargo update` weekly by @xgreenx in
#1415
* CI `cargo update` weekly by @xgreenx in
#1416
* Weekly `cargo update` by @github-actions in
#1417
* Fix typos by @GoodDaisy in
#1424
* feat: Support no_std and WASM compilation for `fuel-core` crates by
@bvrooman in #1411
* Create sanity benchmark checks for all the arithmetic op codes by
@MitchTurner in #1419
* Update benchmarking and collecting for `scwq`, `swwq` and `srwq`
opcodes by @xgreenx in #1427
* Account-base fee collection by @xgreenx in
#1407
* Rollback modification of the chain specification by @xgreenx in
#1429
* Tx subscription cleanup (#1422) by @xgreenx in
#1432
* Mark reserved peers as explicit for gossipsub to avoid reputation
decreasing (#1423) by @xgreenx in
#1434
* Weekly `cargo update` by @github-actions in
#1438
* ci: add beta releasy to fuel-core by @kayagokalp in
#1400
* setup a cron job to test beta-4 continuously by @Voxelot in
#1436
* chore: Use MerkleRootCalculator when only BMT root is needed by
@bvrooman in #1439
* Crypto op code sanity checks by @MitchTurner in
#1430
* Update gas benchmarks for some storage opcodes by @Dentosal in
#1408
* Split keygen into a create and a binary by @cr-fuel in
#1426
* Basic Transfer TPS Benchmarking by @Voxelot in
#1437
* "flow" op code sanity benchmarks by @MitchTurner in
#1433
* Applying `#1435` to `master` by @xgreenx in
#1440
* "memory" opcode sanity checks by @MitchTurner in
#1444
* Add timeout to E2E test by @Voxelot in
#1447
* fix owns_coins to properly paginate by @Voxelot in
#1449
* Fixing incorrect measurement for fast(µs) opcodes by @xgreenx in
#1457
* Call `flush` during end of the `FuelService` by @xgreenx in
#1456
* chore: fix releasy test tracking branch from `main` to `master` by
@kayagokalp in #1460
* Weekly `cargo update` by @github-actions in
#1461
* `DB::repair` breaks the table for checkpoints by @xgreenx in
#1463
* Avoid possible truncation of higher bits by @xgreenx in
#1464
* Bumping `fuel-vm` to `v0.40.0` by @xgreenx in
#1468
* Improvements for keygen cli and crates by @cr-fuel in
#1465
* Handling overflows during arithmetic operations by @xgreenx in
#1466
* test: Add contract code root benchmark by @bvrooman in
#1452
* test: Add state root and contract id benchmarks by @bvrooman in
#1462
* Avoid storage caching in benchmarks by @xgreenx in
#1469
* Weekly `cargo update` by @github-actions in
#1471
* Expose fuel-core version as a constant by @Br1ght0ne in
#1473
* Upgrade ed25519_dalek 1.0.1 -> 2.0.0 by @Dentosal in
#1475
* chore: Upgrade Rust 1.73 by @bvrooman in
#1477
* Decrease number of iterations for sequential benchmarks by @xgreenx in
#1480
* Add mldv bench by @Dentosal in
#1481
* feat: Separate light and heavy gas costs (core) by @bvrooman in
#1483
* chore: Remove `network` parameter from CLI by @bvrooman in
#1484
* Transaction policies support by @xgreenx in
#1472
* stage release candidate for beta-5 by @Voxelot in
#1485
* setup docker auth for binary publishing by @Voxelot in
#1488
* Fix macos binary publishing by @xgreenx in
#1489
* Add documentation for our calculation of a _reasonable_ gas fee for
storage by @MitchTurner in
#1478
* "contract" op code sanity checks by @MitchTurner in
#1453
* "other" op code sanity check by @MitchTurner in
#1476
* Add push and pop benches by @MitchTurner in
#1490
* chore: Remove unused gossipsub items by @bvrooman in
#1491
* Adjusting of the prices benchmarks after sanity check benchmarks by
@xgreenx in #1494
* Weekly `cargo update` by @github-actions in
#1498
* Update benches that are affected by receipts by @Dentosal in
#1454
* Support backward iteration in the RocksDB by @xgreenx in
#1492
* Added validation of the coin's fields during block production and
validation by @xgreenx in
#1506
* Added price benchmark for `vm_initialization` by @xgreenx in
#1502
* Sanity-check `gtf` opcode by @MitchTurner in
#1503
* Tool for generating fee collection contract by @Voxelot in
#1501
* Chain config for beta 5 network by @xgreenx in
#1507
* Remove usage of iter_all_filtered from merkle_contract_state_range by
@Dentosal in #1512

## New Contributors
* @YusongWang made their first contribution in
#1293
* @calldelegation made their first contribution in
#1362
* @PaulRBerg made their first contribution in
#1357
* @cr-fuel made their first contribution in
#1397
* @github-actions made their first contribution in
#1417
* @GoodDaisy made their first contribution in
#1424

**Full Changelog**:
v0.20.8...v0.21.0

---------

Co-authored-by: Brandon Vrooman <brandon.vrooman@fuel.sh>
@xgreenx xgreenx marked this pull request as draft November 27, 2023 17:51
@bvrooman bvrooman changed the title feat: Separate light and heavy gas costs feat: Regression based modelling of gas prices Nov 27, 2023
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.

None yet

4 participants