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

Restrict ClearPrefix by key size #265

Merged
merged 1 commit into from
Jun 20, 2023
Merged

Restrict ClearPrefix by key size #265

merged 1 commit into from
Jun 20, 2023

Conversation

darioush
Copy link
Collaborator

@darioush darioush commented Jun 15, 2023

Why this should be merged

Since trie nodes are not stored with a prefix, it is dangerous to call ClearPrefix without restricting the length.
As the only code path that calls this without a long enough prefix is clearIfRootDoesNotMatch this does not
represent a serious problem.
It is possible this may have corrupted trie nodes if:

  • the user state sync'ed and interrupted that sync
  • waited >= 300,000 blocks
  • tried to state sync again
  • and they had a previously populated DB,
  • and trie nodes were prefixed with sync_storage or sync_segments.

How this works

Adds the expected key length as a parameter to the ClearPrefix function so the caller does not accidentally
erase trie nodes.

How this was tested

UTs

@darioush darioush marked this pull request as ready for review June 15, 2023 23:23
@darioush darioush merged commit c08a7c1 into master Jun 20, 2023
@darioush darioush deleted the fix-clearprefix branch June 20, 2023 22:05
joshua-kim added a commit that referenced this pull request Jul 18, 2023
commit c6c0b1d
Author: Dan Laine <daniel.laine@avalabs.org>
Date:   Tue Jul 18 10:02:30 2023 -0400

    Rename sorting method imported from avalanchego (#272)

    * update avalanchego version

    * rename sorting method import

    * update avalanchego dep

    * fix sorting method name

    * fix sorting method name for real

commit 734c238
Author: aaronbuchwald <aaron.buchwald56@gmail.com>
Date:   Mon Jul 17 21:13:39 2023 -0400

    Add release notes and bump AvalancheGo dep (#289)

commit e024457
Author: aaronbuchwald <aaron.buchwald56@gmail.com>
Date:   Mon Jul 17 14:39:58 2023 -0400

    Prevent panic for LOG edge cases in callTracer (#285)

    * cherry-pick tracer log edge case handling

    * Update goja

    ---------

    Co-authored-by: jwasinger <j-wasinger@hotmail.com>

commit 1855d7e
Author: Darioush Jalali <darioush.jalali@avalabs.org>
Date:   Mon Jul 17 11:39:11 2023 -0700

    Whitespace and nits (#287)

    * Whitespace and nits

    * add cpfg fix

commit 72df753
Author: aaronbuchwald <aaron.buchwald56@gmail.com>
Date:   Mon Jul 17 14:37:11 2023 -0400

    Prestate lookup account storage (#286)

    * Add lookupAccount in lookupStorage

    * fix tracer regression

    * Move tracer test to new directory

    ---------

    Co-authored-by: morrisettjohn <morrisettjohn@gmail.com>

commit 261d2ad
Author: aaronbuchwald <aaron.buchwald56@gmail.com>
Date:   Fri Jul 14 11:17:33 2023 -0400

    Cleanup accepted logs subscription test (#283)

commit a025ecc
Author: Darioush Jalali <darioush.jalali@avalabs.org>
Date:   Mon Jul 10 11:50:09 2023 -0700

    Use go1.19 in CI for consistency with avalanchego (#278)

commit 419b262
Author: Darioush Jalali <darioush.jalali@avalabs.org>
Date:   Fri Jul 7 13:07:54 2023 -0700

    Fix goroutine leaks in core/ tests (#273)

commit fbd9dad
Author: Dan Laine <daniel.laine@avalabs.org>
Date:   Wed Jun 28 14:22:38 2023 -0400

    Use avalanchego's sorting methods (#260)

    * use avalanchgo sorting functions

    * add tests for Less

    * import ordering

    * import ordering

    * Use `slices` methods instead of `sort` methods (#261)

    * use slices.Sort instead of sort.Slice

    * import ordering

    * add test case

commit 3f0df72
Author: aaronbuchwald <aaron.buchwald56@gmail.com>
Date:   Mon Jun 26 23:10:03 2023 -0400

    Bump to v0.12.4 (#271)

commit 6c9d2c3
Author: aaronbuchwald <aaron.buchwald56@gmail.com>
Date:   Thu Jun 22 00:42:44 2023 -0400

    Fix collect unflattened logs (#270)

    * Handle empty logs edge case in collectUnflattenedLogs

    * Add unit test to check log handling for block with atomic tx and no eth transactions

    * Fix race and add nil check

commit c08a7c1
Author: Darioush Jalali <darioush.jalali@avalabs.org>
Date:   Tue Jun 20 15:05:03 2023 -0700

    Restrict ClearPrefix by key size (#265)

commit 0d02ea7
Author: Dan Laine <daniel.laine@avalabs.org>
Date:   Thu Jun 15 11:07:31 2023 -0400

    export CalculateDynamicFee (#259)

commit 0eb8685
Author: Dan Laine <daniel.laine@avalabs.org>
Date:   Thu Jun 15 10:48:26 2023 -0400

    update golangci-lint-action (#263)
joshua-kim added a commit to joshua-kim/coreth that referenced this pull request Jul 27, 2023
commit 8ef933f
Author: Darioush Jalali <darioush.jalali@avalabs.org>
Date:   Tue Jul 25 07:12:10 2023 -0700

    Takes geth changes v1.11.14 -> v1.12.0 (ava-labs#277)

    * trie/

    * remove rej file

    * metrics/

    * accounts/

    * internal

    * rpc/

    * core/rawdb

    * go.mod

    * core/state

    * eth/...

    * core/vm core/types/ ethdb

    * core/txpool

    * left out

    * additional core/

    * should pass tests

    * nits

    * remove .rej file

    * newTestBlockChain TODO

    * Pr comments

    * remove ExcessDataGas

    * Add ExcessDataGas with verification

    * Add verification in plugin/evm

commit 8a8a220
Author: aaronbuchwald <aaron.buchwald56@gmail.com>
Date:   Fri Jul 21 11:36:26 2023 -0400

    Bump coreth to v0.12.5 and bump avalanchego dep to v1.10.5 (ava-labs#291)

commit 1da5b37
Author: Anusha <63559942+anusha-ctrl@users.noreply.github.com>
Date:   Thu Jul 20 12:32:22 2023 -0700

    remove (ava-labs#290)

commit c6c0b1d
Author: Dan Laine <daniel.laine@avalabs.org>
Date:   Tue Jul 18 10:02:30 2023 -0400

    Rename sorting method imported from avalanchego (ava-labs#272)

    * update avalanchego version

    * rename sorting method import

    * update avalanchego dep

    * fix sorting method name

    * fix sorting method name for real

commit 734c238
Author: aaronbuchwald <aaron.buchwald56@gmail.com>
Date:   Mon Jul 17 21:13:39 2023 -0400

    Add release notes and bump AvalancheGo dep (ava-labs#289)

commit e024457
Author: aaronbuchwald <aaron.buchwald56@gmail.com>
Date:   Mon Jul 17 14:39:58 2023 -0400

    Prevent panic for LOG edge cases in callTracer (ava-labs#285)

    * cherry-pick tracer log edge case handling

    * Update goja

    ---------

    Co-authored-by: jwasinger <j-wasinger@hotmail.com>

commit 1855d7e
Author: Darioush Jalali <darioush.jalali@avalabs.org>
Date:   Mon Jul 17 11:39:11 2023 -0700

    Whitespace and nits (ava-labs#287)

    * Whitespace and nits

    * add cpfg fix

commit 72df753
Author: aaronbuchwald <aaron.buchwald56@gmail.com>
Date:   Mon Jul 17 14:37:11 2023 -0400

    Prestate lookup account storage (ava-labs#286)

    * Add lookupAccount in lookupStorage

    * fix tracer regression

    * Move tracer test to new directory

    ---------

    Co-authored-by: morrisettjohn <morrisettjohn@gmail.com>

commit 261d2ad
Author: aaronbuchwald <aaron.buchwald56@gmail.com>
Date:   Fri Jul 14 11:17:33 2023 -0400

    Cleanup accepted logs subscription test (ava-labs#283)

commit a025ecc
Author: Darioush Jalali <darioush.jalali@avalabs.org>
Date:   Mon Jul 10 11:50:09 2023 -0700

    Use go1.19 in CI for consistency with avalanchego (ava-labs#278)

commit 419b262
Author: Darioush Jalali <darioush.jalali@avalabs.org>
Date:   Fri Jul 7 13:07:54 2023 -0700

    Fix goroutine leaks in core/ tests (ava-labs#273)

commit fbd9dad
Author: Dan Laine <daniel.laine@avalabs.org>
Date:   Wed Jun 28 14:22:38 2023 -0400

    Use avalanchego's sorting methods (ava-labs#260)

    * use avalanchgo sorting functions

    * add tests for Less

    * import ordering

    * import ordering

    * Use `slices` methods instead of `sort` methods (ava-labs#261)

    * use slices.Sort instead of sort.Slice

    * import ordering

    * add test case

commit 3f0df72
Author: aaronbuchwald <aaron.buchwald56@gmail.com>
Date:   Mon Jun 26 23:10:03 2023 -0400

    Bump to v0.12.4 (ava-labs#271)

commit 6c9d2c3
Author: aaronbuchwald <aaron.buchwald56@gmail.com>
Date:   Thu Jun 22 00:42:44 2023 -0400

    Fix collect unflattened logs (ava-labs#270)

    * Handle empty logs edge case in collectUnflattenedLogs

    * Add unit test to check log handling for block with atomic tx and no eth transactions

    * Fix race and add nil check

commit c08a7c1
Author: Darioush Jalali <darioush.jalali@avalabs.org>
Date:   Tue Jun 20 15:05:03 2023 -0700

    Restrict ClearPrefix by key size (ava-labs#265)

commit 0d02ea7
Author: Dan Laine <daniel.laine@avalabs.org>
Date:   Thu Jun 15 11:07:31 2023 -0400

    export CalculateDynamicFee (ava-labs#259)

commit 0eb8685
Author: Dan Laine <daniel.laine@avalabs.org>
Date:   Thu Jun 15 10:48:26 2023 -0400

    update golangci-lint-action (ava-labs#263)
darioush pushed a commit that referenced this pull request Apr 25, 2024
* Unwrap ETHChain

* hook in vm.ethConfig

* statesync for subnet-evm

* remove unused configJSON

* add err check

* add synchronization

* add default config values

* delay initialization of gossiper

* Revert "add synchronization"

This reverts commit 6234a1b5a6f944ba5d2e15d3a3ae49a12fca0910.

* fix test

* fix statesync code prefix issue

* fix comment

* wip

* wip2

* add coreth changes

* Merge branch 'master' into coreth-0.8.16-rc2

* updates

* remove coreth from go.mod

* fix linter

* fix

* update gas prices (?)

* fix tracer test

* move dependabot yml to upper file

* more changes ported in from coreth 0.8.16

* Update sync/README.md

Co-authored-by: Ceyhun Onur <ceyhun.onur@avalabs.org>

* Update sync/README.md

Co-authored-by: Ceyhun Onur <ceyhun.onur@avalabs.org>

* Update sync/README.md

Co-authored-by: Ceyhun Onur <ceyhun.onur@avalabs.org>

* Update core/rawdb/accessors_state_sync.go

* port missing file from coreth

* fix-import

* subscribe before goroutine

* Rebase apply coreth diff onto statesync

* fix EOF in tests

* Nits (#265)

* Nits

* Add EIP-1559 link to readme

* Fix linting introduced by merge
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.

3 participants