swanchain / go-computing-provider

A golang implementation of computing provider
MIT License
11 stars 15 forks source link

need to manually generate the wss authentication certificate #5

Closed ThomasBlock closed 5 months ago

ThomasBlock commented 5 months ago

Hi. I followed the manual and have everything set up. But one final step seems to be missing?

export CP_PATH=~/cp
ls ~/cp
account  config.toml  fil-c2.env  inference-model  keystore  logs  private_key

cat ~/cp/config.toml 
[API]
Port = 8085
MultiAddress = "/ip4/XXX/tcp/8085" 
Domain = "XXX"
NodeName = "XXX"
RedisUrl = "redis://127.0.0.1:6379"
RedisPassword = ""
[UBI]
UbiTask = true 
UbiEnginePk = "0xB5aeb540B4895cd024c1625E146684940A849ED9"
UbiUrl ="https://ubi-task.swanchain.io/v1"  
[LOG]
CrtFile = "~/ssl/server.crt"
KeyFile = "~/ssl/server.key"
[HUB]
ServerUrl = "https://orchestrator-api.swanchain.io"
AccessToken = "XXX"
WalletAddress = "XXX"
BalanceThreshold= 50 
[MCS]
ApiKey = "XXX"
BucketName = "XXX"
Network = "polygon.mumbai" 
FileCachePath = "/tmp"
[Registry]
ServerAddress = ""
UserName = ""
Password = ""
[RPC]
SWAN_TESTNET ="https://saturn-rpc.swanchain.io"    
SWAN_MAINNET= ""                                   
[CONTRACT]
SWAN_CONTRACT="0x91B25A65b295F0405552A4bbB77879ab5e38166c"
SWAN_COLLATERAL_CONTRACT="0xB8D9744b46C1ABbd02D62a7eebF193d83965ba39" 

computing-provider info
OWNER:                  0XFE017FF8F0C7349845AB52E58FCA96143F2C4981                                                                                         
Contract Address:       0x0202F822CBaf2a8cD0e39AF601ACE06B8e1688C3                                                                                          
Multi-Address:          /ip4/XXX/tcp/8085                                                                                                           
Name:                   XXX                                                                                                                     
Node ID:                XXX 
Domain:                 XXX                                                                                                                 
Running deployments:    0                                                                                                                                   
Available(SWAN-ETH):    0.20520                                                                                                                             
Collateral(SWAN-ETH):   0.50000                                                                                                                             
UBI FLAG:               Accept                                                                                                                              
Beneficiary Address:    XXX  

computing-provider run
time="2024-01-26 08:55:17.282" level=info msg="Start in computing provider mode." func=func1 file="run.go:41"
time="2024-01-26 08:55:17.282" level=info msg="Node ID :XXX Peer ID:XXX address:XXX" func=InitComputingProvider file="provider.go:81"
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /debug/pprof/             --> github.com/gin-gonic/gin.WrapF.func1 (4 handlers)
[GIN-debug] GET    /debug/pprof/cmdline      --> github.com/gin-gonic/gin.WrapF.func1 (4 handlers)
[GIN-debug] GET    /debug/pprof/profile      --> github.com/gin-gonic/gin.WrapF.func1 (4 handlers)
[GIN-debug] POST   /debug/pprof/symbol       --> github.com/gin-gonic/gin.WrapF.func1 (4 handlers)
[GIN-debug] GET    /debug/pprof/symbol       --> github.com/gin-gonic/gin.WrapF.func1 (4 handlers)
[GIN-debug] GET    /debug/pprof/trace        --> github.com/gin-gonic/gin.WrapF.func1 (4 handlers)
[GIN-debug] GET    /debug/pprof/allocs       --> github.com/gin-gonic/gin.WrapH.func1 (4 handlers)
[GIN-debug] GET    /debug/pprof/block        --> github.com/gin-gonic/gin.WrapH.func1 (4 handlers)
[GIN-debug] GET    /debug/pprof/goroutine    --> github.com/gin-gonic/gin.WrapH.func1 (4 handlers)
[GIN-debug] GET    /debug/pprof/heap         --> github.com/gin-gonic/gin.WrapH.func1 (4 handlers)
[GIN-debug] GET    /debug/pprof/mutex        --> github.com/gin-gonic/gin.WrapH.func1 (4 handlers)
[GIN-debug] GET    /debug/pprof/threadcreate --> github.com/gin-gonic/gin.WrapH.func1 (4 handlers)
[GIN-debug] GET    /api/v1/computing/host/info --> github.com/lagrangedao/go-computing-provider/internal/computing.GetServiceProviderInfo (4 handlers)
[GIN-debug] POST   /api/v1/computing/lagrange/jobs --> github.com/lagrangedao/go-computing-provider/internal/computing.ReceiveJob (4 handlers)
[GIN-debug] POST   /api/v1/computing/lagrange/jobs/redeploy --> github.com/lagrangedao/go-computing-provider/internal/computing.RedeployJob (4 handlers)
[GIN-debug] DELETE /api/v1/computing/lagrange/jobs --> github.com/lagrangedao/go-computing-provider/internal/computing.CancelJob (4 handlers)
[GIN-debug] GET    /api/v1/computing/lagrange/cp --> github.com/lagrangedao/go-computing-provider/internal/computing.StatisticalSources (4 handlers)
[GIN-debug] POST   /api/v1/computing/lagrange/jobs/renew --> github.com/lagrangedao/go-computing-provider/internal/computing.ReNewJob (4 handlers)
[GIN-debug] GET    /api/v1/computing/lagrange/spaces/log --> github.com/lagrangedao/go-computing-provider/internal/computing.GetSpaceLog (4 handlers)
[GIN-debug] POST   /api/v1/computing/lagrange/cp/proof --> github.com/lagrangedao/go-computing-provider/internal/computing.DoProof (4 handlers)
[GIN-debug] GET    /api/v1/computing/cp      --> github.com/lagrangedao/go-computing-provider/internal/computing.StatisticalSources (4 handlers)
[GIN-debug] GET    /api/v1/computing/cp/info --> github.com/lagrangedao/go-computing-provider/internal/computing.GetCpInfo (4 handlers)
[GIN-debug] POST   /api/v1/computing/cp/ubi  --> github.com/lagrangedao/go-computing-provider/internal/computing.DoUbiTask (4 handlers)
[GIN-debug] POST   /api/v1/computing/cp/receive/ubi --> github.com/lagrangedao/go-computing-provider/internal/computing.ReceiveUbiProof (4 handlers)
time="2024-01-26 08:55:17.673" level=info msg="provider status: Active" func=func3 file="task_service.go:184"
time="2024-01-26 08:55:17.674" level=fatal msg="need to manually generate the wss authentication certificate." func=func1 file="shutdown.go:67"
Normalnoise commented 5 months ago
[LOG]
CrtFile = "~/ssl/server.crt"
KeyFile = "~/ssl/server.key"

