Skip to content

Commit

Permalink
Merge pull request #101 from multiversx/rc/spica-patch-relayedv3
Browse files Browse the repository at this point in the history
Rc/spica patch relayedv3
  • Loading branch information
sstanculeanu authored Jan 28, 2025
2 parents 5fcb872 + d5622f3 commit e1d26d4
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
permissions:
packages: write
contents: read
Expand Down
11 changes: 6 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ module github.com/multiversx/mx-chain-simulator-go
go 1.20

require (
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792
github.com/gin-gonic/gin v1.9.1
github.com/multiversx/mx-chain-core-go v1.2.23
github.com/multiversx/mx-chain-go v1.8.6
github.com/multiversx/mx-chain-core-go v1.2.24
github.com/multiversx/mx-chain-go v1.8.9
github.com/multiversx/mx-chain-logger-go v1.0.15
github.com/multiversx/mx-chain-proxy-go v1.1.54
github.com/multiversx/mx-chain-proxy-go v1.1.57
github.com/pelletier/go-toml v1.9.3
github.com/stretchr/testify v1.8.4
github.com/urfave/cli v1.22.10
Expand Down Expand Up @@ -118,9 +119,9 @@ require (
github.com/multiversx/concurrent-map v0.1.4 // indirect
github.com/multiversx/mx-chain-communication-go v1.1.1 // indirect
github.com/multiversx/mx-chain-crypto-go v1.2.12 // indirect
github.com/multiversx/mx-chain-es-indexer-go v1.7.10 // indirect
github.com/multiversx/mx-chain-es-indexer-go v1.7.14 // indirect
github.com/multiversx/mx-chain-scenario-go v1.4.4 // indirect
github.com/multiversx/mx-chain-storage-go v1.0.18 // indirect
github.com/multiversx/mx-chain-storage-go v1.0.19 // indirect
github.com/multiversx/mx-chain-vm-common-go v1.5.16 // indirect
github.com/multiversx/mx-chain-vm-go v1.5.37 // indirect
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.68 // indirect
Expand Down
21 changes: 11 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVa
github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I=
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 h1:R8vQdOQdZ9Y3SkEwmHoWBmX1DNXhXZqlTpq6s4tyJGc=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s=
Expand Down Expand Up @@ -395,22 +396,22 @@ github.com/multiversx/concurrent-map v0.1.4 h1:hdnbM8VE4b0KYJaGY5yJS2aNIW9TFFsUY
github.com/multiversx/concurrent-map v0.1.4/go.mod h1:8cWFRJDOrWHOTNSqgYCUvwT7c7eFQ4U2vKMOp4A/9+o=
github.com/multiversx/mx-chain-communication-go v1.1.1 h1:y4DoQeQOJTaSUsRzczQFazf8JYQmInddypApqA3AkwM=
github.com/multiversx/mx-chain-communication-go v1.1.1/go.mod h1:WK6bP4pGEHGDDna/AYRIMtl6G9OA0NByI1Lw8PmOnRM=
github.com/multiversx/mx-chain-core-go v1.2.23 h1:8WlCGqJHR2HQ0vN4feJwb7W4VrCwBGIzPPHunOOg5Wc=
github.com/multiversx/mx-chain-core-go v1.2.23/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
github.com/multiversx/mx-chain-core-go v1.2.24 h1:O0X7N9GfNVUCE9fukXA+dvfCRRjViYn88zOaE7feUog=
github.com/multiversx/mx-chain-core-go v1.2.24/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
github.com/multiversx/mx-chain-crypto-go v1.2.12 h1:zWip7rpUS4CGthJxfKn5MZfMfYPjVjIiCID6uX5BSOk=
github.com/multiversx/mx-chain-crypto-go v1.2.12/go.mod h1:HzcPpCm1zanNct/6h2rIh+MFrlXbjA5C8+uMyXj3LI4=
github.com/multiversx/mx-chain-es-indexer-go v1.7.10 h1:Umi7WN8h4BOXLw7CM3VgvaWkLGef7nXtaPIGbjBCT3U=
github.com/multiversx/mx-chain-es-indexer-go v1.7.10/go.mod h1:oGcRK2E3Syv6vRTszWrrb/TqD8akq0yeoMr1wPPiTO4=
github.com/multiversx/mx-chain-go v1.8.6 h1:T9S+MxunqtXiPm80IuARoJscQF/AyGKkt2thNQiAruY=
github.com/multiversx/mx-chain-go v1.8.6/go.mod h1:lGO2BKUMu1tS4Jd4VkLBZkivjN9ynYGmQjDCbFrzdIE=
github.com/multiversx/mx-chain-es-indexer-go v1.7.14 h1:V4fuubEUYskWCLQIkbuoB0WHoKyldLQRq/fllIzW1CU=
github.com/multiversx/mx-chain-es-indexer-go v1.7.14/go.mod h1:5Sr49FjWWzZ3/WcC3jzln8TlMSNToCIT9Lqy6P7i7bs=
github.com/multiversx/mx-chain-go v1.8.9 h1:rji7TNHQgnLxDXs2bBo8kgynx0YG20apMWtkD6ENnjw=
github.com/multiversx/mx-chain-go v1.8.9/go.mod h1:CIzT5NttBpnyvDD6jl4pEOP3RoLcSDYDKz1UymJxZVY=
github.com/multiversx/mx-chain-logger-go v1.0.15 h1:HlNdK8etyJyL9NQ+6mIXyKPEBo+wRqOwi3n+m2QIHXc=
github.com/multiversx/mx-chain-logger-go v1.0.15/go.mod h1:t3PRKaWB1M+i6gUfD27KXgzLJJC+mAQiN+FLlL1yoGQ=
github.com/multiversx/mx-chain-proxy-go v1.1.54 h1:o6rcZVpE+Qkf+CyNIZRvfRHAZGO7HcloITglSXRH7n8=
github.com/multiversx/mx-chain-proxy-go v1.1.54/go.mod h1:SMJY0kbqUyehyLoZrPVt0EmSAFsfCuS4QB8y1cHkJUE=
github.com/multiversx/mx-chain-proxy-go v1.1.57 h1:lFfdBZdzKz4WD1VzdGV6DqIk3Dqk1rEBNXd+76gJJ5E=
github.com/multiversx/mx-chain-proxy-go v1.1.57/go.mod h1:FBOgb6uL0FKrRKJxWBbOvcoqHfgiJc6nos4u4yDVoO4=
github.com/multiversx/mx-chain-scenario-go v1.4.4 h1:DVE2V+FPeyD/yWoC+KEfPK3jsFzHeruelESfpTlf460=
github.com/multiversx/mx-chain-scenario-go v1.4.4/go.mod h1:kI+TWR3oIEgUkbwkHCPo2CQ3VjIge+ezGTibiSGwMxo=
github.com/multiversx/mx-chain-storage-go v1.0.18 h1:DA33o5COEjnCKclCeCvzXXI0zIgFp2QqZK32UTVvDes=
github.com/multiversx/mx-chain-storage-go v1.0.18/go.mod h1:eFDEOrG7Wiyk5I/ObpwcN2eoBlOnnfeEMTvTer1cymk=
github.com/multiversx/mx-chain-storage-go v1.0.19 h1:2R35MoSXcuNJOFmV5xEhcXqiEGZw6AYGy9R8J9KH66Q=
github.com/multiversx/mx-chain-storage-go v1.0.19/go.mod h1:Pb/BuVmiFqO66DSZO16KFkSUeom94x3e3Q9IloBvkYI=
github.com/multiversx/mx-chain-vm-common-go v1.5.16 h1:g1SqYjxl7K66Y1O/q6tvDJ37fzpzlxCSfRzSm/woQQY=
github.com/multiversx/mx-chain-vm-common-go v1.5.16/go.mod h1:1rSkXreUZNXyPTTdhj47M+Fy62yjxbu3aAsXEtKN3UY=
github.com/multiversx/mx-chain-vm-go v1.5.37 h1:Iy3KCvM+DOq1f9UPA7uYK/rI3ZbBOXc2CVNO2/vm5zw=
Expand Down
34 changes: 34 additions & 0 deletions pkg/proxy/api/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ import (
"net/http"
"strconv"

"github.com/btcsuite/websocket"
"github.com/gin-gonic/gin"
"github.com/multiversx/mx-chain-core-go/marshal"
"github.com/multiversx/mx-chain-go/api/logs"
"github.com/multiversx/mx-chain-go/node/chainSimulator/dtos"
logger "github.com/multiversx/mx-chain-logger-go"
"github.com/multiversx/mx-chain-proxy-go/api/shared"
"github.com/multiversx/mx-chain-proxy-go/data"
dtosc "github.com/multiversx/mx-chain-simulator-go/pkg/dtos"
)

var log = logger.GetOrCreate("pkg/proxy/api")

const (
generateBlocksEndpoint = "/simulator/generate-blocks/:num"
generateBlocksUntilEpochReached = "/simulator/generate-blocks-until-epoch-reached/:epoch"
Expand Down Expand Up @@ -63,9 +69,37 @@ func (ep *endpointsProcessor) ExtendProxyServer(httpServer *http.Server) error {
ws.GET(observersInfo, ep.getObserversInfo)
ws.POST(epochChange, ep.forceEpochChange)

serializerForLogs := &marshal.GogoProtoMarshalizer{}
registerLoggerWsRoute(ws, serializerForLogs)

return nil
}

// registerLoggerWsRoute will register the log route
func registerLoggerWsRoute(ws *gin.Engine, serializer marshal.Marshalizer) {
upgrader := websocket.Upgrader{}

ws.GET("/log", func(c *gin.Context) {
upgrader.CheckOrigin = func(r *http.Request) bool {
return true
}

conn, err := upgrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
log.Error(err.Error())
return
}

ls, err := logs.NewLogSender(serializer, conn, log)
if err != nil {
log.Error(err.Error())
return
}

ls.StartSendingBlocking()
})
}

func (ep *endpointsProcessor) forceEpochChange(c *gin.Context) {
targetEpoch, err := getTargetEpochQueryParam(c)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/proxy/creator/creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func CreateProxy(args ArgsProxy) (*ArgsOutputProxy, error) {
observersProvider,
fullHistoryNodesProvider,
pubKeyConverter,
false,
)
if err != nil {
return nil, err
Expand Down

0 comments on commit e1d26d4

Please sign in to comment.