Skip to content

feat(platform)!: mitigate issues of asset lock based transitions - #1796

Merged
QuantumExplorer merged 43 commits into
v1.0-devfrom
feat/QueryAllCoreInfoTogether
Mar 31, 2024
Merged

QuantumExplorer merged 43 commits into
v1.0-devfrom
feat/QueryAllCoreInfoTogether

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Mar 26, 2024 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Asset lock transactions (identity create and identity top) were extremely expensive on the system. Since asset locks could not be partially spent this meant that if they failed the system would be out of pocket for paying for expensive processing. This could have led to many types of attacks.

What was done?

Introduced the ability to partially use asset locks.

How Has This Been Tested?

Added a test where the identity create state transition is not valid, it gets rejected but still is paid for, and then we try to use it again and the identity then gets created.

Breaking Changes

Validation was changed, as well as some constants.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Comment thread packages/rs-dpp/src/asset_lock/mod.rs Resolved
)
}

pub fn required_asset_lock_balance_for_processing_start(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shouldn't it be in Drive ABCI? We already have there similar traits

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well it's just state transition + version, so DPP makes more sense.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The problem is that StateTransition is represented all STs but this logic is specific for AssetLocks only. Also this logic is no needed in SDK. If think we had the same case in one of your previous PRs and we decided to move to ABCI sine we can't use AssetLockedProved trait and we don't want to polute API of common library.

}

/// All of these penalty amounts are in credits
#[derive(Clone, Debug, Default)]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

it's not a good idea to mix constants with versions. It's gonna be a mess at some point. Shouldn't they be operations?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

why not?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Because this tree is going to be too big since it mixes two different entities: versions and constants. If we want to have constants based on version I would introduce a separate tree for that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We can make a different PR for that, but we can even do it after mainnet, because it wouldn't be a breaking change.

platform_version,
)
}
_ => Ok(ConsensusValidationResult::new()),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Don't it should be an error since we do not suppose to call this function for other state transitions?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think the default being that it is passing if fine, because that validation would be "YES" by default, since an absence of checks would mean that all is good.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Don't you think that double validation of our logic would be good. We will see bugs right away, I mean the functions what we are calling but not supposed to.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, this is fine.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Remember we won't be including a lot of state transitions :)

@QuantumExplorer

Copy link
Copy Markdown
Member Author

Ivan had one issue that he wanted resolved that is still up for debate, either way this is a very big improvement, so we are going to merge this in and revisit the difference between deserialization in a different PR.

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.

2 participants