Skip to content

Improve precompile-utils#1642

Merged
nanocryk merged 5 commits intomasterfrom
jeremy-improve-precompile-utils
Jul 1, 2022
Merged

Improve precompile-utils#1642
nanocryk merged 5 commits intomasterfrom
jeremy-improve-precompile-utils

Conversation

@nanocryk
Copy link
Copy Markdown
Contributor

@nanocryk nanocryk commented Jun 30, 2022

What does it do?

  • More defencive uintX parsing. It will always parse first a 256bit number, then use try_into() to convert it into the wanted size. This will prevent accidental truncation. (replace Improve amount parsing in assets-erc20 #1630)
  • Refactor the crate.
  • Provide a prelude module re-exporting all the important tools.
  • Get rid of LogsBuilder, and instead have plain functions that takes the emitter address directly.
  • Update the rest of the codebase to those changes.

What important points reviewers should know?

Is there something left for follow-up PRs?

  • PR evm repo to make cost computation public, to avoid duplication in utils
  • Potentially PR frontier to move utils in it?

What alternative implementations were considered?

Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?

What value does it bring to the blockchain users?

@nanocryk nanocryk requested a review from girazoki June 30, 2022 09:51
@girazoki
Copy link
Copy Markdown
Collaborator

LGTM. CAn you bring the tests from #1630? That way we ensure that U256 parsing is correctly done

@nanocryk nanocryk added A0-pleasereview Pull request needs code review. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D5-nicetohaveaudit⚠️ PR contains trivial changes to logic that should be properly reviewed. labels Jun 30, 2022
@nanocryk nanocryk merged commit 13c685d into master Jul 1, 2022
@nanocryk nanocryk deleted the jeremy-improve-precompile-utils branch July 1, 2022 12:22
crystalin pushed a commit that referenced this pull request Jul 3, 2022
* Adds rpc types to moonbeam-types-bundle (#1613)

* Adds rpc types to moonbeam-types-bundle

* Fixes rpc types

* Update types version

* Adds moon to rpc api-augment types

* Adds rpc to api-augment

* Removes eth from types now that it is added to polkadotjs

* Better version for 1606

* Adds moon rpc methods to api-augment

* Finally fix rpc non decorated methods

* Adds script to generate local types

* Call Permit Precompile (#1617)

* call permit precompile

* tests

* add CallPermit to moonbase

* fix permit encoding + add test with permit signed with metamask

* fmt + fix test

* improved docs

* PR feedback

* [WIP] Adds fork tests (#1433)

* Adds fork tests

* Format

* Remove useless package

* Adds Governance support for PoV Test

* Fixes missing force-authoring

* Fix wrong nodeKey for 2nd node

* Adds more doc

* Support 1502

* Fixes top for state modifier

* Fixes state modifier for 1500

* Improves log extractor

* Adds support to skip intermediate runtimes

* Adds spawn script for fork test

* Better state modifier for forked states

* Gives more token to Alith for Fork Test

* Better script/docker

* Longer timeout for para fork-test node

* More debug logs

* delay for monitoring logs

* Make para_node support single para node

* Fix state modifier

* Fix state modifier nimbus key

* Support for orbiters

* Fix comment

* Support highestSlotSeen from nimbus

* Fixes PARA_ID

* Adds skip for block concistency in fork tests

* Better Fork test readme

* Support minor/major version for fork tests

* Adds logs to pov script

* Fixes pov skip flag

* hero re-org

* Display variables

* Better context for para tests

* Fix governance in fork test

* Better run fork script

* Adds RELAY_LOG

* Adds run-fork-chain.sh

* Prevent rust code formatting check to fail on spaces after tabs (#1646)

* Improve precompile-utils (#1642)

* don't truncate uintX values / check remaining bits

* refactor utils

* Port tests from #1630

* update revert message in tests

* fix typo

* update call-permit (#1648)

* Upgrade dependencies to polkadot v0.9.23 (#1622)

* upgrade all dependencies to polkadot v0.9.22

* fix runtime compilation

* migrate moonbeam client to jsonrpsee

* remove temporary  chain spec file

* use bip32 fork

* fix rust tests

* ignore export_current_state

* fix ts tests: the logger is not initialized at startup

* update frontier

* upgrade to polkadot-v0.9.23

* fix rust tests

* fix rust tests

* fix ts tests

* fix ts tests

* Update frontier

* Re-pin frontier

* Fix tests, block gas limit within boundaries

* Add mock weight to gas mapping

* update nimbus

* fix tests

* Fixes missing init logs

* More test fixes

* Re-pin frontier

* Add hardware benchmark telemetry

* Add gas estimation on tests

* better comment

* remove log

* Fixes call permit precompile dependencies

* Re-pin Frontier

* More ts tests fixing

* prettier

* Remove `WeightInfo`

* upgrade GH action yogevbd/enforce-label-action

* t

Co-authored-by: tgmichel <telmo@purestake.com>
Co-authored-by: gorka <gorka.irazoki@gmail.com>
Co-authored-by: Crystalin <alan@purestake.com>

* Hack hack hack

* Revert "Hack hack hack"

This reverts commit 19a616a.

* Fix democracy test

* Fixes fee based tests

* Fixes balance test

* Adds missing Call Permit precompile

* format

Co-authored-by: nanocryk <6422796+nanocryk@users.noreply.github.com>
Co-authored-by: Éloïs <c@elo.tf>
Co-authored-by: tgmichel <telmo@purestake.com>
Co-authored-by: gorka <gorka.irazoki@gmail.com>
Co-authored-by: notlesh <steve@brewcraft.org>
notlesh added a commit that referenced this pull request Jul 5, 2022
* Replace (most) reserves with locks

* fmt

* Convert last remaining reserve -> balance

* Adds simple test for locks in staking (WIP)

* Encapsulation of (most) delegator locking logic

* Convert collator reserve -> lock

* Remove SplitCandidateStateToDecreasePoV

* fmt

* editorconfig

* wtf

* 🚧

* Don't use free_balance with locks

* Very basic migration

* Hook up migration

* Fix try-runtime

* Add logging to migration

* Typo

* Update tests to reflect reserve -> lock

* Better parameter name

* fmt

* fmt (not just in parachain-staking)

* Throw error when additional_required_balance > total

* Staking Locks: JIT migration (#1625)

* Begin work on JIT reserve -> lock migration

* Fixes + make it compile

* Start unit test coverage

* Unmigrate (for testing) works

* Organize

* More tests, fixes

* Add test ideas list

* ➕ more tests

* More

* More more more

* fmt

* Oops

* Tests around unmigrated reserves + bonding more

* fmt

* Test cancel bond less

* Revert log -> panic

* fmt

* Fix compile warnings

* Fixes tests

* Adds support for locks in balance consistency

* prettier

* Fixes rust tests

* Format

* Fixes rust tests

* Adds more tests

* Improve staking tests

* Fix para test

* Adds lock tests for multiple stakings

* Better tests

* More tests

* fixes timeout

Co-authored-by: Crystalin <alan@purestake.com>

* Rename staking lock ids

* Remove staking locks on_runtime_upgrade migration

* Restore `reserved_balance()` checks

* fmt

* use wrapper for incrementing balances

* remove comments

* remove comments

* Add hotfix migrations and lots of related tests

* fmt

* Explicitly ignore error

* Fix lock names in ts tests

* Merge original branch and fix tests

* Create regression test for bumping delegator

* Hacky fix for migrating about-to-be-bumped delegator

* fmt

* fmt

* Add some TODO notes

* Implement crude weight fn

* Add ts test for hotfix extrinsic fees

* fmt

* Poke at locks/reserves when revoking last delegation

* Remove TODO, we have test cases for this

* fmt

* Test that bumping because of top delegator insertion leaves no reserve

* Remove duplicate locks modification

* WIP: test that we can both vote while staked in ts test

* Notlesh staking locks debug (#1651)

* Adds rpc types to moonbeam-types-bundle (#1613)

* Adds rpc types to moonbeam-types-bundle

* Fixes rpc types

* Update types version

* Adds moon to rpc api-augment types

* Adds rpc to api-augment

* Removes eth from types now that it is added to polkadotjs

* Better version for 1606

* Adds moon rpc methods to api-augment

* Finally fix rpc non decorated methods

* Adds script to generate local types

* Call Permit Precompile (#1617)

* call permit precompile

* tests

* add CallPermit to moonbase

* fix permit encoding + add test with permit signed with metamask

* fmt + fix test

* improved docs

* PR feedback

* [WIP] Adds fork tests (#1433)

* Adds fork tests

* Format

* Remove useless package

* Adds Governance support for PoV Test

* Fixes missing force-authoring

* Fix wrong nodeKey for 2nd node

* Adds more doc

* Support 1502

* Fixes top for state modifier

* Fixes state modifier for 1500

* Improves log extractor

* Adds support to skip intermediate runtimes

* Adds spawn script for fork test

* Better state modifier for forked states

* Gives more token to Alith for Fork Test

* Better script/docker

* Longer timeout for para fork-test node

* More debug logs

* delay for monitoring logs

* Make para_node support single para node

* Fix state modifier

* Fix state modifier nimbus key

* Support for orbiters

* Fix comment

* Support highestSlotSeen from nimbus

* Fixes PARA_ID

* Adds skip for block concistency in fork tests

* Better Fork test readme

* Support minor/major version for fork tests

* Adds logs to pov script

* Fixes pov skip flag

* hero re-org

* Display variables

* Better context for para tests

* Fix governance in fork test

* Better run fork script

* Adds RELAY_LOG

* Adds run-fork-chain.sh

* Prevent rust code formatting check to fail on spaces after tabs (#1646)

* Improve precompile-utils (#1642)

* don't truncate uintX values / check remaining bits

* refactor utils

* Port tests from #1630

* update revert message in tests

* fix typo

* update call-permit (#1648)

* Upgrade dependencies to polkadot v0.9.23 (#1622)

* upgrade all dependencies to polkadot v0.9.22

* fix runtime compilation

* migrate moonbeam client to jsonrpsee

* remove temporary  chain spec file

* use bip32 fork

* fix rust tests

* ignore export_current_state

* fix ts tests: the logger is not initialized at startup

* update frontier

* upgrade to polkadot-v0.9.23

* fix rust tests

* fix rust tests

* fix ts tests

* fix ts tests

* Update frontier

* Re-pin frontier

* Fix tests, block gas limit within boundaries

* Add mock weight to gas mapping

* update nimbus

* fix tests

* Fixes missing init logs

* More test fixes

* Re-pin frontier

* Add hardware benchmark telemetry

* Add gas estimation on tests

* better comment

* remove log

* Fixes call permit precompile dependencies

* Re-pin Frontier

* More ts tests fixing

* prettier

* Remove `WeightInfo`

* upgrade GH action yogevbd/enforce-label-action

* t

Co-authored-by: tgmichel <telmo@purestake.com>
Co-authored-by: gorka <gorka.irazoki@gmail.com>
Co-authored-by: Crystalin <alan@purestake.com>

* Hack hack hack

* Revert "Hack hack hack"

This reverts commit 19a616a.

* Fix democracy test

* Fixes fee based tests

* Fixes balance test

* Adds missing Call Permit precompile

* format

Co-authored-by: nanocryk <6422796+nanocryk@users.noreply.github.com>
Co-authored-by: Éloïs <c@elo.tf>
Co-authored-by: tgmichel <telmo@purestake.com>
Co-authored-by: gorka <gorka.irazoki@gmail.com>
Co-authored-by: notlesh <steve@brewcraft.org>

* Adds more testing

* Increase timeout for big staking tests

* Improve timeouts

* More timeout

* Update tests/tests/test-staking/test-staking-locks.ts

Co-authored-by: girazoki <gorka.irazoki@gmail.com>

* Update pallets/parachain-staking/src/types.rs

Co-authored-by: girazoki <gorka.irazoki@gmail.com>

* Update pallets/parachain-staking/src/types.rs

Co-authored-by: girazoki <gorka.irazoki@gmail.com>

* Use generic error instead of irrelevant one

* Remove extra toString()

* Update pallets/parachain-staking/src/types.rs

Co-authored-by: tgmichel <telmo@purestake.com>

* Update pallets/parachain-staking/src/types.rs

Co-authored-by: tgmichel <telmo@purestake.com>

* Use LockIdentifier type alias

* Use usable_balance to include locks in test

* fmt

* Revent default_with_total

Co-authored-by: Crystalin <alan@purestake.com>
Co-authored-by: Nisheeth Barthwal <nbaztec@gmail.com>
Co-authored-by: notlesh <steve@purestake.com>
Co-authored-by: nanocryk <6422796+nanocryk@users.noreply.github.com>
Co-authored-by: Éloïs <c@elo.tf>
Co-authored-by: tgmichel <telmo@purestake.com>
Co-authored-by: gorka <gorka.irazoki@gmail.com>
@notlesh notlesh added D1-audited👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited and removed D5-nicetohaveaudit⚠️ PR contains trivial changes to logic that should be properly reviewed. labels Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A0-pleasereview Pull request needs code review. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D1-audited👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants