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

Experiments on v0.11 #285

Merged
merged 15 commits into from
Feb 19, 2025
Merged

Experiments on v0.11 #285

merged 15 commits into from
Feb 19, 2025

Conversation

zoedberg
Copy link
Contributor

This PR is part of a v0.11 fixes epic, see RGB-WG/rgb-tests#30 for an overview.

@zoedberg
Copy link
Contributor Author

CI fails because this needs other repos in the epic to be patched

Copy link
Member

@dr-orlovsky dr-orlovsky left a comment

Choose a reason for hiding this comment

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

Reviewed first two commits, up to cf40921

Concept ACK.

Approach in cf40921 is NACK: a contract must commit to the Layer1. Yes, it shouldn't commit to AltLayers, but it must now commit to a specific layer1.

Before, all contracts were multi-layer; and thus supported bitcoin + maybe some other layers.

Now contracts are single-layer, and there is no way how to find whether it is bitcoin or liquid or something. It must be specified as a strong commitment in the contract Genesis, like we have that in v0.12,

@zoedberg
Copy link
Contributor Author

Approach in cf40921 is NACK: a contract must commit to the Layer1. Yes, it shouldn't commit to AltLayers, but it must now commit to a specific layer1.

I thought that since the genesis always has some assignments it would be enough to check that those assignments are all defined on the same layer 1. But I'll add a layer 1 to the genesis to make this more explicit.

@zoedberg
Copy link
Contributor Author

@dr-orlovsky added layer1 to genesis, here and in related PRs

@dr-orlovsky
Copy link
Member

dr-orlovsky commented Jan 16, 2025

I thought that since the genesis always has some assignments it would be enough to check that those assignments are all defined on the same layer 1

Consensus doesn't require genesis to have at least one assignment. For instance, in RGB30, genesis doesn't have any.

Copy link
Member

@dr-orlovsky dr-orlovsky left a comment

Choose a reason for hiding this comment

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

Three other general notes:

  1. I do not see how 3030a3f handles reorgs; a new enum field is not used at all
  2. I believe we do not need bundles to commit to the close method, that is excessive
  3. The support of multi-blockchain contracts is still there. Overall, the type XChain needs to be removed - and you will see how many remnants are still haven't dealt with.

@zoedberg
Copy link
Contributor Author

I do not see how 3030a3f handles reorgs; a new enum field is not used at all

@dr-orlovsky Please start reviewing fixes from RGB-WG/rgb-tests#30. Many fixes required changes to multiple repos. For example the "handle RGB reorgs" fix required changes to both rgb-core and rgb-std, you can see this in RGB-WG/rgb-tests@2d00297

I believe we do not need bundles to commit to the close method, that is excessive
The support of multi-blockchain contracts is still there. Overall, the type XChain needs to be removed - and you will see how many remnants are still haven't dealt with.

I'm aware of this but removing the close method from the bundle and the XChain from multiple objects requires a lot of refactor so we decided that for know we accept to have some redundant bytes in the consignment and some extra unneeded code to avoid making too difficult reviewing the PRs. Especially if no one proves that keeping them could cause a bug/attack. We'll do some refactor PRs after we agree these ones are fixing known bugs or adding limitations that we agreed on during Lugano (i.e. contract committing to single chain and close method).

@dr-orlovsky
Copy link
Member

Sorry, for the last four days I was sick and kinda braindead...

I see your point. Let's discuss it during the call today - there are some risks I see with it.

@dr-orlovsky dr-orlovsky changed the base branch from master to v0.11.1 February 11, 2025 16:37
@dr-orlovsky
Copy link
Member

All CI are failing.

Also, I'd like to ask you to provide the detailed description of what specific changes this PR introduce

Finally, can you please use the same style of the commitment messages as used everywhere in the history, based on https://www.conventionalcommits.org/en/v1.0.0/, with two differences:

  • the detailed body is optional
  • if it is a feature, it should start with the module (directory) name it is related to (like schema: ... etc).

Copy link
Member

@dr-orlovsky dr-orlovsky left a comment

Choose a reason for hiding this comment

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

First review of some parts (haven't got to seals and validation yet)

)]
#[repr(u8)]
#[derive(Default)]
pub enum ChainNet {
Copy link
Member

Choose a reason for hiding this comment

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

Regarding the ChainNet: I do believe that we need to keep testnet flag in genesis alongside Chainnet value. The reason is simple: while there might be multiple testnets per blockchain (like in case of Bitcoin, there is testnet3, 4, signet etc); the contract is either has a value (i.e. mainnet) or doesn't (testnet) and can operate any testnet with no further clarification. Otherwise each time a new testned is made we would have to change the consensus by updating ChainNet type.

Thus, my proposal is:

