8000 Error in the introductory guides · Issue #1583 · cometbft/cometbft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
  • Error in the introductory guides #1583
    Closed
    @lasarojc

    Description

    @lasarojc

    Bug Report

    The introductory go.md and go-builtin.md guides have a wrong example of prepareProposal, as noted [here] (#1384 (comment))

    func (app *KVStoreApplication) PrepareProposal(_ context.Context, proposal *abcitypes.RequestPrepareProposal) (*abcitypes.ResponsePrepareProposal, error) {
       totalBytes := int64(0)
       txs := make([]byte, 0)
    
       for _, tx := range proposal.Txs {
         totalBytes += int64(len(tx))
         txs = append(txs, tx...)
    
           if totalBytes > int64(proposal.MaxTxBytes) {
             break
           }
         }
    
         return &abcitypes.ResponsePrepareProposal{Txs: proposal.Txs}, nil
     }
    

    First, txs should be a slice of slices.
    Second, the overflow check should be done before appending the transaction to txs.

    The fix need to be back ported to 0.38 and 0.37.

    Metadata

    Metadata

    Assignees

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0