Skip to content

Commit

Permalink
Merge pull request #2 from capossele/develop
Browse files Browse the repository at this point in the history
testing releaser
  • Loading branch information
capossele authored May 24, 2021
2 parents 5c4c3d2 + c0ade04 commit 804a208
Show file tree
Hide file tree
Showing 156 changed files with 4,874 additions and 2,604 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ jobs:
name: GoReleaser
runs-on:
- ubuntu-latest
container:
image: gohornet/goreleaser-cgo-cross-compiler:1.16.3
volumes: [/repo]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.2
go-version: 1.16.3
- name: Copy config.default.json to config.json
run: cp config.default.json config.json
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
run: goreleaser --rm-dist
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
docker:
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ jobs:
name: Unit tests
runs-on: ubuntu-latest
steps:

- name: Setup dependencies
run: sudo apt-get install libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev

- name: Setup Go 1.16.2
- name: Setup Go 1.16.3
uses: actions/setup-go@v1
with:
go-version: 1.16.2
go-version: 1.16.3

- name: Checkout repository
uses: actions/checkout@v2

- name: Run Tests
run: go test ./...
run: go test ./... -tags rocksdb
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*.dat
*.dat.bkp

# Snapshots are stored in bin format
# *.bin

# cli-wallet config
tools/cli-wallet/config.json

Expand Down
7 changes: 3 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ builds:
# GoShimmer AMD64 all OS
- id: goshimmer
binary: goshimmer
env:
- CGO_ENABLED=0
flags:
- -tags=builtin_static,rocksdb
ldflags:
- -s -w -X github.com/iotaledger/goshimmer/plugins/banner.AppVersion={{.Version}}
main: main.go
goos:
- linux
- darwin
- windows
goarch:
- amd64

Expand Down
19 changes: 10 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# syntax = docker/dockerfile:1.2.1

############################
# Build
############################
# golang:1.16.2-buster
FROM golang@sha256:a23a7e49a820f9ae69df0fedf64f037cb15b004997effa93ec885e5032277bc1 AS build
# golang 1.16.3-buster amd64
FROM golang@sha256:dfa3cef088454200d6b48e2a911138f7d5d9afff77f89243eea6342f16ddcfb0 AS build

ARG BUILD_TAGS=builtin_static,rocksdb

# Ensure ca-certficates are up to date
RUN update-ca-certificates
Expand All @@ -27,17 +27,18 @@ RUN go mod verify
# 4. Verify that goshimmer binary is statically linked
RUN --mount=target=. \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
GOOS=linux GOARCH=amd64 go build \
-tags="$BUILD_TAGS" \
-ldflags='-w -s -extldflags "-static"' \
-o /go/bin/goshimmer; \
./check_static.sh

############################
# Image
############################
# using static nonroot image
# user:group is nonroot:nonroot, uid:gid = 65532:65532
FROM gcr.io/distroless/static@sha256:23aa732bba4c8618c0d97c26a72a32997363d591807b0d4c31b0bbc8a774bddf
# https://github.com/GoogleContainerTools/distroless/tree/master/cc
# using distroless cc image, which includes everything in the base image (glibc, libssl and openssl)
FROM gcr.io/distroless/cc@sha256:4cad7484b00d98ecb300916b1ab71d6c71babd6860c6c5dd6313be41a8c55adb

EXPOSE 14666/tcp
EXPOSE 14626/udp
Expand All @@ -47,6 +48,6 @@ COPY snapshot.bin /snapshot.bin
COPY config.default.json /config.json

# Copy the Pre-built binary file from the previous stage
COPY --from=build /go/bin/goshimmer /run/goshimmer
COPY --chown=nonroot:nonroot --from=build /go/bin/goshimmer /run/goshimmer

ENTRYPOINT ["/run/goshimmer", "--config=/config.json", "--messageLayer.snapshot.file=/snapshot.bin", "--database.directory=/tmp/mainnetdb"]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@

This repository is where the IOTA Foundation's Research Department tests the Coordicide modules to study and evaluate their performance.

