Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nkn.. #982

Open
wants to merge 30 commits into
base: dependabot/npm_and_yarn/dashboard/web/babel/traverse-7.23.5
Choose a base branch
from
Open

Nkn.. #982

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
899f99f
Bump golang.org/x/net from 0.10.0 to 0.17.0
dependabot[bot] Dec 7, 2023
f9e7211
Bump golang.org/x/crypto from 0.14.0 to 0.17.0
dependabot[bot] Dec 18, 2023
2485e65
Bump crypto-js from 4.1.1 to 4.2.0 in /dashboard/web
dependabot[bot] Dec 7, 2023
fd3048c
Bump ip from 1.1.5 to 1.1.9 in /dashboard/web
dependabot[bot] Feb 21, 2024
4fd555c
Change ci badge from travis-ci to github actions
yilunzhang Feb 29, 2024
9afba59
Regenerate dashboard yarn.lock using official npm registry
yilunzhang Feb 29, 2024
c9773e8
fix findSuccessorAddrs has wrong params in comment
yilunzhang Mar 8, 2024
6edd104
Support WebRTC communication
billfort Apr 17, 2024
4d09045
Bump golang.org/x/net from 0.17.0 to 0.23.0
dependabot[bot] Apr 27, 2024
a65026f
Bump google.golang.org/protobuf from 1.30.0 to 1.33.0
dependabot[bot] Mar 13, 2024
d8381da
make config.json optional
yilunzhang May 8, 2024
f6a5802
reduce webrtc error log lvl
yilunzhang May 8, 2024
bbd586f
gofmt
yilunzhang May 8, 2024
24ade56
Add OnOfferConnected channel for synchronize connected event for client
billfort May 9, 2024
4906690
Check if nil before close WebRTC channels
billfort May 10, 2024
3952311
remove some debug log
yilunzhang May 10, 2024
d66c4b3
bump NetVersionNum
yilunzhang May 14, 2024
dff2b99
fix make docker not building amd64 image when running on arm
yilunzhang May 15, 2024
3dfea7c
fix MarshalJSON undefined for non-pointer Uint160
yilunzhang May 19, 2024
3956f06
increase default LowFeeTxnSizePerBlock to 8192
yilunzhang May 24, 2024
c2862f2
increase default rpc client timeout
yilunzhang Jul 15, 2024
c6185d7
chore: fix some function names
mountdisk Aug 16, 2024
6eecd7e
replace github.com/golang/protobuf with google.golang.org/protobuf
nbdy Sep 26, 2024
f69f0f3
regenerated with newer version
nbdy Sep 26, 2024
761f255
remove redundant alias
nbdy Sep 26, 2024
0cec1eb
adjust to nnet changes
nbdy Sep 26, 2024
f7f8a03
dependency bumps
nbdy Sep 26, 2024
741b0f8
use latest nnet
nbdy Sep 28, 2024
e2b4ca6
fix dependency/github workflow compatibility with go 1.20
yilunzhang Sep 28, 2024
69ca3e4
Create devcontainer.json
hmd123pm Dec 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {
}
}
19 changes: 9 additions & 10 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ on:
# branches: [ "master" ]

jobs:

build-ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20"

- name: Build
run: make
- name: Build
run: make

- name: Test
run: go test -v ./...
- name: Test
run: go test -v ./...
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ test:

.PHONY: docker
docker:
docker build -f docker/Dockerfile -t nknorg/nkn:latest-amd64 .
docker build -f docker/Dockerfile --build-arg build_args="build GOOS=linux GOARCH=amd64 BUILD_DIR=. BIN_DIR=." --build-arg base="amd64/" -t nknorg/nkn:latest-amd64 .
docker build -f docker/Dockerfile --build-arg build_args="build GOOS=linux GOARCH=arm GOARM=6 BUILD_DIR=. BIN_DIR=." --build-arg base="arm32v6/" -t nknorg/nkn:latest-arm32v6 .
docker build -f docker/Dockerfile --build-arg build_args="build GOOS=linux GOARCH=arm64 BUILD_DIR=. BIN_DIR=." --build-arg base="arm64v8/" -t nknorg/nkn:latest-arm64v8 .

