Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/leveldb-thread-ut' into leveldb-…
Browse files Browse the repository at this point in the history
…thread-ut
  • Loading branch information
Jim8y committed Sep 27, 2024
2 parents 592b9a7 + 614586c commit 7c62243
Show file tree
Hide file tree
Showing 24 changed files with 1,704 additions and 92 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ indent_size = 2
end_of_line = lf
indent_size = 2

# YAML files
[*.yml]
end_of_line = lf
indent_size = 2

# Dotnet code style settings:
[*.{cs,vb}]
# Member can be made 'readonly'
Expand Down
91 changes: 33 additions & 58 deletions .github/workflows/pkgs-delete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,78 +61,53 @@ jobs:
shell: python

delete-git-pkgs:
name: Delete Old Nuget Packages
delete-git-docker-pkgs:
name: Delete Old Docker Images
runs-on: ubuntu-latest

steps:
- name: Delete Neo.Cryptography.BLS12_381 Package
uses: actions/delete-package-versions@v4
with:
package-name: Neo.Cryptography.BLS12_381
package-type: nuget
min-versions-to-keep: 3
delete-only-pre-release-versions: "true"
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Delete Neo.VM Package
uses: actions/delete-package-versions@v4
with:
package-name: Neo.VM
package-type: nuget
min-versions-to-keep: 3
delete-only-pre-release-versions: "true"
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Delete Neo.Json Package
uses: actions/delete-package-versions@v4
with:
package-name: Neo.Json
package-type: nuget
min-versions-to-keep: 3
delete-only-pre-release-versions: "true"
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Delete Neo.IO Package
uses: actions/delete-package-versions@v4
with:
package-name: Neo.IO
package-type: nuget
min-versions-to-keep: 3
delete-only-pre-release-versions: "true"
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Delete Neo Package (nuget)
uses: actions/delete-package-versions@v4
with:
package-name: Neo
package-type: nuget
min-versions-to-keep: 3
delete-only-pre-release-versions: "true"
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Delete Neo Package (docker)
uses: actions/delete-package-versions@v4
continue-on-error: true
with:
package-name: Neo
package-type: docker
min-versions-to-keep: 1
delete-only-pre-release-versions: "true"
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Delete Neo.ConsoleService Package
uses: actions/delete-package-versions@v4
with:
package-name: Neo.ConsoleService
package-type: nuget
min-versions-to-keep: 3
delete-only-pre-release-versions: "true"
token: "${{ secrets.GITHUB_TOKEN }}"
delete-git-nuget-pkgs:
name: Delete Old Nuget Packages
strategy:
matrix:
pkgs:
- "Neo.Plugins.StatesDumper"
- "Neo.Plugins.StateService"
- "Neo.Plugins.Storage.LevelDBStore"
- "Neo.Plugins.Storage.RocksDBStore"
- "Neo.Plugins.StorageDumper"
- "Neo.Plugins.TokensTracker"
- "Neo.Wallets.SQLite"
- "Neo.Consensus.DBFT"
- "Neo.ConsoleService"
- "Neo.Cryptography.MPT"
- "Neo.Extensions"
- "Neo.Network.RPC.RpcClient"
- "Neo.Plugins.ApplicationLogs"
- "Neo.Plugins.OracleService"
- "Neo.Plugins.RpcServer"
- "Neo.Cryptography.BLS12_381"
- "Neo.VM"
- "Neo.Json"
- "Neo.IO"
- "Neo"
runs-on: ubuntu-latest

- name: Delete Neo.Extensions Package
steps:
- name: Delete ${{ matrix.pkgs }} Package
uses: actions/delete-package-versions@v4
continue-on-error: true
with:
package-name: Neo.Extensions
package-name: ${{ matrix.pkgs }}
package-type: nuget
min-versions-to-keep: 3
delete-only-pre-release-versions: "true"
Expand Down
54 changes: 54 additions & 0 deletions src/Neo.CLI/CLI/MainService.Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
using Neo.Extensions;
using Neo.IO;
using Neo.SmartContract;
using Neo.VM;
using Neo.Wallets;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection;
Expand Down Expand Up @@ -441,6 +443,58 @@ private static string Base64Fixed(string str)
}
}

