Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

RFC: Transaction type #3

Closed
wants to merge 28 commits into from
Closed

RFC: Transaction type #3

wants to merge 28 commits into from

Conversation

samuel-rufi
Copy link
Member

@samuel-rufi samuel-rufi commented Sep 6, 2019


# Summary

This feature is responsible for the creation and interpretation of transactions and bundles.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'ld like the Summary a little bit more detailed, what is actually introduced by this feature. I know that transactions and bundles are absolutely essential to IOTA, but for consistency with other RFCs could you write this section "as if" you would introduce those concepts with this proposal. I think we can expect the reader to have "some" DLT knowledge (so this summary should still remain rather short), but IMHO we should write those RFCs also for people that are fairly new to IOTA to get as many people involved as possible. The summary/abstract will be the first thing someone interested in it will read, and most of the times the last thing as well.

This comment was marked as resolved.

IOTA is a distributed ledger that was designed for payment settlement and data transfer between machines and devices in the Internet of Things (IoT) ecosystem.
The data packets that are sent through the network are called "transactions".
Settlements or data transfers can be done with the help of these transactions. Payment settlements require the help of multiple transactions.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think those sentences should move into the summary as they very well provide the necessary context to understand this proposal. To not repeat yourself in this section, you could pick up from the summary and elaborate on what transactions and bundles are in more detail, and how they are useful or even indispensable for the Bee framework.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @Alex6323 here.

text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
Copy link
Contributor

@SuperFluffy SuperFluffy left a comment

Choose a reason for hiding this comment

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

I like this RFC because I understand its purpose, and because I feel like it fulfills (or is very close to fulfilling) the requirement of taking care of a specific, cleanly separated concern.

The proposal should definitely separate the Transaction and Bundle types into their respective RFCs, because these seem to be sufficiently different.

The RFC can mention that the Transaction type could live in its own crate.


# Summary

This feature is responsible for the creation and interpretation of transactions and bundles.

This comment was marked as resolved.

IOTA is a distributed ledger that was designed for payment settlement and data transfer between machines and devices in the Internet of Things (IoT) ecosystem.
The data packets that are sent through the network are called "transactions".
Settlements or data transfers can be done with the help of these transactions. Payment settlements require the help of multiple transactions.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @Alex6323 here.

text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved

# Drawbacks

Without any bee-model crate, nodes can not exchange transactions. Therefore this crate seems necessary.
Copy link
Contributor

Choose a reason for hiding this comment

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

Drawbacks should ideally also discuss the drawbacks of this design. :)

I am thinking of the String types, for example, which could also be done as their own types.

- The distinction between Transaction and Transaction Builder as well as Bundle and Bundle Builder makes the code cleaner
and helps achieve correctness among the data objects. Properties are clearly assigned to specific data objects and not mixed up.

- The proposed crate interface is intuitive. Completely different alternatives did not naturally come to mind.
Copy link
Contributor

Choose a reason for hiding this comment

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

If it's intuitive is for users to decide. I agree however that it is a very natural proposition to basically treat the incoming transaction as some encoded binary blob.

text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
@@ -0,0 +1,334 @@
+ Feature Name: `bee-model-crate`
Copy link
Contributor

Choose a reason for hiding this comment

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

We should rename it to something like iri-transaction-model or mainnet-transaction-model or v1-transaction-model.

Copy link
Member

Choose a reason for hiding this comment

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

I'd vote for versioning since mainnet-transaction-model is not time-proof and iri-transaction-model is not really the case.

Copy link
Member Author

Choose a reason for hiding this comment

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

How do you want to version it?

text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
@@ -0,0 +1,334 @@
+ Feature Name: `bee-model-crate`
Copy link
Member

Choose a reason for hiding this comment

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

I'd vote for versioning since mainnet-transaction-model is not time-proof and iri-transaction-model is not really the case.

