public inbox for [email protected]
 help / color / mirror / Atom feed
* [RFC] GNU/Weeb Financial Transaction Record Design
@ 2022-06-15  9:21 Alviro Iskandar Setiawan
  2022-06-15  9:23 ` Alviro Iskandar Setiawan
  2022-06-15  9:42 ` Ammar Faizi
  0 siblings, 2 replies; 6+ messages in thread
From: Alviro Iskandar Setiawan @ 2022-06-15  9:21 UTC (permalink / raw)
  To: GNU/Weeb Mailing List; +Cc: Ammar Faizi

Hi,

In order to keep the transaction record consistent, we can use a
chaining hash system that generates the transaction ID by using its
parent ID and the current transaction details.

For example, to create a new transaction, we have several things to note, like:

  1. date
  2. description
  3. commiter
  4. amount

  [ other metadata stuff may be included ]

We can then generate the transaction id by using a hash function,
let's say SHA1:

 trx_info = date . description . commiter . amount . parent_trx_id
 trx_id   = SHA1(info)
 SAVE(trx_id, date, description, commiter, amount, parent_trx_id)

Note that since the current trx ID uses its parent trx ID to generate
itself, it makes the situation impossible to rewrite the history
without breaking the whole chain. That's the point of the consistency
in this design. We can verify that the data is consistent by just
re-hashing the transaction info together with its parent trx id.

Also note that, for the first transaction, it doesn't have a parent
trx id. So only the first transaction doesn't use a parent trx id to
generate itself. Let's call it the genesis transaction.

Please comment!

tq

-- Viro

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC] GNU/Weeb Financial Transaction Record Design
  2022-06-15  9:21 [RFC] GNU/Weeb Financial Transaction Record Design Alviro Iskandar Setiawan
@ 2022-06-15  9:23 ` Alviro Iskandar Setiawan
  2022-06-15  9:42 ` Ammar Faizi
  1 sibling, 0 replies; 6+ messages in thread
From: Alviro Iskandar Setiawan @ 2022-06-15  9:23 UTC (permalink / raw)
  To: GNU/Weeb Mailing List; +Cc: Ammar Faizi

I haven't started writing the code, but if the idea looks good. I can
start writing the MySQL DDL.

tq

-- Viro

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC] GNU/Weeb Financial Transaction Record Design
  2022-06-15  9:21 [RFC] GNU/Weeb Financial Transaction Record Design Alviro Iskandar Setiawan
  2022-06-15  9:23 ` Alviro Iskandar Setiawan
@ 2022-06-15  9:42 ` Ammar Faizi
  2022-06-15 10:00   ` Alviro Iskandar Setiawan
  1 sibling, 1 reply; 6+ messages in thread
From: Ammar Faizi @ 2022-06-15  9:42 UTC (permalink / raw)
  To: Alviro Iskandar Setiawan, GNU/Weeb Mailing List

On 6/15/22 4:21 PM, Alviro Iskandar Setiawan wrote:
> Hi,
> 
> In order to keep the transaction record consistent, we can use a
> chaining hash system that generates the transaction ID by using its
> parent ID and the current transaction details.
> 
> For example, to create a new transaction, we have several things to note, like:
> 
>    1. date
>    2. description
>    3. commiter
>    4. amount
> 
>    [ other metadata stuff may be included ]
> 
> We can then generate the transaction id by using a hash function,
> let's say SHA1:
> 
>   trx_info = date . description . commiter . amount . parent_trx_id
>   trx_id   = SHA1(info)
>   SAVE(trx_id, date, description, commiter, amount, parent_trx_id)
> 
> Note that since the current trx ID uses its parent trx ID to generate
> itself, it makes the situation impossible to rewrite the history
> without breaking the whole chain. That's the point of the consistency
> in this design. We can verify that the data is consistent by just
> re-hashing the transaction info together with its parent trx id.
> 
> Also note that, for the first transaction, it doesn't have a parent
> trx id. So only the first transaction doesn't use a parent trx id to
> generate itself. Let's call it the genesis transaction.
> 
> Please comment!

Hi Al,

I like the idea of chaining the transaction ID to make the history
consistent and immutable. Overall it looks good to me, let's discuss
this further.

Several questions below:

  1) What are the exact fields we are going to save?

  2) How do we maintain a new field in the future if we ever add more?

  3) How do we distribute the trusted chains to public?

For no (2), you must not break the old records that don't have the new
field.

For no (3), I think it's quite simple, just post the transaction
history record periodically to the group. We can use a Telegram bot
for that.

Comment?

[ Anyway, you can start writing the code. ]

-- 
Ammar Faizi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC] GNU/Weeb Financial Transaction Record Design
  2022-06-15  9:42 ` Ammar Faizi
