GoNode comprises two primary applications, walletnode
and supernode
. They are engineered to facilitate NFT registration on the Pastel blockchain. Neither walletnode
nor supernode
directly interface with the blockchain. Instead, they employ Pastel's RPC API to interact with Pastel's cNode, which manages the blockchain itself.
- Begin with
golang
and install the latest version. - To generate mocks, install
mockery
. - For proto generation, install the protoc compiler, protoc-gen-go, and protoc-gen-go-grpc:
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
Run make gen-mocks
if want to build and run unit tests
make build
There are multiple methods and tools available to test the functionality of gonode. However, since the entire system relies on cNode and a collection of remote SuperNodes, setting up such an environment can be challenging.
make sn-unit-tests
make wn-unit-tests
Integration tests ensure API contracts are upheld and the APIs function as anticipated. These tests launch supernode containers and emulate CNode, RaptorQ & Duplication Detection services. These mock services are located in /fakes
.
make integration-tests
For more information about Integration Tests, refer to the README in the /integration
directory.
- Clone Pastelup.
- Install walletnode by following the steps provided in the pastelup README.
- Ensure your cNode is fully synced and returns top nodes when you run
./pastel-cli masternodes top
. - Create an artist pastel Id:
./pastel-cli pastelid newkey passphrase
. Here, the passphrase for artist pastel id ispassphrase
. - Generate an address:
./pastel-cli getnewaddress
. You'll use the generated address in the next step. - From another node on the testnet, send some coins to the newly created artist's address:
./pastel-cli sendtoaddress <artist-addr> <amount> "" "" true
. - Register the artist with the network:
./pastel-cli tickets register id <artist-pastelId> "passphrase" <artist-address>
. After this step, you can use yourpastel-id
to send requests to the walletnode.
The pastel-api
simulates the Pastel RPC API, provided by cNode, and is used for local testing of the walletnode and supernode.
Follow these steps:
- Clone
regtest-network
. - Unzip node files:
cd <your-path>/mock-networks/regtest && mkdir unzipped && cd unzipped && tar -xvf ../node.tar.gz
. - Copy
masternode.conf
to node directory:cp <your-path>/regtest/masternode.conf <your-path>/regtest/unzipped/node14/regtest/
. - Copy
start.py
andstart_masternodes.sh
to regtest directory:cp <your-path>/regtest/{start.py,start_masternodes.sh} <your-path>/regtest/
. - Start python script:
cd <your-path>/regtest && ./start.py
. - Execute
./start_masternodes.sh
and retry if cNode(s) are not ready. - Verify if all masternodes are
ENABLE
using<your-path>/pastel-cli -datadir=<your-path>/regtest/unzipped/node14 masternode list
. - Generate a block to establish connections between masternodes:
<your-path>/pastel-cli -datadir=<your-path>/regtest/unzipped/node13 generate 1
. - Verify top-ranked masternodes contain nodes whose
extAddr
islocalhost:{4444:4445:4446}
using<your-path>/pastel-cli -datadir=<your-path>/regtest/unzipped/node14 masternode top
. These nodes are the ones supernode(s) will connect to. - Verify masternode{0,1,2} also have the same top node list:
<your-path>/pastel-cli -datadir=<your-path>/regtest/unzipped/node{0,1,2} masternode top
. - Start walletnode:
GRPC_TRACE=tcp,http,api GRPC_VERBOSITY=debug WALLETNODE_DEBUG=1 ./walletnode/walletnode --log-level debug -c ./walletnode/examples/configs/localnet.yml --swagger 2>&1 | tee wallet-node.log
. - Start supernode(s):
SUPERNODE_DEBUG=1 LOAD_TFMODELS=0 ./supernode/supernode --log-level debug -c ./supernode/examples/configs/localnet-{4444,4445,4446}.yml 2>&1 | tee sn{1,2,3}.log
. - Create an artist Pastel ID:
<your-path>/pastel-cli -datadir=<your-path>/regtest/unzipped/node14 pastelid newkey passphrase
. The passphrase of the artist Pastel ID ispassphrase
. - Create an address:
<your-path>/pastel-cli -datadir=<your-path>/regtest/unzipped/node14 getnewaddress
. - Register the artist with the network:
<your-path>/pastel-cli -datadir=<your-path>/regtest/unzipped/node14 tickets register id <artist-pastelId> "passphrase" <artist-address>
. - Send coins to the artist's address using this command:
<your-path>/pastel-cli -datadir=<your-path>/regtest/unzipped/node13 sendtoaddress <artist-addr> <amount> "" "" true
. - Open a web browser and navigate to
localhost:8080/swagger
. - Upload an image.
- Register a task by changing the
artist-pastelId
,spendable-address
, andpassphrase
to "passphrase". Use theimage-id
obtained from the result of the image upload REST call. - Monitor the logs and use the appropriate command to generate coins as needed to maintain the flow. Coins need to be generated at the following stages:
- When the Walletnode sends
preburnt-txid
to a Supernode. - When the Walletnode receives
reg-art-txid
from a Supernode. - When the Walletnode receives
reg-act-txid
from the network. - Generating 10 blocks at each step is a safe way to keep the flow going.
- When the Walletnode sends
Notes:
- Walletnode's cNode is Node 14.
- The Miner is Node 13.
- Node{0,1,2} correspond to Supernode{4444,4445,4446} respectively.
Troubleshooting:
- If the Masternode(s) status is
EXPIRE
, repeat step7
. - If any Masternode(s) failed to start due to metadab, remove the respective folder(s) at
~/.pastel/supernode/metadb-444*
. - If any Masternode(s) failed to start due to kamedila, remove the respective folder(s) at
~/.pastel/supernode/p2p-localnet-600*
.
walletnode
operates as an API server, providing REST APIs on the client-side. The APIs enable users to search, view, and download NFTs, as well as register their own NFTs. Additionally, it allows end-users and other applications to utilize the Pastel Network's duplication detection system for images and a storage system. By default, it operates on port :8080. Configurations can be modified via walletnode.yml
in the Pastel configuration directory.
It offers the following Workflow APIs. The list below provides a high-level overview. For detailed API information, please refer to the swagger docs at localhost:8080/swagger
Use this workflow to register a new NFT as an artist/creator. You'll need your PastelID registered on the network. The steps to achieve this are detailed in the Testing Section of this document.
http://localhost:8080/nfts/register/upload
: Upload the image and receive a file_id.http://localhost:8080/nfts/register
: Initiate NFT register task. It returns a task_id in response.ws://127.0.0.1:8080/nfts/register/<<task_id>>/state
: Connect to this Websocket URL to monitor the status of the NFT register task. A successful registration will display the Task Completed status. NFT registration can take between 20 and 60 minutes.http://localhost:8080/nfts/<<task_id>>/history
: View task status history and details.http://localhost:8080/nfts/download?pid=<<pastel_id>>L&txid=<<tx_id>>
: Download the NFT. Only the current owner can download the original NFT.ws://localhost:8080/nfts/search?query=<<query>>&creator_name=true&art_title=true
: Search for an NFT. This WS provides various filters. Please consult the swagger docs for details.
Cascade facilitates secure and reliable file storage for other applications or users through Pastel's storage layer.
- Use
http://127.0.0.1:8080/openapi/cascade/upload
to upload a file and retrievefile_id
andestimated_fee
. - Initiate the Cascade register task by burning 20% of the
estimated_fee
. Find the burn address inwalletnode.yml
and send 20% of the estimated fee to this address from your address (the one used to register your PastelID). - Use
http://localhost:8080/openapi/cascade/start/<<file_id>>
to start the Cascade register task, which will return atask_id
in the response. - Monitor the status of the Cascade register task by connecting to this Websocket URL:
ws://127.0.0.1:8080/openapi/cascade/start/<<task_id>>/state
. A successful register will display aTask Completed
status. Note that the registration process may take between 20 - 60 minutes. - Use
http://localhost:8080/openapi/cascade/<<task_id>>/history
to view the task status history and details.
Sense provides other applications or users access to Pastel's state-of-the-art Duplication Detection service in exchange for a small fee.
- Use
http://127.0.0.1:8080/openapi/sense/upload
to upload a file and retrievefile_id
andestimated_fee
. - Initiate the Sense register task by burning 20% of the
estimated_fee
. Find the burn address inwalletnode.yml
and send 20% of the estimated fee to this address from your address (the one used to register your PastelID). - Use
http://localhost:8080/openapi/sense/start/<<file_id>>
to start the Sense register task, which will return atask_id
in the response. - Monitor the status of the Sense register task by connecting to this Websocket URL:
ws://127.0.0.1:8080/openapi/sense/start/<<task_id>>/state
. A successful register will display aTask Completed
status. Note that the registration process may take between 20 - 60 minutes. - Use
http://localhost:8080/openapi/sense/<<task_id>>/history
to view the task status history and details.
- To download the original file, use
http://localhost:8080/openapi/cascade/download?pid=<<pastel_id>>L&txid=<<tx_id>>
. Only the owner can download the file. - To download the duplication detection results for the provided image, use
http://localhost:8080/openapi/sense/download?pid=<<pastel_id>>L&txid=<<tx_id>>
.
supernode
is a server application for walletnode
. It handles communication with the blockchain, duplication detection server, storage, and other services.
Hermes has two primary roles:
-
Cleans up inactive tickets: If Registration or Action (Sense\Cascade) tickets aren't activated after a specified block height (configurable), Hermes will remove the data from the local SQLite Database. This process helps maintain a manageable database size and eliminates unnecessary data.
-
Stores fingerprints of Registration and Action ticket files in the fingerprints Database.
make sn-unit-tests
: Execute sn unit tests, including relevant packages.make wn-unit-tests
: Execute wn unit tests, including relevant packages.make integration-tests
: Execute integration tests.make build
: Verify if WN & SN can build successfully.make gen-mocks
: Remove existing mocks and generate new ones for interfaces throughout gonode (mocks are used in unit tests).make gen-proto
: Generate all protobuf models & services.make clean-proto
: Remove all protobuf models & services.