Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use protocol version of existing block #1162

Merged
merged 2 commits into from Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions CHANGES.md
Expand Up @@ -11,11 +11,11 @@ To be released.
- Added the parameter `protocolVersion` to `Block<T>(long, long, BigInteger,
Nonce, Address?, HashDigest<SHA256>?, DateTimeOffset,
IEnumerable<Transaction<T>> transactions, HashDigest<SHA256>?,
HashDigest<SHA256>?)` constructor. [[#1142], [#1147]]
HashDigest<SHA256>?)` constructor. [[#1142], [#1147], [#1162]]
- Added the parameter to `protocolVersion` to `Block<T>.Mine()` method.
[[#1142], [#1147]]
[[#1142], [#1147], [#1162]]
- Added the first parameter `protocolVersion` to `BlockHeader()` constructor.
[[#1142], [#1147]]
[[#1142], [#1147], [#1162]]
- Added `stagePolicy` as the second parameter to `BlockChain<T>()`
constructor. [[#1130], [#1131]]
- Removed `IBlockStatesStore` interface. [[#1117]]
Expand Down Expand Up @@ -99,10 +99,10 @@ To be released.
- Introduced the [protocol versioning scheme][#1142]. This purposes to change
the protocol without breaking backward compatibility. Even the protocol
is changed, the existing blocks made before the new protocol are guaranteed
to behave as it had done. [[#1142], [#1147]]
to behave as it had done. [[#1142], [#1147], [#1162]]
- Since `BlockHeader.ProtocolVersion` was added, the existing blocks are
considered protocol compliant with the protocol version zero.
[[#1142], [#1147]]
[[#1142], [#1147], [#1162]]
- When a `BlockChain<T>` follows `VolatileStagePolicy<T>`, which is
Libplanet's the only built-in `IStagePolicy<T>` implementation at
the moment, as its `StagePolicy`, its staged transactions are no longer
Expand Down Expand Up @@ -177,6 +177,7 @@ To be released.
[#1143]: https://github.com/planetarium/libplanet/pull/1143
[#1147]: https://github.com/planetarium/libplanet/pull/1147
[#1152]: https://github.com/planetarium/libplanet/pull/1152
[#1162]: https://github.com/planetarium/libplanet/pull/1162


Version 0.10.2
Expand Down
18 changes: 18 additions & 0 deletions Libplanet.Tests/Store/StoreTest.cs
Expand Up @@ -646,6 +646,24 @@ public void Copy()
}
}

[SkippableFact]
public void GetBlock()
{
using (StoreFixture fx = FxConstructor())
{
Block<DumbAction> genesisBlock = fx.GenesisBlock;
// NOTE: it depends on that Block<T>.CurrentProtocolVersion is not 0.
Block<DumbAction> block = TestUtils.MineNext(
genesisBlock,
protocolVersion: 0);

fx.Store.PutBlock(block);
Block<DumbAction> storedBlock = fx.Store.GetBlock<DumbAction>(block.Hash);

Assert.Equal(block, storedBlock);
}
}

private class AtomicityTestAction : IAction
{
public ImmutableArray<byte> ArbitraryBytes { get; set; }
Expand Down
3 changes: 2 additions & 1 deletion Libplanet/Store/BaseStore.cs
Expand Up @@ -94,7 +94,8 @@ public Block<T> GetBlock<T>(HashDigest<SHA256> blockHash)
transactions: blockDigest.TxIds
.Select(bytes => GetTransaction<T>(new TxId(bytes.ToArray()))),
preEvaluationHash: preEvaluationHash,
stateRootHash: stateRootHash
stateRootHash: stateRootHash,
protocolVersion: blockDigest.Header.ProtocolVersion
);
}

Expand Down