Skip to content

Commit

Permalink
feat: apply requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ninabarbakadze committed Sep 17, 2024
1 parent 4d4b663 commit 8547221
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 44 deletions.
11 changes: 5 additions & 6 deletions app/ante/tx_size_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package ante_test

import (
"fmt"
"strings"
"testing"

"github.com/celestiaorg/celestia-app/v3/app"
"github.com/celestiaorg/celestia-app/v3/app/ante"
"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
v2 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v2"
v3 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v3"
testutil "github.com/celestiaorg/celestia-app/v3/test/util"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
Expand Down Expand Up @@ -64,10 +63,10 @@ func TestConsumeGasForTxSize(t *testing.T) {
name string
sigV2 signing.SignatureV2
}{
{v2.Version, "SingleSignatureData", signing.SignatureV2{PubKey: priv1.PubKey()}},
{v2.Version, "MultiSignatureData", signing.SignatureV2{PubKey: priv1.PubKey(), Data: multisig.NewMultisig(2)}},
{v3.Version, "SingleSignatureData", signing.SignatureV2{PubKey: priv1.PubKey()}},
{v3.Version, "MultiSignatureData", signing.SignatureV2{PubKey: priv1.PubKey(), Data: multisig.NewMultisig(2)}},
{v2.Version, "SingleSignatureData v2", signing.SignatureV2{PubKey: priv1.PubKey()}},
{v2.Version, "MultiSignatureData v2", signing.SignatureV2{PubKey: priv1.PubKey(), Data: multisig.NewMultisig(2)}},
{appconsts.LatestVersion, fmt.Sprintf("SingleSignatureData v%d", appconsts.LatestVersion), signing.SignatureV2{PubKey: priv1.PubKey()}},
{appconsts.LatestVersion, fmt.Sprintf("MultiSignatureData v%d", appconsts.LatestVersion), signing.SignatureV2{PubKey: priv1.PubKey(), Data: multisig.NewMultisig(2)}},
}

for _, tc := range testCases {
Expand Down
72 changes: 72 additions & 0 deletions specs/src/parameters_v3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Parameters v3

The parameters below represent the parameters for app version 3.

Note that not all of these parameters are changeable via governance. This list
also includes parameter that require a hardfork to change due to being manually
hardcoded in the application or they are blocked by the `x/paramfilter` module.

## Global parameters

| Parameter | Default | Summary | Changeable via Governance |
|-------------------|---------|------------------------------------------------------------------------------------------------------------------------|---------------------------|
| MaxBlockSizeBytes | 100MiB | Hardcoded value in CometBFT for the protobuf encoded block. | False |
| MaxSquareSize | 128 | Hardcoded maximum square size determined per shares per row or column for the original data square (not yet extended). | False |

## Module parameters

| Module.Parameter | Default | Summary | Changeable via Governance |
|-----------------------------------------------|---------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|---------------------------|
| auth.MaxMemoCharacters | 256 | Largest allowed size for a memo in bytes. | True |
| auth.SigVerifyCostED25519 | 590 | Gas used to verify Ed25519 signature. | True |
| auth.SigVerifyCostSecp256k1 | 1000 | Gas used to verify secp256k1 signature. | True |
| auth.TxSigLimit | 7 | Max number of signatures allowed in a multisig transaction. | True |
| auth.TxSizeCostPerByte | 10 | Gas used per transaction byte. | False |
| bank.SendEnabled | true | Allow transfers. | False |
| blob.GasPerBlobByte | 8 | Gas used per blob byte. | False |
| blob.GovMaxSquareSize | 64 | Governance parameter for the maximum square size of the original data square. | True |
| consensus.block.MaxBytes | 1974272 bytes (~1.88 MiB) | Governance parameter for the maximum size of the protobuf encoded block. | True |
| consensus.block.MaxGas | -1 | Maximum gas allowed per block (-1 is infinite). | True |
| consensus.block.TimeIotaMs | 1000 | Minimum time added to the time in the header each block. | False |
| consensus.evidence.MaxAgeDuration | 1814400000000000 (21 days) | The maximum age of evidence before it is considered invalid in nanoseconds. This value should be identical to the unbonding period. | True |
| consensus.evidence.MaxAgeNumBlocks | 120960 | The maximum number of blocks before evidence is considered invalid. This value will stop CometBFT from pruning block data. | True |
| consensus.evidence.MaxBytes | 1MiB | Maximum size in bytes used by evidence in a given block. | True |
| consensus.validator.PubKeyTypes | Ed25519 | The type of public key used by validators. | False |
| consensus.Version.AppVersion | 2 | Determines protocol rules used for a given height. Incremented by the application upon an upgrade. | True |
| distribution.BaseProposerReward | 0 | Reward in the mint denomination for proposing a block. | True |
| distribution.BonusProposerReward | 0 | Extra reward in the mint denomination for proposers based on the voting power included in the commit. | True |
| distribution.CommunityTax | 0.02 (2%) | Percentage of the inflation sent to the community pool. | True |
| distribution.WithdrawAddrEnabled | true | Enables delegators to withdraw funds to a different address. | True |
| gov.DepositParams.MaxDepositPeriod | 604800000000000 (1 week) | Maximum period for token holders to deposit on a proposal in nanoseconds. | True |
| gov.DepositParams.MinDeposit | 10_000_000_000 utia (10,000 TIA) | Minimum deposit for a proposal to enter voting period. | True |
| gov.TallyParams.Quorum | 0.334 (33.4%) | Minimum percentage of total stake needed to vote for a result to be considered valid. | True |
| gov.TallyParams.Threshold | 0.50 (50%) | Minimum proportion of Yes votes for proposal to pass. | True |
| gov.TallyParams.VetoThreshold | 0.334 (33.4%) | Minimum value of Veto votes to Total votes ratio for proposal to be vetoed. | True |
| gov.VotingParams.VotingPeriod | 604800000000000 (1 week) | Duration of the voting period in nanoseconds. | True |
| ibc.ClientGenesis.AllowedClients | []string{"06-solomachine", "07-tendermint"} | List of allowed IBC light clients. | True |
| ibc.ConnectionGenesis.MaxExpectedTimePerBlock | 7500000000000 (75 seconds) | Maximum expected time per block in nanoseconds under normal operation. | True |
| ibc.Transfer.ReceiveEnabled | true | Enable receiving tokens via IBC. | True |
| ibc.Transfer.SendEnabled | true | Enable sending tokens via IBC. | True |
| icahost.HostEnabled | True | Enables or disables the Inter-Chain Accounts host module. | True |
| icahost.AllowMessages | [icaAllowMessages] | Defines a list of sdk message typeURLs allowed to be executed on a host chain. | True |
| minfee.NetworkMinGasPrice | 0.000001 utia | All transactions must have a gas price greater than or equal to this value. | True |
| mint.BondDenom | utia | Denomination that is inflated and sent to the distribution module account. | False |
| mint.DisinflationRate | 0.10 (10%) | The rate at which the inflation rate decreases each year. | False |
| mint.InitialInflationRate | 0.08 (8%) | The inflation rate the network starts at. | False |
| mint.TargetInflationRate | 0.015 (1.5%) | The inflation rate that the network aims to stabilize at. | False |
| packetfowardmiddleware.FeePercentage | 0 | % of the forwarded packet amount which will be subtracted and distributed to the community pool. | True |
| slashing.DowntimeJailDuration | 1 min | Duration of time a validator must stay jailed. | True |
| slashing.MinSignedPerWindow | 0.75 (75%) | The percentage of SignedBlocksWindow that must be signed not to get jailed. | True |
| slashing.SignedBlocksWindow | 5000 | The range of blocks used to count for downtime. | True |
| slashing.SlashFractionDoubleSign | 0.02 (2%) | Percentage slashed after a validator is jailed for double signing. | True |
| slashing.SlashFractionDowntime | 0.00 (0%) | Percentage slashed after a validator is jailed for downtime. | True |
| staking.BondDenom | utia | Bondable coin denomination. | False |
| staking.HistoricalEntries | 10000 | Number of historical entries to persist in store. | True |
| staking.MaxEntries | 7 | Maximum number of entries in the redelegation queue. | True |
| staking.MaxValidators | 100 | Maximum number of validators. | True |
| staking.MinCommissionRate | 0.05 (5%) | Minimum commission rate used by all validators. | True |
| staking.UnbondingTime | 1814400 (21 days) | Duration of time for unbonding in seconds. | False |

Note: none of the mint module parameters are governance modifiable because they have been converted into hardcoded constants. See the x/mint README.md for more details.

[icaAllowMessages]: https://github.com/rootulp/celestia-app/blob/8caa5807df8d15477554eba953bd056ae72d4503/app/ica_host.go#L3-L18
65 changes: 27 additions & 38 deletions x/blob/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"testing"

"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
v2 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v2"
v3 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v3"
testutil "github.com/celestiaorg/celestia-app/v3/test/util"
"github.com/celestiaorg/celestia-app/v3/x/blob/keeper"
"github.com/celestiaorg/celestia-app/v3/x/blob/types"
Expand All @@ -29,44 +27,34 @@ import (

// TestPayForBlobs verifies the attributes on the emitted event.
func TestPayForBlobs(t *testing.T) {
// Testing transition from v2 -> v3
// v2 uses the GasPerBlobByte key from the params store
// v3 uses the GasPerBlobByte from the appconsts
// TODO: Replace this with appversion latest
versions := []uint64{v2.Version, v3.Version}

for _, version := range versions {
t.Run("AppVersion_"+fmt.Sprint(version), func(t *testing.T) {
k, _, ctx := CreateKeeper(t, version)
signer := "celestia15drmhzw5kwgenvemy30rqqqgq52axf5wwrruf7"
namespace := share.MustNewV0Namespace(bytes.Repeat([]byte{1}, share.NamespaceVersionZeroIDSize))
namespaces := [][]byte{namespace.Bytes()}
blobData := []byte("blob")
blobSizes := []uint32{uint32(len(blobData))}

// verify no events exist yet
events := ctx.EventManager().Events().ToABCIEvents()
assert.Len(t, events, 0)

// emit an event by submitting a PayForBlob
msg := createMsgPayForBlob(t, signer, namespace, blobData)
_, err := k.PayForBlobs(ctx, msg)
require.NoError(t, err)
k, _, ctx := CreateKeeper(t, appconsts.LatestVersion)
signer := "celestia15drmhzw5kwgenvemy30rqqqgq52axf5wwrruf7"
namespace := share.MustNewV0Namespace(bytes.Repeat([]byte{1}, share.NamespaceVersionZeroIDSize))
namespaces := [][]byte{namespace.Bytes()}
blobData := []byte("blob")
blobSizes := []uint32{uint32(len(blobData))}

// verify no events exist yet
events := ctx.EventManager().Events().ToABCIEvents()
assert.Len(t, events, 0)

// emit an event by submitting a PayForBlob
msg := createMsgPayForBlob(t, signer, namespace, blobData)
_, err := k.PayForBlobs(ctx, msg)
require.NoError(t, err)

// verify that an event was emitted
events = ctx.EventManager().Events().ToABCIEvents()
assert.Len(t, events, 1)
protoEvent, err := sdk.ParseTypedEvent(events[0])
require.NoError(t, err)
event, err := convertToEventPayForBlobs(protoEvent)
require.NoError(t, err)
// verify that an event was emitted
events = ctx.EventManager().Events().ToABCIEvents()
assert.Len(t, events, 1)
protoEvent, err := sdk.ParseTypedEvent(events[0])
require.NoError(t, err)
event, err := convertToEventPayForBlobs(protoEvent)
require.NoError(t, err)

// verify the attributes of the event
assert.Equal(t, signer, event.Signer)
assert.Equal(t, namespaces, event.Namespaces)
assert.Equal(t, blobSizes, event.BlobSizes)
})
}
// verify the attributes of the event
assert.Equal(t, signer, event.Signer)
assert.Equal(t, namespaces, event.Namespaces)
assert.Equal(t, blobSizes, event.BlobSizes)
}

func convertToEventPayForBlobs(message proto.Message) (*types.EventPayForBlobs, error) {
Expand Down Expand Up @@ -113,6 +101,7 @@ func CreateKeeper(t *testing.T, version uint64) (*keeper.Keeper, store.CommitMul
cdc,
paramsSubspace,
)
// change the params to a non default value
k.SetParams(ctx, types.DefaultParams())

return k, stateStore, ctx
Expand Down

0 comments on commit 8547221

Please sign in to comment.