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

🔀 Port 5.3.2 to main #3993

Merged
merged 5 commits into from
Nov 22, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ Released on November 13, 2024.
[#3974]: https://github.com/planetarium/libplanet/pull/3974


Version 5.3.2
-------------

Released on November 21, 2024

- There is no longer a check at block validation time to see
if the actions contained in a block are interpretable. [[#3973]]

[#3973]: https://github.com/planetarium/libplanet/pull/3973


Version 5.3.1
-------------

Expand Down
12 changes: 0 additions & 12 deletions src/Libplanet/Blockchain/BlockChain.Validate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using Bencodex.Types;
using Libplanet.Action;
using Libplanet.Action.State;
using Libplanet.Common;
Expand Down Expand Up @@ -196,17 +195,6 @@ internal Dictionary<Address, long> ValidateBlockNonces(
return nonceDeltas;
}

internal void ValidateBlockLoadActions(Block block)
{
foreach (Transaction tx in block.Transactions)
{
foreach (IValue rawAction in tx.Actions)
{
_ = ActionEvaluator.ActionLoader.LoadAction(block.Index, rawAction);
}
}
}

internal void ValidateBlock(Block block)
{
if (block.Index <= 0)
Expand Down
2 changes: 0 additions & 2 deletions src/Libplanet/Blockchain/BlockChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,6 @@ internal void Append(
.ToDictionary(signer => signer, signer => Store.GetTxNonce(Id, signer)),
block);

ValidateBlockLoadActions(block);

if (Policy.ValidateNextBlock(this, block) is { } bpve)
{
throw bpve;
Expand Down
50 changes: 0 additions & 50 deletions test/Libplanet.Tests/Blockchain/BlockChainTest.Append.cs
Original file line number Diff line number Diff line change
Expand Up @@ -651,56 +651,6 @@ void AssertTxIdSetEqual(
_blockChain.StagePolicy.Iterate(_blockChain, filtered: false).Select(tx => tx.Id));
}

[SkippableFact]
public void CannotAppendBlockWithInvalidActions()
{
var txSigner = new PrivateKey();
var unsignedInvalidTx = new UnsignedTx(
new TxInvoice(
_blockChain.Genesis.Hash,
DateTimeOffset.UtcNow,
new TxActionList((IValue)List.Empty.Add(new Text("Foo")))), // Invalid action
new TxSigningMetadata(txSigner.PublicKey, 1));
var invalidTx = new Transaction(
unsignedInvalidTx, unsignedInvalidTx.CreateSignature(txSigner));
var txs = new[]
{
Transaction.Create(
nonce: 0,
privateKey: txSigner,
genesisHash: _blockChain.Genesis.Hash,
actions: Array.Empty<DumbAction>().ToPlainValues()),
invalidTx,
Transaction.Create(
nonce: 2,
privateKey: txSigner,
genesisHash: _blockChain.Genesis.Hash,
actions: Array.Empty<DumbAction>().ToPlainValues()),
}.OrderBy(tx => tx.Id);
var evs = Array.Empty<EvidenceBase>();

var metadata = new BlockMetadata(
index: 1L,
timestamp: DateTimeOffset.UtcNow,
publicKey: _fx.Proposer.PublicKey,
previousHash: _blockChain.Genesis.Hash,
txHash: BlockContent.DeriveTxHash(txs),
lastCommit: null,
evidenceHash: null);
var preEval = new PreEvaluationBlock(
preEvaluationBlockHeader: new PreEvaluationBlockHeader(
metadata, metadata.DerivePreEvaluationHash()),
transactions: txs,
evidence: evs);
var block = preEval.Sign(
_fx.Proposer,
(HashDigest<SHA256>)_blockChain.GetNextStateRootHash(_blockChain.Tip.Hash));

Assert.Throws<InvalidActionException>(
() => _blockChain.Append(block, TestUtils.CreateBlockCommit(block)));
Assert.Equal(0, _blockChain.Tip.Index);
}

[SkippableFact]
public void DoesNotMigrateStateWithoutAction()
{
Expand Down
Loading