-
Notifications
You must be signed in to change notification settings - Fork 38
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 new MinTxsInBlock consensus param #252
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -384,7 +384,7 @@ func TestTxMempool_ReapMaxBytesMaxGas(t *testing.T) { | |
wg.Add(1) | ||
go func() { | ||
defer wg.Done() | ||
reapedTxs := txmp.ReapMaxBytesMaxGas(-1, 50) | ||
reapedTxs := txmp.ReapMaxBytesMaxGas(-1, 50, 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. coudl we add unit tests for when this value isn't 0? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it might be good to permutate these situations:
|
||
ensurePrioritized(reapedTxs) | ||
require.Equal(t, len(tTxs), txmp.Size()) | ||
require.Equal(t, int64(5690), txmp.SizeBytes()) | ||
|
@@ -395,7 +395,7 @@ func TestTxMempool_ReapMaxBytesMaxGas(t *testing.T) { | |
wg.Add(1) | ||
go func() { | ||
defer wg.Done() | ||
reapedTxs := txmp.ReapMaxBytesMaxGas(1000, -1) | ||
reapedTxs := txmp.ReapMaxBytesMaxGas(1000, -1, 0) | ||
ensurePrioritized(reapedTxs) | ||
require.Equal(t, len(tTxs), txmp.Size()) | ||
require.Equal(t, int64(5690), txmp.SizeBytes()) | ||
|
@@ -407,7 +407,7 @@ func TestTxMempool_ReapMaxBytesMaxGas(t *testing.T) { | |
wg.Add(1) | ||
go func() { | ||
defer wg.Done() | ||
reapedTxs := txmp.ReapMaxBytesMaxGas(1500, 30) | ||
reapedTxs := txmp.ReapMaxBytesMaxGas(1500, 30, 0) | ||
ensurePrioritized(reapedTxs) | ||
require.Equal(t, len(tTxs), txmp.Size()) | ||
require.Equal(t, int64(5690), txmp.SizeBytes()) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,8 +57,9 @@ type HashedParams struct { | |
// BlockParams define limits on the block size and gas plus minimum time | ||
// between blocks. | ||
type BlockParams struct { | ||
MaxBytes int64 `json:"max_bytes,string"` | ||
MaxGas int64 `json:"max_gas,string"` | ||
MaxBytes int64 `json:"max_bytes,string"` | ||
MaxGas int64 `json:"max_gas,string"` | ||
MinTxsInBlock int64 `json:"min_txs_in_block,string"` | ||
} | ||
|
||
// EvidenceParams determine how we handle evidence of malfeasance. | ||
|
@@ -132,7 +133,8 @@ func DefaultBlockParams() BlockParams { | |
MaxBytes: 22020096, // 21MB | ||
// Default, can be increased and tuned as needed | ||
// match sei-devnet-3 and atlantic-2 current values | ||
MaxGas: 100000000, | ||
MaxGas: 100000000, | ||
MinTxsInBlock: 0, | ||
} | ||
} | ||
|
||
|
@@ -286,6 +288,11 @@ func (params ConsensusParams) ValidateConsensusParams() error { | |
params.Block.MaxGas) | ||
} | ||
|
||
if params.Block.MinTxsInBlock < 0 { | ||
return fmt.Errorf("block.MinTxsInBlock must be positive. Got %d", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit - "must be non-negative" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
params.Block.MinTxsInBlock) | ||
} | ||
|
||
if params.Evidence.MaxAgeNumBlocks <= 0 { | ||
return fmt.Errorf("evidence.MaxAgeNumBlocks must be greater than 0. Got %d", | ||
params.Evidence.MaxAgeNumBlocks) | ||
|
@@ -423,6 +430,7 @@ func (params ConsensusParams) UpdateConsensusParams(params2 *tmproto.ConsensusPa | |
if params2.Block != nil { | ||
res.Block.MaxBytes = params2.Block.MaxBytes | ||
res.Block.MaxGas = params2.Block.MaxGas | ||
res.Block.MinTxsInBlock = params2.Block.MinTxsInBlock | ||
} | ||
if params2.Evidence != nil { | ||
res.Evidence.MaxAgeNumBlocks = params2.Evidence.MaxAgeNumBlocks | ||
|
@@ -473,8 +481,9 @@ func (params ConsensusParams) UpdateConsensusParams(params2 *tmproto.ConsensusPa | |
func (params *ConsensusParams) ToProto() tmproto.ConsensusParams { | ||
return tmproto.ConsensusParams{ | ||
Block: &tmproto.BlockParams{ | ||
MaxBytes: params.Block.MaxBytes, | ||
MaxGas: params.Block.MaxGas, | ||
MaxBytes: params.Block.MaxBytes, | ||
MaxGas: params.Block.MaxGas, | ||
MinTxsInBlock: params.Block.MinTxsInBlock, | ||
}, | ||
Evidence: &tmproto.EvidenceParams{ | ||
MaxAgeNumBlocks: params.Evidence.MaxAgeNumBlocks, | ||
|
@@ -509,8 +518,9 @@ func (params *ConsensusParams) ToProto() tmproto.ConsensusParams { | |
func ConsensusParamsFromProto(pbParams tmproto.ConsensusParams) ConsensusParams { | ||
c := ConsensusParams{ | ||
Block: BlockParams{ | ||
MaxBytes: pbParams.Block.MaxBytes, | ||
MaxGas: pbParams.Block.MaxGas, | ||
MaxBytes: pbParams.Block.MaxBytes, | ||
MaxGas: pbParams.Block.MaxGas, | ||
MinTxsInBlock: pbParams.Block.MinTxsInBlock, | ||
}, | ||
Evidence: EvidenceParams{ | ||
MaxAgeNumBlocks: pbParams.Evidence.MaxAgeNumBlocks, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might need to be also
or size threshold is exceeded
. I suspect the incremented valuestotalSize
,totalGas
should only be incremented if the transaction is appended?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's kinda what i'm thinking:
with helper:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should exempt txs from exceeding size limit since a large size does mean we need to store more data on chain (i.e. it's not sizeWanted but always sizeUsed)