The aim of this open repository is to give the community the opportunity to follow developments, take part in testing, and learn more about [Coordicide](https://coordicide.iota.org/).
The aim of this open repository is to give the community the opportunity to follow developments, take part in testing, and learn more about [Coordicide](https://coordicide.iota.org/).

For a documentation, including tutorials and resources, we refer to the [Documentation](http://goshimmer.docs.iota.org/) (Github [link](https://github.com/iotaledger/goshimmer/blob/develop/docs/SUMMARY.md)).

**Note:** You can find details about future development plans on our [roadmap](https://roadmap.iota.org).

Expand Down
4 changes: 2 additions & 2 deletions client/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ func (api *GoShimmerAPI) SendFaucetRequest(base58EncodedAddr string, powTarget i
var cManaPledgeID identity.ID
if len(pledgeIDs) > 1 {
aManaPledgeIDFromString, err := mana.IDFromStr(pledgeIDs[0])
if err != nil {
if err == nil {
aManaPledgeID = aManaPledgeIDFromString
}
cManaPledgeIDFromString, err := mana.IDFromStr(pledgeIDs[1])
if err != nil {
if err == nil {
cManaPledgeID = cManaPledgeIDFromString
}
}
Expand Down
25 changes: 11 additions & 14 deletions client/manualpeering.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,35 @@ import (
"github.com/iotaledger/hive.go/autopeering/peer"
"github.com/iotaledger/hive.go/crypto/ed25519"

"github.com/iotaledger/goshimmer/plugins/manualpeering"
)

const (
routeManualConnectedPeers = "manualpeering/peers/connected"
routeManualPeers = "manualpeering/peers"
"github.com/iotaledger/goshimmer/packages/manualpeering"
plugin "github.com/iotaledger/goshimmer/plugins/manualpeering"
)

// AddManualPeers adds the provided list of peers to the manual peering layer.
func (api *GoShimmerAPI) AddManualPeers(peers []*peer.Peer) error {
if err := api.do(http.MethodPost, routeManualPeers, peers, nil); err != nil {
if err := api.do(http.MethodPost, plugin.RouteManualPeers, peers, nil); err != nil {
return errors.Wrap(err, "failed to add manual peers via the HTTP API")
}
return nil
}

// RemoveManualPeers remove the provided list of peers from the manual peering layer.
func (api *GoShimmerAPI) RemoveManualPeers(keys []ed25519.PublicKey) error {
peersToRemove := make([]*manualpeering.PeerToRemove, len(keys))
peersToRemove := make([]*plugin.PeerToRemove, len(keys))
for i, key := range keys {
peersToRemove[i] = &manualpeering.PeerToRemove{PublicKey: key.String()}
peersToRemove[i] = &plugin.PeerToRemove{PublicKey: key.String()}
}
if err := api.do(http.MethodDelete, routeManualPeers, peersToRemove, nil); err != nil {
if err := api.do(http.MethodDelete, plugin.RouteManualPeers, peersToRemove, nil); err != nil {
return errors.Wrap(err, "failed to remove manual peers via the HTTP API")
}
return nil
}

// GetManualConnectedPeers gets the list of connected neighbors from the manual peering layer.
func (api *GoShimmerAPI) GetManualConnectedPeers() ([]*peer.Peer, error) {
var peers []*peer.Peer
if err := api.do(http.MethodGet, routeManualConnectedPeers, nil, &peers); err != nil {
// GetManualKnownPeers gets the list of connected neighbors from the manual peering layer.
func (api *GoShimmerAPI) GetManualKnownPeers(opts ...manualpeering.GetKnownPeersOption) (
peers []*manualpeering.KnownPeer, err error) {
conf := manualpeering.BuildGetKnownPeersConfig(opts)
if err := api.do(http.MethodGet, plugin.RouteManualPeers, conf, &peers); err != nil {
return nil, errors.Wrap(err, "failed to get manual connected peers from the API")
}
return peers, nil
Expand Down
13 changes: 0 additions & 13 deletions client/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
const (
routePastCone = "tools/message/pastcone"
routeMissing = "tools/message/missing"

routeValueDebug = "tools/value/objects"
)

// ------------------- Communication layer -----------------------------
Expand Down Expand Up @@ -45,14 +43,3 @@ func (api *GoShimmerAPI) Missing() (*jsonmodels.MissingResponse, error) {
}
return res, nil
}

// ------------------- Value layer -----------------------------

// ValueObjects returns the list of value objects.
func (api *GoShimmerAPI) ValueObjects() (*jsonmodels.ObjectsResponse, error) {
res := &jsonmodels.ObjectsResponse{}
if err := api.do(http.MethodGet, routeValueDebug, nil, res); err != nil {
return nil, err
}
return res, nil
}
80 changes: 0 additions & 80 deletions client/value.go

This file was deleted.

42 changes: 38 additions & 4 deletions client/wallet/asset.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package wallet

import (
"github.com/capossele/asset-registry/pkg/registry"
"github.com/cockroachdb/errors"

"github.com/iotaledger/goshimmer/packages/ledgerstate"
)

Expand All @@ -18,9 +21,40 @@ type Asset struct {
// Precision defines how many decimal places are shown when showing this asset in wallets
Precision int

// Address defines the target address where the asset is supposed to be created
Address ledgerstate.Address
// Supply is the amount of tokens that we want to create
Supply uint64

// TransactionID that created the asset
TransactionID ledgerstate.TransactionID
}

// ToRegistry creates a ergistry asset from a wallet asset.
func (a *Asset) ToRegistry() *registry.Asset {
return &registry.Asset{
ID: a.Color.Base58(),
Name: a.Name,
Symbol: a.Symbol,
Supply: a.Supply,
TransactionID: a.TransactionID.Base58(),
}
}

// the amount of tokens that we want to create
Amount uint64
// AssetFromRegistryEntry creates a wallet asset from a registry asset.
func AssetFromRegistryEntry(regAsset *registry.Asset) (*Asset, error) {
color, err := ledgerstate.ColorFromBase58EncodedString(regAsset.ID)
if err != nil {
return nil, errors.Errorf("failed to parse color(ID) of asset from registry response: %w, err")
}
var txID ledgerstate.TransactionID
txID, err = ledgerstate.TransactionIDFromBase58(regAsset.TransactionID)
if err != nil {
return nil, errors.Errorf("failed to parse TransactionID of asset from registry response: %w, err")
}
return &Asset{
Color: color,
Name: regAsset.Name,
Symbol: regAsset.Symbol,
Supply: regAsset.Supply,
TransactionID: txID,
}, nil
}
Loading

0 comments on commit 804a208

Please sign in to comment.