-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Witness filtering with refactored state management workflow #241
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dr-orlovsky
added
bug
Something isn't working
epic
Epic task covering multiple steps of implementation
labels
Jul 26, 2024
dr-orlovsky
force-pushed
the
mining
branch
2 times, most recently
from
July 27, 2024 21:06
5fff29a
to
f69a5ce
Compare
required to deal with complex lifetime situations downstream
This was referenced Jul 29, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses RGB-WG/rgb#124 and #238
Also provides prerequisites for fulfilling RGB-WG/rgb-core#147 and completing RGB-WG/rgb-core#208
Requires/based on RGB-WG/rgb-core#208
The PR refactors
State
type - the manager of the state of smart contracts - in the same mannerStash
andIndex
work. Previously, most of contract state related types were the part of RGB Core library, due to the fact that contract state can be accessed by AluVM op-codes.The mentioned issues required introducing concept of checking witness transaction mining (or channel) status (see
WitnessOrd
type) and filtering only the state which is valid. This can be done only with a "thick"State
type organized in the same manner asStash
orIndex
. To achieve this purpose, RGB Core instead of using concrete state types has moved to the use of trait-based accessors to the contract state, ensuring that the consensus parameters of the state are fixed there. Next, this PR does the refactoring of theState
in the standard library, adding information about the status of the witness transactions and using it for filtering all contract state data.With that, the contract state becomes aware of witness transaction mining status and knows how to re-organize itself on blockchain re-orgs. Thus, an RGB wallet just gets proper state, with state not anymore commited to valid transactions (like previous channel state or related to transactions removed from the blockchain after a re-org) already filtered out; nothing additional should be done on the wallet part and no new filters are needed. As a result, when you try to do a payment, you get a consistent state of PSBT inputs using only valid transactions.
The new workflow also works with a global state (it was the harderst part of the story). Other than that, API ensures that all of that is present in the same consitent way in the consensus level (will be needed when we will have full contract state introspection in AluVM, which is related to RGB-WG/rgb-core#147 and RGB-WG/rgb-core#208).
Pls keep in mind these changes do touch only state, not stash or index, meaning that stash still contains all the past state transitions, even those which witnesses are no more mined or are related to the past channel. It is only ephemeral state which reacts to re-orgs and adjusts itself accordingly, filtering out the no-more-valid parts of the stash (which may become valid again after another re-org or because of a non-cooperative closing).
TODO list:
rgb
Part of the epic: