Skip to content

Commit

Permalink
Merge branch 'main' into feature/container-security
Browse files Browse the repository at this point in the history
  • Loading branch information
smuu committed Mar 15, 2023
2 parents d0273ab + 953860c commit 204387f
Show file tree
Hide file tree
Showing 15 changed files with 508 additions and 47 deletions.
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
# owner is fully deferring ownership to the directory owner
docs @liamsi @adlerjohn @MSevey @evan-forbes
x/qgb @SweeXordious @evan-forbes
pkg/shares @rootulp @evan-forbes
pkg/shares @rootulp @evan-forbes
pkg/wrapper @staheri14 @evan-forbes
11 changes: 10 additions & 1 deletion .github/workflows/issue-label-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
pull-requests: write
steps:
- name: Check if issue or PR was created by external contributor
if: ${{ github.actor != 'dependabot[bot]' }}
uses: tspascoal/get-user-teams-membership@v2
id: teamCheck
with:
Expand All @@ -31,8 +32,16 @@ jobs:
# If an issue or PR was created by someone that isn't part of
# celestia-core, add the `external` label.
- name: Maybe label issue or PR with `external`
if: ${{ steps.teamCheck.outputs.isTeamMember == 'false' }}
if: ${{ github.actor != 'dependabot[bot]' && steps.teamCheck.outputs.isTeamMember == 'false' }}
uses: andymckay/labeler@master
with:
add-labels: "external"
repo-token: ${{ secrets.GITHUB_TOKEN }}

# If a PR was created by dependabot add the `bot` label.
- name: Maybe label PR with `bot`
if: ${{ github.actor == 'dependabot[bot]' }}
uses: andymckay/labeler@master
with:
add-labels: "bot"
repo-token: ${{ secrets.GITHUB_TOKEN }}
20 changes: 8 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ name: Tests / Code Coverage
on:
workflow_call:

jobs:
cleanup-runs:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: |
!startsWith(github.ref, 'refs/tags/') &&
github.ref != 'refs/heads/master'
concurrency:
# do not cancel jobs from earlier commits for tags or the main branch
group: ${{ github.workflow }}-${{ !startsWith(github.ref, 'refs/tags/') &&
github.ref != 'refs/heads/main' }}
cancel-in-progress: true

jobs:
install-tparse:
runs-on: ubuntu-latest
steps:
Expand All @@ -29,7 +25,7 @@ jobs:
run: >
export GO111MODULE="on" &&
go install github.com/mfridman/tparse@v0.8.3
- uses: actions/cache@v3.2.6
- uses: actions/cache@v3.3.1
with:
path: ~/go/bin
key: ${{ runner.os }}-go-tparse-binary
Expand Down Expand Up @@ -228,7 +224,7 @@ jobs:
with:
name: "${{ github.sha }}-03-race-output"
if: env.GIT_DIFF
- uses: actions/cache@v3.2.6
- uses: actions/cache@v3.3.1
with:
path: ~/go/bin
key: ${{ runner.os }}-go-tparse-binary
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ help: Makefile

## build: Build the celestia-appd binary into the ./build directory.
build: mod
@go install github.com/gobuffalo/packr/v2/packr2@latest
@cd ./cmd/celestia-appd && packr2
@cd ./cmd/celestia-appd
@mkdir -p build/
@go build $(BUILD_FLAGS) -o build/ ./cmd/celestia-appd
@packr2 clean
@go mod tidy -compat=1.18
.PHONY: build

Expand Down
2 changes: 2 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Celestia App
Copyright 2021 and onwards Strange Loop Labs AG
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ node | | | |

## Install

