Skip to content

Commit

Permalink
Merge branch 'master' into expression-comment
Browse files Browse the repository at this point in the history
* master:
  [Framework Add] predefine manifest (neo-project#903)
  TestEngine: Get instruction coverage and move to net standard (neo-project#898)
  remove disable PublishToGithub (neo-project#901)
  Added `publish` to `github packages` and fix submodules (neo-project#899)
  bug: Fix default value when Stored (neo-project#895)
  Modify changelog during release (neo-project#900)
  Fixed `PackageReference` for `neo` (neo-project#897)
  cancel optimization on exception
  fix catch
  new Testing environment (neo-project#890)
  Updated submodule neo (neo-project#892)
  Update and fix Nep17 template (neo-project#891)
  • Loading branch information
Jim8y committed Feb 15, 2024
2 parents 4cd8139 + dfb1d3d commit 2c8d94a
Show file tree
Hide file tree
Showing 58 changed files with 4,483 additions and 102 deletions.
48 changes: 15 additions & 33 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,6 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}

PublishGithub:
# Because sometimes this action is not working as expected we will disable it until determine that it's more stable
if: false && github.ref == 'refs/heads/master' && startsWith(github.repository, 'neo-project/')
needs: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Setup NuGet.exe for use with actions
uses: NuGet/setup-nuget@v1
with:
nuget-version: latest
- name: Pack with dotnet
run: git rev-list --count HEAD | xargs printf "CI%05d" | xargs dotnet pack src/Neo.SmartContract.Framework -c Debug -o out --include-source --version-suffix
- name: Publish to Github Packages
run: |
nuget source Add -Name "GitHub" -Source "https://nuget.pkg.github.com/neo-project/index.json" -UserName neo-project -Password "${{ secrets.GITHUB_TOKEN }}"
nuget push out/*.nupkg -Source "GitHub"
PublishMyGet:
if: github.ref == 'refs/heads/master' && startsWith(github.repository, 'neo-project/')
needs: Test
runs-on: ubuntu-latest
Expand All @@ -83,29 +58,35 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Set Version
run: git rev-list --count HEAD | xargs printf 'CI%05d' | xargs -I{} echo 'VERSION_SUFFIX={}' >> $GITHUB_ENV
- name: Pack Package(s)

- name : Pack (Neo.SmartContract.Framework)
run: |
dotnet pack ./src/Neo.SmartContract.Framework \
--configuration Debug \
--output ./out \
--version-suffix ${{ env.VERSION_SUFFIX }}
- name: Publish to MyGet
- name : Pack (Neo.SmartContract.Testing)
run: |
dotnet pack ./src/Neo.SmartContract.Testing \
--configuration Debug \
--output ./out \
--version-suffix ${{ env.VERSION_SUFFIX }}
- name: Publish to Github Packages
working-directory: ./out
run: |
for filename in *.nupkg; do
dotnet nuget push "${filename}" \
--source https://www.myget.org/F/neo/api/v3/index.json \
--api-key "${{ secrets.MYGET_TOKEN }}" \
dotnet nuget push * \
--source https://nuget.pkg.github.com/neo-project/index.json \
--api-key "${{ secrets.GITHUB_TOKEN }}" \
--disable-buffering \
--no-service-endpoint;
done;
shell: bash
Release:
if: github.ref == 'refs/heads/master' && startsWith(github.repository, 'neo-project/')
Expand All @@ -116,6 +97,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Get version
id: get_version
run: |
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/pkgs-delete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Nuget Package Cleanup (github)

on:
schedule:
- cron: '0 0 * * *' # Run every day at 24:00

jobs:
delete-pkgs:
name: Delete Old Nuget Packages
runs-on: ubuntu-latest

steps:
- name: Delete Neo.SmartContract.Testing Package
uses: actions/delete-package-versions@v4
with:
package-name: Neo.SmartContract.Testing
package-type: nuget
min-versions-to-keep: 3
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Delete Neo.SmartContract.Framework Package
uses: actions/delete-package-versions@v4
with:
package-name: Neo.Neo.SmartContract.Framework
package-type: nuget
min-versions-to-keep: 3
token: "${{ secrets.GITHUB_TOKEN }}"
16 changes: 16 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
changelog:
exclude:
labels:
- ignore-for-release
authors:
- octocat
categories:
- title: Breaking Changes 🛠
labels:
- breaking-change
- title: Exciting New Features 🎉
labels:
- enhancement
- title: What's Changed
labels:
- "*"
2 changes: 1 addition & 1 deletion NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<configuration>
<packageSources>
<clear />
<add key="MyGet-neo" value="https://www.myget.org/F/neo/api/v3/index.json" />
<add key="github" value="https://nuget.pkg.github.com/neo-project/index.json" />
<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
2 changes: 1 addition & 1 deletion neo
34 changes: 24 additions & 10 deletions neo-devpack-dotnet.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.452
# Visual Studio Version 17
VisualStudioVersion = 17.7.34003.232
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.SmartContract.Framework", "src\Neo.SmartContract.Framework\Neo.SmartContract.Framework.csproj", "{C30B5859-D4B9-46E8-A797-6B0A1B49B590}"
EndProject
Expand All @@ -16,22 +16,26 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{79389FC0-C62
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{D5266066-0AFD-44D5-A83E-2F73668A63C8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Compiler.CSharp.TestContracts", "tests\Neo.Compiler.CSharp.TestContracts\Neo.Compiler.CSharp.TestContracts.csproj", "{8D67DD5A-D683-481F-915E-98683EA38791}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.Compiler.CSharp.TestContracts", "tests\Neo.Compiler.CSharp.TestContracts\Neo.Compiler.CSharp.TestContracts.csproj", "{8D67DD5A-D683-481F-915E-98683EA38791}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.SmartContract.Framework.TestContracts", "tests\Neo.SmartContract.Framework.TestContracts\Neo.SmartContract.Framework.TestContracts.csproj", "{A372F1D6-51FF-472C-9508-FDAF7E6FEB13}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.SmartContract.Framework.TestContracts", "tests\Neo.SmartContract.Framework.TestContracts\Neo.SmartContract.Framework.TestContracts.csproj", "{A372F1D6-51FF-472C-9508-FDAF7E6FEB13}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.SmartContract.TestEngine", "tests\Neo.SmartContract.TestEngine\Neo.SmartContract.TestEngine.csproj", "{D0153204-6AEF-4D94-B0E1-8124C38C91D4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.SmartContract.TestEngine", "tests\Neo.SmartContract.TestEngine\Neo.SmartContract.TestEngine.csproj", "{D0153204-6AEF-4D94-B0E1-8124C38C91D4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo", "neo\src\Neo\Neo.csproj", "{73223FBD-C562-4FA0-9722-C7F1C382A9DE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo", "neo\src\Neo\Neo.csproj", "{73223FBD-C562-4FA0-9722-C7F1C382A9DE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Cryptography.BLS12_381", "neo\src\Neo.Cryptography.BLS12_381\Neo.Cryptography.BLS12_381.csproj", "{D541BCE9-65BC-475B-94E5-19B6BFFF2B8E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.Cryptography.BLS12_381", "neo\src\Neo.Cryptography.BLS12_381\Neo.Cryptography.BLS12_381.csproj", "{D541BCE9-65BC-475B-94E5-19B6BFFF2B8E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Json", "neo\src\Neo.Json\Neo.Json.csproj", "{35A34EBD-F2BF-4D83-A096-D5F007B12732}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.Json", "neo\src\Neo.Json\Neo.Json.csproj", "{35A34EBD-F2BF-4D83-A096-D5F007B12732}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.VM", "neo\src\Neo.VM\Neo.VM.csproj", "{D6D53889-5A10-46A4-BA66-E78B56EC1881}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.VM", "neo\src\Neo.VM\Neo.VM.csproj", "{D6D53889-5A10-46A4-BA66-E78B56EC1881}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependency", "Dependency", "{49D5873D-7B38-48A5-B853-85146F032091}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.SmartContract.Testing", "src\Neo.SmartContract.Testing\Neo.SmartContract.Testing.csproj", "{648DCE6F-A0BA-4032-951B-20CF5BBFD998}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.SmartContract.Testing.UnitTests", "tests\Neo.SmartContract.Testing.UnitTests\Neo.SmartContract.Testing.UnitTests.csproj", "{B772B8A9-9362-4C6F-A6D3-2A4138439B2C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -86,6 +90,14 @@ Global
{D6D53889-5A10-46A4-BA66-E78B56EC1881}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6D53889-5A10-46A4-BA66-E78B56EC1881}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6D53889-5A10-46A4-BA66-E78B56EC1881}.Release|Any CPU.Build.0 = Release|Any CPU
{648DCE6F-A0BA-4032-951B-20CF5BBFD998}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{648DCE6F-A0BA-4032-951B-20CF5BBFD998}.Debug|Any CPU.Build.0 = Debug|Any CPU
{648DCE6F-A0BA-4032-951B-20CF5BBFD998}.Release|Any CPU.ActiveCfg = Release|Any CPU
{648DCE6F-A0BA-4032-951B-20CF5BBFD998}.Release|Any CPU.Build.0 = Release|Any CPU
{B772B8A9-9362-4C6F-A6D3-2A4138439B2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B772B8A9-9362-4C6F-A6D3-2A4138439B2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B772B8A9-9362-4C6F-A6D3-2A4138439B2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B772B8A9-9362-4C6F-A6D3-2A4138439B2C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -101,8 +113,10 @@ Global
{D0153204-6AEF-4D94-B0E1-8124C38C91D4} = {D5266066-0AFD-44D5-A83E-2F73668A63C8}
{73223FBD-C562-4FA0-9722-C7F1C382A9DE} = {49D5873D-7B38-48A5-B853-85146F032091}
{D541BCE9-65BC-475B-94E5-19B6BFFF2B8E} = {49D5873D-7B38-48A5-B853-85146F032091}
{D6D53889-5A10-46A4-BA66-E78B56EC1881} = {49D5873D-7B38-48A5-B853-85146F032091}
{35A34EBD-F2BF-4D83-A096-D5F007B12732} = {49D5873D-7B38-48A5-B853-85146F032091}
{D6D53889-5A10-46A4-BA66-E78B56EC1881} = {49D5873D-7B38-48A5-B853-85146F032091}
{648DCE6F-A0BA-4032-951B-20CF5BBFD998} = {79389FC0-C621-4CEA-AD2B-6074C32E7BCA}
{B772B8A9-9362-4C6F-A6D3-2A4138439B2C} = {D5266066-0AFD-44D5-A83E-2F73668A63C8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6DA935E1-C674-4364-B087-F1B511B79215}
Expand Down
18 changes: 12 additions & 6 deletions src/Neo.Compiler.CSharp/CompilationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -426,31 +426,37 @@ private void ProcessClass(SemanticModel model, INamedTypeSymbol symbol)
bool isSmartContract = isPublic && !isAbstract && isContractType;
if (isSmartContract)
{
if (scTypeFound) throw new CompilationException(DiagnosticId.MultiplyContracts, $"Only one smart contract is allowed.");
if (scTypeFound) throw new CompilationException(DiagnosticId.MultiplyContracts, "Only one smart contract is allowed.");
scTypeFound = true;
foreach (var attribute in symbol.GetAttributesWithInherited())
{
if (attribute.AttributeClass!.IsSubclassOf(nameof(ManifestExtraAttribute)))
{
manifestExtra[ManifestExtraAttribute.AttributeType[attribute.AttributeClass!.Name]] = (string)attribute.ConstructorArguments[0].Value!;
continue;
}

switch (attribute.AttributeClass!.Name)
{
case nameof(DisplayNameAttribute):
displayName = (string)attribute.ConstructorArguments[0].Value!;
break;
case nameof(scfx.Neo.SmartContract.Framework.Attributes.ContractSourceCodeAttribute):
case nameof(ContractSourceCodeAttribute):
Source = (string)attribute.ConstructorArguments[0].Value!;
break;
case nameof(scfx.Neo.SmartContract.Framework.Attributes.ManifestExtraAttribute):
case nameof(ManifestExtraAttribute):
manifestExtra[(string)attribute.ConstructorArguments[0].Value!] = (string)attribute.ConstructorArguments[1].Value!;
break;
case nameof(scfx.Neo.SmartContract.Framework.Attributes.ContractPermissionAttribute):
case nameof(ContractPermissionAttribute):
permissions.Add((string)attribute.ConstructorArguments[0].Value!, attribute.ConstructorArguments[1].Values.Select(p => (string)p.Value!).ToArray());
break;
case nameof(scfx.Neo.SmartContract.Framework.Attributes.ContractTrustAttribute):
case nameof(ContractTrustAttribute):
string trust = (string)attribute.ConstructorArguments[0].Value!;
if (!ValidateContractTrust(trust))
throw new ArgumentException($"The value {trust} is not a valid one for ContractTrust");
trusts.Add(trust);
break;
case nameof(scfx.Neo.SmartContract.Framework.Attributes.SupportedStandardsAttribute):
case nameof(SupportedStandardsAttribute):
supportedStandards.UnionWith(
attribute.ConstructorArguments[0].Values
.Select(p => p.Value)
Expand Down
51 changes: 42 additions & 9 deletions src/Neo.Compiler.CSharp/MethodConvert/MethodConvert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -574,21 +574,42 @@ private void ConvertStorageBackedProperty(IPropertySymbol property, AttributeDat
Call(ApplicationEngine.System_Storage_Get);
switch (property.Type.Name)
{
case "SByte":
case "Short":
case "Int32":
case "Int64":
case "byte":
case "sbyte":
case "Byte":
case "SByte":

case "short":
case "ushort":
case "Int16":
case "UInt16":

case "int":
case "uint":
case "Int32":
case "UInt32":

case "long":
case "ulong":
case "Int64":
case "UInt64":
case "BigInteger":
ChangeType(VM.Types.StackItemType.Integer);
// Replace NULL with 0
AddInstruction(OpCode.DUP);
AddInstruction(OpCode.ISNULL);
JumpTarget ifFalse = new();
Jump(OpCode.JMPIFNOT_L, ifFalse);
{
AddInstruction(OpCode.DROP);
AddInstruction(OpCode.PUSH0);
}
ifFalse.Instruction = AddInstruction(OpCode.NOP);
break;
case "String":
case "ByteString":
case "UInt160":
case "UInt256":
case "ECPoint":
break;
default:
Call(NativeContract.StdLib.Hash, "deserialize", 1, true);
Expand Down Expand Up @@ -620,19 +641,31 @@ private void ConvertStorageBackedProperty(IPropertySymbol property, AttributeDat
AccessSlot(OpCode.LDARG, 1);
switch (property.Type.Name)
{
case "SByte":
case "Short":
case "Int32":
case "Int64":
case "byte":
case "sbyte":
case "Byte":
case "SByte":

case "short":
case "ushort":
case "Int16":
case "UInt16":

case "int":
case "uint":
case "Int32":
case "UInt32":

case "long":
case "ulong":
case "Int64":
case "UInt64":
case "BigInteger":
case "String":
case "ByteString":
case "UInt160":
case "UInt256":
case "ECPoint":
break;
default:
Call(NativeContract.StdLib.Hash, "serialize", 1, true);
Expand Down
2 changes: 1 addition & 1 deletion src/Neo.Compiler.CSharp/Neo.Compiler.CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="Neo" Version="3.6.2" />
<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" />
</ItemGroup>

Expand All @@ -28,6 +27,7 @@
<ProjectReference Include="..\Neo.SmartContract.Framework\Neo.SmartContract.Framework.csproj">
<Aliases>scfx</Aliases>
</ProjectReference>
<ProjectReference Include="..\Neo.SmartContract.Testing\Neo.SmartContract.Testing.csproj" />
</ItemGroup>

</Project>
9 changes: 6 additions & 3 deletions src/Neo.Compiler.CSharp/Optimizer/Strategies/Reachability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,12 @@ public static BranchType CoverInstruction(int addr, Script script, Dictionary<in
((catchAddr, finallyAddr), stackType) = stack.Peek();
if (stackType != TryStack.TRY && stackType != TryStack.CATCH) throw new BadScriptException("No try stack on ENDTRY");

// Visit catchAddr because there may still be exceptions at runtime
Stack<((int returnAddr, int finallyAddr), TryStack stackType)> newStack = new(stack);
CoverInstruction(catchAddr, script, coveredMap, stack: newStack, throwed: true);
if (stackType == TryStack.TRY)
{
// Visit catchAddr because there may still be exceptions at runtime
Stack<((int returnAddr, int finallyAddr), TryStack stackType)> newStack = new(stack);
CoverInstruction(catchAddr, script, coveredMap, stack: newStack, throwed: true);
}

stack.Pop();
int endPointer = addr + instruction.TokenI8;
Expand Down
1 change: 1 addition & 0 deletions src/Neo.Compiler.CSharp/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class Options
public bool Checked { get; set; }
public bool Debug { get; set; }
public bool Assembly { get; set; }
public bool NoArtifacts { get; set; }
public bool NoOptimize { get; set; }
public bool NoInline { get; set; }
public byte AddressVersion { get; set; }
Expand Down
Loading

0 comments on commit 2c8d94a

Please sign in to comment.