Skip to content

Commit d943576

Browse files
committed
Merge attestation and attestation_with_dal contents
1 parent 51553a9 commit d943576

File tree

9 files changed

+95
-51
lines changed

9 files changed

+95
-51
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0b7e640e3e07beb8dc10a7582ad323c5788258b90186bd730d24e1962e082966020000008b449b5ed2f52b357b3a8df4794643408248e27839fdf7e2d28db64d65135c2e2e15005300074004000000009c602403e53efcd8c1c6def8dff2dce4e65169bfe3b9dc83c999401ffbf6dc50dc86bd6bcd6cb80de43fc274409a57bb74f3fc863d67619cc94f303afdfa9d48fee1e9ddce6883cbe84642efb8f05831c0c3ebd5acdbf8e28b111cec175d470a0000008b449b5ed2f52b357b3a8df4794643408248e27839fdf7e2d28db64d65135c2e2e1500530007400400000000126252e0a3e4b4912b08f9eb686b9e31589ef97749e0f2aeefcac9fa385c34faabef4735682bb173152481e3638d33a8dd51456334a1b6bc3c671ff626a95004a77639b29b48da6920f773fe37789574405894de77f467865647a7d076f7ef0b
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"branch": "BKoLvj4KKvpYZogKgjARRu6jzcJMqTm8NRUe47dNHKguTYUCmnx",
3+
"contents": [
4+
{
5+
"kind": "double_attestation_evidence",
6+
"op1": {
7+
"branch": "BLEVomdmPi274XtWAu6uVB5S1Dchba5xmJ8YfS7kxaprBPWWMLL",
8+
"operations": {
9+
"kind": "attestation",
10+
"slot": 83,
11+
"level": 475140,
12+
"round": 0,
13+
"block_payload_hash": "vh2rzWxkdUALsamUHcNFi8kybDM7R26xgyFyv1WVZaowW2VWJ2ot"
14+
},
15+
"signature": "sigrqfEUAcALXvU7cCeiTGzQrRmL9PE7w3pUvA5i8C5V53aUpqkQqvzic5NEwbR7zNG8ndFJTmJusS6CRLk2iBUNYamnLc4V"
16+
},
17+
"op2": {
18+
"branch": "BLEVomdmPi274XtWAu6uVB5S1Dchba5xmJ8YfS7kxaprBPWWMLL",
19+
"operations": {
20+
"kind": "attestation",
21+
"slot": 83,
22+
"level": 475140,
23+
"round": 0,
24+
"block_payload_hash": "vh1pDiA9BsDjscfR7hBeGnzWUGa1hPqDDwKtECZNcBYPBiB3hvsN"
25+
},
26+
"signature": "sigkUwi8AKuL9ViT56ktaEBxF7Zb4JsSSqgVewYdMjjQm9S7oY7j4aZZSWX47i9xHsMkTeauPzD47mK5XJn6Q3wzeUeaWZoq"
27+
}
28+
}
29+
]
30+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0b7e640e3e07beb8dc10a7582ad323c5788258b90186bd730d24e1962e082966020000008c449b5ed2f52b357b3a8df4794643408248e27839fdf7e2d28db64d65135c2e2e17005300074004000000009c602403e53efcd8c1c6def8dff2dce4e65169bfe3b9dc83c999401ffbf6dc5000dc86bd6bcd6cb80de43fc274409a57bb74f3fc863d67619cc94f303afdfa9d48fee1e9ddce6883cbe84642efb8f05831c0c3ebd5acdbf8e28b111cec175d470a00000094449b5ed2f52b357b3a8df4794643408248e27839fdf7e2d28db64d65135c2e2e1700530007400400000000126252e0a3e4b4912b08f9eb686b9e31589ef97749e0f2aeefcac9fa385c34fa83cdaa9680f5b5b503abef4735682bb173152481e3638d33a8dd51456334a1b6bc3c671ff626a95004a77639b29b48da6920f773fe37789574405894de77f467865647a7d076f7ef0b
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"branch": "BKoLvj4KKvpYZogKgjARRu6jzcJMqTm8NRUe47dNHKguTYUCmnx",
3+
"contents": [
4+
{
5+
"kind": "double_attestation_evidence",
6+
"op1": {
7+
"branch": "BLEVomdmPi274XtWAu6uVB5S1Dchba5xmJ8YfS7kxaprBPWWMLL",
8+
"operations": {
9+
"kind": "attestation_with_dal",
10+
"slot": 83,
11+
"level": 475140,
12+
"round": 0,
13+
"block_payload_hash": "vh2rzWxkdUALsamUHcNFi8kybDM7R26xgyFyv1WVZaowW2VWJ2ot",
14+
"dal_attestation": "0"
15+
},
16+
"signature": "sigrqfEUAcALXvU7cCeiTGzQrRmL9PE7w3pUvA5i8C5V53aUpqkQqvzic5NEwbR7zNG8ndFJTmJusS6CRLk2iBUNYamnLc4V"
17+
},
18+
"op2": {
19+
"branch": "BLEVomdmPi274XtWAu6uVB5S1Dchba5xmJ8YfS7kxaprBPWWMLL",
20+
"operations": {
21+
"kind": "attestation_with_dal",
22+
"slot": 83,
23+
"level": 475140,
24+
"round": 0,
25+
"block_payload_hash": "vh1pDiA9BsDjscfR7hBeGnzWUGa1hPqDDwKtECZNcBYPBiB3hvsN",
26+
"dal_attestation": "123123123123213123"
27+
},
28+
"signature": "sigkUwi8AKuL9ViT56ktaEBxF7Zb4JsSSqgVewYdMjjQm9S7oY7j4aZZSWX47i9xHsMkTeauPzD47mK5XJn6Q3wzeUeaWZoq"
29+
}
30+
}
31+
]
32+
}

