Skip to content

Commit 51bcc3e

Browse files
Merge pull request #6491 from multiversx/merge-rc-v1.8.0-feat-governance-fixes
Merge rc v1.8.0 feat governance fixes
2 parents 5739ad1 + 5b4b719 commit 51bcc3e

File tree

836 files changed

+66517
-15749
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

836 files changed

+66517
-15749
lines changed

.github/workflows/build_and_test.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
name: Build
1+
name: Build and smoke test
22

33
on:
44
pull_request:
5-
branches: [ master, rc/* ]
6-
types: [opened, ready_for_review]
7-
push:
5+
branches: [master, rc/*]
86
workflow_dispatch:
97

108
jobs:
119
build:
1210
strategy:
1311
matrix:
14-
runs-on: [ubuntu-latest]
12+
runs-on: [ubuntu-latest, macos-13, macos-13-xlarge]
1513
runs-on: ${{ matrix.runs-on }}
1614
name: Build
1715
steps:
@@ -28,12 +26,23 @@ jobs:
2826
run: |
2927
go get -v -t -d ./...
3028
if [ -f Gopkg.toml ]; then
31-
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
32-
dep ensure
29+
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
30+
dep ensure
3331
fi
32+
3433
- name: Build
3534
run: |
3635
cd ${GITHUB_WORKSPACE}/cmd/node && go build .
36+
cd ${GITHUB_WORKSPACE}/cmd/seednode && go build .
3737
cd ${GITHUB_WORKSPACE}/cmd/keygenerator && go build .
3838
cd ${GITHUB_WORKSPACE}/cmd/logviewer && go build .
3939
cd ${GITHUB_WORKSPACE}/cmd/termui && go build .
40+
41+
# On GitHub, we only run the short tests, and we only run them for some OS/ARCH combinations.
42+
- name: Run tests
43+
run: |
44+
GOOS=$(go env GOOS)
45+
46+
if [[ "$GOOS" == darwin ]]; then
47+
go test -short -v ./...
48+
fi

.github/workflows/create_release.yml

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
build:
1616
strategy:
1717
matrix:
18-
runs-on: [ubuntu-latest] # TODO add macos-latest when builds are possible on macs
18+
runs-on: [ubuntu-latest, macos-13, macos-13-xlarge]
1919
runs-on: ${{ matrix.runs-on }}
2020
name: Build
2121
steps:
@@ -45,21 +45,23 @@ jobs:
4545
GOOS=$(go env GOOS)
4646
GOARCH=$(go env GOARCH)
4747
GOPATH=$(go env GOPATH)
48-
ARCHIVE="multiversx_""$APP_VER_SHORT""_""$GOOS""_""$GOARCH"".tgz"
48+
ARCHIVE="multiversx_""$APP_VER_SHORT""_""$GOOS""_""$GOARCH"".zip"
4949
BUILD_DIR=${GITHUB_WORKSPACE}/build
50-
WASM_VERSION=$(cat go.mod | grep mx-chain-vm-v | sort -n | tail -n -1| awk -F '/' '{print$3}'| sed 's/ /@/g')
51-
WASMER_DIR=${GOPATH}/pkg/mod/github.com/multiversx/${WASM_VERSION}/wasmer
50+
VM_GO_VERSION=$(cat go.mod | grep mx-chain-vm-go | sort -n | tail -n -1| awk -F '/' '{print$3}'| sed 's/ /@/g')
51+
VM_GO_DIR=${GOPATH}/pkg/mod/github.com/multiversx/${VM_GO_VERSION}
5252
5353
echo "GOOS=${GOOS}" >> $GITHUB_ENV
5454
echo "GOARCH=${GOARCH}" >> $GITHUB_ENV
5555
echo "ARCHIVE=${ARCHIVE}" >> $GITHUB_ENV
5656
echo "BUILD_DIR=${BUILD_DIR}" >> $GITHUB_ENV
57-
echo "WASMER_DIR=${WASMER_DIR}" >> $GITHUB_ENV
57+
echo "VM_GO_VERSION=${VM_GO_VERSION}" >> $GITHUB_ENV
58+
echo "VM_GO_DIR=${VM_GO_DIR}" >> $GITHUB_ENV
5859
5960
- name: Build
6061
run: |
6162
mkdir -p ${BUILD_DIR}
6263
cd ${GITHUB_WORKSPACE}/cmd/node && go build -o "${BUILD_DIR}/node" -a -ldflags="-X main.appVersion=${APP_VER}"
64+
cd ${GITHUB_WORKSPACE}/cmd/seednode && go build -o "${BUILD_DIR}/seednode" -a -ldflags="-X main.appVersion=${APP_VER}"
6365
cd ${GITHUB_WORKSPACE}/cmd/keygenerator && go build -o "${BUILD_DIR}/keygenerator" -a -ldflags="-X main.appVersion=${APP_VER}"
6466
cd ${GITHUB_WORKSPACE}/cmd/logviewer && go build -o "${BUILD_DIR}/logviewer" -a -ldflags="-X main.appVersion=${APP_VER}"
6567
cd ${GITHUB_WORKSPACE}/cmd/termui && go build -o "${BUILD_DIR}/termui" -a -ldflags="-X main.appVersion=${APP_VER}"
@@ -69,24 +71,68 @@ jobs:
6971
cd ${GITHUB_WORKSPACE}
7072
7173
if [[ "$GOOS" == linux && "$GOARCH" == amd64 ]]; then
72-
cp -f ${WASMER_DIR}/libwasmer_linux_amd64.so ${BUILD_DIR};
74+
cp --verbose --no-preserve=mode,ownership ${VM_GO_DIR}/wasmer2/libvmexeccapi.so ${BUILD_DIR}/libvmexeccapi.so
75+
cp --verbose --no-preserve=mode,ownership ${VM_GO_DIR}/wasmer/libwasmer_linux_amd64.so ${BUILD_DIR}/libwasmer_linux_amd64.so
7376
fi
77+
78+
# Actually, there's no runner for this combination (as of March 2024).
7479
if [[ "$GOOS" == linux && "$GOARCH" == arm64 ]]; then
75-
cp -f ${WASMER_DIR}/libwasmer_linux_arm64.so ${BUILD_DIR};
80+
cp --verbose --no-preserve=mode,ownership ${VM_GO_DIR}/wasmer2/libvmexeccapi_arm.so ${BUILD_DIR}/libvmexeccapi_arm.so
81+
cp --verbose --no-preserve=mode,ownership ${VM_GO_DIR}/wasmer/libwasmer_linux_arm64_shim.so ${BUILD_DIR}/libwasmer_linux_arm64_shim.so
7682
fi
83+
7784
if [[ "$GOOS" == darwin && "$GOARCH" == amd64 ]]; then
78-
cp -f ${WASMER_DIR}/libwasmer_darwin_amd64.dylib ${BUILD_DIR};
85+
cp -v ${VM_GO_DIR}/wasmer2/libvmexeccapi.dylib ${BUILD_DIR}/libvmexeccapi.dylib
86+
cp -v ${VM_GO_DIR}/wasmer/libwasmer_darwin_amd64.dylib ${BUILD_DIR}/libwasmer_darwin_amd64.dylib
87+
fi
88+
89+
if [[ "$GOOS" == darwin && "$GOARCH" == arm64 ]]; then
90+
cp -v ${VM_GO_DIR}/wasmer2/libvmexeccapi_arm.dylib ${BUILD_DIR}/libvmexeccapi_arm.dylib
91+
cp -v ${VM_GO_DIR}/wasmer/libwasmer_darwin_arm64_shim.dylib ${BUILD_DIR}/libwasmer_darwin_arm64_shim.dylib
7992
fi
8093
81-
cd ${BUILD_DIR}
82-
tar czvf "${GITHUB_WORKSPACE}/${ARCHIVE}" *
83-
stat ${GITHUB_WORKSPACE}/${ARCHIVE}
94+
if [[ "$GOOS" == linux ]]; then
95+
patchelf --set-rpath "\$ORIGIN" ${BUILD_DIR}/node
96+
patchelf --set-rpath "\$ORIGIN" ${BUILD_DIR}/seednode
97+
98+
ldd ${BUILD_DIR}/node
99+
ldd ${BUILD_DIR}/seednode
100+
fi
101+
102+
if [[ "$GOOS" == darwin ]]; then
103+
install_name_tool -add_rpath "@loader_path" ${BUILD_DIR}/node
104+
install_name_tool -add_rpath "@loader_path" ${BUILD_DIR}/seednode
105+
106+
otool -L ${BUILD_DIR}/node
107+
otool -L ${BUILD_DIR}/seednode
108+
fi
109+
110+
- name: Smoke test
111+
run: |
112+
# Remove all downloaded Go packages, so that we can test the binary's independence from them (think of Wasmer libraries).
113+
sudo rm -rf ${GOPATH}/pkg/mod
114+
115+
# Test binaries in different current directories.
116+
cd ${BUILD_DIR} && ./node --version
117+
cd ${GITHUB_WORKSPACE} && ${BUILD_DIR}/node --version
118+
cd / && ${BUILD_DIR}/node --version
119+
120+
cd ${BUILD_DIR} && ./seednode --version
121+
cd ${GITHUB_WORKSPACE} && ${BUILD_DIR}/seednode --version
122+
cd / && ${BUILD_DIR}/seednode --version
123+
124+
- name: Package build output
125+
run: |
126+
sudo chown -R $USER: ${BUILD_DIR}
127+
chmod -R 755 ${BUILD_DIR}
128+
ls -al ${BUILD_DIR}
129+
zip -r -j ${ARCHIVE} ${BUILD_DIR}
84130
85131
- name: Save artifacts
86132
uses: actions/upload-artifact@v3
87133
with:
88134
name: ${{ env.ARCHIVE }}
89-
path: ${{ github.workspace }}/${{ env.ARCHIVE }}
135+
path: ${{ env.ARCHIVE }}
90136
if-no-files-found: error
91137

92138
release:
@@ -113,6 +159,6 @@ jobs:
113159
run: |
114160
gh release create --draft --notes="Release draft from Github Actions" vNext
115161
sleep 10
116-
for i in $(find ./assets -name '*.tgz' -type f); do
162+
for i in $(find ./assets -name '*.zip' -type f); do
117163
gh release upload vNext ${i}
118164
done
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Build & push keygenerator docker image
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
7+
jobs:
8+
build-docker-image:
9+
strategy:
10+
matrix:
11+
runs-on: [ubuntu-latest]
12+
runs-on: ${{ matrix.runs-on }}
13+
14+
steps:
15+
- name: Check out code into the Go module directory
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@v3
20+
21+
- name: Log into Docker Hub
22+
if: github.event_name != 'pull_request'
23+
uses: docker/login-action@v3
24+
with:
25+
username: ${{ secrets.DOCKERHUB_USERNAME }}
26+
password: ${{ secrets.DOCKERHUB_TOKEN }}
27+
28+
- name: Build and push image to Docker Hub
29+
id: push
30+
uses: docker/build-push-action@v6
31+
with:
32+
context: .
33+
file: ./docker/keygenerator/Dockerfile
34+
platforms: linux/amd64,linux/arm64
35+
push: ${{ github.event_name != 'pull_request' }}
36+
tags: multiversx/chain-keygenerator:latest

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
- master
66
pull_request:
77
branches: [ master, feat/*, rc/* ]
8+
workflow_dispatch:
89

910
permissions:
1011
contents: read

api/errors/errors.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,6 @@ var ErrGetWaitingManagedKeys = errors.New("error getting the waiting managed key
174174

175175
// ErrGetWaitingEpochsLeftForPublicKey signals that an error occurred while getting the waiting epochs left for public key
176176
var ErrGetWaitingEpochsLeftForPublicKey = errors.New("error getting the waiting epochs left for public key")
177+
178+
// ErrRecursiveRelayedTxIsNotAllowed signals that recursive relayed tx is not allowed
179+
var ErrRecursiveRelayedTxIsNotAllowed = errors.New("recursive relayed tx is not allowed")

api/groups/addressGroup.go

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const (
3838
urlParamBlockHash = "blockHash"
3939
urlParamBlockRootHash = "blockRootHash"
4040
urlParamHintEpoch = "hintEpoch"
41+
urlParamWithKeys = "withKeys"
4142
)
4243

4344
// addressFacadeHandler defines the methods to be implemented by a facade for handling address requests
@@ -71,9 +72,11 @@ type esdtTokenData struct {
7172
Properties string `json:"properties"`
7273
}
7374

74-
type esdtNFTTokenData struct {
75+
// ESDTNFTTokenData defines the exposed nft token data structure
76+
type ESDTNFTTokenData struct {
7577
TokenIdentifier string `json:"tokenIdentifier"`
7678
Balance string `json:"balance"`
79+
Type string `json:"type"`
7780
Properties string `json:"properties,omitempty"`
7881
Name string `json:"name,omitempty"`
7982
Nonce uint64 `json:"nonce,omitempty"`
@@ -185,6 +188,14 @@ func (ag *addressGroup) getAccount(c *gin.Context) {
185188
return
186189
}
187190

191+
withKeys, err := parseBoolUrlParam(c, urlParamWithKeys)
192+
if err != nil {
193+
shared.RespondWithValidationError(c, errors.ErrCouldNotGetAccount, err)
194+
return
195+
}
196+
197+
options.WithKeys = withKeys
198+
188199
accountResponse, blockInfo, err := ag.getFacade().GetAccount(addr, options)
189200
if err != nil {
190201
shared.RespondWithInternalError(c, errors.ErrCouldNotGetAccount, err)
@@ -439,7 +450,7 @@ func (ag *addressGroup) getAllESDTData(c *gin.Context) {
439450
return
440451
}
441452

442-
formattedTokens := make(map[string]*esdtNFTTokenData)
453+
formattedTokens := make(map[string]*ESDTNFTTokenData)
443454
for tokenID, esdtData := range tokens {
444455
tokenData := buildTokenDataApiResponse(tokenID, esdtData)
445456

@@ -472,12 +483,14 @@ func (ag *addressGroup) isDataTrieMigrated(c *gin.Context) {
472483
shared.RespondWithSuccess(c, gin.H{"isMigrated": isMigrated})
473484
}
474485

475-
func buildTokenDataApiResponse(tokenIdentifier string, esdtData *esdt.ESDigitalToken) *esdtNFTTokenData {
476-
tokenData := &esdtNFTTokenData{
486+
func buildTokenDataApiResponse(tokenIdentifier string, esdtData *esdt.ESDigitalToken) *ESDTNFTTokenData {
487+
tokenData := &ESDTNFTTokenData{
477488
TokenIdentifier: tokenIdentifier,
478489
Balance: esdtData.Value.String(),
479490
Properties: hex.EncodeToString(esdtData.Properties),
480491
}
492+
493+
tokenType := core.ESDTType(esdtData.Type).String()
481494
if esdtData.TokenMetaData != nil {
482495
tokenData.Name = string(esdtData.TokenMetaData.Name)
483496
tokenData.Nonce = esdtData.TokenMetaData.Nonce
@@ -486,11 +499,25 @@ func buildTokenDataApiResponse(tokenIdentifier string, esdtData *esdt.ESDigitalT
486499
tokenData.Hash = esdtData.TokenMetaData.Hash
487500
tokenData.URIs = esdtData.TokenMetaData.URIs
488501
tokenData.Attributes = esdtData.TokenMetaData.Attributes
502+
503+
tokenType = getTokenType(esdtData.GetType(), tokenData.Nonce)
489504
}
490505

506+
tokenData.Type = tokenType
507+
491508
return tokenData
492509
}
493510

511+
func getTokenType(tokenType uint32, tokenNonce uint64) string {
512+
isNotFungible := tokenNonce != 0
513+
tokenTypeNotSet := isNotFungible && core.ESDTType(tokenType) == core.NonFungible
514+
if tokenTypeNotSet {
515+
return ""
516+
}
517+
518+
return core.ESDTType(tokenType).String()
519+
}
520+
494521
func (ag *addressGroup) getFacade() addressFacadeHandler {
495522
ag.mutFacade.RLock()
496523
defer ag.mutFacade.RUnlock()

api/groups/nodeGroup.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const (
2828
bootstrapStatusPath = "/bootstrapstatus"
2929
connectedPeersRatingsPath = "/connected-peers-ratings"
3030
managedKeys = "/managed-keys"
31+
loadedKeys = "/loaded-keys"
3132
managedKeysCount = "/managed-keys/count"
3233
eligibleManagedKeys = "/managed-keys/eligible"
3334
waitingManagedKeys = "/managed-keys/waiting"
@@ -44,6 +45,7 @@ type nodeFacadeHandler interface {
4445
GetConnectedPeersRatingsOnMainNetwork() (string, error)
4546
GetManagedKeysCount() int
4647
GetManagedKeys() []string
48+
GetLoadedKeys() []string
4749
GetEligibleManagedKeys() ([]string, error)
4850
GetWaitingManagedKeys() ([]string, error)
4951
GetWaitingEpochsLeftForPublicKey(publicKey string) (uint32, error)
@@ -129,6 +131,11 @@ func NewNodeGroup(facade nodeFacadeHandler) (*nodeGroup, error) {
129131
Method: http.MethodGet,
130132
Handler: ng.managedKeys,
131133
},
134+
{
135+
Path: loadedKeys,
136+
Method: http.MethodGet,
137+
Handler: ng.loadedKeys,
138+
},
132139
{
133140
Path: eligibleManagedKeys,
134141
Method: http.MethodGet,
@@ -411,6 +418,19 @@ func (ng *nodeGroup) managedKeys(c *gin.Context) {
411418
)
412419
}
413420

421+
// loadedKeys returns all keys loaded by the current node
422+
func (ng *nodeGroup) loadedKeys(c *gin.Context) {
423+
keys := ng.getFacade().GetLoadedKeys()
424+
c.JSON(
425+
http.StatusOK,
426+
shared.GenericAPIResponse{
427+
Data: gin.H{"loadedKeys": keys},
428+
Error: "",
429+
Code: shared.ReturnCodeSuccess,
430+
},
431+
)
432+
}
433+
414434
// managedKeysEligible returns the node's eligible managed keys
415435
func (ng *nodeGroup) managedKeysEligible(c *gin.Context) {
416436
keys, err := ng.getFacade().GetEligibleManagedKeys()

0 commit comments

Comments
 (0)