-
Notifications
You must be signed in to change notification settings - Fork 0
Add x/escrow #2
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
Merged
Merged
Add x/escrow #2
Changes from all commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
e35b90e
Implement x/escrow prototype
0Tech cd44da2
Implement app
0Tech 990ce3a
Implement cmd
0Tech bff7ddf
Implement x/test
0Tech 202c652
Use x/test in tests
0Tech ceaaa36
Add documentations
0Tech 537519d
Do `go mod tidy`
0Tech ce4daea
Add metadata
0Tech 4608f25
Update documentation
0Tech d1ab23c
Update x/test documentation
0Tech 76bcac5
Make assets prefix configurable so the consumer can avoid collision
0Tech 89e2f28
Add minimal build configuration
0Tech 20f5a5e
Add workflows
0Tech ae3020c
Lint x/test
0Tech a670afe
Lint x/escrow
0Tech 954ad1f
Lint app
0Tech 11ccef2
Lint cmd/and
0Tech c6a76a7
Increase linter timeouts
0Tech d3c7220
Increase coverage
0Tech dffc158
Decrease ExportGenesis cost and increase ValidateGenesis cost
0Tech 80c93b4
Update sonar configs
0Tech 488a55b
Separate depinject
0Tech 4334e2f
Remove unused codes
0Tech 51e4ce9
Update proto field names
0Tech 49127a9
Resolve SonarCloud issues
0Tech 8fdfb8d
Update errors
0Tech b033bbc
Allow decreasing metadata limit
0Tech 3f0e965
Define error for duplicate entry in genesis
0Tech 966567c
Remove duplicating literals
0Tech 0d0be5f
Stop using alias
0Tech 1149b4c
Update CHANGELOG.md
0Tech a1e65c7
Refactor test cases of genesis
0Tech b6fd28d
Refactor key schema of agents
0Tech 9681d1a
Refactor proposals key schema
0Tech e05a07e
Remove proposal id
0Tech a28bbac
Copy MultiIterator for pagination
0Tech 821247e
Add queries
0Tech 87e4897
Add target for installing prerequisites
0Tech b164721
Add build folder to gitignore
0Tech feff202
Add docker runners
0Tech a17fd1c
Use bare runners in workflows for now
0Tech 7253cbb
Lint dogsled
0Tech d68ee0d
Cache mod
0Tech 9fbb432
Install packages using CMake
0Tech 9138a04
Refactor target dependencies
0Tech 95a1f0a
Expand Msg/Exec
0Tech 222858b
Update documents and autocli
0Tech e48c377
Refactor builder setups
0Tech ea8ef4e
Buf format
0Tech 15bdc93
Fix builder setups
0Tech 2fa70d7
Check inputs in scripts
0Tech dc34bec
Rename builder folder
0Tech 3bcc9b2
Document the function for the temporary solution
0Tech 81e51b4
Use crypto/rand
0Tech 14e8a43
Update buf lint config
0Tech d2870ff
Fix workflow
0Tech df29a95
Update address creations
0Tech 57ba778
Refactor AutoCLIOptions
0Tech b6f7d64
Update go lint config
0Tech c5bde2e
Don't check the return value in case of error
0Tech 4fc5ea9
Fix hard coded download url
0Tech fcc9900
Ensure input validness right before the test
0Tech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,6 @@ | |
|
|
||
| # Dependency directories (remove the comment below to include it) | ||
| # vendor/ | ||
|
|
||
| # Build | ||
| /build | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: | ||
| all: | ||
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
|
0Tech marked this conversation as resolved.
|
||
| } | ||
|
|
||
| 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 | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.