forked from cerc-io/laconicd
Additional CI workflows (#16)
Reviewed-on: deep-stack/laconic2d#16 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
parent
4e4e9caccf
commit
33b6cce362
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Dockerfile
|
||||||
|
build
|
17
.gitea/workflows/build.yml
Normal file
17
.gitea/workflows/build.yml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
name: Build
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 1.21
|
||||||
|
check-latest: true
|
||||||
|
- run: |
|
||||||
|
make build
|
28
.gitea/workflows/docker-image.yml
Normal file
28
.gitea/workflows/docker-image.yml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
name: Publish on release
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Run docker build and publish
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Run docker build
|
||||||
|
run: docker build -t cerc-io/laconic2d -f Dockerfile .
|
||||||
|
- name: Get the version
|
||||||
|
id: vars
|
||||||
|
run: |
|
||||||
|
echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7})
|
||||||
|
echo ::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/})
|
||||||
|
- name: Tag docker image
|
||||||
|
run: docker tag cerc-io/laconic2d git.vdb.to/cerc-io/laconic2d/laconic2d:${{steps.vars.outputs.sha}}
|
||||||
|
- name: Tag docker image
|
||||||
|
run: docker tag git.vdb.to/cerc-io/laconic2d/laconic2d:${{steps.vars.outputs.sha}} git.vdb.to/cerc-io/laconic2d/laconic2d:${{steps.vars.outputs.tag}}
|
||||||
|
- name: Docker Login
|
||||||
|
run: echo ${{ secrets.CICD_PUBLISH_TOKEN }} | docker login https://git.vdb.to -u cerccicd --password-stdin
|
||||||
|
- name: Docker Push
|
||||||
|
run: docker push git.vdb.to/cerc-io/laconic2d/laconic2d:${{steps.vars.outputs.sha}}
|
||||||
|
- name: Docker Push TAGGED
|
||||||
|
run: docker push git.vdb.to/cerc-io/laconic2d/laconic2d:${{steps.vars.outputs.tag}}
|
||||||
|
|
27
.gitea/workflows/lint.yml
Normal file
27
.gitea/workflows/lint.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
name: Lint
|
||||||
|
# Lint runs golangci-lint over the entire repository This workflow is
|
||||||
|
# run on every pull request and push to main The `golangci` will pass without
|
||||||
|
# running if no *.{go, mod, sum} files have been changed.
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
jobs:
|
||||||
|
golangci:
|
||||||
|
name: Run golangci-lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
steps:
|
||||||
|
# Required: setup-go, for all versions v3.0.0+ of golangci-lint
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 1.21
|
||||||
|
check-latest: true
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: golangci/golangci-lint-action@v3.3.1
|
||||||
|
with:
|
||||||
|
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
||||||
|
version: latest
|
||||||
|
args: --timeout 10m
|
||||||
|
github-token: ${{ secrets.github_token }}
|
29
.gitea/workflows/proto.yml
Normal file
29
.gitea/workflows/proto.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
name: Protobuf
|
||||||
|
# Protobuf runs buf (https://buf.build/) lint and check-breakage
|
||||||
|
# This workflow is only run when a .proto file has been changed
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- "proto/**"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 5
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: bufbuild/buf-setup-action@v1.9.0
|
||||||
|
- uses: bufbuild/buf-lint-action@v1
|
||||||
|
with:
|
||||||
|
input: "proto"
|
||||||
|
|
||||||
|
# TODO: Update with gitea reference
|
||||||
|
# break-check:
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# steps:
|
||||||
|
# - uses: actions/checkout@v3
|
||||||
|
# - uses: bufbuild/buf-setup-action@v1.9.0
|
||||||
|
# - uses: bufbuild/buf-breaking-action@v1
|
||||||
|
# with:
|
||||||
|
# input: "proto"
|
||||||
|
# against: "https://github.com/${{ github.repository }}.git#branch=${{ github.event.pull_request.base.ref }},ref=HEAD~1,subdir=proto"
|
19
.gitea/workflows/test-unit.yml
Normal file
19
.gitea/workflows/test-unit.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
name: Unit Tests
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-unit:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 1.21
|
||||||
|
check-latest: true
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
make test-unit
|
3
Makefile
3
Makefile
@ -103,3 +103,6 @@ test-integration:
|
|||||||
|
|
||||||
test-e2e:
|
test-e2e:
|
||||||
$(MAKE) -C tests test-e2e
|
$(MAKE) -C tests test-e2e
|
||||||
|
|
||||||
|
test-unit:
|
||||||
|
go test ./utils/... ./cmd/... -mod=readonly -test.v
|
||||||
|
14
README.md
14
README.md
@ -1,4 +1,12 @@
|
|||||||
# laconic2d
|
<div align="center">
|
||||||
|
<h1> Laconic Network </h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
![banner](docs/laconic.jpeg)
|
||||||
|
|
||||||
|
The Source of Proof. Laconic is a next generation data availability & verifiability layer with cryptographic proofs, powering internet-scale Web3 applications, built on Proof-of-Stake with fast-finality using the [Cosmos SDK](https://github.com/cosmos/cosmos-sdk/) which runs on top of [CometBFT](https://github.com/cometbft/cometbft) consensus engine.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
Install `laconic2d`:
|
Install `laconic2d`:
|
||||||
|
|
||||||
@ -7,6 +15,8 @@ Install `laconic2d`:
|
|||||||
make install
|
make install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
Run with a single node fixture:
|
Run with a single node fixture:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -17,6 +27,8 @@ Run with a single node fixture:
|
|||||||
./scripts/init.sh clean
|
./scripts/init.sh clean
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Tests
|
||||||
|
|
||||||
Run tests:
|
Run tests:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -73,7 +73,7 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
|
|||||||
/* Handle fee distribution state. */
|
/* Handle fee distribution state. */
|
||||||
|
|
||||||
// withdraw all validator commission
|
// withdraw all validator commission
|
||||||
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
|
_ = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
|
||||||
valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
|
valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -114,7 +114,7 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
|
|||||||
ctx = ctx.WithBlockHeight(0)
|
ctx = ctx.WithBlockHeight(0)
|
||||||
|
|
||||||
// reinitialize all validators
|
// reinitialize all validators
|
||||||
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
|
_ = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
|
||||||
valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
|
valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -171,20 +171,20 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
|
|||||||
/* Handle staking state. */
|
/* Handle staking state. */
|
||||||
|
|
||||||
// iterate through redelegations, reset creation height
|
// iterate through redelegations, reset creation height
|
||||||
app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
|
_ = app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
|
||||||
for i := range red.Entries {
|
for i := range red.Entries {
|
||||||
red.Entries[i].CreationHeight = 0
|
red.Entries[i].CreationHeight = 0
|
||||||
}
|
}
|
||||||
app.StakingKeeper.SetRedelegation(ctx, red)
|
_ = app.StakingKeeper.SetRedelegation(ctx, red)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
// iterate through unbonding delegations, reset creation height
|
// iterate through unbonding delegations, reset creation height
|
||||||
app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
|
_ = app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
|
||||||
for i := range ubd.Entries {
|
for i := range ubd.Entries {
|
||||||
ubd.Entries[i].CreationHeight = 0
|
ubd.Entries[i].CreationHeight = 0
|
||||||
}
|
}
|
||||||
app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
|
_ = app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
|
|||||||
validator.Jailed = true
|
validator.Jailed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
app.StakingKeeper.SetValidator(ctx, validator)
|
_ = app.StakingKeeper.SetValidator(ctx, validator)
|
||||||
counter++
|
counter++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
28
cmd/laconic2d/cmd_test.go
Normal file
28
cmd/laconic2d/cmd_test.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package main_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
|
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
||||||
|
|
||||||
|
"git.vdb.to/cerc-io/laconic2d/app"
|
||||||
|
"git.vdb.to/cerc-io/laconic2d/cmd/laconic2d/cmd"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestInitCmd(t *testing.T) {
|
||||||
|
rootCmd := cmd.NewRootCmd()
|
||||||
|
rootCmd.SetArgs([]string{
|
||||||
|
"init", // Test the init cmd
|
||||||
|
"localtestnet", // Moniker
|
||||||
|
fmt.Sprintf("--%s=%s", cli.FlagOverwrite, "true"), // Overwrite genesis.json, in case it already exists
|
||||||
|
fmt.Sprintf("--%s=%s", flags.FlagChainID, "laconic_9000-1"),
|
||||||
|
})
|
||||||
|
|
||||||
|
err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome)
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
BIN
docs/laconic.jpeg
Normal file
BIN
docs/laconic.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 147 KiB |
@ -6,6 +6,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
|
types "github.com/cosmos/cosmos-sdk/types"
|
||||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||||
|
|
||||||
@ -216,7 +217,7 @@ func (q queryResolver) GetAccount(ctx context.Context, address string) (*Account
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var account authtypes.AccountI
|
var account types.AccountI
|
||||||
err = q.ctx.Codec.UnpackAny(accountResponse.GetAccount(), &account)
|
err = q.ctx.Codec.UnpackAny(accountResponse.GetAccount(), &account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -130,19 +130,16 @@ func (ets *E2ETestSuite) createAuctionAndBid(createAuction, createBid bool) stri
|
|||||||
return auctionId
|
return auctionId
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ets *E2ETestSuite) cleanupBidFiles() error {
|
func (ets *E2ETestSuite) cleanupBidFiles() {
|
||||||
matches, err := filepath.Glob(fmt.Sprintf("%s-*.json", bidderAccount))
|
matches, err := filepath.Glob(fmt.Sprintf("%s-*.json", bidderAccount))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ets.T().Errorf("Error matching bidder files: %v\n", err)
|
ets.T().Errorf("Error matching bidder files: %v\n", err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, match := range matches {
|
for _, match := range matches {
|
||||||
err := os.Remove(match)
|
err := os.Remove(match)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
ets.T().Errorf("Error removing bidder file: %v\n", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,11 @@ type KeeperTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (kts *KeeperTestSuite) SetupTest() {
|
func (kts *KeeperTestSuite) SetupTest() {
|
||||||
kts.TestFixture.Setup()
|
err := kts.TestFixture.Setup()
|
||||||
|
assert.Nil(kts.T(), err)
|
||||||
|
|
||||||
// set default params
|
// set default params
|
||||||
err := kts.RegistryKeeper.Params.Set(kts.SdkCtx, types.DefaultParams())
|
err = kts.RegistryKeeper.Params.Set(kts.SdkCtx, types.DefaultParams())
|
||||||
assert.Nil(kts.T(), err)
|
assert.Nil(kts.T(), err)
|
||||||
|
|
||||||
qr := kts.App.QueryHelper()
|
qr := kts.App.QueryHelper()
|
||||||
|
33
utils/json_test.go
Normal file
33
utils/json_test.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAndValidateCIDGeneration(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
name string
|
||||||
|
content string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"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\"}",
|
||||||
|
"bafyreiek4hnoqmits66bjyxswapplweuoqe4en2ux6u772o4y3askpd3ny",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
newImpl, err := CIDFromJSONBytes([]byte(tc.content))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, tc.expected, newImpl)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user