@ThomasBlock it needs a absolutely path

ThomasBlock commented 5 months ago

ah okay great, that helped. now i see this log. regarding collateraL. do i need 50 like stated in old docs ? how do i get so much when Sepolia faucet gives only 0.5 ?

time="2024-01-26 14:05:27.048" level=info msg="provider status: Active" func=func3 file="task_service.go:184"
time="2024-01-26 14:05:27.116" level=info msg="collect all node: 2" func=func1 file="task_service.go:133"
time="2024-01-26 14:05:27.116" level=error msg="convert to json, nodeName swan1, error: invalid character '.' looking for beginning of value" func=func1 file="task_service.go:141"
time="2024-01-26 14:05:27.258" level=info msg="publicIpAddress: 45.153.35.150" func=getLocation file="cp_service.go:1303"
time="2024-01-26 14:05:31.416" level=warning msg="No sufficient collateral Balance, the current collateral balance is: 0.500. Please run: computing-provider collateral [fromWalletAddress] [amount]" func=func1 file="cron_task.go:78"
time="2024-01-26 14:05:37.345" level=error msg="nodeName: %s, error: %+vswan1invalid character '.' looking for beginning of value" func=StatisticalSources file="k8s_service.go:347"
time="2024-01-26 14:05:37.442" level=error msg="report cluster node resources failed, status code: 400" func=reportClusterResource file="task_service.go:242"
time="2024-01-26 14:05:42.331" level=warning msg="resp status: %d, retrying to connect to the Swan Hub server 500" func=sendHeartbeat file="initializer.go:41"

but maybe no big problem as ubi-test-task works?