Expand All @@ -111,6 +111,7 @@ docker_publish:
docker push nknorg/nkn:latest-arm32v6
docker push nknorg/nkn:latest-arm64v8
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create nknorg/nkn:latest nknorg/nkn:latest-amd64 nknorg/nkn:latest-arm32v6 nknorg/nkn:latest-arm64v8 --amend
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest annotate nknorg/nkn:latest nknorg/nkn:latest-amd64 --os linux --arch amd64
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest annotate nknorg/nkn:latest nknorg/nkn:latest-arm32v6 --os linux --arch arm
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest annotate nknorg/nkn:latest nknorg/nkn:latest-arm64v8 --os linux --arch arm64
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push -p nknorg/nkn:latest
90 changes: 36 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

# NKN Full Node

### *Official Go implementation of NKN full node.*
### _Official Go implementation of NKN full node._

<br/>

[![GitHub license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/nknorg/nkn)](https://goreportcard.com/report/github.com/nknorg/nkn) [![Build Status](https://travis-ci.org/nknorg/nkn.svg?branch=master)](https://travis-ci.org/nknorg/nkn) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](#contributing)
[![GitHub license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/nknorg/nkn/v2)](https://goreportcard.com/report/github.com/nknorg/nkn/v2) [![Build Status](https://github.com/nknorg/nkn/actions/workflows/build-ubuntu.yml/badge.svg)](https://github.com/nknorg/nkn/actions/workflows/build-ubuntu.yml) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](#contributing)

### Dev Status: V2 line, Production (Stable and Feature-Complete)

---

<br/>

> NKN, short for New Kind of Network, is a project aiming to rebuild the
Expand All @@ -21,9 +24,9 @@ Note: This is the official **full node** implementation of the NKN protocol,
which relays data for clients and earn mining rewards. For **client**
implementation which can send and receive data, please refer to:

* [nkn-sdk-go](https://github.com/nknorg/nkn-sdk-go)
* [nkn-sdk-js](https://github.com/nknorg/nkn-sdk-js)
* [nkn-java-sdk](https://github.com/nknorg/nkn-java-sdk)
- [nkn-sdk-go](https://github.com/nknorg/nkn-sdk-go)
- [nkn-sdk-js](https://github.com/nknorg/nkn-sdk-js)
- [nkn-java-sdk](https://github.com/nknorg/nkn-java-sdk)

## Introduction

Expand All @@ -50,13 +53,13 @@ More details can be found in [our wiki](https://github.com/nknorg/nkn/wiki).

## Technical Highlights

* Transmit any data to any node/client without any centralized server.
* Proof-of-Relay, a useful proof of work: mining is relaying data.
* Extremely scalable consensus algorithm (billions of nodes within seconds).
* Strong consistency rather than eventual consistency.
* Dynamic, large-scale network.
* Verifiable topology and routes.
* Secure address scheme with public key embedded.
- Transmit any data to any node/client without any centralized server.
- Proof-of-Relay, a useful proof of work: mining is relaying data.
- Extremely scalable consensus algorithm (billions of nodes within seconds).
- Strong consistency rather than eventual consistency.
- Dynamic, large-scale network.
- Verifiable topology and routes.
- Secure address scheme with public key embedded.

### Use pre-built binaries

Expand All @@ -68,7 +71,7 @@ a node.

### Use pre-built Docker image

*Prerequirement*: Have working docker software installed. For help with that
_Prerequirement_: Have working docker software installed. For help with that
visit [official docker
docs](https://docs.docker.com/install/#supported-platforms)

Expand All @@ -85,7 +88,7 @@ a node.

### Building using Docker

*Prerequirement*: Have working docker software installed. For help with that
_Prerequirement_: Have working docker software installed. For help with that
visit [official docker
docs](https://docs.docker.com/install/#supported-platforms)

Expand All @@ -99,7 +102,7 @@ This command should be run once every time you update the code base.

### Building from source

To build from source, you need a properly configured Go environment (lookup the required version within [go.mod](https://github.com/nknorg/nkn/blob/master/go.mod#L3), and
To build from source, you need a properly configured Go environment (lookup the required version within [go.mod](https://github.com/nknorg/nkn/blob/master/go.mod#L3), and
see [Go Official Installation Documentation](https://golang.org/doc/install) for install instructions).

Build the source code with make
Expand All @@ -111,6 +114,7 @@ $ make
```

Run Unit Tests

```sh
# run all tests
$ go test -v ./...
Expand All @@ -121,8 +125,8 @@ go test -v ./chain/store

After building is successful, you should see two executables:

* `nknd`: the nkn node program
* `nknc`: command line tool for nkn node control
- `nknd`: the nkn node program
- `nknc`: command line tool for nkn node control

Now you can see [configuration](#configuration) for how to configure and run a
node.
Expand Down Expand Up @@ -152,24 +156,25 @@ be specified by passing arguments to `nknd` or in `config.json`, run `nknd

We provide a few sample `config.json`:

* `config.mainnet.json`: join the mainnet
* `config.testnet.json`: join the testnet
* `config.local.json`: create and join a private chain on your localhost
- `config.mainnet.json`: join the mainnet
- `config.local.json`: create and join a private chain on your localhost

You can copy the one you want to `config.json` or write your own.

For convenience, we ship a copy of `config.mainnet.json` in release version (as
`default.json`) and in docker image (under `/nkn/`). The docker container will
copy this default one to `/nkn/data/config.json` if not exists on nknd launch.

If config file is not provided, node will join the mainnet by default.

#### `wallet.json`:

Before starting the node, you need to create a new wallet first. Wallet
information will be saved at `wallet.json` and it's encrypted with the password
you provided when creating the wallet. So please make sure you pick a strong
password and remember it!

``` shell
```shell
$ ./nknc wallet -c
Password:
Re-enter Password:
Expand All @@ -191,11 +196,7 @@ random password saved to `/nkn/data/wallet.pswd` if not exists on nknd launch.

#### `certs/`

`nknd` uses Let's Encrypt to apply and renew TLS certificate and put in into
`cert/` directory.

By default `nknd` will generate certificate with `x-x-x-x.ipv4.nknlabs.io` domain name which `x-x-x-x` is your ipv4
address, replace dot with dash.
`nknd` uses Let's Encrypt to apply and renew TLS certificate and put in into `cert/` directory. By default `nknd` will generate certificate with `x-x-x-x.ipv4.staticdns{1,2,3}.io` domain name which `x-x-x-x` is your ipv4 address, replace dot with dash. **The default cert domain is deprecated and will be removed in the future version. Please provide your own domain or cert if you need to use tls.**

If you would like to use your own domain name, simply set `CertDomainName` with your domain name in `config.json`, `nknd` will
automatically apply or renew certificate from Let's Encrypt and deploy it.
Expand All @@ -204,17 +205,14 @@ If you already have certificate and want to use it in `nknd`, you can put it in
`HttpsJsonDomain` `HttpWssDomain` with your domain name, `HttpsJsonCert` `HttpsJsonKey` `HttpWssCert` `HttpWssKey`
with your certificate full chain file and private key file.


#### Data and Logs

After `nknd` starts, it will creates two directories: `ChainDB` to store
blockchain data, and `Log` to store logs. By default `nknd` will creates these
directories in the current working directory, but it can be changed by passing
`--chaindb` and `--log` arguments to `nknd` or specify in config.json.

Now you can [join the mainnet](#join-the-mainnet), [join the
testnet](#join-the-testnet) or [create a private
chain](https://github.com/nknorg/nkn/wiki/Create-a-Private-Chain).
Now you can [join the mainnet](#join-the-mainnet) or [create a private chain](https://github.com/nknorg/nkn/wiki/Create-a-Private-Chain).

### Join the MainNet

Expand Down Expand Up @@ -261,12 +259,12 @@ wrong. If the problem still persists, [create an
issue](https://github.com/nknorg/nkn/issues/new) or ask us in our [Discord
group](#community).

### [Recommended] Using BeneficiaryAddr
### [Recommended] Using Beneficiary Address

By default, token mined by your node will be sent to the wallet your node is
using, which is NOT as safe as you might think. The recommended way is to use
another cold wallet (that is saved and backed up well) to store your token. You
can use your code wallet address as `BeneficiaryAddr` in `config.json` such that
can use your code wallet address as `beneficiaryAddr` in `config.json` such that
token mined by your node will be sent directly to that beneficiary address. This
is safer and more convenient because: 1. even if your node is hacked, or your
node wallet is leaked, you will not lose any token; 2. if you run multiple
Expand All @@ -275,16 +273,7 @@ address.

### NAT traversal and port forwarding

Most likely your node is behind a router and does not have a public IP address.
By default, `nknd` will try to detect if your router supports UPnP or NAT-PMP
protocol, and if success, it will try to set up port forwarding automatically.
You can add `--no-nat` flag when starting nknd OR add `"NAT": false` in
`config.json` to disable automatic port forwarding. If your router does not
support such protocol, you **have to** setup port forwarding on your router for
port 30001 as well as **all** other ports specified in `config.json`
(30001-30005 by default), otherwise other nodes cannot establish connections to
you and you will **NOT** be able to mine token even though your node can still
run and sync blocks.
By default, `nknd` will try to detect if your node is behind a router and if your router supports UPnP or NAT-PMP protocol, and if success, it will try to set up port forwarding automatically. You can add `--no-nat` flag when starting nknd OR add `"NAT": false` in `config.json` to disable automatic port forwarding. If your router does not support such protocol, you **have to** setup port forwarding on your router for port 30001 as well as **all** other ports specified in `config.json` (30001-30005 by default), otherwise other nodes cannot establish connections to you and you will **NOT** be able to earn mining rewards even though your node can still run and sync blocks.

When setting up port forwarding, public port needs to be the same as private
port mapped to your node. For example, you should map port 30001 on your
Expand All @@ -297,13 +286,6 @@ mappings, one for each port. One of the easiest way to find out how to setup
port forwarding on your router is to search "how to setup port forwarding" +
your router model or name online.

### Join the TestNet

Joining the TestNet is the same as joining MainNet, except for using
`config.testnet.json` as your config file instead of `config.mainnet.json`. Note
that TestNet token is for testing purpose only (thus do not have value), and may
be cleared at any time when TestNet upgrades.

## Contributing

**Can I submit a bug, suggestion or feature request?**
Expand All @@ -330,8 +312,8 @@ git commit -s

## Community

* [Forum](https://forum.nkn.org/)
* [Discord](https://discord.gg/c7mTynX)
* [Telegram](https://t.me/nknorg)
* [Reddit](https://www.reddit.com/r/nknblockchain/)
* [Twitter](https://twitter.com/NKN_ORG)
- [Forum](https://forum.nkn.org/)
- [Discord](https://discord.gg/c7mTynX)
- [Telegram](https://t.me/nknorg)
- [Reddit](https://www.reddit.com/r/nknblockchain/)
- [Twitter](https://twitter.com/NKN_ORG)
7 changes: 3 additions & 4 deletions api/common/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import (
"context"
"errors"
"fmt"
"google.golang.org/protobuf/encoding/protowire"

"github.com/nknorg/nkn/v2/config"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/common"
"github.com/nknorg/nkn/v2/config"
"github.com/nknorg/nkn/v2/transaction"
"github.com/nknorg/nkn/v2/vault"
)
Expand Down Expand Up @@ -197,7 +196,7 @@ func MakeGenerateIDTransaction(ctx context.Context, pubkey []byte, wallet *vault
default:
}

txn, err = transaction.NewGenerateIDTransaction(pubkey, sender, regFee, maxVersion, nonce, txnFee, proto.EncodeVarint(i))
txn, err = transaction.NewGenerateIDTransaction(pubkey, sender, regFee, maxVersion, nonce, txnFee, protowire.AppendVarint(nil, i))
if err != nil {
return nil, err
}
Expand Down
Loading