Skip to content

Commit

Permalink
Merge remote-tracking branch 'ZhangTao1596/dbft-constructor' into dbf…
Browse files Browse the repository at this point in the history
…t-constructor
  • Loading branch information
shargon committed Mar 10, 2021
2 parents 8319255 + f62e71a commit 71ba43f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 41 deletions.
50 changes: 10 additions & 40 deletions src/DBFTPlugin/RecoveryMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,12 @@ public RecoveryMessage(int validatorsCount) : base(ConsensusMessageType.Recovery
public override void Deserialize(BinaryReader reader)
{
base.Deserialize(reader);
ChangeViewMessages = new Dictionary<int, ChangeViewPayloadCompact>();
ulong count = reader.ReadVarInt(validatorsCount);
for (ulong i = 0; i < count; i++)
{
ChangeViewPayloadCompact payload = new();
payload.Deserialize(reader);

if (payload.ValidatorIndex >= validatorsCount)
throw new FormatException();

ChangeViewMessages.Add(payload.ValidatorIndex, payload);
}
ChangeViewMessages = reader.ReadSerializableArray<ChangeViewPayloadCompact>((int)validatorsCount).ToDictionary(p => (int)p.ValidatorIndex);
if (ChangeViewMessages.Values.Any(p => p.ValidatorIndex >= validatorsCount))
throw new FormatException();
if (reader.ReadBoolean())
{
PrepareRequestMessage = new PrepareRequest();
PrepareRequestMessage.Deserialize(reader);

PrepareRequestMessage = reader.ReadSerializable<PrepareRequest>();
if (PrepareRequestMessage.ValidatorIndex >= validatorsCount)
throw new FormatException();
}
Expand All @@ -61,31 +50,12 @@ public override void Deserialize(BinaryReader reader)
PreparationHash = new UInt256(reader.ReadFixedBytes(preparationHashSize));
}

PreparationMessages = new Dictionary<int, PreparationPayloadCompact>();
count = reader.ReadVarInt(validatorsCount);
for (ulong i = 0; i < count; i++)
{
PreparationPayloadCompact payload = new();
payload.Deserialize(reader);

if (payload.ValidatorIndex >= validatorsCount)
throw new FormatException();

PreparationMessages.Add(payload.ValidatorIndex, payload);
}

CommitMessages = new Dictionary<int, CommitPayloadCompact>();
count = reader.ReadVarInt(validatorsCount);
for (ulong i = 0; i < count; i++)
{
CommitPayloadCompact payload = new();
payload.Deserialize(reader);

if (payload.ValidatorIndex >= validatorsCount)
throw new FormatException();

CommitMessages.Add(payload.ValidatorIndex, payload);
}
PreparationMessages = reader.ReadSerializableArray<PreparationPayloadCompact>((int)validatorsCount).ToDictionary(p => (int)p.ValidatorIndex);
if (PreparationMessages.Values.Any(p => p.ValidatorIndex >= validatorsCount))
throw new FormatException();
CommitMessages = reader.ReadSerializableArray<CommitPayloadCompact>((int)validatorsCount).ToDictionary(p => (int)p.ValidatorIndex);
if (CommitMessages.Values.Any(p => p.ValidatorIndex >= validatorsCount))
throw new FormatException();
}

internal ExtensiblePayload[] GetChangeViewPayloads(ConsensusContext context)
Expand Down
2 changes: 1 addition & 1 deletion src/RpcServer/RpcServer.Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ private JObject GetVerificationResult(UInt160 scriptHash, ContractParameter[] ar
wallet.Sign(context);
tx.Witnesses = context.Completed ? context.GetWitnesses() : null;

using ApplicationEngine engine = ApplicationEngine.Create(TriggerType.Verification, tx, snapshot.CreateSnapshot());
using ApplicationEngine engine = ApplicationEngine.Create(TriggerType.Verification, tx, snapshot.CreateSnapshot(), settings: system.Settings);
engine.LoadScript(new ScriptBuilder().EmitDynamicCall(scriptHash, methodName, args).ToArray(), rvcount: 1);

JObject json = new JObject();
Expand Down

0 comments on commit 71ba43f

Please sign in to comment.