0xMiden / 0xMiden/protocol

Allow private notes as inputs to `MockChain::build_tx_context`

Đang mở
#1,607 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
tests
Ngôn ngữ chính
Rust
Star
132
Fork
167
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
110

Mô tả

Even though we did https://github.com/0xMiden/miden-base/pull/1310, we currently can't easily build a transaction with private input notes, since the `MockChainNote` doesn't track enough information to create an `InputNote`:

https://github.com/0xMiden/miden-base/blob/8e88dc6b04429f67c685ce577f2afce6f8df757a/crates/miden-testing/src/mock_chain/note.rs#L13-L19

This is by design to mirror the privacy aspect of the notes. However, it would be great if we could pass a full private note into `build_tx_context` to be able to easily build a transaction with a private note. Currently, we use public notes exclusively, I think.

One way to do this would be similar to how we allow both a full `Account` and just an `AccountId` to be provided as input using `TxContextInput`. Analogously we could do:

```rust
pub TxContextNoteInput {
Private(Note),
Public(NoteId),
}

impl From for TxContextNoteInput {
// Depending on the note type return either
// TxContextNoteInput::Public(..) / TxContextNoteInput::Private(..)
}
impl From for TxContextNoteInput {
// Return TxContextNoteInput::Public(..)
}
```

Then `build_tx_context`'s signature can be changed to:

```rust
pub fn build_tx_context(
&self,
input: impl Into,
note_ids: &[impl Into],
unauthenticated_notes: &[Note],
) -> anyhow::Result { ... }
```

We should also rename `TxContextInput` to `TxContextAccountInput` for clarity.

As part of this we should rewrite at least one test to use private notes as inputs. One candidate is `settle_coincidence_of_wants`.

cc @tomyrd in case I've missed how the above is already possible.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.