-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6aaf43b
Showing
21 changed files
with
2,590 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# IDE related files | ||
.vscode/ | ||
|
||
# Git related files | ||
.github/ | ||
.git/ | ||
|
||
# Docker related files | ||
.dockerignore | ||
docker-compose.yml | ||
|
||
# Documentation | ||
documentation/ | ||
|
||
# Scripts + Tools | ||
scripts/ | ||
tools/ | ||
|
||
# OSX related files | ||
.DS_Store | ||
|
||
# Executable | ||
/inx-validator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
target-branch: "develop" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Build | ||
|
||
on: | ||
pull_request | ||
|
||
jobs: | ||
build: | ||
name: Go | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.21" | ||
id: go | ||
|
||
- name: Print Go version | ||
run: go version | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build | ||
run: go build -v . | ||
|
||
build_docker: | ||
name: Docker | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build Docker image | ||
run: docker build . --file Dockerfile --tag inx-validator:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: gendoc | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
gendoc: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.21" | ||
id: go | ||
|
||
- name: Print Go version | ||
run: go version | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v3 | ||
|
||
- name: Run gendoc | ||
working-directory: tools/gendoc | ||
run: go mod tidy && go run main.go | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
title: "chore(gendoc): update docs" | ||
commit-message: "chore(gendoc): update docs" | ||
body: | | ||
Generated new config documentation. | ||
This PR is auto generated by [gendoc workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3Agendoc). | ||
branch: chore/gendoc | ||
base: develop | ||
add-paths: | | ||
*.json | ||
*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: GolangCIlint | ||
|
||
on: | ||
pull_request: | ||
paths-ignore: | ||
- 'documentation/**' | ||
- 'scripts/**' | ||
- 'tools/**' | ||
|
||
jobs: | ||
golangci-lint: | ||
name: GolangCI-Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v3 | ||
|
||
- name: golangci-lint | ||
uses: reviewdog/action-golangci-lint@v2 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
golangci_lint_flags: "--timeout=10m" | ||
reporter: github-pr-check | ||
filter_mode: nofilter | ||
fail_on_error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
docker: | ||
name: Release Docker | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: iotaledger/inx-validator | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
type=match,pattern=v(\d+.\d+),suffix=-alpha,group=1,enable=${{ contains(github.ref, '-alpha') }} | ||
type=match,pattern=v(\d+.\d+),suffix=-beta,group=1,enable=${{ contains(github.ref, '-beta') }} | ||
type=match,pattern=v(\d+.\d+),suffix=-rc,group=1,enable=${{ contains(github.ref, '-rc') }} | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.IOTALEDGER_DOCKER_USERNAME }} | ||
password: ${{ secrets.IOTALEDGER_DOCKER_PASSWORD }} | ||
|
||
- name: Build and push to Dockerhub | ||
uses: docker/build-push-action@v4 | ||
with: | ||
file: ./Dockerfile | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea | ||
.DS_Store | ||
inx-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# https://hub.docker.com/_/golang | ||
FROM golang:1.21-bullseye AS build | ||
|
||
# Ensure ca-certificates are up to date | ||
RUN update-ca-certificates | ||
|
||
# Set the current Working Directory inside the container | ||
RUN mkdir /scratch | ||
WORKDIR /scratch | ||
|
||
# Prepare the folder where we are putting all the files | ||
RUN mkdir /app | ||
|
||
# Copy everything from the current directory to the PWD(Present Working Directory) inside the container | ||
COPY . . | ||
|
||
# Download go modules | ||
RUN go mod download | ||
RUN go mod verify | ||
|
||
# Build the binary | ||
RUN go build -o /app/inx-validator -a | ||
|
||
# Copy the assets | ||
COPY ./config_defaults.json /app/config.json | ||
|
||
############################ | ||
# Image | ||
############################ | ||
# https://console.cloud.google.com/gcr/images/distroless/global/cc-debian11 | ||
# using distroless cc "nonroot" image, which includes everything in the base image (glibc, libssl and openssl) | ||
FROM gcr.io/distroless/cc-debian11:nonroot | ||
|
||
EXPOSE 9086/tcp | ||
|
||
# Copy the app dir into distroless image | ||
COPY --chown=nonroot:nonroot --from=build /app /app | ||
|
||
WORKDIR /app | ||
USER nonroot | ||
|
||
ENTRYPOINT ["/app/inx-validator"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package app | ||
|
||
import ( | ||
"github.com/iotaledger/hive.go/app" | ||
"github.com/iotaledger/hive.go/app/components/profiling" | ||
"github.com/iotaledger/hive.go/app/components/shutdown" | ||
"github.com/iotaledger/inx-app/components/inx" | ||
"github.com/iotaledger/inx-validator/components/validator" | ||
) | ||
|
||
var ( | ||
// Name of the app. | ||
Name = "inx-validator" | ||
|
||
// Version of the app. | ||
Version = "1.0.0-alpha.1" | ||
) | ||
|
||
func App() *app.App { | ||
return app.New(Name, Version, | ||
app.WithInitComponent(InitComponent), | ||
app.WithComponents( | ||
inx.Component, | ||
validator.Component, | ||
shutdown.Component, | ||
profiling.Component, | ||
), | ||
) | ||
} | ||
|
||
var ( | ||
InitComponent *app.InitComponent | ||
) | ||
|
||
func init() { | ||
InitComponent = &app.InitComponent{ | ||
Component: &app.Component{ | ||
Name: "App", | ||
}, | ||
NonHiddenFlags: []string{ | ||
"config", | ||
"help", | ||
"version", | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package validator | ||
|
||
import ( | ||
"crypto/ed25519" | ||
|
||
iotago "github.com/iotaledger/iota.go/v4" | ||
) | ||
|
||
// Account represents an account. | ||
type Account interface { | ||
// ID returns the accountID. | ||
ID() iotago.AccountID | ||
|
||
// Address returns the account address. | ||
Address() iotago.Address | ||
|
||
// PrivateKey returns the account private key for signing. | ||
PrivateKey() ed25519.PrivateKey | ||
} | ||
|
||
var _ Account = &Ed25519Account{} | ||
|
||
// Ed25519Account is an account that uses an Ed25519 key pair. | ||
type Ed25519Account struct { | ||
accountID iotago.AccountID | ||
privateKey ed25519.PrivateKey | ||
} | ||
|
||
// NewEd25519Account creates a new Ed25519Account. | ||
func NewEd25519Account(accountID iotago.AccountID, privateKey ed25519.PrivateKey) *Ed25519Account { | ||
return &Ed25519Account{ | ||
accountID: accountID, | ||
privateKey: privateKey, | ||
} | ||
} | ||
|
||
// ID returns the accountID. | ||
func (e *Ed25519Account) ID() iotago.AccountID { | ||
return e.accountID | ||
} | ||
|
||
// Address returns the account address. | ||
func (e *Ed25519Account) Address() iotago.Address { | ||
ed25519PubKey, ok := e.privateKey.Public().(ed25519.PublicKey) | ||
if !ok { | ||
panic("invalid public key type") | ||
} | ||
|
||
return iotago.Ed25519AddressFromPubKey(ed25519PubKey) | ||
} | ||
|
||
// PrivateKey returns the account private key for signing. | ||
func (e *Ed25519Account) PrivateKey() ed25519.PrivateKey { | ||
return e.privateKey | ||
} |
Oops, something went wrong.