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

Add x/escrow #2

Merged
merged 62 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
e35b90e
Implement x/escrow prototype
0Tech Jan 21, 2024
cd44da2
Implement app
0Tech Jan 21, 2024
990ce3a
Implement cmd
0Tech Jan 21, 2024
bff7ddf
Implement x/test
0Tech Jan 21, 2024
202c652
Use x/test in tests
0Tech Jan 21, 2024
ceaaa36
Add documentations
0Tech Jan 22, 2024
537519d
Do `go mod tidy`
0Tech Jan 22, 2024
ce4daea
Add metadata
0Tech Jan 22, 2024
4608f25
Update documentation
0Tech Jan 22, 2024
d1ab23c
Update x/test documentation
0Tech Jan 23, 2024
76bcac5
Make assets prefix configurable so the consumer can avoid collision
0Tech Jan 23, 2024
89e2f28
Add minimal build configuration
0Tech Jan 24, 2024
20f5a5e
Add workflows
0Tech Jan 25, 2024
ae3020c
Lint x/test
0Tech Jan 25, 2024
a670afe
Lint x/escrow
0Tech Jan 25, 2024
954ad1f
Lint app
0Tech Jan 25, 2024
11ccef2
Lint cmd/and
0Tech Jan 25, 2024
c6a76a7
Increase linter timeouts
0Tech Jan 25, 2024
d3c7220
Increase coverage
0Tech Jan 26, 2024
dffc158
Decrease ExportGenesis cost and increase ValidateGenesis cost
0Tech Jan 26, 2024
80c93b4
Update sonar configs
0Tech Jan 26, 2024
488a55b
Separate depinject
0Tech Jan 26, 2024
4334e2f
Remove unused codes
0Tech Jan 26, 2024
51e4ce9
Update proto field names
0Tech Jan 26, 2024
49127a9
Resolve SonarCloud issues
0Tech Jan 26, 2024
8fdfb8d
Update errors
0Tech Jan 27, 2024
b033bbc
Allow decreasing metadata limit
0Tech Jan 27, 2024
3f0e965
Define error for duplicate entry in genesis
0Tech Jan 27, 2024
966567c
Remove duplicating literals
0Tech Jan 27, 2024
0d0be5f
Stop using alias
0Tech Jan 27, 2024
1149b4c
Update CHANGELOG.md
0Tech Jan 27, 2024
a1e65c7
Refactor test cases of genesis
0Tech Jan 27, 2024
b6fd28d
Refactor key schema of agents
0Tech Jan 29, 2024
9681d1a
Refactor proposals key schema
0Tech Jan 29, 2024
e05a07e
Remove proposal id
0Tech Jan 29, 2024
a28bbac
Copy MultiIterator for pagination
0Tech Jan 29, 2024
821247e
Add queries
0Tech Jan 29, 2024
87e4897
Add target for installing prerequisites
0Tech Jan 31, 2024
b164721
Add build folder to gitignore
0Tech Jan 31, 2024
feff202
Add docker runners
0Tech Feb 1, 2024
a17fd1c
Use bare runners in workflows for now
0Tech Feb 1, 2024
7253cbb
Lint dogsled
0Tech Feb 8, 2024
d68ee0d
Cache mod
0Tech Feb 8, 2024
9fbb432
Install packages using CMake
0Tech Feb 12, 2024
9138a04
Refactor target dependencies
0Tech Feb 12, 2024
95a1f0a
Expand Msg/Exec
0Tech Feb 12, 2024
222858b
Update documents and autocli
0Tech Feb 12, 2024
e48c377
Refactor builder setups
0Tech Feb 12, 2024
ea8ef4e
Buf format
0Tech Feb 12, 2024
15bdc93
Fix builder setups
0Tech Feb 12, 2024
2fa70d7
Check inputs in scripts
0Tech Feb 13, 2024
dc34bec
Rename builder folder
0Tech Feb 13, 2024
3bcc9b2
Document the function for the temporary solution
0Tech Feb 13, 2024
81e51b4
Use crypto/rand
0Tech Feb 13, 2024
14e8a43
Update buf lint config
0Tech Feb 14, 2024
d2870ff
Fix workflow
0Tech Feb 13, 2024
df29a95
Update address creations
0Tech Feb 14, 2024
57ba778
Refactor AutoCLIOptions
0Tech Feb 14, 2024
b6f7d64
Update go lint config
0Tech Feb 15, 2024
c5bde2e
Don't check the return value in case of error
0Tech Feb 15, 2024
4fc5ea9
Fix hard coded download url
0Tech Feb 15, 2024
fcc9900
Ensure input validness right before the test
0Tech Feb 15, 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
81 changes: 81 additions & 0 deletions .github/workflows/module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Check Module
on:
workflow_call:
inputs:
name:
required: true
type: string
timeout-minutes:
required: false
type: number
default: 30
secrets:
sonar-token:
required: true
env:
target: x-${{ inputs.name }}
path: x/${{ inputs.name }}
jobs:
go-lint:
name: go lint
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- uses: actions/checkout@v4
- name: Configure
run: cmake -S . -B build -D USE_DOCKER=ON -D UID=$(id -u) -D GID=$(id -g) -D FIX_IS_ERROR=ON
- name: Lint
run: cmake --build build --target go_lint_${{ env.target }}
go-build:
name: go build
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- uses: actions/checkout@v4
- name: Configure
run: cmake -S . -B build -D USE_DOCKER=ON -D UID=$(id -u) -D GID=$(id -g) -D FIX_IS_ERROR=ON
- name: Build
run: cmake --build build --target go_build_${{ env.target }}
go-test:
name: go test
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Configure
run: cmake -S . -B build -D USE_DOCKER=ON -D UID=$(id -u) -D GID=$(id -g) -D FIX_IS_ERROR=ON
- name: Install builders
run: cmake --build build --target install_builders
- name: Test
run: |
VERBOSE=1 ctest --test-dir build --output-on-failure --stop-on-failure -R ${{ env.target }}
mv build/${{ env.path }}/docker/${{ env.path }}/cover.out ${{ env.path }}/
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.sonar-token }}
with:
projectBaseDir: ${{ env.path }}/
buf-format:
name: buf format
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- uses: actions/checkout@v4
- name: Configure
run: cmake -S . -B build -D USE_DOCKER=ON -D UID=$(id -u) -D GID=$(id -g) -D FIX_IS_ERROR=ON
- name: Lint
run: cmake --build build --target buf_format_${{ env.target }}
buf-lint:
name: buf lint
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- uses: actions/checkout@v4
- name: Configure
run: cmake -S . -B build -D USE_DOCKER=ON -D UID=$(id -u) -D GID=$(id -g) -D FIX_IS_ERROR=ON
- name: Lint
run: cmake --build build --target buf_lint_${{ env.target }}
21 changes: 21 additions & 0 deletions .github/workflows/modules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Check Modules
on:
push:
branches:
- main
pull_request:
jobs:
check-modules:
name: x-${{ matrix.name }}
strategy:
matrix:
include:
- name: test
sonar-token: SONAR_TOKEN_X_TEST
- name: escrow
sonar-token: SONAR_TOKEN_X_ESCROW
uses: ./.github/workflows/module.yml
with:
name: ${{ matrix.name }}
secrets:
sonar-token: ${{ secrets[matrix.sonar-token] }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@

# Dependency directories (remove the comment below to include it)
# vendor/

# Build
/build
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Add x/escrow prototype (#2).
- Add x/test prototype (#2).
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.25.1)

option(CMAKE_COLOR_DIAGNOSTICS
"Enable/Disable color output during build.")

project(andromeda
LANGUAGES NONE
)
enable_testing()

add_subdirectory(builders)

add_subdirectory(app)
add_subdirectory(cmd/and)

add_subdirectory(x/escrow)
add_subdirectory(x/test)
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# andromeda
# andromeda

This project provides several [modules](x/README.md) based on
[Cosmos SDK](https://github.com/cosmos/cosmos-sdk).
38 changes: 38 additions & 0 deletions app/.golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
run:
timeout: 5m
linters:
enable:
- depguard
- dogsled
- exportloopref
- goconst
- gocritic
- gofumpt
- gosec
- misspell
- nakedret
- nolintlint
- revive
- stylecheck
- unconvert

linters-settings:
gci:
custom-order: true
sections:
- standard
- default
- prefix(cosmossdk.io)
- prefix(github.com/cosmos/cosmos-sdk)
- prefix(github.com/0tech/andromeda)
depguard:
rules:
main:
allow:
- $gostd
- github.com/stretchr/testify
- github.com/cometbft/cometbft
- cosmossdk.io
- github.com/cosmos/cosmos-db
- github.com/cosmos/cosmos-sdk
- github.com/0tech/andromeda
8 changes: 8 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
project(app
LANGUAGES NONE
)

add_go_tidy()
add_go_lint()
add_go_build()
add_go_test()
84 changes: 84 additions & 0 deletions app/abci.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package app

import (
"bytes"
"crypto/rand"
"encoding/json"
"fmt"

abci "github.com/cometbft/cometbft/abci/types"

"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
)

type (
// VoteExtensionHandler defines a dummy vote extension handler for SimApp.
//
// NOTE: This implementation is solely used for testing purposes. DO NOT use
// in a production application!
VoteExtensionHandler struct{}

// VoteExtension defines the structure used to create a dummy vote extension.
VoteExtension struct {
Hash []byte
Height int64
Data []byte
}
)

func NewVoteExtensionHandler() *VoteExtensionHandler {
return &VoteExtensionHandler{}
}

func (h *VoteExtensionHandler) SetHandlers(bApp *baseapp.BaseApp) {
bApp.SetExtendVoteHandler(h.ExtendVote())
bApp.SetVerifyVoteExtensionHandler(h.VerifyVoteExtension())
}

func (h *VoteExtensionHandler) ExtendVote() sdk.ExtendVoteHandler {
return func(_ sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) {
buf := make([]byte, 1024)

_, err := rand.Read(buf)
if err != nil {
return nil, fmt.Errorf("failed to generate random vote extension data: %w", err)
}

ve := VoteExtension{
Hash: req.Hash,
Height: req.Height,
Data: buf,
}

bz, err := json.Marshal(ve)
if err != nil {
return nil, fmt.Errorf("failed to encode vote extension: %w", err)
}

return &abci.ResponseExtendVote{VoteExtension: bz}, nil
}
}

func (h *VoteExtensionHandler) VerifyVoteExtension() sdk.VerifyVoteExtensionHandler {
return func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) {
var ve VoteExtension

if err := json.Unmarshal(req.VoteExtension, &ve); err != nil {
return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil
}

switch {
case req.Height != ve.Height:
return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil

case !bytes.Equal(req.Hash, ve.Hash):
return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil

case len(ve.Data) != 1024:
return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil
}

return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil
}
}
Loading