/// <summary>
/// Base64 .nef file Analysis
/// </summary>
[ParseFunction("Base64 .nef file Analysis")]
private string? NefFileAnalyis(string base64)
{
byte[] nefData;
if (File.Exists(base64)) // extension name not considered
nefData = File.ReadAllBytes(base64);
else
{
try
{
nefData = Convert.FromBase64String(base64);
}
catch { return null; }
}
NefFile nef;
Script script;
bool verifyChecksum = false;
bool strictMode = false;
try
{
nef = NefFile.Parse(nefData, true);
verifyChecksum = true;
}
catch (FormatException)
{
nef = NefFile.Parse(nefData, false);
}
catch { return null; }
try
{
script = new Script(nef.Script, true);
strictMode = true;
}
catch (BadScriptException)
{
script = new Script(nef.Script, false);
}
catch { return null; }
string? result = ScriptsToOpCode(Convert.ToBase64String(nef.Script.ToArray()));
if (result == null)
return null;
string prefix = $"\r\n# Compiler: {nef.Compiler}";
if (!verifyChecksum)
prefix += $"\r\n# Warning: Invalid .nef file checksum";
if (!strictMode)
prefix += $"\r\n# Warning: Failed in {nameof(strictMode)}";
return prefix + result;
}

/// <summary>
/// Checks if the string is null or cannot be printed.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Neo.VM/JumpTable/JumpTable.Compound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ public virtual void ClearItems(ExecutionEngine engine, Instruction instruction)
/// </summary>
/// <param name="engine">The execution engine.</param>
/// <param name="instruction">The instruction being executed.</param>
/// <remarks>Pop 1, Push 0</remarks>
/// <remarks>Pop 1, Push 1</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public virtual void PopItem(ExecutionEngine engine, Instruction instruction)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Neo.VM/OpCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,7 @@ public enum OpCode : byte
/// Using this opcode will need to dup the array before using it.
///
/// <remarks>
/// Push: 0 item(s)
/// Push: 1 item(s)
/// Pop: 1 item(s)
/// </remarks>
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion src/Neo.VM/ScriptBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ public ScriptBuilder EmitPush(BigInteger value)
<= 4 => Emit(OpCode.PUSHINT32, PadRight(buffer, bytesWritten, 4, value.Sign < 0)),
<= 8 => Emit(OpCode.PUSHINT64, PadRight(buffer, bytesWritten, 8, value.Sign < 0)),
<= 16 => Emit(OpCode.PUSHINT128, PadRight(buffer, bytesWritten, 16, value.Sign < 0)),
_ => Emit(OpCode.PUSHINT256, PadRight(buffer, bytesWritten, 32, value.Sign < 0)),
<= 32 => Emit(OpCode.PUSHINT256, PadRight(buffer, bytesWritten, 32, value.Sign < 0)),
_ => throw new ArgumentOutOfRangeException(nameof(value), "Invalid value: BigInteger is too large"),
};
}

Expand Down
90 changes: 90 additions & 0 deletions src/Neo/Builders/AndConditionBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// AndConditionBuilder.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
// for more details.
//
// Redistribution and use in source and binary forms with or without
// modifications are permitted.

using Neo.Cryptography.ECC;
using Neo.Network.P2P.Payloads.Conditions;
using System;

namespace Neo.Builders
{
public sealed class AndConditionBuilder
{
private readonly AndCondition _condition = new() { Expressions = [] };

private AndConditionBuilder() { }

public static AndConditionBuilder CreateEmpty()
{
return new AndConditionBuilder();
}

public AndConditionBuilder And(Action<AndConditionBuilder> config)
{
var acb = new AndConditionBuilder();
config(acb);

_condition.Expressions = [.. _condition.Expressions, acb.Build()];

return this;
}

public AndConditionBuilder Or(Action<OrConditionBuilder> config)
{
var ocb = OrConditionBuilder.CreateEmpty();
config(ocb);

_condition.Expressions = [.. _condition.Expressions, ocb.Build()];

return this;
}

public AndConditionBuilder Boolean(bool expression)
{
_condition.Expressions = [.. _condition.Expressions, new BooleanCondition { Expression = expression }];
return this;
}

public AndConditionBuilder CalledByContract(UInt160 hash)
{
_condition.Expressions = [.. _condition.Expressions, new CalledByContractCondition { Hash = hash }];
return this;
}

public AndConditionBuilder CalledByEntry()
{
_condition.Expressions = [.. _condition.Expressions, new CalledByEntryCondition()];
return this;
}

public AndConditionBuilder CalledByGroup(ECPoint publicKey)
{
_condition.Expressions = [.. _condition.Expressions, new CalledByGroupCondition { Group = publicKey }];
return this;
}

public AndConditionBuilder Group(ECPoint publicKey)
{
_condition.Expressions = [.. _condition.Expressions, new GroupCondition() { Group = publicKey }];
return this;
}

public AndConditionBuilder ScriptHash(UInt160 scriptHash)
{
_condition.Expressions = [.. _condition.Expressions, new ScriptHashCondition() { Hash = scriptHash }];
return this;
}

public AndCondition Build()
{
return _condition;
}
}
}
Loading

0 comments on commit 7c62243

Please sign in to comment.