Skip to content

Merge 1.4.8 to dev#3302

Merged
casperlabs-bors-ng[bot] merged 27 commits intocasper-network:devfrom
mpapierski:merge-1.4.8-to-dev
Sep 6, 2022
Merged

Merge 1.4.8 to dev#3302
casperlabs-bors-ng[bot] merged 27 commits intocasper-network:devfrom
mpapierski:merge-1.4.8-to-dev

Conversation

@mpapierski
Copy link
Collaborator

This PR merges the 1.4.8 bugfix release into dev by cherry-picking relevant fixes from the history of the v1.4.8 release.

A complete history of v1.4.8 release as compared to dev: dev...v1.4.8

Commits cherry-picked in order starting from Clippy fixes with recent stable (a369e37).

Message Git SHA on v1.4.8 Cherry-picked
(Merge #115, 2022-08-14) b94c4f7 merge commit
(version bump casper-node and assembly script, 2022-08-12) 389dddc 696206e
(Merge pull request #114 from casper-network/regression-20220727-part2, 2022-08-12) 281061f merge commit
(Add changelog and docs., 2022-08-12) 01999db a301241
(Shuffle ensure_* functions in order, 2022-08-12) 3677f9d 99bfdd9
(Simplify checking algorithm, 2022-08-12) 6658738 5a7d1bd
(Fix clippy issues., 2022-08-12) 0ee97fc empty commit
(Add checks to avoid panics in the gas accounting, 2022-08-11) 4340204 3881820
(Add regression tests for gas counter injector., 2022-08-11) e710b8e 09f023a
(Restrict access to non-declared globals., 2022-08-10) 7944881 a2ca3dc
(Regression tests for global set/get access., 2022-08-10) 843cf53 5432145
(Merge #113, 2022-08-03) 298dfaa merge commit
(further updates required for version bumps, 2022-08-03) 9129165 5c07b4e
(Bumping EE, casper-node and assembly script (to keep from erroring on publish)., 2022-08-02) 55a413d 6823aa6
(Merge pull request #110 from casper-network/regression-20220727, 2022-08-02) 17a39d8
(Fix backwards compatibility, 2022-08-02) 476a236 1ac4e8c
(Apply suggestions from code review, 2022-08-02) 7ae3f1d 11c0f95
(Rewrite for clarity as @goral09 suggested, 2022-08-01) 7b84dfa 1de2f62
(Ensure internal gas function cannot be imported., 2022-07-29) 31fe6b3 822bea0
(Ensure functions max param size., 2022-07-29) ea0f05c 8f2dff4
(Ensure module doesnt declare more than 256 globals, 2022-07-29) 20a667a 496f5a8
(Limit the size of a br_table to 256 elements., 2022-07-29) 3d51997 83023e1
(Apply review comments, 2022-07-29) e562a5c 5ec9af7
(Apply review comments, 2022-07-28) 223d861 f064a36
(Lower the table size to 4k, 2022-07-28) 438f56e 66b3e9c
(Fix the issue by imposing a limit for table size., 2022-07-27) 7dc6dcb bec2292
(Add regression test to trigger the issue., 2022-07-27) 1eafe74 c31d448
(Clippy fixes with recent stable, 2022-07-27) a369e37 effectively empty commit

Michał Papierski and others added 24 commits September 2, 2022 10:22
Arbitrary length br_tables are limited only by the maximum stack depth
of a wasmi executor.

The largest possible br_table doing nothing could execute for about
120ms on my machine and only consumed 7210890 in gas which poses a
risk of potential abuse.
Co-authored-by: Fraser Hutchison <190532+Fraser999@users.noreply.github.com>
Co-authored-by: George Pisaltu <georgep@casperlabs.io>
Co-authored-by: George Pisaltu <georgep@casperlabs.io>
Each of the tests triggers a panic with an arithmetic overflow in 4
different places.

Co-authored-by: George Pisaltu <georgep@casperlabs.io>
Co-authored-by: George Pisaltu <georgep@casperlabs.io>
Co-authored-by: Fraser Hutchison <fraser@casperlabs.io>

### Security
* Implement checks before preprocessing Wasm to avoid potential OOM when initializing table section.
* Implement checks before preprocessing Wasm to avoid references to undeclared functions or globals.
Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't we have something with gas counter as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Forgot about adding this one entry in 1.4.8. Addressed in 77b5503

"subcall expected to cost more gas due to storing contract"
);
assert!(add_some_gas_from_session_cost.value() > expected_gas);
assert!(add_some_gas_via_subcall_cost.value() > expected_gas);
Copy link
Contributor

Choose a reason for hiding this comment

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

These changes look like the cost of execution changed - does it mean that some contracts' execution will change now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The intention here was to make a wasm cost "at least the expected_gas amount" as this PR disables import of internal 'gas' function. With expected_gas large enough, it should be a precise measurement. Previously, you could precisely add the amount of gas to the counter with the imported gas function.

const ARG_GAS_AMOUNT: &str = "gas_amount";
const ARG_METHOD_NAME: &str = "method_name";

fn consume_gas(amount: i32) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to have a comment on this method. Are you sure it will consume exactly amount of gas?

Also, why is amount a signed integer, can't it be unsinged?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated in 6169414 to better reflect what it does

@mpapierski
Copy link
Collaborator Author

bors r+

@casperlabs-bors-ng
Copy link
Contributor

Build succeeded:

@casperlabs-bors-ng casperlabs-bors-ng bot merged commit f34e582 into casper-network:dev Sep 6, 2022
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.

4 participants