From 9692c96ca656d8cc6809393f6ee679b7b293b01c Mon Sep 17 00:00:00 2001 From: Steven Landers Date: Wed, 19 Feb 2025 19:47:33 -0500 Subject: [PATCH 1/3] add gas wanted log --- internal/consensus/state.go | 11 +++++++++-- internal/state/execution.go | 6 +++--- internal/state/execution_test.go | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/internal/consensus/state.go b/internal/consensus/state.go index dd06cc659..f01ca95a0 100644 --- a/internal/consensus/state.go +++ b/internal/consensus/state.go @@ -1722,10 +1722,16 @@ func (cs *State) defaultDoPrevote(ctx context.Context, height int64, round int32 liveness properties. Please see PrepareProposal-ProcessProposal coherence and determinism properties in the ABCI++ specification. */ - isAppValid, err := cs.blockExec.ProcessProposal(ctx, cs.roundState.ProposalBlock(), cs.state) + isAppValid, resp, err := cs.blockExec.ProcessProposal(ctx, cs.roundState.ProposalBlock(), cs.state) if err != nil { panic(fmt.Sprintf("ProcessProposal: %v", err)) } + + var gasWanted int64 + for _, tx := range resp.TxResults { + gasWanted += tx.GasWanted + } + cs.metrics.MarkProposalProcessed(isAppValid) numberOfTxs := cs.roundState.ProposalBlock().Txs.Len() @@ -1736,7 +1742,8 @@ func (cs *State) defaultDoPrevote(ctx context.Context, height int64, round int32 logger.Error("prevote step: state machine rejected a proposed block; this should not happen:"+ "the proposer may be misbehaving; prevoting nil", "err", err, "proposerAddress", cs.roundState.ProposalBlock().ProposerAddress, - "numberOfTxs", numberOfTxs) + "numberOfTxs", numberOfTxs, + "gasWanted", gasWanted) cs.signAddVote(ctx, tmproto.PrevoteType, nil, types.PartSetHeader{}) return diff --git a/internal/state/execution.go b/internal/state/execution.go index 8b0a94572..3bd262d7e 100644 --- a/internal/state/execution.go +++ b/internal/state/execution.go @@ -161,7 +161,7 @@ func (blockExec *BlockExecutor) ProcessProposal( ctx context.Context, block *types.Block, state State, -) (bool, error) { +) (bool, *abci.ResponseProcessProposal, error) { txs := block.Data.Txs.ToSliceOfBytes() resp, err := blockExec.appClient.ProcessProposal(ctx, &abci.RequestProcessProposal{ Hash: block.Header.Hash(), @@ -184,13 +184,13 @@ func (blockExec *BlockExecutor) ProcessProposal( LastResultsHash: block.LastResultsHash, }) if err != nil { - return false, ErrInvalidBlock(err) + return false, resp, ErrInvalidBlock(err) } if resp.IsStatusUnknown() { panic(fmt.Sprintf("ProcessProposal responded with status %s", resp.Status.String())) } - return resp.IsAccepted(), nil + return resp.IsAccepted(), resp, nil } // ValidateBlock validates the given block against the given state. diff --git a/internal/state/execution_test.go b/internal/state/execution_test.go index 1e7b5cf55..41951278f 100644 --- a/internal/state/execution_test.go +++ b/internal/state/execution_test.go @@ -367,7 +367,7 @@ func TestProcessProposal(t *testing.T) { } app.On("ProcessProposal", mock.Anything, mock.Anything).Return(&abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil) - acceptBlock, err := blockExec.ProcessProposal(ctx, block1, state) + acceptBlock, _, err := blockExec.ProcessProposal(ctx, block1, state) require.NoError(t, err) require.True(t, acceptBlock) app.AssertExpectations(t) From 4e8e2a938ff15fd648b043f110a1ee42eee8eca2 Mon Sep 17 00:00:00 2001 From: _dssei_ Date: Wed, 19 Feb 2025 16:54:46 -0800 Subject: [PATCH 2/3] add info of proposal info --- internal/consensus/state.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/consensus/state.go b/internal/consensus/state.go index f01ca95a0..2350069d1 100644 --- a/internal/consensus/state.go +++ b/internal/consensus/state.go @@ -1737,6 +1737,11 @@ func (cs *State) defaultDoPrevote(ctx context.Context, height int64, round int32 numberOfTxs := cs.roundState.ProposalBlock().Txs.Len() cs.metrics.MarkProposalTxNumber(numberOfTxs) + logger.Info("proposal info", + "proposerAddress", cs.roundState.ProposalBlock().ProposerAddress, + "numberOfTxs", numberOfTxs, + "gasWanted", gasWanted) + // Vote nil if the Application rejected the block if !isAppValid { logger.Error("prevote step: state machine rejected a proposed block; this should not happen:"+ From 61e1daecfb0d31011ed2c344c9c564903ac11752 Mon Sep 17 00:00:00 2001 From: _dssei_ Date: Wed, 19 Feb 2025 17:12:51 -0800 Subject: [PATCH 3/3] comment out metrics for now --- internal/consensus/metrics.go | 2 +- internal/consensus/state.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/consensus/metrics.go b/internal/consensus/metrics.go index e5b580e64..68bf9dfbb 100644 --- a/internal/consensus/metrics.go +++ b/internal/consensus/metrics.go @@ -254,5 +254,5 @@ func (m *Metrics) MarkStep(s cstypes.RoundStepType) { } func (m *Metrics) MarkProposalTxNumber(txs int) { - m.ProposalTxs.With("proposal_tx_number").Add(float64(txs)) + m.ProposalTxs.Add(float64(txs)) } diff --git a/internal/consensus/state.go b/internal/consensus/state.go index 2350069d1..47fea3307 100644 --- a/internal/consensus/state.go +++ b/internal/consensus/state.go @@ -1735,7 +1735,7 @@ func (cs *State) defaultDoPrevote(ctx context.Context, height int64, round int32 cs.metrics.MarkProposalProcessed(isAppValid) numberOfTxs := cs.roundState.ProposalBlock().Txs.Len() - cs.metrics.MarkProposalTxNumber(numberOfTxs) + //cs.metrics.MarkProposalTxNumber(numberOfTxs) logger.Info("proposal info", "proposerAddress", cs.roundState.ProposalBlock().ProposerAddress,