Skip to content

Commit

Permalink
validator_public_key
Browse files Browse the repository at this point in the history
  • Loading branch information
rjnrohit committed Jun 12, 2024
1 parent 3ed58a3 commit 7ccaca1
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ WithdrawalRequest[] CalculateValidatorExits(IReleaseSpec spec, IWorldState state
WithdrawalRequest request = new();
Span<byte> span = new Span<byte>(result, i * sizeOfClass, sizeOfClass);
request.SourceAddress = new Address(span.Slice(0, 20).ToArray());
request.ValidatorPublicKey = span.Slice(20, 48).ToArray();
request.ValidatorPubKey = span.Slice(20, 48).ToArray();
request.Amount = BitConverter.ToUInt64(span.Slice(68, 8));

withdrawalRequests.Add(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public IEnumerable<WithdrawalRequest> ReadWithdrawalRequests(IReleaseSpec spec,
WithdrawalRequest request = new();
Span<byte> span = new Span<byte>(result, i * sizeOfClass, sizeOfClass);
request.SourceAddress = new Address(span.Slice(0, 20).ToArray());
request.ValidatorPublicKey = span.Slice(20, 48).ToArray();
request.ValidatorPubKey = span.Slice(20, 48).ToArray();
request.Amount = BitConverter.ToUInt64(span.Slice(68, 8).ToArray().Reverse().ToArray()); // ToDo Optimize

yield return request;
Expand Down
12 changes: 6 additions & 6 deletions src/Nethermind/Nethermind.Core.Test/Builders/TestItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ public static Hash256 KeccakFromNumber(int i)
public static Deposit DepositF_6Eth = new() { Index = 6, Pubkey = PublicKeyF.Bytes, Amount = 6_000_000_000, WithdrawalCredentials = AddressF.Bytes, Signature = KeccakF.Bytes.ToArray() };


public static WithdrawalRequest WithdrawalRequestA = new() { SourceAddress = AddressA, ValidatorPublicKey = PublicKeyA.Bytes };
public static WithdrawalRequest WithdrawalRequestB = new() { SourceAddress = AddressB, ValidatorPublicKey = PublicKeyB.Bytes };
public static WithdrawalRequest WithdrawalRequestC = new() { SourceAddress = AddressC, ValidatorPublicKey = PublicKeyC.Bytes };
public static WithdrawalRequest WithdrawalRequestD = new() { SourceAddress = AddressD, ValidatorPublicKey = PublicKeyD.Bytes };
public static WithdrawalRequest WithdrawalRequestE = new() { SourceAddress = AddressE, ValidatorPublicKey = PublicKeyE.Bytes };
public static WithdrawalRequest WithdrawalRequestF = new() { SourceAddress = AddressF, ValidatorPublicKey = PublicKeyF.Bytes };
public static WithdrawalRequest WithdrawalRequestA = new() { SourceAddress = AddressA, ValidatorPubKey = PublicKeyA.Bytes };
public static WithdrawalRequest WithdrawalRequestB = new() { SourceAddress = AddressB, ValidatorPubKey = PublicKeyB.Bytes };
public static WithdrawalRequest WithdrawalRequestC = new() { SourceAddress = AddressC, ValidatorPubKey = PublicKeyC.Bytes };
public static WithdrawalRequest WithdrawalRequestD = new() { SourceAddress = AddressD, ValidatorPubKey = PublicKeyD.Bytes };
public static WithdrawalRequest WithdrawalRequestE = new() { SourceAddress = AddressE, ValidatorPubKey = PublicKeyE.Bytes };
public static WithdrawalRequest WithdrawalRequestF = new() { SourceAddress = AddressF, ValidatorPubKey = PublicKeyF.Bytes };

public static IPEndPoint IPEndPointA = IPEndPoint.Parse("10.0.0.1");
public static IPEndPoint IPEndPointB = IPEndPoint.Parse("10.0.0.2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public WithdrawalRequestBuilder WithSourceAddress(Address sourceAddress)

public WithdrawalRequestBuilder WithValidatorPubkey(byte[] validatorPubkey)
{
TestObject.ValidatorPublicKey = validatorPubkey;
TestObject.ValidatorPubKey = validatorPubkey;

return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void Roundtrip_withdrawalRequest()
ConsensusRequest withdrawalRequest = new WithdrawalRequest()
{
SourceAddress = TestItem.AddressA,
ValidatorPublicKey = validatorPubkey,
ValidatorPubKey = validatorPubkey,
Amount = int.MaxValue
};

Expand Down Expand Up @@ -78,7 +78,7 @@ public void Should_decode_withdrawalRequest_with_ValueDecoderContext()
ConsensusRequest withdrawalRequest = new WithdrawalRequest()
{
SourceAddress = TestItem.AddressA,
ValidatorPublicKey = KeccakTests.KeccakOfAnEmptyString.ToBytes(),
ValidatorPubKey = KeccakTests.KeccakOfAnEmptyString.ToBytes(),
Amount = int.MaxValue
};
RlpStream stream = new(1024);
Expand Down Expand Up @@ -115,7 +115,7 @@ public void Should_encode_withdrawalRequest_same_for_Rlp_Encode_and_DepositDecod
ConsensusRequest withdrawalRequest = new WithdrawalRequest()
{
SourceAddress = TestItem.AddressA,
ValidatorPublicKey = KeccakTests.KeccakOfAnEmptyString.ToBytes(),
ValidatorPubKey = KeccakTests.KeccakOfAnEmptyString.ToBytes(),
Amount = int.MaxValue
};
byte[] rlp1 = new ConsensusRequestDecoder().Encode(withdrawalRequest).Bytes;
Expand All @@ -140,7 +140,7 @@ public void Should_encode_ConsensusRequests_Array()
new WithdrawalRequest()
{
SourceAddress = TestItem.AddressA,
ValidatorPublicKey = KeccakTests.KeccakOfAnEmptyString.ToBytes(),
ValidatorPubKey = KeccakTests.KeccakOfAnEmptyString.ToBytes(),
Amount = int.MaxValue
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public Address? SourceAddress
set { SourceAddressField = value; }
}

public byte[]? ValidatorPublicKey
public byte[]? ValidatorPubKey
{
get { return PubKeyField; }
set { PubKeyField = value; }
Expand All @@ -36,7 +36,7 @@ public ulong Amount

public string ToString(string indentation) => @$"{indentation}{nameof(WithdrawalRequest)}
{{{nameof(SourceAddress)}: {SourceAddress},
{nameof(ValidatorPublicKey)}: {ValidatorPublicKey?.ToHexString()},
{nameof(ValidatorPubKey)}: {ValidatorPubKey?.ToHexString()},
{nameof(Amount)}: {Amount}}}";


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public int GetLength(WithdrawalRequest item, RlpBehaviors rlpBehaviors) =>
Rlp.LengthOfSequence(GetContentLength(item, rlpBehaviors));

public int GetContentLength(WithdrawalRequest item, RlpBehaviors rlpBehaviors) =>
Rlp.LengthOf(item.SourceAddress) + Rlp.LengthOf(item.ValidatorPublicKey) +
Rlp.LengthOf(item.SourceAddress) + Rlp.LengthOf(item.ValidatorPubKey) +
Rlp.LengthOf(item.Amount);

public WithdrawalRequest Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None)
Expand All @@ -26,7 +26,7 @@ public WithdrawalRequest Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors =
return new WithdrawalRequest()
{
SourceAddress = sourceAddress,
ValidatorPublicKey = validatorPubkey,
ValidatorPubKey = validatorPubkey,
Amount = amount
};
}
Expand All @@ -41,7 +41,7 @@ public WithdrawalRequest Decode(ref Rlp.ValueDecoderContext decoderContext, RlpB
return new WithdrawalRequest()
{
SourceAddress = sourceAddress,
ValidatorPublicKey = validatorPubkey,
ValidatorPubKey = validatorPubkey,
Amount = amount
};
}
Expand All @@ -51,7 +51,7 @@ public void Encode(RlpStream stream, WithdrawalRequest item, RlpBehaviors rlpBeh
int contentLength = GetContentLength(item, rlpBehaviors);
stream.StartSequence(contentLength);
stream.Encode(item.SourceAddress);
stream.Encode(item.ValidatorPublicKey);
stream.Encode(item.ValidatorPubKey);
stream.Encode(item.Amount);
}

Expand Down

0 comments on commit 7ccaca1

Please sign in to comment.