Skip to content

Commit

Permalink
Rename endorsements to attestations
Browse files Browse the repository at this point in the history
  • Loading branch information
Groxan committed May 22, 2024
1 parent 5539779 commit 0c8fe80
Show file tree
Hide file tree
Showing 16 changed files with 150 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"branch": "BLkEJhg3usiyEEnXo4bPn7J4ZAA92K4QJ8usSfMc6djgyWU8Jai",
"contents": [
{
"kind": "preendorsement",
"kind": "preattestation",
"slot": 0,
"level": 9168,
"round": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"branch": "BLuyhUCVEhbjwjpC7RE16sjoVNi1bvQiUdmDndUqM41vnpzqFoH",
"contents": [
{
"kind": "double_preendorsement_evidence",
"kind": "double_preattestation_evidence",
"op1": {
"branch": "BLBPGmGahGToPBGsNzwPmV5A3ciqVe5HD5nGRUVHqiJgoyMPH1t",
"operations": {
"kind": "preendorsement",
"kind": "preattestation",
"slot": 106,
"level": 35248,
"round": 1,
Expand All @@ -17,7 +17,7 @@
"op2": {
"branch": "BLBPGmGahGToPBGsNzwPmV5A3ciqVe5HD5nGRUVHqiJgoyMPH1t",
"operations": {
"kind": "preendorsement",
"kind": "preattestation",
"slot": 106,
"level": 35248,
"round": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"branch": "BL897B6K3nzQ8cD91WxYNNKdmfiCBkD4xMu2QTWmAQ6i7G1DAE1",
"contents": [
{
"kind": "endorsement",
"kind": "attestation",
"slot": 94,
"level": 9167,
"round": 0,
Expand Down
10 changes: 10 additions & 0 deletions Netezos.Tests/Rpc/TestHelpersQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ public async Task TestHelpersBakingRights()
Assert.True(res is DJsonArray);
}

[Fact]
public async Task TestHelpersAttestationRights()
{
var query = Rpc.Blocks.Head.Helpers.AttestationRights;
Assert.Equal($"chains/main/blocks/head/helpers/attestation_rights", query.ToString());

var res = await query.GetAsync();
Assert.True(res is DJsonArray);
}

[Fact]
public async Task TestHelpersCurrentLevel()
{
Expand Down
50 changes: 25 additions & 25 deletions Netezos/Forging/Local/LocalForge.Forgers.Operations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ static byte[] ForgeOperation(OperationContent content)
{
return content switch
{
AttestationContent op => ForgeAttestation(op),
AttestationWithDalContent op => ForgeAttestationWithDal(op),
EndorsementContent op => ForgeEndorsement(op),
PreendorsementContent op => ForgePreendorsement(op),
PreattestationContent op => ForgePreattestation(op),
BallotContent op => ForgeBallot(op),
ProposalsContent op => ForgeProposals(op),
ActivationContent op => ForgeActivation(op),
DoubleBakingContent op => ForgeDoubleBaking(op),
DoubleEndorsementContent op => ForgeDoubleEndorsement(op),
DoublePreendorsementContent op => ForgeDoublePreendorsement(op),
DoubleAttestationContent op => ForgeDoubleAttestation(op),
DoublePreattestationContent op => ForgeDoublePreattestation(op),
SeedNonceRevelationContent op => ForgeSeedNonceRevelation(op),
VdfRevelationContent op => ForgeVdfRevelation(op),
DrainDelegateContent op => ForgeDrainDelegate(op),
Expand Down Expand Up @@ -53,31 +53,31 @@ static byte[] ForgeOperation(OperationContent content)
};
}

static byte[] ForgeAttestationWithDal(AttestationWithDalContent operation)
static byte[] ForgeAttestation(AttestationContent operation)
{
return Bytes.Concat(
ForgeTag(OperationTag.AttestationWithDal),
ForgeTag(OperationTag.Attestation),
ForgeInt32(operation.Slot, 2),
ForgeInt32(operation.Level),
ForgeInt32(operation.Round),
Base58.Parse(operation.PayloadHash, Prefix.vh),
ForgeMicheInt(operation.DalAttestation));
Base58.Parse(operation.PayloadHash, Prefix.vh));
}

static byte[] ForgeEndorsement(EndorsementContent operation)
static byte[] ForgeAttestationWithDal(AttestationWithDalContent operation)
{
return Bytes.Concat(
ForgeTag(OperationTag.Endorsement),
ForgeTag(OperationTag.AttestationWithDal),
ForgeInt32(operation.Slot, 2),
ForgeInt32(operation.Level),
ForgeInt32(operation.Round),
Base58.Parse(operation.PayloadHash, Prefix.vh));
Base58.Parse(operation.PayloadHash, Prefix.vh),
ForgeMicheInt(operation.DalAttestation));
}

static byte[] ForgePreendorsement(PreendorsementContent operation)
static byte[] ForgePreattestation(PreattestationContent operation)
{
return Bytes.Concat(
ForgeTag(OperationTag.Preendorsement),
ForgeTag(OperationTag.Preattestation),
ForgeInt32(operation.Slot, 2),
ForgeInt32(operation.Level),
ForgeInt32(operation.Round),
Expand Down Expand Up @@ -122,20 +122,20 @@ static byte[] ForgeDoubleBaking(DoubleBakingContent operation)
ForgeArray(ForgeBlockHeader(operation.BlockHeader2)));
}

static byte[] ForgeDoubleEndorsement(DoubleEndorsementContent operation)
static byte[] ForgeDoubleAttestation(DoubleAttestationContent operation)
{
return Bytes.Concat(
ForgeTag(OperationTag.DoubleEndorsement),
ForgeArray(ForgeInlineEndorsement(operation.Op1)),
ForgeArray(ForgeInlineEndorsement(operation.Op2)));
ForgeTag(OperationTag.DoubleAttestation),
ForgeArray(ForgeInlineAttestation(operation.Op1)),
ForgeArray(ForgeInlineAttestation(operation.Op2)));
}

static byte[] ForgeDoublePreendorsement(DoublePreendorsementContent operation)
static byte[] ForgeDoublePreattestation(DoublePreattestationContent operation)
{
return Bytes.Concat(
ForgeTag(OperationTag.DoublePreendorsement),
ForgeArray(ForgeInlinePreendorsement(operation.Op1)),
ForgeArray(ForgeInlinePreendorsement(operation.Op2)));
ForgeTag(OperationTag.DoublePreattestation),
ForgeArray(ForgeInlinePreattestation(operation.Op1)),
ForgeArray(ForgeInlinePreattestation(operation.Op2)));
}

static byte[] ForgeSeedNonceRevelation(SeedNonceRevelationContent operation)
Expand Down Expand Up @@ -546,19 +546,19 @@ static byte[] ForgeBlockHeader(BlockHeader header)
Base58.Parse(header.Signature, 3));
}

static byte[] ForgeInlineEndorsement(InlineEndorsement op)
static byte[] ForgeInlineAttestation(InlineAttestation op)
{
return Bytes.Concat(
Base58.Parse(op.Branch, 2),
ForgeEndorsement(op.Operations),
ForgeAttestation(op.Operations),
Base58.Parse(op.Signature, 3));
}

static byte[] ForgeInlinePreendorsement(InlinePreendorsement op)
static byte[] ForgeInlinePreattestation(InlinePreattestation op)
{
return Bytes.Concat(
Base58.Parse(op.Branch, 2),
ForgePreendorsement(op.Operations),
ForgePreattestation(op.Operations),
Base58.Parse(op.Signature, 3));
}

Expand Down
54 changes: 27 additions & 27 deletions Netezos/Forging/Local/LocalForge.Unforgers.Operations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ static OperationContent UnforgeOperation(ForgedReader reader)
{
return (OperationTag)reader.ReadByte() switch
{
OperationTag.Attestation => UnforgeAttestation(reader),
OperationTag.AttestationWithDal => UnforgeAttestationWithDal(reader),
OperationTag.Endorsement => UnforgeEndorsement(reader),
OperationTag.Preendorsement => UnforgePreendorsement(reader),
OperationTag.Preattestation => UnforgePreattestation(reader),
OperationTag.Ballot => UnforgeBallot(reader),
OperationTag.Proposals => UnforgeProposals(reader),
OperationTag.Activation => UnforgeActivation(reader),
OperationTag.DoubleBaking => UnforgeDoubleBaking(reader),
OperationTag.DoubleEndorsement => UnforgeDoubleEndorsement(reader),
OperationTag.DoublePreendorsement => UnforgeDoublePreendorsement(reader),
OperationTag.DoubleAttestation => UnforgeDoubleAttestation(reader),
OperationTag.DoublePreattestation => UnforgeDoublePreattestation(reader),
OperationTag.SeedNonceRevelation => UnforgeSeedNonceRevelation(reader),
OperationTag.VdfRevelation => UnforgeVdfRevelation(reader),
OperationTag.DrainDelegate => UnforgeDrainDelegate(reader),
Expand Down Expand Up @@ -52,32 +52,32 @@ static OperationContent UnforgeOperation(ForgedReader reader)
};
}

static AttestationWithDalContent UnforgeAttestationWithDal(ForgedReader reader)
static AttestationContent UnforgeAttestation(ForgedReader reader)
{
return new AttestationWithDalContent
return new AttestationContent
{
Slot = reader.ReadInt32(2),
Level = reader.ReadInt32(),
Round = reader.ReadInt32(),
PayloadHash = reader.ReadBase58(32, Prefix.vh),
DalAttestation = reader.ReadMichelineInt().Value
PayloadHash = reader.ReadBase58(32, Prefix.vh)
};
}

static EndorsementContent UnforgeEndorsement(ForgedReader reader)
static AttestationWithDalContent UnforgeAttestationWithDal(ForgedReader reader)
{
return new EndorsementContent
return new AttestationWithDalContent
{
Slot = reader.ReadInt32(2),
Level = reader.ReadInt32(),
Round = reader.ReadInt32(),
PayloadHash = reader.ReadBase58(32, Prefix.vh)
PayloadHash = reader.ReadBase58(32, Prefix.vh),
DalAttestation = reader.ReadMichelineInt().Value
};
}

static PreendorsementContent UnforgePreendorsement(ForgedReader reader)
static PreattestationContent UnforgePreattestation(ForgedReader reader)
{
return new PreendorsementContent
return new PreattestationContent
{
Slot = reader.ReadInt32(2),
Level = reader.ReadInt32(),
Expand Down Expand Up @@ -125,21 +125,21 @@ static DoubleBakingContent UnforgeDoubleBaking(ForgedReader reader)
};
}

static DoubleEndorsementContent UnforgeDoubleEndorsement(ForgedReader reader)
static DoubleAttestationContent UnforgeDoubleAttestation(ForgedReader reader)
{
return new DoubleEndorsementContent
return new DoubleAttestationContent
{
Op1 = reader.ReadEnumerableSingle(UnforgeInlineEndorsement),
Op2 = reader.ReadEnumerableSingle(UnforgeInlineEndorsement)
Op1 = reader.ReadEnumerableSingle(UnforgeInlineAttestation),
Op2 = reader.ReadEnumerableSingle(UnforgeInlineAttestation)
};
}

static DoublePreendorsementContent UnforgeDoublePreendorsement(ForgedReader reader)
static DoublePreattestationContent UnforgeDoublePreattestation(ForgedReader reader)
{
return new DoublePreendorsementContent
return new DoublePreattestationContent
{
Op1 = reader.ReadEnumerableSingle(UnforgeInlinePreendorsement),
Op2 = reader.ReadEnumerableSingle(UnforgeInlinePreendorsement)
Op1 = reader.ReadEnumerableSingle(UnforgeInlinePreattestation),
Op2 = reader.ReadEnumerableSingle(UnforgeInlinePreattestation)
};
}

Expand Down Expand Up @@ -586,22 +586,22 @@ static BlockHeader UnforgeBlockHeader(ForgedReader reader)
};
}

static InlineEndorsement UnforgeInlineEndorsement(ForgedReader reader)
static InlineAttestation UnforgeInlineAttestation(ForgedReader reader)
{
return new InlineEndorsement
return new InlineAttestation
{
Branch = reader.ReadBase58(Lengths.B.Decoded, Prefix.B),
Operations = (EndorsementContent)UnforgeOperation(reader),
Operations = (AttestationContent)UnforgeOperation(reader),
Signature = reader.ReadBase58(Lengths.sig.Decoded, Prefix.sig)
};
}

static InlinePreendorsement UnforgeInlinePreendorsement(ForgedReader reader)
static InlinePreattestation UnforgeInlinePreattestation(ForgedReader reader)
{
return new InlinePreendorsement
return new InlinePreattestation
{
Branch = reader.ReadBase58(Lengths.B.Decoded, Prefix.B),
Operations = (PreendorsementContent)UnforgeOperation(reader),
Operations = (PreattestationContent)UnforgeOperation(reader),
Signature = reader.ReadBase58(Lengths.sig.Decoded, Prefix.sig)
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Netezos.Forging.Models
{
public class EndorsementContent : OperationContent
public class AttestationContent : OperationContent
{
[JsonPropertyName("kind")]
public override string Kind => "endorsement";
public override string Kind => "attestation";

[JsonPropertyName("slot")]
public int Slot { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

namespace Netezos.Forging.Models
{
public class DoubleEndorsementContent : OperationContent
public class DoubleAttestationContent : OperationContent
{
[JsonPropertyName("kind")]
public override string Kind => "double_endorsement_evidence";
public override string Kind => "double_attestation_evidence";

[JsonPropertyName("op1")]
public InlineEndorsement Op1 { get; set; } = null!;
public InlineAttestation Op1 { get; set; } = null!;

[JsonPropertyName("op2")]
public InlineEndorsement Op2 { get; set; } = null!;
public InlineAttestation Op2 { get; set; } = null!;
}

public class InlineEndorsement
public class InlineAttestation
{
[JsonPropertyName("branch")]
public string Branch { get; set; } = null!;

[JsonPropertyName("operations")]
public EndorsementContent Operations { get; set; } = null!;
public AttestationContent Operations { get; set; } = null!;

[JsonPropertyName("signature")]
public string Signature { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

namespace Netezos.Forging.Models
{
public class DoublePreendorsementContent : OperationContent
public class DoublePreattestationContent : OperationContent
{
[JsonPropertyName("kind")]
public override string Kind => "double_preendorsement_evidence";
public override string Kind => "double_preattestation_evidence";

[JsonPropertyName("op1")]
public InlinePreendorsement Op1 { get; set; } = null!;
public InlinePreattestation Op1 { get; set; } = null!;

[JsonPropertyName("op2")]
public InlinePreendorsement Op2 { get; set; } = null!;
public InlinePreattestation Op2 { get; set; } = null!;
}

public class InlinePreendorsement
public class InlinePreattestation
{
[JsonPropertyName("branch")]
public string Branch { get; set; } = null!;

[JsonPropertyName("operations")]
public PreendorsementContent Operations { get; set; } = null!;
public PreattestationContent Operations { get; set; } = null!;

[JsonPropertyName("signature")]
public string Signature { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Netezos.Forging.Models
{
public class PreendorsementContent : OperationContent
public class PreattestationContent : OperationContent
{
[JsonPropertyName("kind")]
public override string Kind => "preendorsement";
public override string Kind => "preattestation";

[JsonPropertyName("slot")]
public int Slot { get; set; }
Expand Down
Loading

0 comments on commit 0c8fe80

Please sign in to comment.