Compare commits

..
Author SHA1 Message Date
0xmuralik db2c3afef1 rename func 2023-03-10 16:50:47 +05:30
0xmuralik 8932d69f36 fix unit test CID 2023-03-09 00:47:04 +05:30
0xmuralik 1d73452ff6 replace fn 2023-03-07 14:51:54 +05:30
4 changed files with 32 additions and 51 deletions
+15 -24
View File
@@ -1,4 +1,4 @@
# Validator Guide for laconic_81337-6 Testnet
# Validator Guide for laconic_81337-5 Testnet
## Hardware Prerequisites
@@ -48,8 +48,8 @@ sudo apt install git curl build-essential make jq -y
# Remove any existing installation of `go`
sudo rm -rf /usr/local/go
# Install Go version 1.19.7
curl https://dl.google.com/go/go1.19.7.linux-amd64.tar.gz | sudo tar -C/usr/local -zxvf -
# Install Go version 1.18.8
curl https://dl.google.com/go/go1.18.8.linux-amd64.tar.gz | sudo tar -C/usr/local -zxvf -
# Update env variables to include go
cat <<'EOF' >>$HOME/.profile
@@ -67,7 +67,7 @@ Check the version of go installed
```sh
go version
# Should return something like: go version go1.19.7 linux/amd64
# Should return something like: go version go1.17.2 linux/amd64
```
---
@@ -80,17 +80,16 @@ cd laconicd
# Checkout main branch
git fetch --all
git checkout v0.8.0
git checkout v0.6.0
# Build and install laconic
make VERSION=v0.8.0 install
make install
```
Verify your installation
```sh
laconicd version --long
```
On running the above command, you should see a similar response like this. Make sure that the _version_ and _commit
@@ -123,13 +122,13 @@ Make sure the directory `~/.laconicd` does not exist or is empty
>In order to run the below commands in a docker container:
>```sh
>docker run -ti -v ~/.laconicd:/root/.laconicd \
>git.vdb.to/cerc-io/laconicd/laconicd:v0.8.0 /bin/sh
>git.vdb.to/cerc-io/laconicd/laconicd:v0.6.0 /bin/sh
>```
---
```sh
# Initialize the validator node
laconicd init <your-node-moniker> --chain-id laconic_81337-6
laconicd init <your-node-moniker> --chain-id laconic_81337-5
```
Running the above commands will initialize the validator node with default configuration. The config files will be saved in the default location (`~/.laconicd/config`).
@@ -169,7 +168,7 @@ Create Your `gentx` transaction file
```sh
laconicd gentx <key-name> 12900000000000000000000achk \
--pubkey=$(laconicd tendermint show-validator) \
--chain-id="laconic_81337-6" \
--chain-id="laconic_81337-5" \
--moniker="<your-moniker-name>" \
--website="<your-validator-website>" \
--details="<your-validator-description>" \
@@ -199,10 +198,10 @@ Submit your `gentx` file to the [https://github.com/cerc-io/laconic-testnet](htt
To submit the gentx file, follow the below process:
- Fork the [https://github.com/cerc-io/laconic-testnet](https://github.com/cerc-io/laconic-testnet) repository
- Upload your gentx file in the `laconic_81337-6/config/gentxs` folder
- Upload your gentx file in the `laconic_81337-5/config/gentxs` folder
- Submit Pull Request to [https://github.com/cerc-io/laconic-testnet](https://github.com/cerc-io/laconic-testnet) with name `ADD <your-moniker> gentx`
The genesis file will be published in the `laconic_81337-6/config/` folder within the [https://github.com/cerc-io/laconic-testnet](https://github.com/cerc-io/laconic-testnet) repository.
The genesis file will be published in the `laconic_81337-5/config/` folder within the [https://github.com/cerc-io/laconic-testnet](https://github.com/cerc-io/laconic-testnet) repository.
# CONTINUE WITH BELOW STEPS ONLY AFTER GENESIS FILE HAS BEEN PUBLISHED
@@ -272,33 +271,25 @@ journalctl -f -u laconicd
In this example the Tendermint RPC and Prometheus metrics ports are exposed only to localhost. You may want to change 127.0.0.1 to private or public network interface of your host if you need to access these ports remotely.
```sh
docker create \
--name laconic-testnet-6 \
--restart always \
-v ~/.laconicd:/root/.laconicd \
-p 26656:26656 \
-p 127.0.0.1:26657:26657 \
-p 127.0.0.1:26660:26660 \
git.vdb.to/cerc-io/laconicd/laconicd:v0.8.0 \
laconicd start --gql-playground --gql-server --log_level=warn
docker create --name laconic-testnet-5 -v ~/.laconicd:/root/.laconicd -p 26656:26656 -p 127.0.0.1:26657:26657 -p 127.0.0.1:26660:26660 git.vdb.to/cerc-io/laconicd/laconicd:v0.6.0 laconicd start --gql-playground --gql-server --log_level=warn
```
### Run validator node
```sh
docker start laconic-testnet-6
docker start laconic-testnet-5
```
### Check validator node logs
```sh
docker logs laconic-testnet-6
docker logs laconic-testnet-5
```
### Run shell inside docker container
```sh
docker exec -ti laconic-testnet-6 /bin/sh
docker exec -ti laconic-testnet-5 /bin/sh
```
---
## Helpful commands
+7 -15
View File
@@ -10,7 +10,6 @@ import (
canonicalJson "github.com/gibson042/canonicaljson-go"
"github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/ipld/go-ipld-prime/codec/dagcbor"
"github.com/ipld/go-ipld-prime/codec/dagjson"
"github.com/ipld/go-ipld-prime/linking"
@@ -18,7 +17,6 @@ import (
"github.com/ipld/go-ipld-prime/multicodec"
basicnode "github.com/ipld/go-ipld-prime/node/basic"
"github.com/ipld/go-ipld-prime/storage/memstore"
mh "github.com/multiformats/go-multihash"
)
var store = memstore.Store{}
@@ -35,7 +33,7 @@ func GenerateHash(json map[string]interface{}) (string, []byte, error) {
return "", nil, err
}
cidString, err := CIDFromJSONBytesUsingIpldPrime(content)
cidString, err := CIDFromJSONBytes(content)
if err != nil {
return "", nil, err
}
@@ -43,16 +41,6 @@ func GenerateHash(json map[string]interface{}) (string, []byte, error) {
return cidString, content, nil
}
// CIDFromJSONBytes returns CID (cbor) for json (as bytes).
func CIDFromJSONBytes(content []byte) (string, error) {
cid, err := cbor.FromJSON(bytes.NewReader(content), mh.SHA2_256, -1)
if err != nil {
return "", err
}
return cid.String(), nil
}
// GetAttributeAsString returns a map attribute as string, if possible.
func GetAttributeAsString(obj map[string]interface{}, attr string) (string, error) {
if value, ok := obj[attr]; ok {
@@ -66,10 +54,14 @@ func GetAttributeAsString(obj map[string]interface{}, attr string) (string, erro
return "", errors.New("attribute not found")
}
// CIDFromJSONBytesUsingIpldPrime returns CID (dagcbor) for json (as bytes).
// CIDFromJSONBytes returns CID (dagcbor) for json (as bytes).
// This is combination of samples for unmarshalling and linking
// see: https://pkg.go.dev/github.com/ipld/go-ipld-prime
func CIDFromJSONBytesUsingIpldPrime(content []byte) (string, error) {
func CIDFromJSONBytes(content []byte) (string, error) {
if len(content) == 0 {
return "", nil
}
np := basicnode.Prototype.Any // Pick a stle for the in-memory data.
nb := np.NewBuilder() // Create a builder.
err := dagjson.Decode(nb, bytes.NewReader(content)) // Hand the builder to decoding -- decoding will fill it in!
+9 -11
View File
@@ -1,8 +1,9 @@
package utils
import (
"github.com/stretchr/testify/require"
"testing"
"github.com/stretchr/testify/require"
)
func TestAndValidateCIDGeneration(t *testing.T) {
@@ -11,13 +12,12 @@ func TestAndValidateCIDGeneration(t *testing.T) {
content string
expected string
}{
// empty string and empty json blows up
// {
// "empty string", "", "bafyreiengp2sbi6ez34a2jctv34bwyjl7yoliteleaswgcwtqzrhmpyt2m",
// },
// {
// "empty json", "{}", "bafyreihpfkdvib5muloxlj5b3tgdwibjdcu3zdsuhyft33z7gtgnlzlkpm",
// },
{
"empty string", "", "",
},
{
"empty json", "{}", "bafyreigbtj4x7ip5legnfznufuopl4sg4knzc2cof6duas4b3q2fy6swua",
},
{
"test record", "{\"build_artifact_cid\":\"QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9\",\"repo_registration_record_cid\":\"QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D\",\"tls_cert_cid\":\"QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR\",\"type\":\"WebsiteRegistrationRecord\",\"url\":\"https://cerc.io\",\"version\":\"0.0.1\"}",
@@ -26,10 +26,8 @@ func TestAndValidateCIDGeneration(t *testing.T) {
}
for _, tc := range testCases {
deprecatedAndCorrect, _ := CIDFromJSONBytes([]byte(tc.content))
newImpl, err := CIDFromJSONBytesUsingIpldPrime([]byte(tc.content))
newImpl, err := CIDFromJSONBytes([]byte(tc.content))
require.NoError(t, err)
require.Equal(t, deprecatedAndCorrect, newImpl, tc.name)
require.Equal(t, tc.expected, newImpl)
}
}
+1 -1
View File
@@ -70,7 +70,7 @@ func UnMarshalMapFromJSONBytes(bytes []byte) map[string]interface{} {
// GetCid gets the content ID.
func GetCid(content []byte) (string, error) {
return wnsUtils.CIDFromJSONBytesUsingIpldPrime(content)
return wnsUtils.CIDFromJSONBytes(content)
}
// BytesToBase64 encodes a byte array as a base64 string.