text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
```rust
struct Transaction {

signature_fragments: String,
Copy link
Member

Choose a reason for hiding this comment

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

I'd like the name to reflect that it doesn't necessarily contain a signature. signature_or_message ?

Copy link

Choose a reason for hiding this comment

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

Is it possible to even not contain this field if the instance doesn't have signature_or_message? It would be sth like this:

Suggested change
signature_fragments: String,
signature_or_message: Option<String>,

Copy link
Member

Choose a reason for hiding this comment

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

Option still allocates memory for the field so it's not really helpful

Copy link
Member Author

Choose a reason for hiding this comment

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

@SuperFluffy what are your thoughts regarding Option. Semantically, it would be more correct, right?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure it makes more sense "semantically", an empty sig_or_msg doesn't mean there is no sig_or_msg. There is always a sig_or_msg :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree, so maybe Option isn't necessary. And if we use static types, we could initialize it with an empty (9's) SignatureOrMessageFragment and could be sure the internal state of the builder object is always valid.

text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
text/0000-bee-model-crate/0000-bee-model-crate.md Outdated Show resolved Hide resolved
@lunfardo314
Copy link

Transaction and related types better be abstract traits since the beginning.
I refer to requirements of Q-nodes to Bee: #6 (comment) .
The assemblies would need multiple types of transactions in the same bundle and some new constrains on the ledger, other than usual constraints on token accounts. For example, there's a need to support unforkable chains, signed by the assembly.

samuel-rufi and others added 3 commits October 7, 2019 20:36
…n't needed anymore, removed it from the build() of TransactionBuilder. Changed visibility of fields in TransactionBuilder to private. Setter/getter functions will be used to set/access fields.

Moved from_bytes() constructor of Transaction to TransactionBuilder. TransactionBuilder also allows to set Timestamp and Nonce manually in case they are available.
@samuel-rufi samuel-rufi changed the title RFC: bee-model crate RFC: bee-model module Oct 8, 2019
…d info regarding the Pow:compute(&TransactionBuilder) call since it should not be overseen and reviewed.

- Introducing a fluent API to the TransactionBuilder?
- Should we use Option<T> for the fields in TransactionBuilder?
Copy link

Choose a reason for hiding this comment

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

Some fields would need this I guess. Others like timestamp, index etc are mandatory.

Copy link
Contributor

@SuperFluffy SuperFluffy Oct 10, 2019

Choose a reason for hiding this comment

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

The build method is responsible for ensuring that mandatory fields are set, returning Result::Err if not. The type of the field is Option if there is no natural (read: meaningful) way of providing a default.

@wusyong wusyong changed the title RFC: bee-model module RFC: bee-transaction module Oct 9, 2019
Comment on lines +67 to +68
| `signature_or_message_fragment` | contains the signature of the transfer | |
| | or user-defined message data | 6561 |
Copy link

Choose a reason for hiding this comment

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

I think it's no need to be separate line. Besides, this would become totally different row. Normal markdown display would just adjust them.

Suggested change
| `signature_or_message_fragment` | contains the signature of the transfer | |
| | or user-defined message data | 6561 |
| `signature_or_message_fragment` | contains the signature of the transfer or user-defined message data | 6561 |

Copy link

Choose a reason for hiding this comment

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

@SuperFluffy I think we could ignore max chars limit during table format. We should make representation correct at least.

Comment on lines +69 to +70
| `address` | receiver (output) if value > 0,
| | or sender (input) if value < 0 | 243 |
Copy link

Choose a reason for hiding this comment

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

ditto

@SuperFluffy
Copy link
Contributor

SuperFluffy commented Oct 14, 2019 via email

Comment on lines +168 to +174
The `TransactionError` is not fully fleshed out yet. For the time being, it
definitely contains `io::Error`:

```rust
pub enum TransactionError {
Io(io::Error),
}
Copy link

Choose a reason for hiding this comment

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

I think we should also start considering which error handling library to use. I saw there's another new one called thiserror. What do you think?

unimplemented!()
}

pub fn address(&mut self, address: Address) -> &mut Self {
Copy link

Choose a reason for hiding this comment

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

How about give a proper setter method prefix like set_address?

Copy link
Member Author

Choose a reason for hiding this comment

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

@SuperFluffy SuperFluffy changed the title RFC: bee-transaction module RFC: Transaction type Oct 15, 2019
@SuperFluffy
Copy link
Contributor

SuperFluffy commented Oct 15, 2019

Incorporated into #20.

While discussing the design of the Transaction, we realized that a new transaction is not supposed to be create directly. Instead, when constructing a new message, the Bundle is the fundamental object one wants to crate, which in turn splits up its message into several Transactions. A Transaction thus becomes a very simple type. More complicated logic should thus be handled by the Bundle.

@SuperFluffy SuperFluffy mentioned this pull request Oct 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants