Skip to content

Commit

Permalink
Add validation stamp checksum in tx summary
Browse files Browse the repository at this point in the history
  • Loading branch information
Neylix authored and samuelmanzanera committed Mar 24, 2023
1 parent 14bd0b7 commit d750034
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 76 deletions.
17 changes: 14 additions & 3 deletions lib/archethic/beacon_chain/replication_attestation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ defmodule Archethic.BeaconChain.ReplicationAttestation do
...> 200, 170, 241, 23, 249, 75, 17, 23, 241, 185, 36, 15, 66>>,
...> type: :transfer,
...> timestamp: ~U[2022-01-27 09:14:22Z],
...> fee: 10_000_000
...> fee: 10_000_000,
...> validation_stamp_checksum: <<17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66,
...> 167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219>>
...> },
...> confirmations: [
...> {
Expand All @@ -52,6 +54,8 @@ defmodule Archethic.BeaconChain.ReplicationAttestation do
<<
# Version
1,
# Transaction summary version
1,
# Tx address
0, 0, 232, 183, 247, 15, 195, 209, 138, 58, 226, 218, 221, 135, 181, 43, 216,
164, 4, 187, 38, 200, 170, 241, 23, 249, 75, 17, 23, 241, 185, 36, 15, 66,
Expand All @@ -63,6 +67,9 @@ defmodule Archethic.BeaconChain.ReplicationAttestation do
0, 0, 0, 0, 0, 152, 150, 128,
# Nb movements
1, 0,
# Validation stamp checksum
17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66,
167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219,
# Nb confirmations
1,
# Replication node position
Expand Down Expand Up @@ -98,10 +105,12 @@ defmodule Archethic.BeaconChain.ReplicationAttestation do
## Examples
iex> <<1, 0, 0, 232, 183, 247, 15, 195, 209, 138, 58, 226, 218, 221, 135, 181, 43, 216,
iex> <<1, 1, 0, 0, 232, 183, 247, 15, 195, 209, 138, 58, 226, 218, 221, 135, 181, 43, 216,
...> 164, 4, 187, 38, 200, 170, 241, 23, 249, 75, 17, 23, 241, 185, 36, 15, 66,
...> 0, 0, 1, 126, 154, 208, 125, 176,
...> 253, 0, 0, 0, 0, 0, 152, 150, 128, 1, 0,
...> 17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66,
...> 167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219,
...> 1, 0,64,
...> 129, 204, 107, 81, 235, 88, 234, 207, 125, 1, 208, 227, 239, 175, 78, 217,
...> 100, 172, 67, 228, 131, 42, 177, 200, 54, 225, 34, 241, 35, 226, 108, 138,
Expand All @@ -116,7 +125,9 @@ defmodule Archethic.BeaconChain.ReplicationAttestation do
200, 170, 241, 23, 249, 75, 17, 23, 241, 185, 36, 15, 66>>,
type: :transfer,
timestamp: ~U[2022-01-27 09:14:22.000Z],
fee: 10_000_000
fee: 10_000_000,
validation_stamp_checksum: <<17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66,
167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219>>
},
confirmations: [
{
Expand Down
33 changes: 21 additions & 12 deletions lib/archethic/beacon_chain/slot.ex
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,9 @@ defmodule Archethic.BeaconChain.Slot do
...> timestamp: ~U[2020-06-25 15:11:53Z],
...> type: :transfer,
...> movements_addresses: [],
...> fee: 10_000_000
...> fee: 10_000_000,
...> validation_stamp_checksum: <<17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66,
...> 167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219>>
...> },
...> confirmations: [{0, <<129, 204, 107, 81, 235, 88, 234, 207, 125, 1, 208, 227, 239, 175, 78, 217,
...> 100, 172, 67, 228, 131, 42, 177, 200, 54, 225, 34, 241, 35, 226, 108, 138,
Expand Down Expand Up @@ -401,6 +403,8 @@ defmodule Archethic.BeaconChain.Slot do
1, 1,
# Attestation version
1,
# Transaction summary version
1,
# Address
0, 0, 234, 233, 156, 155, 114, 241, 116, 246, 27, 130, 162, 205, 249, 65, 232, 166,
99, 207, 133, 252, 112, 223, 41, 12, 206, 162, 233, 28, 49, 204, 255, 12,
Expand All @@ -412,6 +416,9 @@ defmodule Archethic.BeaconChain.Slot do
0, 0, 0, 0, 0, 152, 150, 128,
# Nb movements addresses
1, 0,
# Validation stamp checksum
17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66,
167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219,
# Nb confirmations
1,
# Replication node position
Expand Down Expand Up @@ -483,16 +490,16 @@ defmodule Archethic.BeaconChain.Slot do
## Examples
iex> <<1, 0, 96, 8, 1, 120, 1, 1, 1, 0, 0, 234, 233, 156, 155, 114, 241, 116,
...> 246, 27, 130, 162, 205, 249, 65, 232, 166, 99, 207, 133, 252, 112, 223, 41, 12,
...> 206, 162, 233, 28, 49, 204, 255, 12, 0, 0, 1, 114, 236, 9, 2, 168, 253, 0, 0, 0,
...> 0, 0, 152, 150, 128, 1, 0, 1, 0, 64, 129, 204, 107, 81, 235, 88, 234, 207,
...> 125, 1, 208, 227, 239, 175, 78, 217, 100, 172, 67, 228, 131, 42, 177, 200, 54,
...> 225, 34, 241, 35, 226, 108, 138, 201, 2, 32, 75, 92, 49, 194, 42, 113, 154, 20,
...> 43, 216, 176, 11, 159, 188, 119, 6, 8, 48, 201, 244, 138, 99, 52, 22, 1, 97, 123,
...> 140, 195, 1, 1, 0, 0, 38, 105, 235, 147, 234, 114, 41, 1, 152, 148, 120, 31, 200,
...> 255, 174, 190, 91, 100, 169, 225, 113, 249, 125, 21, 168, 14, 196, 222, 140, 87,
...> 143, 241, 94, 244, 190, 185, 0, 2, 600::16, 356::16, 10, 0 >>
iex> <<1, 0, 96, 8, 1, 120, 1, 1, 1, 1, 0, 0, 234, 233, 156, 155, 114, 241, 116, 246, 27, 130, 162, 205, 249, 65, 232, 166,
...> 99, 207, 133, 252, 112, 223, 41, 12, 206, 162, 233, 28, 49, 204, 255, 12, 0, 0, 1, 114, 236, 9, 2, 168, 253,
...> 0, 0, 0, 0, 0, 152, 150, 128, 1, 0, 17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66,
...> 167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219, 1, 0, 64,
...> 129, 204, 107, 81, 235, 88, 234, 207, 125, 1, 208, 227, 239, 175, 78, 217,
...> 100, 172, 67, 228, 131, 42, 177, 200, 54, 225, 34, 241, 35, 226, 108, 138,
...> 201, 2, 32, 75, 92, 49, 194, 42, 113, 154, 20, 43, 216, 176, 11, 159, 188,
...> 119, 6, 8, 48, 201, 244, 138, 99, 52, 22, 1, 97, 123, 140, 195, 1, 1,
...> 0, 0, 38, 105, 235, 147, 234, 114, 41, 1, 152, 148, 120, 31, 200, 255, 174, 190, 91,
...> 100, 169, 225, 113, 249, 125, 21, 168, 14, 196, 222, 140, 87, 143, 241, 94, 244, 190, 185, 0, 2, 600::16, 356::16, 10, 0>>
...> |> Slot.deserialize()
{
%Slot{
Expand All @@ -507,7 +514,9 @@ defmodule Archethic.BeaconChain.Slot do
timestamp: ~U[2020-06-25 15:11:53.000Z],
type: :transfer,
movements_addresses: [],
fee: 10_000_000
fee: 10_000_000,
validation_stamp_checksum: <<17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66,
167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219>>
},
confirmations: [{0, <<129, 204, 107, 81, 235, 88, 234, 207, 125, 1, 208, 227, 239, 175, 78, 217,
100, 172, 67, 228, 131, 42, 177, 200, 54, 225, 34, 241, 35, 226, 108, 138,
Expand Down
28 changes: 19 additions & 9 deletions lib/archethic/beacon_chain/summary.ex
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ defmodule Archethic.BeaconChain.Summary do
...> timestamp: ~U[2020-06-25 15:11:53Z],
...> type: :transfer,
...> movements_addresses: [],
...> fee: 10_000_000
...> fee: 10_000_000,
...> validation_stamp_checksum: <<17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66,
...> 167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219>>
...> },
...> confirmations: [{0, <<255, 120, 232, 52, 141, 15, 97, 213, 231, 93, 242, 160, 123, 25, 192, 3, 133,
...> 170, 197, 102, 148, 208, 119, 130, 225, 102, 130, 96, 223, 61, 36, 76, 229,
Expand All @@ -383,6 +385,8 @@ defmodule Archethic.BeaconChain.Summary do
1, 1,
# Replication attestation version
1,
# Transaction summary version
1,
# Transaction address
0, 0, 234, 233, 156, 155, 114, 241, 116, 246, 27, 130, 162, 205, 249, 65, 232, 166,
99, 207, 133, 252, 112, 223, 41, 12, 206, 162, 233, 28, 49, 204, 255, 12,
Expand All @@ -394,6 +398,9 @@ defmodule Archethic.BeaconChain.Summary do
0, 0, 0, 0, 0, 152, 150, 128,
# Nb movement addresses
1, 0,
# Validation stamp checksum
17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66,
167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219,
# Nb confirmations
1,
# Replication storage node position
Expand Down Expand Up @@ -463,15 +470,16 @@ defmodule Archethic.BeaconChain.Summary do
## Examples
iex> <<1, 0, 96, 7, 114, 128, 1, 1, 1, 0, 0, 234, 233, 156, 155, 114, 241, 116, 246,
...> 27, 130, 162, 205, 249, 65, 232, 166, 99, 207, 133, 252, 112, 223, 41, 12,
...> 206, 162, 233, 28, 49, 204, 255, 12, 0, 0, 1, 114, 236, 9, 2, 168, 253, 0, 0,
...> 0, 0, 0, 152, 150, 128, 1, 0, 1, 0, 64, 255, 120, 232, 52, 141, 15, 97, 213, 231, 93, 242, 160, 123, 25, 192, 3, 133,
iex> << 1, 0, 96, 7, 114, 128, 1, 1, 1, 1, 0, 0, 234, 233, 156, 155, 114, 241, 116, 246, 27, 130, 162, 205, 249, 65, 232, 166,
...> 99, 207, 133, 252, 112, 223, 41, 12, 206, 162, 233, 28, 49, 204, 255, 12, 0, 0, 1, 114, 236, 9, 2, 168,
...> 253, 0, 0, 0, 0, 0, 152, 150, 128, 1, 0, 17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66,
...> 167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219, 1, 0, 64,
...> 255, 120, 232, 52, 141, 15, 97, 213, 231, 93, 242, 160, 123, 25, 192, 3, 133,
...> 170, 197, 102, 148, 208, 119, 130, 225, 102, 130, 96, 223, 61, 36, 76, 229,
...> 210, 5, 142, 79, 249, 177, 51, 15, 45, 45, 141, 217, 85, 77, 146, 199, 126,
...> 213, 205, 108, 164, 167, 112, 201, 194, 113, 133, 242, 104, 254, 253,
...> 0, 2, 1::1, 1::1, 100, 100, 1, 1, 0, 1, 190, 20, 188, 141, 156, 135, 91, 37, 96, 187, 27, 24, 41, 130, 118,
...> 93, 43, 240, 229, 97, 227, 194, 31, 97, 228, 78, 156, 194, 154, 74, 160, 104, 3, 132>>
...> 213, 205, 108, 164, 167, 112, 201, 194, 113, 133, 242, 104, 254, 253, 0, 2, 1::1, 1::1, 100, 100, 1, 1,
...> 0, 1, 190, 20, 188, 141, 156, 135, 91, 37, 96, 187, 27, 24, 41, 130, 118,
...> 93, 43, 240, 229, 97, 227, 194, 31, 97, 228, 78, 156, 194, 154, 74, 160, 104, 3, 132 >>
...> |> Summary.deserialize()
{
%Summary{
Expand All @@ -486,7 +494,9 @@ defmodule Archethic.BeaconChain.Summary do
timestamp: ~U[2020-06-25 15:11:53.000Z],
type: :transfer,
movements_addresses: [],
fee: 10_000_000
fee: 10_000_000,
validation_stamp_checksum: <<17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66,
167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219>>
},
confirmations: [{0, <<255, 120, 232, 52, 141, 15, 97, 213, 231, 93, 242, 160, 123, 25, 192, 3, 133,
170, 197, 102, 148, 208, 119, 130, 225, 102, 130, 96, 223, 61, 36, 76, 229,
Expand Down
32 changes: 22 additions & 10 deletions lib/archethic/beacon_chain/summary_aggregate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ defmodule Archethic.BeaconChain.SummaryAggregate do
...> 249, 138, 85, 71, 127, 190, 20, 186, 69, 131, 97, 194, 30, 71, 116>>,
...> type: :transfer,
...> timestamp: ~U[2022-02-01 10:00:00.204Z],
...> fee: 10_000_000
...> fee: 10_000_000,
...> validation_stamp_checksum: <<17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66,
...> 167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219>>
...> },
...> confirmations: [
...> {
Expand Down Expand Up @@ -246,6 +248,8 @@ defmodule Archethic.BeaconChain.SummaryAggregate do
1, 1,
# Replication attestations version
1,
# Transaction summary version
1,
# Address
0, 0, 120, 123, 229, 13, 144, 130, 230, 18, 17, 45, 244, 92, 226, 107, 11, 104, 226,
249, 138, 85, 71, 127, 190, 20, 186, 69, 131, 97, 194, 30, 71, 116,
Expand All @@ -257,6 +261,9 @@ defmodule Archethic.BeaconChain.SummaryAggregate do
0, 0, 0, 0, 0, 152, 150, 128,
# Nb movements addresses
1, 0,
# Validation stamp checksum
17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66,
167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219,
# Nb confirmations
1,
# Replication node position
Expand Down Expand Up @@ -336,14 +343,17 @@ defmodule Archethic.BeaconChain.SummaryAggregate do
## Examples
iex> SummaryAggregate.deserialize(<<1, 98, 29, 98, 0, 1, 1, 1, 0, 0, 120, 123, 229, 13, 144, 130, 230,
...> 18, 17, 45, 244, 92, 226, 107, 11, 104, 226, 249, 138, 85, 71, 127, 190, 20, 186, 69, 131, 97, 194,
...> 30, 71, 116, 0, 0, 1, 126, 180, 186, 17, 204, 253, 0, 0, 0, 0, 0, 152, 150, 128, 1, 0, 1, 0, 64,
...> 129, 204, 107, 81, 235, 88, 234, 207, 125, 1, 208, 227, 239, 175, 78, 217, 100, 172, 67, 228, 131,
...> 42, 177, 200, 54, 225, 34, 241, 35, 226, 108, 138, 201, 2, 32, 75, 92, 49, 194, 42, 113, 154, 20,
...> 43, 216, 176, 11, 159, 188, 119, 6, 8, 48, 201, 244, 138, 99, 52, 22, 1, 97, 123, 140, 195, 1, 0, 1,
...> 3, 1::1, 0::1, 1::1, 50, 70, 80, 1, 1, 0, 1, 57, 98, 198, 202, 155, 43, 217, 149, 5, 213, 109, 252,
...> 111, 87, 231, 170, 54, 211, 178, 208, 5, 184, 33, 193, 167, 91, 160, 131, 129, 117, 45, 242, 3, 132>>)
iex> SummaryAggregate.deserialize(<<1, 98, 29, 98, 0, 1, 1, 1, 1, 0, 0, 120, 123, 229, 13, 144,
...> 130, 230, 18, 17, 45, 244, 92, 226, 107, 11, 104, 226, 249, 138, 85, 71, 127, 190, 20, 186, 69,
...> 131, 97, 194, 30, 71, 116, 0, 0, 1, 126, 180, 186, 17, 204, 253, 0, 0, 0, 0, 0, 152, 150, 128,
...> 1, 0, 17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66,
...> 167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219, 1, 0, 64,
...> 129, 204, 107, 81, 235, 88, 234, 207, 125, 1, 208, 227, 239, 175, 78, 217,
...> 100, 172, 67, 228, 131, 42, 177, 200, 54, 225, 34, 241, 35, 226, 108, 138,
...> 201, 2, 32, 75, 92, 49, 194, 42, 113, 154, 20, 43, 216, 176, 11, 159, 188,
...> 119, 6, 8, 48, 201, 244, 138, 99, 52, 22, 1, 97, 123, 140, 195, 1, 0, 1, 3, 1::1, 0::1, 1::1,
...> 50, 70, 80, 1, 1, 0, 1, 57, 98, 198, 202, 155, 43, 217, 149, 5, 213, 109, 252, 111, 87, 231, 170, 54,
...> 211, 178, 208, 5, 184, 33, 193, 167, 91, 160, 131, 129, 117, 45, 242, 3, 132>>)
{
%SummaryAggregate{
summary_time: ~U[2022-03-01 00:00:00Z],
Expand All @@ -354,7 +364,9 @@ defmodule Archethic.BeaconChain.SummaryAggregate do
249, 138, 85, 71, 127, 190, 20, 186, 69, 131, 97, 194, 30, 71, 116>>,
type: :transfer,
timestamp: ~U[2022-02-01 10:00:00.204Z],
fee: 10_000_000
fee: 10_000_000,
validation_stamp_checksum: <<17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66,
167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219>>
},
confirmations: [
{
Expand Down
5 changes: 1 addition & 4 deletions lib/archethic/transaction_chain.ex
Original file line number Diff line number Diff line change
Expand Up @@ -643,10 +643,7 @@ defmodule Archethic.TransactionChain do
case get_transaction(address, [
:address,
:type,
validation_stamp: [
:timestamp,
ledger_operations: [:fee, :transaction_movements]
]
:validation_stamp
]) do
{:ok, tx} ->
{:ok, TransactionSummary.from_transaction(tx)}
Expand Down
Loading

0 comments on commit d750034

Please sign in to comment.