  1. Make enum ChainNet { Bitcoin, Liquid } and that's it.
  2. Add testnet: bool to the Genesis back.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We think testnet is not precise enough. Treating test networks differently from mainnet makes some tests possible only using mainnet, while the purpose of test networks is to simulate the behavior of mainnet without actually using it. Moreover we added a check on the resolver to detect if the resolver chain-network pair is different from the contract one, making some errors impossible (see the issue_on_different_layers test in rgb-tests). We already simulated what happens when a new ChainNet variant is added and old contracts still work so we don't see any issue in that regard.

Copy link
Member

@dr-orlovsky dr-orlovsky Feb 14, 2025

Choose a reason for hiding this comment

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

There is a clear issue I have described: "each time a new testned is made we would have to change the consensus by updating ChainNet type.".

Both in RGB v0.11.0 and in v0.12 testnet was a flag separate from blockchain. If we intend to change that, this should be discussed as a separate proposal and implemented once a common decision is achieved - like with each one past consensus changes we had.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see an issue with changing rgb-core each time a new testnet needs to be added, for the following reasons:

  1. this is a consensus change because it affects rgb-core, but it doesn't mean there would be any consensus-breaking when it comes to contracts, as existing contracts will continue to work fine and only new contracts using the new testnet will require an updated RGB stack
  2. we're talking about rare events (e.g. testnet5) that take time to settle, so the time-frame of the update process is reasonable
  3. this allows testing conditions that the testnet bool alone prevents us from
  4. ChainNet already existed (in rgb-std) and has just been moved to rgb-core, so it's not an addition of new untested code but just a small change that is IMO a very good tradeoff
  5. consensus code (i.e. rgb-core) changes will always be needed, e.g. when addressing bugs or updating dependencies

To me, 1 to 3 are the main points, others are there to make it clearer that it's also a low-impact change.

/// Original value in smallest indivisible units
pub value: FungibleState,
/// Field necessary only to avoid clash with RevealedValue during yaml deserialization
pub concealed_dummy: (),
Copy link
Member

Choose a reason for hiding this comment

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

Nope, we can't add something because of "YAML" to the consensus level. It's like making Linux kernel depend on JSON specifics

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is temporary, it's there because the removal of pedersen commitments was already causing a lot of changes and we wanted to keep the diff small (also easing the review). We're going to refactor this on the next batch of PRs.

Copy link
Member

Choose a reason for hiding this comment

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

Why do we need "temporary" things in consensus layer? It will be easy to forget to remove it later, so it will stay forever.

Can you explain the problem with YAML; I am quite sure there can be a simple solution (since I had a lot of YAML problems in the past and know some gotchas how to overcome them).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why do we need "temporary" things in consensus layer? It will be easy to forget to remove it later, so it will stay forever.

Because we agreed that this approach was ok on a different communication channel. We also agreed there's no reason to worry about details since this version is experimental for now. We can open a tracking issue if you are worried that we may forget about things. Moreover, we decided that you should review the changes only when we'll have finished everything, so I think we should just discuss these matters at that point and avoid adding any friction right now.

Can you explain the problem with YAML; I am quite sure there can be a simple solution (since I had a lot of YAML problems in the past and know some gotchas how to overcome them).

The code comment "Field necessary only to avoid clash with RevealedValue during yaml deserialization" means that since RevealedValue and ConcealedValue would be identical without adding the concealed_dummy field, the deserialization wouldn't know if it should deserialize the value into one struct or the other. This was the fastest temporary fix we found.

Anyway, I've just pushed the removal of the ConcealedValue so that there's no need for this dummy field anymore.

@zoedberg
Copy link
Contributor Author

All CI are failing.

CI is failing because we needed to update to the new bp-core first (which has been released yesterday). I've added a commit to fix that and now the CI should pass.

Also, I'd like to ask you to provide the detailed description of what specific changes this PR introduce

The detailed description of the changes is RGB-WG/rgb-tests#30, as the description of this PR says. Anyway, ignoring chore commits like lint and those commits that have been superseded by others, this PR:

  • removes support for alternative layer1s and makes the contract commit to a chain-network pair
  • fixes RGB state when a reorg happens
  • fixes an undetected double spend in consignment validation
  • removes pedersen commitments
  • implements the unified seals by removing anchor dichotomy

Finally, can you please use the same style of the commitment messages as used everywhere in the history, based on https://www.conventionalcommits.org/en/v1.0.0/, with two differences:

* the detailed body is optional

* if it is a feature, it should start with the module (directory) name it is related to (like `schema: ...` etc).

Done. On this matter, I haven't seen this requirement in the contributing instructions, it would be nice IMO if this was documented there along with the set of supported tags.

@dr-orlovsky
Copy link
Member

Ok, merging this with no review and without approval from my side.

NB: this is alpha-release, and merge into an experimental branch, and using of the new v0.11.1-alpha.1 is discouraged for anyone

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