1. [Install Go](https://go.dev/doc/install) 1.18+
1. [Install Go](https://go.dev/doc/install) 1.18
1. Clone this repo
1. Install the celestia-app CLI

Expand Down
48 changes: 27 additions & 21 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client"
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/evidence"
Expand All @@ -47,7 +46,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/gov"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1beta2 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
Expand All @@ -56,7 +54,6 @@ import (
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/params"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
Expand All @@ -67,15 +64,13 @@ import (
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/cosmos/ibc-go/v6/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v6/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v6/modules/core"
ibcclient "github.com/cosmos/ibc-go/v6/modules/core/02-client"
ibcclientclient "github.com/cosmos/ibc-go/v6/modules/core/02-client/client"
ibcclienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
ibcporttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v6/modules/core/24-host"
Expand All @@ -97,6 +92,7 @@ import (
qgbmodule "github.com/celestiaorg/celestia-app/x/qgb"
qgbmodulekeeper "github.com/celestiaorg/celestia-app/x/qgb/keeper"
qgbmoduletypes "github.com/celestiaorg/celestia-app/x/qgb/types"
ibctestingtypes "github.com/cosmos/ibc-go/v6/testing/types"
)

const (
Expand Down Expand Up @@ -143,7 +139,7 @@ var (
stakingModule{},
mintModule{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(getGovProposalHandlers()),
newGovModule(),
params.AppModuleBasic{},
crisisModule{},
slashing.AppModuleBasic{},
Expand Down Expand Up @@ -587,6 +583,31 @@ func (app *App) ModuleAccountAddrs() map[string]bool {
return modAccAddrs
}

// GetBaseApp implements the TestingApp interface.
func (app *App) GetBaseApp() *baseapp.BaseApp {
return app.BaseApp
}

// GetStakingKeeper implements the TestingApp interface.
func (app *App) GetStakingKeeper() ibctestingtypes.StakingKeeper {
return app.StakingKeeper
}

// GetIBCKeeper implements the TestingApp interface.
func (app *App) GetIBCKeeper() *ibckeeper.Keeper {
return app.IBCKeeper
}

// GetScopedIBCKeeper implements the TestingApp interface.
func (app *App) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper {
return app.ScopedIBCKeeper
}

// GetTxConfig implements the TestingApp interface.
func (app *App) GetTxConfig() client.TxConfig {
return app.txConfig
}

// LegacyAmino returns SimApp's amino codec.
//
// NOTE: This is solely to be used for testing purposes as it may be desirable
Expand Down Expand Up @@ -700,21 +721,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
return paramsKeeper
}

func getGovProposalHandlers() []govclient.ProposalHandler {
var govProposalHandlers []govclient.ProposalHandler

govProposalHandlers = append(govProposalHandlers,
paramsclient.ProposalHandler,
distrclient.ProposalHandler,
upgradeclient.LegacyProposalHandler,
upgradeclient.LegacyCancelProposalHandler,
ibcclientclient.UpdateClientProposalHandler,
ibcclientclient.UpgradeProposalHandler,
)

return govProposalHandlers
}

func moduleMapToSlice(m module.BasicManager) []encoding.ModuleRegister {
// TODO: might be able to use some standard generics in go 1.18
s := make([]encoding.ModuleRegister, len(m))
Expand Down
7 changes: 7 additions & 0 deletions app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package app

import (
"encoding/json"

"github.com/cosmos/cosmos-sdk/codec"
)

// The genesis state of the blockchain is represented here as a map of raw json
Expand All @@ -12,3 +14,8 @@ import (
// the ModuleBasicManager which populates json from each BasicModule
// object provided to it during init.
type GenesisState map[string]json.RawMessage

// NewDefaultGenesisState generates the default state for the application.
func NewDefaultGenesisState(cdc codec.JSONCodec) GenesisState {
return ModuleBasics.DefaultGenesis(cdc)
}
38 changes: 38 additions & 0 deletions app/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client"
"github.com/cosmos/cosmos-sdk/x/gov"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/cosmos-sdk/x/mint"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
ibcclientclient "github.com/cosmos/ibc-go/v6/modules/core/02-client/client"
)

// bankModule defines a custom wrapper around the x/bank module's AppModuleBasic
Expand Down Expand Up @@ -89,3 +96,34 @@ func (mintModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {

return cdc.MustMarshalJSON(genState)
}

func newGovModule() govModule {
return govModule{gov.NewAppModuleBasic(getLegacyProposalHandlers())}
}

// govModule is a custom wrapper around the x/gov module's AppModuleBasic
// implementation to provide custom default genesis state.
type govModule struct {
gov.AppModuleBasic
}

// DefaultGenesis returns custom x/gov module genesis state.
func (govModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
genState := govtypes.DefaultGenesisState()
genState.DepositParams.MinDeposit = sdk.NewCoins(sdk.NewCoin(BondDenom, sdk.NewInt(10000000)))

return cdc.MustMarshalJSON(genState)
}

func getLegacyProposalHandlers() (result []govclient.ProposalHandler) {
result = append(result,
paramsclient.ProposalHandler,
distrclient.ProposalHandler,
upgradeclient.LegacyProposalHandler,
upgradeclient.LegacyCancelProposalHandler,
ibcclientclient.UpdateClientProposalHandler,
ibcclientclient.UpgradeProposalHandler,
)

return result
}
33 changes: 33 additions & 0 deletions app/module_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package app

import (
"encoding/json"
"testing"

"github.com/celestiaorg/celestia-app/app/encoding"
"github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/stretchr/testify/assert"
)

// Test_newGovModule tests that the default genesis state for the gov module
// uses the utia denominiation.
func Test_newGovModule(t *testing.T) {
encCfg := encoding.MakeConfig(ModuleEncodingRegisters...)

govModule := newGovModule()
raw := govModule.DefaultGenesis(encCfg.Codec)
govGenesisState := govtypes.GenesisState{}

// HACKHACK explicitly ignore the error returned from json.Unmarshal because
// the error is a failure to unmarshal the string StartingProposalId as a
// uint which is unrelated to the test here.
_ = json.Unmarshal(raw, &govGenesisState)

want := []types.Coin{{
Denom: BondDenom,
Amount: types.NewInt(10000000),
}}

assert.Equal(t, want, govGenesisState.DepositParams.MinDeposit)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/celestiaorg/nmt v0.14.0
github.com/celestiaorg/quantum-gravity-bridge v1.3.0
github.com/ethereum/go-ethereum v1.11.3
github.com/ethereum/go-ethereum v1.11.4
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.2
github.com/google/uuid v1.3.0 // indirect
Expand Down
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum/go-ethereum v1.10.17/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0=
github.com/ethereum/go-ethereum v1.11.3 h1:uuBkYUJW9aY5JYi3+sqLHz+XWyo5fmn/ab9XcbtVDTU=
github.com/ethereum/go-ethereum v1.11.3/go.mod h1:rBUvAl5cdVrAei9q5lgOU7RSEuPJk1nlBDnS/YSoKQE=
github.com/ethereum/go-ethereum v1.11.4 h1:KG81SnUHXWk8LJB3mBcHg/E2yLvXoiPmRMCIRxgx3cE=
github.com/ethereum/go-ethereum v1.11.4/go.mod h1:it7x0DWnTDMfVFdXcU6Ti4KEFQynLHVRarcSlPr0HBo=
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0=
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A=
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk=
Expand Down Expand Up @@ -620,7 +620,6 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 h1:aSVUgRRRtOrZOC1fYmY9gV0e9z/Iu+xNVSASWjsuyGU=
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3/go.mod h1:5PC6ZNPde8bBqU/ewGZig35+UIZtw9Ytxez8/q5ZyFE=
github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e h1:pIYdhNkDh+YENVNi3gto8n9hAmRxKxoar0iE6BLucjw=
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
github.com/holiman/uint256 v1.2.0 h1:gpSYcPLWGv4sG43I2mVLiDZCNDh/EpGjSk8tmtxitHM=
Expand Down
14 changes: 10 additions & 4 deletions pkg/da/data_availability_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"errors"
"fmt"

"github.com/celestiaorg/rsmt2d"
"github.com/tendermint/tendermint/crypto/merkle"
"github.com/tendermint/tendermint/types"

"github.com/celestiaorg/celestia-app/pkg/appconsts"
"github.com/celestiaorg/celestia-app/pkg/shares"
"github.com/celestiaorg/celestia-app/pkg/wrapper"
daproto "github.com/celestiaorg/celestia-app/proto/celestia/da"
"github.com/celestiaorg/rsmt2d"
"github.com/tendermint/tendermint/crypto/merkle"
"github.com/tendermint/tendermint/types"
)

const (
Expand Down Expand Up @@ -171,11 +172,16 @@ func (dah *DataAvailabilityHeader) IsZero() bool {
// It is equal to the data availability header for a block with one tail padding
// share.
func MinDataAvailabilityHeader() DataAvailabilityHeader {
s := shares.ToBytes(shares.TailPaddingShares(appconsts.MinShareCount))
s := MinShares()
eds, err := ExtendShares(appconsts.DefaultMinSquareSize, s)
if err != nil {
panic(err)
}
dah := NewDataAvailabilityHeader(eds)
return dah
}

// MinShares returns one tail-padded share.
func MinShares() [][]byte {
return shares.ToBytes(shares.TailPaddingShares(appconsts.MinShareCount))
}
Loading

0 comments on commit 204387f

Please sign in to comment.