Netezos/Forging/Local/LocalForge.Forgers.Operations.cs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ static byte[] ForgeOperation(OperationContent content)
1111
return content switch
1212
{
1313
AttestationContent op => ForgeAttestation(op),
14-
AttestationWithDalContent op => ForgeAttestationWithDal(op),
1514
PreattestationContent op => ForgePreattestation(op),
1615
BallotContent op => ForgeBallot(op),
1716
ProposalsContent op => ForgeProposals(op),
@@ -55,23 +54,25 @@ static byte[] ForgeOperation(OperationContent content)
5554

5655
static byte[] ForgeAttestation(AttestationContent operation)
5756
{
58-
return Bytes.Concat(
59-
ForgeTag(OperationTag.Attestation),
60-
ForgeInt32(operation.Slot, 2),
61-
ForgeInt32(operation.Level),
62-
ForgeInt32(operation.Round),
63-
Base58.Parse(operation.PayloadHash, Prefix.vh));
64-
}
65-
66-
static byte[] ForgeAttestationWithDal(AttestationWithDalContent operation)
67-
{
68-
return Bytes.Concat(
69-
ForgeTag(OperationTag.AttestationWithDal),
70-
ForgeInt32(operation.Slot, 2),
71-
ForgeInt32(operation.Level),
72-
ForgeInt32(operation.Round),
73-
Base58.Parse(operation.PayloadHash, Prefix.vh),
74-
ForgeMicheInt(operation.DalAttestation));
57+
if (operation.DalAttestation == null)
58+
{
59+
return Bytes.Concat(
60+
ForgeTag(OperationTag.Attestation),
61+
ForgeInt32(operation.Slot, 2),
62+
ForgeInt32(operation.Level),
63+
ForgeInt32(operation.Round),
64+
Base58.Parse(operation.PayloadHash, Prefix.vh));
65+
}
66+
else
67+
{
68+
return Bytes.Concat(
69+
ForgeTag(OperationTag.AttestationWithDal),
70+
ForgeInt32(operation.Slot, 2),
71+
ForgeInt32(operation.Level),
72+
ForgeInt32(operation.Round),
73+
Base58.Parse(operation.PayloadHash, Prefix.vh),
74+
ForgeMicheInt(operation.DalAttestation.Value));
75+
}
7576
}
7677

7778
static byte[] ForgePreattestation(PreattestationContent operation)

Netezos/Forging/Local/LocalForge.Unforgers.Operations.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,14 @@ static AttestationContent UnforgeAttestation(ForgedReader reader)
5959
Slot = reader.ReadInt32(2),
6060
Level = reader.ReadInt32(),
6161
Round = reader.ReadInt32(),
62-
PayloadHash = reader.ReadBase58(32, Prefix.vh)
62+
PayloadHash = reader.ReadBase58(32, Prefix.vh),
63+
DalAttestation = null
6364
};
6465
}
6566

66-
static AttestationWithDalContent UnforgeAttestationWithDal(ForgedReader reader)
67+
static AttestationContent UnforgeAttestationWithDal(ForgedReader reader)
6768
{
68-
return new AttestationWithDalContent
69+
return new AttestationContent
6970
{
7071
Slot = reader.ReadInt32(2),
7172
Level = reader.ReadInt32(),

Netezos/Forging/Models/Operations/Content/AttestationContent.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
using System.Text.Json.Serialization;
1+
using System.Numerics;
2+
using System.Text.Json.Serialization;
23

34
namespace Netezos.Forging.Models
45
{
56
public class AttestationContent : OperationContent
67
{
78
[JsonPropertyName("kind")]
8-
public override string Kind => "attestation";
9+
public override string Kind => DalAttestation == null ? "attestation" : "attestation_with_dal";
910

1011
[JsonPropertyName("slot")]
1112
public int Slot { get; set; }
@@ -18,5 +19,9 @@ public class AttestationContent : OperationContent
1819

1920
[JsonPropertyName("block_payload_hash")]
2021
public string PayloadHash { get; set; } = null!;
22+
23+
[JsonPropertyName("dal_attestation")]
24+
[JsonConverter(typeof(BigIntegerNullableStringConverter))]
25+
public BigInteger? DalAttestation { get; set; }
2126
}
2227
}

Netezos/Forging/Models/Operations/Content/AttestationWithDalContent.cs

Lines changed: 0 additions & 27 deletions
This file was deleted.

Netezos/Utils/Converters/OperationContentConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class OperationContentConverter : JsonConverter<OperationContent?>
2020
return sideReader.GetString() switch
2121
{
2222
"attestation" => JsonSerializer.Deserialize<AttestationContent>(ref reader, options),
23-
"attestation_with_dal" => JsonSerializer.Deserialize<AttestationWithDalContent>(ref reader, options),
23+
"attestation_with_dal" => JsonSerializer.Deserialize<AttestationContent>(ref reader, options),
2424
"preattestation" => JsonSerializer.Deserialize<PreattestationContent>(ref reader, options),
2525
"ballot" => JsonSerializer.Deserialize<BallotContent>(ref reader, options),
2626
"proposals" => JsonSerializer.Deserialize<ProposalsContent>(ref reader, options),

0 commit comments

Comments
 (0)