Skip to content

Commit

Permalink
Merge pull request #5592 from multiversx/rc/v1.7.0
Browse files Browse the repository at this point in the history
Rc/v1.7.0
  • Loading branch information
iulianpascalau authored May 10, 2024
2 parents 69d5f59 + 8732346 commit f1b87e8
Show file tree
Hide file tree
Showing 735 changed files with 50,171 additions and 19,997 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
name: Build
name: Build and smoke test

on:
pull_request:
branches: [ master, rc/* ]
types: [opened, ready_for_review]
push:
branches: [master, rc/*]
workflow_dispatch:

jobs:
build:
strategy:
matrix:
runs-on: [ubuntu-latest]
runs-on: [ubuntu-latest, macos-latest, macos-13-xlarge]
runs-on: ${{ matrix.runs-on }}
name: Build
steps:
Expand All @@ -28,12 +26,23 @@ jobs:
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build
run: |
cd ${GITHUB_WORKSPACE}/cmd/node && go build .
cd ${GITHUB_WORKSPACE}/cmd/seednode && go build .
cd ${GITHUB_WORKSPACE}/cmd/keygenerator && go build .
cd ${GITHUB_WORKSPACE}/cmd/logviewer && go build .
cd ${GITHUB_WORKSPACE}/cmd/termui && go build .
# On GitHub, we only run the short tests, and we only run them for some OS/ARCH combinations.
- name: Run tests
run: |
GOOS=$(go env GOOS)
if [[ "$GOOS" == darwin ]]; then
go test -short -v ./...
fi
72 changes: 59 additions & 13 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
build:
strategy:
matrix:
runs-on: [ubuntu-latest] # TODO add macos-latest when builds are possible on macs
runs-on: [ubuntu-latest, macos-latest, macos-13-xlarge]
runs-on: ${{ matrix.runs-on }}
name: Build
steps:
Expand Down Expand Up @@ -45,21 +45,23 @@ jobs:
GOOS=$(go env GOOS)
GOARCH=$(go env GOARCH)
GOPATH=$(go env GOPATH)
ARCHIVE="multiversx_""$APP_VER_SHORT""_""$GOOS""_""$GOARCH"".tgz"
ARCHIVE="multiversx_""$APP_VER_SHORT""_""$GOOS""_""$GOARCH"".zip"
BUILD_DIR=${GITHUB_WORKSPACE}/build
WASM_VERSION=$(cat go.mod | grep mx-chain-vm-v | sort -n | tail -n -1| awk -F '/' '{print$3}'| sed 's/ /@/g')
WASMER_DIR=${GOPATH}/pkg/mod/github.com/multiversx/${WASM_VERSION}/wasmer
VM_GO_VERSION=$(cat go.mod | grep mx-chain-vm-go | sort -n | tail -n -1| awk -F '/' '{print$3}'| sed 's/ /@/g')
VM_GO_DIR=${GOPATH}/pkg/mod/github.com/multiversx/${VM_GO_VERSION}
echo "GOOS=${GOOS}" >> $GITHUB_ENV
echo "GOARCH=${GOARCH}" >> $GITHUB_ENV
echo "ARCHIVE=${ARCHIVE}" >> $GITHUB_ENV
echo "BUILD_DIR=${BUILD_DIR}" >> $GITHUB_ENV
echo "WASMER_DIR=${WASMER_DIR}" >> $GITHUB_ENV
echo "VM_GO_VERSION=${VM_GO_VERSION}" >> $GITHUB_ENV
echo "VM_GO_DIR=${VM_GO_DIR}" >> $GITHUB_ENV
- name: Build
run: |
mkdir -p ${BUILD_DIR}
cd ${GITHUB_WORKSPACE}/cmd/node && go build -o "${BUILD_DIR}/node" -a -ldflags="-X main.appVersion=${APP_VER}"
cd ${GITHUB_WORKSPACE}/cmd/seednode && go build -o "${BUILD_DIR}/seednode" -a -ldflags="-X main.appVersion=${APP_VER}"
cd ${GITHUB_WORKSPACE}/cmd/keygenerator && go build -o "${BUILD_DIR}/keygenerator" -a -ldflags="-X main.appVersion=${APP_VER}"
cd ${GITHUB_WORKSPACE}/cmd/logviewer && go build -o "${BUILD_DIR}/logviewer" -a -ldflags="-X main.appVersion=${APP_VER}"
cd ${GITHUB_WORKSPACE}/cmd/termui && go build -o "${BUILD_DIR}/termui" -a -ldflags="-X main.appVersion=${APP_VER}"
Expand All @@ -69,24 +71,68 @@ jobs:
cd ${GITHUB_WORKSPACE}
if [[ "$GOOS" == linux && "$GOARCH" == amd64 ]]; then
cp -f ${WASMER_DIR}/libwasmer_linux_amd64.so ${BUILD_DIR};
cp --verbose --no-preserve=mode,ownership ${VM_GO_DIR}/wasmer2/libvmexeccapi.so ${BUILD_DIR}/libvmexeccapi.so
cp --verbose --no-preserve=mode,ownership ${VM_GO_DIR}/wasmer/libwasmer_linux_amd64.so ${BUILD_DIR}/libwasmer_linux_amd64.so
fi
# Actually, there's no runner for this combination (as of March 2024).
if [[ "$GOOS" == linux && "$GOARCH" == arm64 ]]; then
cp -f ${WASMER_DIR}/libwasmer_linux_arm64.so ${BUILD_DIR};
cp --verbose --no-preserve=mode,ownership ${VM_GO_DIR}/wasmer2/libvmexeccapi_arm.so ${BUILD_DIR}/libvmexeccapi_arm.so
cp --verbose --no-preserve=mode,ownership ${VM_GO_DIR}/wasmer/libwasmer_linux_arm64_shim.so ${BUILD_DIR}/libwasmer_linux_arm64_shim.so
fi
if [[ "$GOOS" == darwin && "$GOARCH" == amd64 ]]; then
cp -f ${WASMER_DIR}/libwasmer_darwin_amd64.dylib ${BUILD_DIR};
cp -v ${VM_GO_DIR}/wasmer2/libvmexeccapi.dylib ${BUILD_DIR}/libvmexeccapi.dylib
cp -v ${VM_GO_DIR}/wasmer/libwasmer_darwin_amd64.dylib ${BUILD_DIR}/libwasmer_darwin_amd64.dylib
fi
if [[ "$GOOS" == darwin && "$GOARCH" == arm64 ]]; then
cp -v ${VM_GO_DIR}/wasmer2/libvmexeccapi_arm.dylib ${BUILD_DIR}/libvmexeccapi_arm.dylib
cp -v ${VM_GO_DIR}/wasmer/libwasmer_darwin_arm64_shim.dylib ${BUILD_DIR}/libwasmer_darwin_arm64_shim.dylib
fi
cd ${BUILD_DIR}
tar czvf "${GITHUB_WORKSPACE}/${ARCHIVE}" *
stat ${GITHUB_WORKSPACE}/${ARCHIVE}
if [[ "$GOOS" == linux ]]; then
patchelf --set-rpath "\$ORIGIN" ${BUILD_DIR}/node
patchelf --set-rpath "\$ORIGIN" ${BUILD_DIR}/seednode
ldd ${BUILD_DIR}/node
ldd ${BUILD_DIR}/seednode
fi
if [[ "$GOOS" == darwin ]]; then
install_name_tool -add_rpath "@loader_path" ${BUILD_DIR}/node
install_name_tool -add_rpath "@loader_path" ${BUILD_DIR}/seednode
otool -L ${BUILD_DIR}/node
otool -L ${BUILD_DIR}/seednode
fi
- name: Smoke test
run: |
# Remove all downloaded Go packages, so that we can test the binary's independence from them (think of Wasmer libraries).
sudo rm -rf ${GOPATH}/pkg/mod
# Test binaries in different current directories.
cd ${BUILD_DIR} && ./node --version
cd ${GITHUB_WORKSPACE} && ${BUILD_DIR}/node --version
cd / && ${BUILD_DIR}/node --version
cd ${BUILD_DIR} && ./seednode --version
cd ${GITHUB_WORKSPACE} && ${BUILD_DIR}/seednode --version
cd / && ${BUILD_DIR}/seednode --version
- name: Package build output
run: |
sudo chown -R $USER: ${BUILD_DIR}
chmod -R 755 ${BUILD_DIR}
ls -al ${BUILD_DIR}
zip -r -j ${ARCHIVE} ${BUILD_DIR}
- name: Save artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARCHIVE }}
path: ${{ github.workspace }}/${{ env.ARCHIVE }}
path: ${{ env.ARCHIVE }}
if-no-files-found: error

release:
Expand All @@ -113,6 +159,6 @@ jobs:
run: |
gh release create --draft --notes="Release draft from Github Actions" vNext
sleep 10
for i in $(find ./assets -name '*.tgz' -type f); do
for i in $(find ./assets -name '*.zip' -type f); do
gh release upload vNext ${i}
done
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,36 @@ sudo cp protoc-gen-gogoslick /usr/bin/

Done

## Running p2p Prometheus dashboards
1. Start the node with `--p2p-prometheus-metrics` flag. This exposes a metrics collection at http://localhost:8080/debug/metrics/prometheus (port defined by -rest-api-interface flag, default 8080)
2. Clone libp2p repository: `git clone https://github.com/libp2p/go-libp2p`
3. `cd go-libp2p/dasboards/swarm` and under the
```
"templating": {
"list": [
```
section, add the following lines:
```
{
"hide": 0,
"label": "datasource",
"name": "DS_PROMETHEUS",
"options": [],
"query": "prometheus",
"refresh": 1,
"regex": "",
"type": "datasource"
},
```
(this step will be removed once it will be fixed on libp2p)
4. `cd ..` to dashboards directory and update the port of `host.docker.internal` from `prometheus.yml` to node's Rest API port(default `8080`)
5. From this directory, run the following docker compose command:
```
sudo docker compose -f docker-compose.base.yml -f docker-compose-linux.yml up --force-recreate
```
**Note:** If you choose to install the new Docker version manually, please make sure that installation is done for all users of the system. Otherwise, the docker command will fail because it needs the super-user privileges.
6. The preconfigured dashboards should be now available on Grafana at http://localhost:3000/dashboards

## Progress

### Done
Expand Down
3 changes: 3 additions & 0 deletions api/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,6 @@ var ErrGetEligibleManagedKeys = errors.New("error getting the eligible managed k

// ErrGetWaitingManagedKeys signals that an error occurred while getting the waiting managed keys
var ErrGetWaitingManagedKeys = errors.New("error getting the waiting managed keys")

// ErrGetWaitingEpochsLeftForPublicKey signals that an error occurred while getting the waiting epochs left for public key
var ErrGetWaitingEpochsLeftForPublicKey = errors.New("error getting the waiting epochs left for public key")
7 changes: 6 additions & 1 deletion api/gin/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ func TestCommon_checkArgs(t *testing.T) {
err := checkArgs(args)
require.True(t, errors.Is(err, apiErrors.ErrCannotCreateGinWebServer))

args.Facade, err = initial.NewInitialNodeFacade("api interface", false, &testscommon.StatusMetricsStub{})
args.Facade, err = initial.NewInitialNodeFacade(initial.ArgInitialNodeFacade{
ApiInterface: "api interface",
PprofEnabled: false,
P2PPrometheusMetricsEnabled: false,
StatusMetricsHandler: &testscommon.StatusMetricsStub{},
})
require.NoError(t, err)
err = checkArgs(args)
require.NoError(t, err)
Expand Down
7 changes: 7 additions & 0 deletions api/gin/webServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ import (
"github.com/multiversx/mx-chain-go/config"
"github.com/multiversx/mx-chain-go/facade"
logger "github.com/multiversx/mx-chain-logger-go"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

var log = logger.GetOrCreate("api/gin")

const prometheusMetricsRoute = "/debug/metrics/prometheus"

// ArgsNewWebServer holds the arguments needed to create a new instance of webServer
type ArgsNewWebServer struct {
Facade shared.FacadeHandler
Expand Down Expand Up @@ -227,6 +230,10 @@ func (ws *webServer) registerRoutes(ginRouter *gin.Engine) {
if ws.facade.PprofEnabled() {
pprof.Register(ginRouter)
}

if ws.facade.P2PPrometheusMetricsEnabled() {
ginRouter.GET(prometheusMetricsRoute, gin.WrapH(promhttp.Handler()))
}
}

func (ws *webServer) createMiddlewareLimiters() ([]shared.MiddlewareProcessor, error) {
Expand Down
9 changes: 9 additions & 0 deletions api/groups/addressGroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (
urlParamBlockHash = "blockHash"
urlParamBlockRootHash = "blockRootHash"
urlParamHintEpoch = "hintEpoch"
urlParamWithKeys = "withKeys"
)

// addressFacadeHandler defines the methods to be implemented by a facade for handling address requests
Expand Down Expand Up @@ -185,6 +186,14 @@ func (ag *addressGroup) getAccount(c *gin.Context) {
return
}

withKeys, err := parseBoolUrlParam(c, urlParamWithKeys)
if err != nil {
shared.RespondWithValidationError(c, errors.ErrCouldNotGetAccount, err)
return
}

options.WithKeys = withKeys

accountResponse, blockInfo, err := ag.getFacade().GetAccount(addr, options)
if err != nil {
shared.RespondWithInternalError(c, errors.ErrCouldNotGetAccount, err)
Expand Down
19 changes: 19 additions & 0 deletions api/groups/nodeGroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
managedKeysCount = "/managed-keys/count"
eligibleManagedKeys = "/managed-keys/eligible"
waitingManagedKeys = "/managed-keys/waiting"
epochsLeftInWaiting = "/waiting-epochs-left/:key"
)

// nodeFacadeHandler defines the methods to be implemented by a facade for node requests
Expand All @@ -47,6 +48,7 @@ type nodeFacadeHandler interface {
GetLoadedKeys() []string
GetEligibleManagedKeys() ([]string, error)
GetWaitingManagedKeys() ([]string, error)
GetWaitingEpochsLeftForPublicKey(publicKey string) (uint32, error)
IsInterfaceNil() bool
}

Expand Down Expand Up @@ -144,6 +146,11 @@ func NewNodeGroup(facade nodeFacadeHandler) (*nodeGroup, error) {
Method: http.MethodGet,
Handler: ng.managedKeysWaiting,
},
{
Path: epochsLeftInWaiting,
Method: http.MethodGet,
Handler: ng.waitingEpochsLeft,
},
}
ng.endpoints = endpoints

Expand Down Expand Up @@ -460,6 +467,18 @@ func (ng *nodeGroup) managedKeysWaiting(c *gin.Context) {
)
}

// waitingEpochsLeft returns the number of epochs left for the public key until it becomes eligible
func (ng *nodeGroup) waitingEpochsLeft(c *gin.Context) {
publicKey := c.Param("key")
epochsLeft, err := ng.getFacade().GetWaitingEpochsLeftForPublicKey(publicKey)
if err != nil {
shared.RespondWithInternalError(c, errors.ErrGetWaitingEpochsLeftForPublicKey, err)
return
}

shared.RespondWithSuccess(c, gin.H{"epochsLeft": epochsLeft})
}

func (ng *nodeGroup) getFacade() nodeFacadeHandler {
ng.mutFacade.RLock()
defer ng.mutFacade.RUnlock()
Expand Down
Loading

0 comments on commit f1b87e8

Please sign in to comment.