@ 2022-06-15 10:00   ` Alviro Iskandar Setiawan
  2022-06-15 10:03     ` Ammar Faizi
  0 siblings, 1 reply; 6+ messages in thread
From: Alviro Iskandar Setiawan @ 2022-06-15 10:00 UTC (permalink / raw)
  To: Ammar Faizi; +Cc: GNU/Weeb Mailing List

On Wed, Jun 15, 2022 at 4:42 PM Ammar Faizi <[email protected]> wrote:
> Several questions below:
>
>   1) What are the exact fields we are going to save?

I will post the DDL with exact fields we are going to save to answer
this question.

>   2) How do we maintain a new field in the future if we ever add more?

Maybe just make them be an empty string. Appending an empty string
won't change the hash because it doesn't change anything. For example,
we create a new field x, make it nullable, if it's NULL then when
we're validating the old records that don't have this field just treat
it as an empty string, it won't change the hash, so it's backward
compatible.

>   3) How do we distribute the trusted chains to public?
>
> For no (2), you must not break the old records that don't have the new
> field.
>
> For no (3), I think it's quite simple, just post the transaction
> history record periodically to the group. We can use a Telegram bot
> for that.

I agree with you.

> [ Anyway, you can start writing the code. ]

oc

tq

-- Viro

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC] GNU/Weeb Financial Transaction Record Design
  2022-06-15 10:00   ` Alviro Iskandar Setiawan
@ 2022-06-15 10:03     ` Ammar Faizi
  2022-06-15 10:06       ` Alviro Iskandar Setiawan
  0 siblings, 1 reply; 6+ messages in thread
From: Ammar Faizi @ 2022-06-15 10:03 UTC (permalink / raw)
  To: Alviro Iskandar Setiawan; +Cc: GNU/Weeb Mailing List

On 6/15/22 5:00 PM, Alviro Iskandar Setiawan wrote:
>>    2) How do we maintain a new field in the future if we ever add more?
> 
> Maybe just make them be an empty string. Appending an empty string
> won't change the hash because it doesn't change anything. For example,
> we create a new field x, make it nullable, if it's NULL then when
> we're validating the old records that don't have this field just treat
> it as an empty string, it won't change the hash, so it's backward
> compatible.

Not sure how will it look like. I am looking forward to the patchset then.

-- 
Ammar Faizi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC] GNU/Weeb Financial Transaction Record Design
  2022-06-15 10:03     ` Ammar Faizi
@ 2022-06-15 10:06       ` Alviro Iskandar Setiawan
  0 siblings, 0 replies; 6+ messages in thread
From: Alviro Iskandar Setiawan @ 2022-06-15 10:06 UTC (permalink / raw)
  To: Ammar Faizi; +Cc: GNU/Weeb Mailing List

On Wed, Jun 15, 2022 at 5:03 PM Ammar Faizi <[email protected]> wrote:
> On 6/15/22 5:00 PM, Alviro Iskandar Setiawan wrote:
> >>    2) How do we maintain a new field in the future if we ever add more?
> >
> > Maybe just make them be an empty string. Appending an empty string
> > won't change the hash because it doesn't change anything. For example,
> > we create a new field x, make it nullable, if it's NULL then when
> > we're validating the old records that don't have this field just treat
> > it as an empty string, it won't change the hash, so it's backward
> > compatible.
>
> Not sure how will it look like. I am looking forward to the patchset then.

Yeeeeeeh, just sit and wait for my patchset, you can comment later on :p

tq

-- Viro

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-15 10:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-15  9:21 [RFC] GNU/Weeb Financial Transaction Record Design Alviro Iskandar Setiawan
2022-06-15  9:23 ` Alviro Iskandar Setiawan
2022-06-15  9:42 ` Ammar Faizi
2022-06-15 10:00   ` Alviro Iskandar Setiawan
2022-06-15 10:03     ` Ammar Faizi
2022-06-15 10:06       ` Alviro Iskandar Setiawan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox