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

New transfer id workflows #148

Merged
merged 13 commits into from
Feb 28, 2024
Merged

New transfer id workflows #148

merged 13 commits into from
Feb 28, 2024

Conversation

dr-orlovsky
Copy link
Member

No description provided.

Copy link
Member

@theacdutra theacdutra left a comment

Choose a reason for hiding this comment

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

Now, the following error is occurring:

The transfer the actual data doesn't match the provided id.\nActual id: transfer:Cs7AAr-dHR89bcS-nJ86BwiN-QXHcMKXj-yRvgKsb3-1D8LnV#baker-manual-patent.\nExpected id: transfer:ARZGSt-jNh7wRYp-zK9cyLXX-o2psW26n-GWf9qedh-j3JxY1#clever-dispute-zipper. presents inconsistency

Just a testing: If we change self.id in the line to self.bindle_id(), the error is corrected.

Copy link
Member

@cryptoquick cryptoquick left a comment

Choose a reason for hiding this comment

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

Some questions

@@ -1,11 +1,11 @@
-----BEGIN STRICT TYPE LIB-----
Id: urn:ubideco:stl:GVz4mvYE94aQ9q2HPtV9VuoppcDdduP54BMKffF7YoFH
Id: GVz4mvYE94aQ9q2HPtV9VuoppcDdduP54BMKffF7YoFH#prince-scarlet-ringo
Copy link
Member

Choose a reason for hiding this comment

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

Were we supposed to lose the URN prefix?

-- urn:ubideco:semid:BsYakBZMzKBDfgpfhXt1p81Q1WT27V8U7LvHG4NPmGmM#montana-torso-pierre
data Error :: supplyMismatch:1 | nonEqualAmounts:2 | invalidProof:3 | insufficientReserves:4
| insufficientCoverage:5 | issueExceedsAllowance:6
@mnemonic(montana-torso-pierre)
Copy link
Member

Choose a reason for hiding this comment

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

What's the reasoning behind providing less data here?

@dr-orlovsky dr-orlovsky changed the title Dependency updates New transfer id workflows Feb 16, 2024
Comment on lines 79 to 86
e.commit_to(&self.version);
e.commit_to(&self.transfer);

e.commit_to(&self.contract_id());
e.commit_to(&self.genesis.disclose_hash());
e.commit_to(&TinyOrdSet::from_iter_unsafe(
self.ifaces.values().map(|pair| pair.iimpl.impl_id()),
));
Copy link
Member

Choose a reason for hiding this comment

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

All items must be named types.

Comment on lines 88 to 99
e.commit_to(&LargeOrdSet::from_iter_unsafe(
self.bundles.iter().map(|ab| ab.bundle.disclose_hash()),
));
e.commit_to(&LargeOrdSet::from_iter_unsafe(
self.extensions.iter().map(Extension::disclose_hash),
));
e.commit_to(&SmallOrdSet::from_iter_unsafe(self.terminals_disclose()));

e.commit_to(&SmallOrdSet::from_iter_unsafe(self.attachments.keys().copied()));
e.commit_to(&self.supplements);
e.commit_to(&self.asset_tags);
e.commit_to(&self.signatures);
Copy link
Member

Choose a reason for hiding this comment

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

All items must be named types.

Copy link
Member

@theacdutra theacdutra left a comment

Choose a reason for hiding this comment

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

We have good news: all tests ran successfully in my environment, so I believe that everything is now working.

However, the only bug I found occurs when we try converting a Bindle<Transfer> to string and string to Bindle<Transfer>:

The transfer the actual data doesn't match the provided id.
Actual id: transfer:CeJAm5-nw1WxMzV-81DtaJSa-CTgjJ1MS-g9NmSjvi-6vMkT3#bonanza-shelter-organic.
Expected id: transfer:CgtX9T-9uVVt1Rq-3dPAs62P-CegfHe1Y-Gjs8D8Uu-onnw1L#rebel-justice-lithium. presents inconsistency

I think we need make some changes here, from writeln!(f, "Id: {:-#}", self.id)?; to writeln!(f, "Id: {:-#}", self.bindle_id())?;

If this change, this validation works.

@dr-orlovsky
Copy link
Member Author

@crisdut thank you for figuring out the source of the problem! You are right: bindle.id is the ID for the bindle content, while bindle.bindle_id() commits to both content AND signatures...

Shit, these id's are really getting out of control...

@dr-orlovsky
Copy link
Member Author

No, I am wrong: id and bindle_id should be the same thing! At least according to the code:

id: data.bindle_id(),

Any guesses why we have this bug? I can easily fix with your suggestion above, but I am afraid we are missing some deep bug here...

@theacdutra
Copy link
Member

Any guesses why we have this bug? I can easily fix with your suggestion above, but I am afraid we are missing some deep bug here...

I found the reason.

When we create the bindle, we use the Bindle::new method:

pub struct Bindle<C: BindleContent> {
    id: C::Id,
    data: C,
    sigs: TinyVec<Cert>,
}

impl<C: BindleContent> Bindle<C> {
    pub fn new(data: C) -> Self {
        Bindle {
            id: data.bindle_id(),
            data,
            sigs: empty!(),
        }
    }
}

In some cases, we modify the tranfer, and this changes producing another id when we execute bindle_id and transfer_id, but Bindle::Id remain fixed.

Example:

https://github.com/RGB-WG/rgb/blob/master/src/pay.rs#L337-L353

My recommendation is remove the directly access by id, and use always bindle_id.

What's you think?

@dr-orlovsky dr-orlovsky added this to the v0.11.0 milestone Feb 26, 2024
@dr-orlovsky
Copy link
Member Author

@crisdut I did this way in 0a9c92e and updated RGB wallet in master. Please let me know if everything works now - and I will merge this PR

@dr-orlovsky dr-orlovsky merged commit 6801aa5 into master Feb 28, 2024
13 of 19 checks passed
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