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

Suspend MantaPay when InternalLedgerError #977

Merged
merged 12 commits into from
Jan 17, 2023

Conversation

ghzlatarev
Copy link
Contributor

@ghzlatarev ghzlatarev commented Jan 9, 2023

Signed-off-by: Georgi Zlatarev georgi.zlatarev@manta.network

Description

The following errors mean that the ledger is uncrecovarble broken:

  • ReceiverLedgerError::ChecksumError
  • ReceiverLedgerError::MerkleTreeCapacityError
  • TransferLedgerError::ChecksumError
  • TransferLedgerError::VerifiyingContextDecodeError

When they occur we just trigger tx-pause pause_pallets for MantaPay, in order to shut down any further operations, until we figure out a way forward.


Before we can approve this PR for merge, please make sure that all the following items have been checked off:

  • Connected to an issue with discussion and accepted design using zenhub "Connect issue" button below
  • Added one label out of the L- group to this PR
  • Added one or more labels from the A- and C- groups to this PR
  • Explicitly labelled A-calamari, A-dolphin and/or A-manta if your changes are meant for/impact either of these (CI depends on it)
  • Re-reviewed Files changed in the Github PR explorer.

Situational Notes:

  • If adding functionality, write unit tests!
  • If importing a new pallet, choose a proper module index for it, and allow it in BaseFilter. Ensure every extrinsic works from front-end. If there's corresponding tool, ensure both work for each other.
  • If needed, update our Javascript/Typescript APIs. These APIs are officially used by exchanges or community developers.
  • If modifying existing runtime storage items, make sure to implement storage migrations for the runtime and test them with try-runtime. This includes migrations inherited from upstream changes, and you can search the diffs for modifications of #[pallet::storage] items to check for any.

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
@ghzlatarev ghzlatarev added C-enhancement Category: An issue proposing an enhancement or a PR with one A-calamari Area: Issues and PRs related to the Calamari Runtime A-dolphin Area: Issues and PRs related to the Dolphin Runtime L-changed Log: Issues and PRs related to changes labels Jan 13, 2023
@ghzlatarev ghzlatarev self-assigned this Jan 13, 2023
@ghzlatarev ghzlatarev marked this pull request as ready for review January 13, 2023 19:09
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
pallets/manta-pay/src/lib.rs Show resolved Hide resolved
pallets/manta-pay/src/lib.rs Outdated Show resolved Hide resolved
pallets/manta-pay/src/lib.rs Show resolved Hide resolved
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
…xtra unit case and comments.

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
ferrell-code
ferrell-code previously approved these changes Jan 14, 2023
Copy link
Contributor

@ferrell-code ferrell-code left a comment

Choose a reason for hiding this comment

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

Nice, LGTM

@Dengjianping
Copy link
Contributor

I forget or don't have the context. why do we suspend mantapay if this error happen?

@ghzlatarev
Copy link
Contributor Author

I forget or don't have the context. why do we suspend mantapay if this error happen?

If these errors happen, the ledger is unrecoverable broken, so we should just shut it down.
Let me add a description, forgot about that.

pallets/manta-pay/src/lib.rs Show resolved Hide resolved
pallets/manta-pay/src/lib.rs Show resolved Hide resolved
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
SupremoUGH
SupremoUGH previously approved these changes Jan 16, 2023
ferrell-code
ferrell-code previously approved these changes Jan 16, 2023
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
ferrell-code
ferrell-code previously approved these changes Jan 16, 2023
Signed-off-by: Adam Reif <Garandor@manta.network>
@Garandor Garandor force-pushed the ghzlatarev/tx-pause-on-internal-ledger-error branch from 7f368d1 to 775be42 Compare January 17, 2023 05:03
Copy link
Contributor

@ferrell-code ferrell-code left a comment

Choose a reason for hiding this comment

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

A few more tests that make sure errors that shouldn't suspend mantapay indeed do not maybe useful too. Code LGTM though

@Garandor
Copy link
Contributor

A few more tests that make sure errors that shouldn't suspend mantapay indeed do not maybe useful too. Code LGTM though

Each invocation of suspend_manta_pay_execution is behind a match, so i think this is reasonably certain not to blow up randomly even without tests.
Not sure how one would test absence of pausing for all other error conditions, the overflow recommends an external crate for this purpose. I would like an iter-all-possible-enum-value-combinations-and-match style test more for assurance that ONLY the listed combinations pause the ledger (adding single combination negative tests is fragile on adding new error types), but this is good enough already.
Merging into 401

@Garandor Garandor merged commit f7cf15b into manta Jan 17, 2023
@Garandor Garandor deleted the ghzlatarev/tx-pause-on-internal-ledger-error branch January 17, 2023 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-calamari Area: Issues and PRs related to the Calamari Runtime A-dolphin Area: Issues and PRs related to the Dolphin Runtime C-enhancement Category: An issue proposing an enhancement or a PR with one L-changed Log: Issues and PRs related to changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants