neo-project / neo-modules

MIT License
60 stars 100 forks source link

Rest server #839

Closed cschuchardt88 closed 3 months ago

cschuchardt88 commented 10 months ago

RestServer

In this section you will learn about RestServer plugin and how it works.

Dependencies

In Docker

RestServer
|   |   |-- Microsoft.AspNetCore.JsonPatch.dll
|   |   |-- Microsoft.AspNetCore.Mvc.NewtonsoftJson.dll
|   |   |-- Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer.dll
|   |   |-- Microsoft.AspNetCore.Mvc.Versioning.dll
|   |   |-- Microsoft.OpenApi.dll
|   |   |-- Neo.ConsoleService.dll
|   |   |-- Newtonsoft.Json.Bson.dll
|   |   |-- Newtonsoft.Json.dll
|   |   |-- RestServer.deps.json
|   |   |-- RestServer.dll
|   |   |-- RestServer.pdb
|   |   |-- RestServer.xml
|   |   |-- Swashbuckle.AspNetCore.Newtonsoft.dll
|   |   |-- Swashbuckle.AspNetCore.Swagger.dll
|   |   |-- Swashbuckle.AspNetCore.SwaggerGen.dll
|   |   |-- Swashbuckle.AspNetCore.SwaggerUI.dll
|   |   |-- System.ServiceProcess.ServiceController.dll
|   |   |-- config.json
|   |   `-- runtimes
|   |       `-- win
|   |           `-- lib
|   |               `-- net6.0
|   |                   `-- System.ServiceProcess.ServiceController.dll

These files go in the same directory as the RestServer.dll. In neo-cli plugins/RestServer/ folder.

Response Headers

Name Value(s) Description
server neo-cli/3.6.0 RestServer/3.6.0 neo-cli and RestServer version.

JSON Serializer

RestServer uses custom Newtonsoft Json Converters to serialize controller action responses and route parameters.

One Way Binding - Write only.

Two Way Binding - Read & Write

Remote Endpoints

Parametes {hash} can be any Neo N3 address or scripthash; {address} can be any Neo N3 address only; {number} and {index} can be any uint32.

Parameter Examples

Paths

Jim8y commented 10 months ago

@superboyiii can you please review and test it?

superboyiii commented 10 months ago

This is awesome. Need some time for test.

cschuchardt88 commented 9 months ago

anyone know what this error is about? It builds fine on my computer. CodeQL / Analyze (csharp) gets error only.

  MSBuild version 17.8.3+195e7f5a3 for .NET
    Determining projects to restore...
    All projects are up-to-date for restore.
    LevelDBStore -> /home/runner/work/neo-modules/neo-modules/src/LevelDBStore/bin/Debug/net7.0/LevelDBStore.dll
    RocksDBStore -> /home/runner/work/neo-modules/neo-modules/src/RocksDBStore/bin/Debug/net7.0/RocksDBStore.dll
    StatesDumper -> /home/runner/work/neo-modules/neo-modules/src/StatesDumper/bin/Debug/net7.0/StatesDumper.dll
    RpcServer -> /home/runner/work/neo-modules/neo-modules/src/RpcServer/bin/Debug/net7.0/RpcServer.dll
  CSC : error CS0006: Metadata file '/home/runner/work/neo-modules/neo-modules/src/RpcServer/obj/Debug/net7.0/ref/RpcServer.dll' could not be found [/home/runner/work/neo-modules/neo-modules/src/OracleService/OracleService.csproj]
  CSC : error CS0006: Metadata file '/home/runner/work/neo-modules/neo-modules/src/RpcServer/obj/Debug/net7.0/ref/RpcServer.dll' could not be found [/home/runner/work/neo-modules/neo-modules/src/ApplicationLogs/ApplicationLogs.csproj]
superboyiii commented 9 months ago

Build well on my local PC, not sure if it referred to the changes on *csproj of Oracle and Applicationlog image

superboyiii commented 9 months ago

Tried to revert the modification from ApplicationLogs and OracleService, forked it to my repo and run CodeQL check. Still failed.

cschuchardt88 commented 9 months ago

In the code.yml it says if there is an error autobuilding the project to comment out that step and add your own build commands or script to run. we needed to do that for neo-express repo you can have a look at that if you want https://github.com/neo-project/neo-express/blob/master/.github/workflows/code.yml

superboyiii commented 9 months ago

1701940303290 Is it necessary to put HardFork into CamelCasePropertyNamesContractResolver() ?

cschuchardt88 commented 9 months ago

Changed hardfork names. Now removed prefix. image

cschuchardt88 commented 9 months ago

Fixed image

cschuchardt88 commented 9 months ago

@superboyiii This may help you. Just do Ctrl+O in postman. Some URL may have been removed. Neo API version 1.0.postman_collection.json

should look like this image

superboyiii commented 8 months ago

@cschuchardt88 I can't get any response from Wallet model, even can't debug into it. Other models work well. Is it working on yours?

cschuchardt88 commented 8 months ago

Check the config? Its disabled by default.

superboyiii commented 8 months ago

Check the config? Its disabled by default.

Oh, OK. Works now, thanks.

cschuchardt88 commented 8 months ago

@superboyiii I added you to my repos, so you can commit changes directly.

superboyiii commented 8 months ago

Is this OK? @cschuchardt88 https://github.com/neo-project/neo-modules/pull/839/commits/784c7dbdcf9bcd207f4c63416e2fa0d11a2628b8 1703732686186

cschuchardt88 commented 8 months ago

Has to be this:

Rules = signer.Rules != null ? signer.Rules.Select(s => WitnessRuleToJToken(s, serializer)) : Array.Empty<WitnessRule>(),

You have to call WitnessRuleToJToken or else it can't serialize the object, and you will get an error.

cschuchardt88 commented 8 months ago

Also i forgot to mention there is console commands.

image

superboyiii commented 8 months ago

@Jim8y @shargon Need your review for double check.

Jim8y commented 8 months ago

My environment is kinda painful to set up testing this pr. Will take a while for me, but shargon and superboy's review should be sufficient to merge.

cschuchardt88 commented 8 months ago

@superboyiii Did you check out the Swagger UI?

image

superboyiii commented 8 months ago

@superboyiii Did you check out the Swagger UI?

Tried it, it's really cool and convinent!

shargon commented 8 months ago

Is not forgotten, I will need time to review it, I really love this PR

vncoelho commented 8 months ago
neo> FATAL [12:50:32.505]   System.Reflection.ReflectionTypeLoadException
Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=7.0.10.0,  Culture=neutral,  PublicKeyToken=adb9793829...ch()
   at  System.Thr...eadStart()
Unhandled exception. System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=7.0.10.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerFeatureProvider.PopulateFeature(IEnumerable`1 parts, ControllerFeature feature)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature)
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetControllerTypes()
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetDescriptors()
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.OnProvidersExecuting(ActionDescriptorProviderContext context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.UpdateCollection()
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.Initialize()
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.get_ActionDescriptors()
   at Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiVersionDescriptionProvider.EnumerateApiVersions(IActionDescriptorCollectionProvider actionDescriptorCollectionProvider)
   at Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiVersionDescriptionProvider.LazyApiVersionDescriptions.EnumerateApiVersions()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiVersionDescriptionProvider.get_ApiVersionDescriptions()
   at Neo.Plugins.RestServer.RestWebServer.<>c__DisplayClass7_3.<Start>b__37(SwaggerUIOptions options)
   at Microsoft.AspNetCore.Builder.SwaggerUIBuilderExtensions.UseSwaggerUI(IApplicationBuilder app, Action`1 setupAction)
   at Neo.Plugins.RestServer.RestWebServer.<Start>b__7_2(IApplicationBuilder app)
   at Microsoft.Extensions.DependencyInjection.AutoRegisterMiddleware.<>c__DisplayClass4_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.WebHost.BuildApplication()
   at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Hosting.WebHost.Start()
   at Neo.Plugins.RestServer.RestWebServer.Start()
   at Neo.Plugins.RestServer.RestServerPlugin.OnSystemLoaded(NeoSystem system)
   at Neo.NeoSystem..ctor(ProtocolSettings settings, String storageEngine, String storagePath) in /opt/neoLib/src/Neo/NeoSystem.cs:line 130
   at Neo.CLI.MainService.Start(String[] args) in /opt/neoLib/src/Neo.CLI/CLI/MainService.cs:line 379
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=7.0.10.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

File name: 'Microsoft.EntityFrameworkCore, Version=7.0.10.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
/opt/start_node.sh: line 2:   116 Aborted                 (core dumped) dotnet neo-cli.dll
root@292575307a6c:/# 

I am trying to set it online on neocompiler.io for who wants to test.

vncoelho commented 8 months ago

I was missing the .xml file in the folder. I will try again.

vncoelho commented 8 months ago

image

vncoelho commented 8 months ago
neo> FATAL [13:05:36.078]   System.IO.FileNotFoundException
Could not load file or assembly 'Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer, Version=5.1.0.0,  Culture=neutral,  PublicKeyToken=adb9793829...ch()
   at  System.Thr...eadStart()
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer, Version=5.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

File name: 'Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer, Version=5.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
   at Neo.Plugins.RestServer.RestWebServer.<Start>b__7_1(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
   at Neo.Plugins.RestServer.RestWebServer.Start()
   at Neo.Plugins.RestServer.RestServerPlugin.OnSystemLoaded(NeoSystem system)
   at Neo.NeoSystem..ctor(ProtocolSettings settings, String storageEngine, String storagePath) in /opt/neoLib/src/Neo/NeoSystem.cs:line 130
   at Neo.CLI.MainService.Start(String[] args) in /opt/neoLib/src/Neo.CLI/CLI/MainService.cs:line 379
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
/opt/start_node.sh: line 2:   111 Aborted                 (core dumped) dotnet neo-cli.dll
root@a262d64d5120:/# 
vncoelho commented 8 months ago

I tried now copying all .dlls to the folder. But still some errors

image

NEO-CLI v3.6.2  -  NEO v3.6.2  -  NEO-VM v3.6.2

neo> FATAL [15:12:58.316]   System.Reflection.ReflectionTypeLoadException
Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=7.0.10.0,  Culture=neutral,  PublicKeyToken=adb9793829...ch()
   at  System.Thr...eadStart()
Unhandled exception. System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=7.0.10.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerFeatureProvider.PopulateFeature(IEnumerable`1 parts, ControllerFeature feature)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature)
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetControllerTypes()
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetDescriptors()
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.OnProvidersExecuting(ActionDescriptorProviderContext context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.UpdateCollection()
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.Initialize()
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.get_ActionDescriptors()
   at Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiVersionDescriptionProvider.EnumerateApiVersions(IActionDescriptorCollectionProvider actionDescriptorCollectionProvider)
   at Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiVersionDescriptionProvider.LazyApiVersionDescriptions.EnumerateApiVersions()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiVersionDescriptionProvider.get_ApiVersionDescriptions()
   at Neo.Plugins.RestServer.RestWebServer.<>c__DisplayClass7_3.<Start>b__37(SwaggerUIOptions options)
   at Microsoft.AspNetCore.Builder.SwaggerUIBuilderExtensions.UseSwaggerUI(IApplicationBuilder app, Action`1 setupAction)
   at Neo.Plugins.RestServer.RestWebServer.<Start>b__7_2(IApplicationBuilder app)
   at Microsoft.Extensions.DependencyInjection.AutoRegisterMiddleware.<>c__DisplayClass4_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.WebHost.BuildApplication()
   at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Hosting.WebHost.Start()
   at Neo.Plugins.RestServer.RestWebServer.Start()
   at Neo.Plugins.RestServer.RestServerPlugin.OnSystemLoaded(NeoSystem system)
   at Neo.NeoSystem..ctor(ProtocolSettings settings, String storageEngine, String storagePath) in /opt/neoLib/src/Neo/NeoSystem.cs:line 130
   at Neo.CLI.MainService.Start(String[] args) in /opt/neoLib/src/Neo.CLI/CLI/MainService.cs:line 379
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=7.0.10.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

File name: 'Microsoft.EntityFrameworkCore, Version=7.0.10.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
/opt/start_node.sh: line 2:    99 Aborted                 (core dumped) dotnet neo-cli.dll
root@2b23b4535fb1:/# 
cschuchardt88 commented 8 months ago

@vncoelho Looks like you are using Microsoft.EntityFrameworkCore? You site is programmed in asp.net mvc? Looks like my plugin is loading your mvc controllers for your site?

vncoelho commented 8 months ago

Everything is built with SDK mcr.microsoft.com/dotnet/sdk:7.0.404-jammy

Node is created with dotnet publish -c Release -f net7.0 Plugins are generated with dotnet publish -c Release -o app

Client is run with a container with image mcr.microsoft.com/dotnet/aspnet:7.0.14-jammy We used to use aspnet because it was enough for neo-cli to run, image was more compact. Perhaps we may need another image for client now.

cschuchardt88 commented 8 months ago

My thoughts are, that you are using the wrong image. Why are you using web image like aspnet:7.0.14-jammy? Since your doing that way, Microsoft.Extensions.DependencyInjection.AutoRegisterMiddleware will; you guessed it auto register. In this case its trying to auto register Microsoft.EntityFrameworkCore or something that needs it; but not likely. however i don't use Microsoft.EntityFrameworkCore thats for interacting with SQL databases.

Maybe also try only the dependencies that RestServer Require. Here is an updated list: image

vncoelho commented 8 months ago

I tried just with that dependencies already. I sent the error above.

Maybe I could try with another image.

cschuchardt88 commented 8 months ago

Different image for sure, But also try disabling swagger in the config.json.

vncoelho commented 8 months ago

Which one in this case? This involves a change in the packages needed for the client.

The commands I use are all dockerized. Any change in this image means some compatibility and additional packages in the images, which leads to more possible leaks for official nodes to use.

If used just by isolated seed nodes without assets management is one thing.

In my vision, simplicity makes security. Lets just exactly understand why there is a need to change/improve the core image that runs for a client that runs consensus, for example.

cschuchardt88 commented 8 months ago

Have you tried docker image ghcr.io/axlabs/neo3-privatenet-docker/neo-cli-with-plugins:neo-node-3.6.2?

One reason is that image is for web sites or web development.

cschuchardt88 commented 8 months ago

Also with #3018 you dont need dotnet installed at all. Another thing is with #3039 I forget to remove asp.net core framework libray. from the csproj

vncoelho commented 8 months ago

@cschuchardt88, everything is running with the image we current have, except this plugin. I will try with dotnet sdk image for image that runs the node.

vncoelho commented 8 months ago

Tried with FROM mcr.microsoft.com/dotnet/sdk:7.0.404-jammy

neo> FATAL [11:44:19.675]   System.Reflection.ReflectionTypeLoadException
Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=7.0.10.0,  Culture=neutral,  PublicKeyToken=adb9793829...ch()
   at  System.Thr...eadStart()
Unhandled exception. System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=7.0.10.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerFeatureProvider.PopulateFeature(IEnumerable`1 parts, ControllerFeature feature)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature)
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetControllerTypes()
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetDescriptors()
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.OnProvidersExecuting(ActionDescriptorProviderContext context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.UpdateCollection()
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.Initialize()
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.get_ActionDescriptors()
   at Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiVersionDescriptionProvider.EnumerateApiVersions(IActionDescriptorCollectionProvider actionDescriptorCollectionProvider)
   at Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiVersionDescriptionProvider.LazyApiVersionDescriptions.EnumerateApiVersions()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiVersionDescriptionProvider.get_ApiVersionDescriptions()
   at Neo.Plugins.RestServer.RestWebServer.<>c__DisplayClass7_3.<Start>b__37(SwaggerUIOptions options)
   at Microsoft.AspNetCore.Builder.SwaggerUIBuilderExtensions.UseSwaggerUI(IApplicationBuilder app, Action`1 setupAction)
   at Neo.Plugins.RestServer.RestWebServer.<Start>b__7_2(IApplicationBuilder app)
   at Microsoft.Extensions.DependencyInjection.AutoRegisterMiddleware.<>c__DisplayClass4_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.WebHost.BuildApplication()
   at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Hosting.WebHost.Start()
   at Neo.Plugins.RestServer.RestWebServer.Start()
   at Neo.Plugins.RestServer.RestServerPlugin.OnSystemLoaded(NeoSystem system)
   at Neo.NeoSystem..ctor(ProtocolSettings settings, String storageEngine, String storagePath) in /opt/neoLib/src/Neo/NeoSystem.cs:line 130
   at Neo.CLI.MainService.Start(String[] args) in /opt/neoLib/src/Neo.CLI/CLI/MainService.cs:line 379
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=7.0.10.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

File name: 'Microsoft.EntityFrameworkCore, Version=7.0.10.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
/opt/start_node.sh: line 2:   101 Aborted                 (core dumped) dotnet neo-cli.dll
vncoelho commented 8 months ago

@superboyiii Did you check out the Swagger UI?

Tried it, it's really cool and convinent!

@superboyiii,

It is strange because the same images is running in another nodes and everything is working, just the container with rest server is bugging.

vncoelho commented 8 months ago

@cschuchardt88, setting the "EnableSwagger" flag to false it was able to run.

cschuchardt88 commented 8 months ago

Its Microsoft's Swagger library, I have no clue, why they want to load the Entity Framework. I have found bugs with swagger, and Microsoft never said anything on their github page, when i created issue, It's been about 6 months now and 2 bugs reported and now this.

@superboyiii I think we remove swagger for now.

vncoelho commented 8 months ago
if [ $PLUGIN_TO_INCLUDE = "RestServer" ]; then
    echo "Going to copy file $ORIGIN_PATH/$PLUGIN_TO_INCLUDE.dll TO $DEST_FOLDER - and some other dependencies"
    cp -ri $ORIGIN_PATH/$PLUGIN_TO_INCLUDE.dll $DEST_FOLDER
    cp -ri $ORIGIN_PATH/Microsoft.AspNetCore.JsonPatch.dll $DEST_FOLDER
    cp -ri $ORIGIN_PATH/Microsoft.AspNetCore.Mvc.NewtonsoftJson.dll $DEST_FOLDER
    cp -ri $ORIGIN_PATH/Microsoft.OpenApi.dll $DEST_FOLDER
    cp -ri $ORIGIN_PATH/Swashbuckle.AspNetCore.Swagger.dll $DEST_FOLDER
    cp -ri $ORIGIN_PATH/Swashbuckle.AspNetCore.SwaggerGen.dll $DEST_FOLDER
    cp -ri $ORIGIN_PATH/Swashbuckle.AspNetCore.SwaggerUI.dll $DEST_FOLDER
    cp -ri $ORIGIN_PATH/*.dll $DEST_FOLDER    
    cp -ri $ORIGIN_PATH/RestServer.xml $DEST_FOLDER   
fi

I did not identified all one by one. But to work I needed to copy all cp -ri $ORIGIN_PATH/*.dll $DEST_FOLDER

vncoelho commented 8 months ago
code | -2146232830
name | "ReflectionTypeLoadException"
message | "Unable to load one or more of the requested types.\nCould not load file or assembly 'Microsoft.EntityFrameworkCore, Version=7.0.10.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.\n"

Error when I accessed the main url of the api

vncoelho commented 8 months ago

@cschuchardt88,

I see that you opened 3 big PRs in this repo. Maybe it is time to migrate this repo to Neo-Core as well and you move those PRs in the sequence. I believe it will be better for us and our workflow.

shargon commented 8 months ago

@cschuchardt88,

I see that you opened 3 big PRs in this repo. Maybe it is time to migrate this repo to Neo-Core as well and you move those PRs in the sequence. I believe it will be better for us and our workflow.

After we merge the big PR we can do that

cschuchardt88 commented 8 months ago
code | -2146232830
name | "ReflectionTypeLoadException"
message | "Unable to load one or more of the requested types.\nCould not load file or assembly 'Microsoft.EntityFrameworkCore, Version=7.0.10.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.\n"

Error when I accessed the main url of the api

Must be the configuration of the docker image. Have you tried full version of dotnet (docker image)? and not a lite version?

shargon commented 8 months ago

Awesome work @cschuchardt88 👏 for me is ready to merge when nullable is fixed

vncoelho commented 8 months ago
code | -2146232830
name | "ReflectionTypeLoadException"
message | "Unable to load one or more of the requested types.\nCould not load file or assembly 'Microsoft.EntityFrameworkCore, Version=7.0.10.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.\n"

Error when I accessed the main url of the api

Must be the configuration of the docker image. Have you tried full version of dotnet (docker image)? and not a lite version?

https://hub.docker.com/_/microsoft-dotnet

Which one of these images?

cschuchardt88 commented 8 months ago

@vncoelho ill look into it, its going to take some time to set up.

cschuchardt88 commented 8 months ago

@vncoelho If you want to get up and running now

use jammy

docker pull ubuntu

Follow this

https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install


Aslo have you tried

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:7.0 AS Build

COPY neo-cli /neo-cli
COPY Neo.ConsoleService /Neo.ConsoleService
COPY NuGet.Config /neo-cli

WORKDIR /neo-cli
RUN dotnet restore && dotnet publish -c Release -o /app

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:7.0 AS Final
RUN apt-get update && apt-get install -y \
  screen \
  libleveldb-dev \
  sqlite3
RUN rm -rf /var/lib/apt/lists/*

WORKDIR /neo-cli
COPY  --from=Build /app .

ENTRYPOINT ["screen","-DmS","node","dotnet","neo-cli.dll","-r"]
vncoelho commented 8 months ago

@vncoelho If you want to get up and running now

use jammy

docker pull ubuntu

Follow this

https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install


Aslo have you tried

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:7.0 AS Build

COPY neo-cli /neo-cli
COPY Neo.ConsoleService /Neo.ConsoleService
COPY NuGet.Config /neo-cli

WORKDIR /neo-cli
RUN dotnet restore && dotnet publish -c Release -o /app

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:7.0 AS Final
RUN apt-get update && apt-get install -y \
  screen \
  libleveldb-dev \
  sqlite3
RUN rm -rf /var/lib/apt/lists/*

WORKDIR /neo-cli
COPY  --from=Build /app .

ENTRYPOINT ["screen","-DmS","node","dotnet","neo-cli.dll","-r"]

I do not understand your message. You say to download Ubuntu.

I only use Ubuntu or other linux distro.