curl -k --location --request POST 'https://192.168.128.71:8085/api/v1/computing/lagrange/cp/proof' \
--header 'Content-Type: application/json' \
--data-raw '{
"method": "mine",
"block_data": "this-is-a-ubi-test-task",
"exp": 230
}'
{"status":"success","code":200,"data":"{\"data\":\"this-is-a-ubi-test-task\",\"hash\":\"0000003885a242c2c6c82be3e0ef8adb8fff43ec2b990ae86b748d8566215a36\",\"nonce\":\"12387293\",\"target\":\"1725436586697640946858688965569256363112777243042596638790631055
Normalnoise commented 5 months ago

ah okay great, that helped. now i see this log. regarding collateraL. do i need 50 like stated in old docs ? how do i get so much when Sepolia faucet gives only 0.5 ?

time="2024-01-26 14:05:27.048" level=info msg="provider status: Active" func=func3 file="task_service.go:184"
time="2024-01-26 14:05:27.116" level=info msg="collect all node: 2" func=func1 file="task_service.go:133"
time="2024-01-26 14:05:27.116" level=error msg="convert to json, nodeName swan1, error: invalid character '.' looking for beginning of value" func=func1 file="task_service.go:141"
time="2024-01-26 14:05:27.258" level=info msg="publicIpAddress: 45.153.35.150" func=getLocation file="cp_service.go:1303"
time="2024-01-26 14:05:31.416" level=warning msg="No sufficient collateral Balance, the current collateral balance is: 0.500. Please run: computing-provider collateral [fromWalletAddress] [amount]" func=func1 file="cron_task.go:78"
time="2024-01-26 14:05:37.345" level=error msg="nodeName: %s, error: %+vswan1invalid character '.' looking for beginning of value" func=StatisticalSources file="k8s_service.go:347"
time="2024-01-26 14:05:37.442" level=error msg="report cluster node resources failed, status code: 400" func=reportClusterResource file="task_service.go:242"
time="2024-01-26 14:05:42.331" level=warning msg="resp status: %d, retrying to connect to the Swan Hub server 500" func=sendHeartbeat file="initializer.go:41"

but maybe no big problem as ubi-test-task works?

curl -k --location --request POST 'https://192.168.128.71:8085/api/v1/computing/lagrange/cp/proof' \
--header 'Content-Type: application/json' \
--data-raw '{
"method": "mine",
"block_data": "this-is-a-ubi-test-task",
"exp": 230
}'
{"status":"success","code":200,"data":"{\"data\":\"this-is-a-ubi-test-task\",\"hash\":\"0000003885a242c2c6c82be3e0ef8adb8fff43ec2b990ae86b748d8566215a36\",\"nonce\":\"12387293\",\"target\":\"1725436586697640946858688965569256363112777243042596638790631055

@ThomasBlock in the Saturn testnet, CP just need 0.001 SwanETH for one task, please refer here

if you want to do the zk ubi task, please follow the newest steps: Config and Receive UBI Tasks(optional)

ThomasBlock commented 5 months ago

Thank you for the feedback. This is my config ( we now have two places for UbiTask? )

Nothing seems to happen now. Are you sure the remaining error messages are no problem?

[GIN-debug] POST   /api/v1/computing/cp/receive/ubi --> github.com/lagrangedao/go-computing-provider/internal/computing.ReceiveUbiProof (4 handlers)
time="2024-01-27 08:29:26.876" level=info msg="collect all node: 2" func=func1 file="task_service.go:133"
time="2024-01-27 08:29:26.876" level=error msg="convert to json, nodeName swan1, error: invalid character '.' looking for beginning of value" func=func1 file="task_service.go:141"
time="2024-01-27 08:29:27.106" level=info msg="publicIpAddress: 45.153.35.150" func=getLocation file="cp_service.go:1303"
time="2024-01-27 08:29:37.169" level=error msg="nodeName: %s, error: %+vswan1invalid character '.' looking for beginning of value" func=StatisticalSources file="k8s_service.go:347"
time="2024-01-27 08:29:37.275" level=error msg="report cluster node resources failed, status code: 400" func=reportClusterResource file="task_service.go:242"
time="2024-01-27 08:29:42.127" level=warning msg="resp status: %d, retrying to connect to the Swan Hub server 500" func=sendHeartbeat file="initializer.go:41"
cat ~/cp/config.toml 
[API]
UbiTask = true 
Port = 8085
MultiAddress = "/ip4/XXX/tcp/8085" 
Domain = "XXX"
NodeName = "XXX"
RedisUrl = "redis://127.0.0.1:6379"
RedisPassword = ""
[UBI]
UbiTask = true 
UbiEnginePk = "0xB5aeb540B4895cd024c1625E146684940A849ED9"
UbiUrl ="https://ubi-task.swanchain.io/v1"  
[LOG]
CrtFile = "/home/user/ssl/server.crt"
KeyFile = "/home/user/ssl/server.key"
[HUB]
ServerUrl = "https://orchestrator-api.swanchain.io"
AccessToken = "XXX"
WalletAddress = "XXX"
BalanceThreshold= 0.3
[MCS]
ApiKey = "XXX"
BucketName = "XXX"
Network = "polygon.mumbai" 
FileCachePath = "/tmp"
[Registry]
ServerAddress = ""
UserName = ""
Password = ""
[RPC]
SWAN_TESTNET ="https://saturn-rpc.swanchain.io"    
SWAN_MAINNET= ""                                   
[CONTRACT]
SWAN_CONTRACT="0x91B25A65b295F0405552A4bbB77879ab5e38166c"
SWAN_COLLATERAL_CONTRACT="0xB8D9744b46C1ABbd02D62a7eebF193d83965ba39" 
ThomasBlock commented 5 months ago

Okay i could repair the 400 and 500 swan hub errors by creating a new api key. ( it only works if i use the beneficiary address and not the owner ). So i am listed now as a provider. Here is the last little error which remains:

time="2024-01-28 11:00:21.772" level=error msg="nodeName: %s, error: %+vswan1invalid character '.' looking for beginning of value" func=StatisticalSources file="k8s_service.go:347"