Skip to content

Commit

Permalink
Merge branch 'main' into rp/ica
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Feb 22, 2024
2 parents 1ddae24 + 9fe864c commit 735f2b9
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 110 deletions.
91 changes: 0 additions & 91 deletions app/test/block_production_test.go

This file was deleted.

22 changes: 22 additions & 0 deletions app/test/prepare_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,25 @@ func queryAccountInfo(capp *app.App, accs []string, kr keyring.Keyring) []blobfa
}
return infos
}

func TestPrepareProposalZeroTxsInFirstBlock(t *testing.T) {
accounts := testfactory.GenerateAccounts(6)
testApp, _, kr := testutil.NewTestAppWithGenesisSet(app.DefaultConsensusParams(), accounts...)
require.Equal(t, int64(0), testApp.LastBlockHeight())
encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...)
sendTxs := coretypes.Txs{testutil.SendTxWithManualSequence(
t,
encCfg.TxConfig,
kr,
accounts[0],
accounts[1],
1000,
testutil.ChainID,
1,
1,
)}.ToSliceOfBytes()
resp := testApp.PrepareProposal(abci.RequestPrepareProposal{
BlockData: &tmproto.Data{Txs: sendTxs},
})
require.Len(t, resp.BlockData.Txs, 0)
}
4 changes: 2 additions & 2 deletions specs/src/specs/ante_handler.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ The AnteHandler chains together several decorators to ensure the following crite
- The tx's count of signatures <= the max number of signatures. The max number of signatures is [`TxSigLimit = 7`](https://github.com/cosmos/cosmos-sdk/blob/a429238fc267da88a8548bfebe0ba7fb28b82a13/x/auth/README.md?plain=1#L231).
- The tx's [gas_limit](https://github.com/cosmos/cosmos-sdk/blob/22c28366466e64ebf0df1ce5bec8b1130523552c/proto/cosmos/tx/v1beta1/tx.proto#L211-L213) is > the gas consumed based on the tx's signatures.
- The tx's [signatures](https://github.com/cosmos/cosmos-sdk/blob/22c28366466e64ebf0df1ce5bec8b1130523552c/types/tx/signing/signature.go#L10-L26) are valid. For each signature, ensure that the signature's sequence number (a.k.a nonce) matches the account sequence number of the signer.
- The tx's [gas_limit](https://github.com/cosmos/cosmos-sdk/blob/22c28366466e64ebf0df1ce5bec8b1130523552c/proto/cosmos/tx/v1beta1/tx.proto#L211-L213) is > the gas consumed based on the blob size(s). Since blobs are charged based on the number of shares they occupy, the gas consumed is calculated as follows: `gasToConsume = sharesNeeded(blob) * bytesPerShare * gasPerBlobByte`. Where `bytesPerShare` is a a global constant (an alias for [`ShareSize = 512`](https://github.com/celestiaorg/celestia-app/blob/c90e61d5a2d0c0bd0e123df4ab416f6f0d141b7f/pkg/appconsts/global_consts.go#L27-L28)) and `gasPerBlobByte` is a governance parameter that can be modified (the [`DefaultGasPerBlobByte = 8`](https://github.com/celestiaorg/celestia-app/blob/c90e61d5a2d0c0bd0e123df4ab416f6f0d141b7f/pkg/appconsts/initial_consts.go#L16-L18)).
- The tx's [gas_limit](https://github.com/cosmos/cosmos-sdk/blob/22c28366466e64ebf0df1ce5bec8b1130523552c/proto/cosmos/tx/v1beta1/tx.proto#L211-L213) is > the gas consumed based on the blob size(s). Since blobs are charged based on the number of shares they occupy, the gas consumed is calculated as follows: `gasToConsume = sharesNeeded(blob) * bytesPerShare * gasPerBlobByte`. Where `bytesPerShare` is a global constant (an alias for [`ShareSize = 512`](https://github.com/celestiaorg/celestia-app/blob/c90e61d5a2d0c0bd0e123df4ab416f6f0d141b7f/pkg/appconsts/global_consts.go#L27-L28)) and `gasPerBlobByte` is a governance parameter that can be modified (the [`DefaultGasPerBlobByte = 8`](https://github.com/celestiaorg/celestia-app/blob/c90e61d5a2d0c0bd0e123df4ab416f6f0d141b7f/pkg/appconsts/initial_consts.go#L16-L18)).
- The tx's total blob size is <= the max blob size. The max blob size is derived from the maximum valid square size. The max valid square size is the minimum of: `GovMaxSquareSize` and `SquareSizeUpperBound`.
- The tx does not contain a message of type [MsgSubmitProposal](https://github.com/cosmos/cosmos-sdk/blob/d6d929843bbd331b885467475bcb3050788e30ca/proto/cosmos/gov/v1/tx.proto#L33-L43) with zero proposal messages.
- The tx is not an IBC packet or update message that has already been processed.

In addition to the above criteria, the AnteHandler also has a number of side-effects:

- Tx fees are deducted from the tx's feepayer and added to the fee collector module account.
- Tx priority is calculated based on the the smallest denomination of gas price in the tx and set in context.
- Tx priority is calculated based on the smallest denomination of gas price in the tx and set in context.
- The nonce of all tx signers is incremented by 1.
4 changes: 2 additions & 2 deletions specs/src/specs/block_validity_rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ constrained light clients must be able to detect when a subset of these validity
rules have not been followed in order to avoid making an honest majority
assumption on the consensus network. This has a significant impact on their
design. More information on how light clients can check the invalidity of a
block can be foud in the [Fraud Proofs](./fraud_proofs.md) spec.
block can be found in the [Fraud Proofs](./fraud_proofs.md) spec.

> **Note** Celestia relies on CometBFT (formerly tendermint) for consensus,
> meaning that it has single slot finality and is fork-free. Therefore, in order
Expand All @@ -27,7 +27,7 @@ rules](https://github.com/cometbft/cometbft/blob/v0.34.28/spec/core/data_structu
must be followed.

Notably, this includes verifying data availability. Consensus nodes verify data
availabily by simply downloading the entire block.
availability by simply downloading the entire block.

> **Note** Light clients only sample a fraction of the block. More details on
> how sampling actually works can be found in the seminal ["Fraud and Data
Expand Down
3 changes: 3 additions & 0 deletions test/util/direct_tx_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ func SendTxsWithAccounts(

// update the account info in the signer so the signature is valid
acc := DirectQueryAccount(capp, signingAddr)
if acc == nil {
t.Fatalf("account %s not found", signingAddr)
}

txs[i] = SendTxWithManualSequence(
t,
Expand Down
35 changes: 20 additions & 15 deletions test/util/test_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,25 @@ func (ao EmptyAppOptions) Get(_ string) interface{} {
// is bonded with a delegation of one consensus engine unit in the default token
// of the app from first genesis account. A no-op logger is set in app.
func SetupTestAppWithGenesisValSet(cparams *tmproto.ConsensusParams, genAccounts ...string) (*app.App, keyring.Keyring) {
testApp, valSet, kr := NewTestAppWithGenesisSet(cparams, genAccounts...)

// commit genesis changes
testApp.Commit()
testApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{
ChainID: ChainID,
Height: testApp.LastBlockHeight() + 1,
AppHash: testApp.LastCommitID().Hash,
ValidatorsHash: valSet.Hash(),
NextValidatorsHash: valSet.Hash(),
Version: tmversion.Consensus{
App: cparams.Version.AppVersion,
},
}})

return testApp, kr
}

func NewTestAppWithGenesisSet(cparams *tmproto.ConsensusParams, genAccounts ...string) (*app.App, *tmtypes.ValidatorSet, keyring.Keyring) {
// var cache sdk.MultiStorePersistentCache
// EmptyAppOptions is a stub implementing AppOptions
emptyOpts := EmptyAppOptions{}
Expand Down Expand Up @@ -98,21 +117,7 @@ func SetupTestAppWithGenesisValSet(cparams *tmproto.ConsensusParams, genAccounts
ChainId: ChainID,
},
)

// commit genesis changes
testApp.Commit()
testApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{
ChainID: ChainID,
Height: testApp.LastBlockHeight() + 1,
AppHash: testApp.LastCommitID().Hash,
ValidatorsHash: valSet.Hash(),
NextValidatorsHash: valSet.Hash(),
Version: tmversion.Consensus{
App: cparams.Version.AppVersion,
},
}})

return testApp, kr
return testApp, valSet, kr
}

// AddAccount mimics the cli addAccount command, providing an
Expand Down

0 comments on commit 735f2b9

Please sign in to comment.