Skip to content
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

go/consensus/tendermint: Always accept own transactions #2586

Merged
merged 1 commit into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changelog/2586.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
go/consensus/tendermint: Always accept own transactions.

A validator node should always accept own transactions (signed by the node's identity key)
regardless of the configured gas price.
10 changes: 10 additions & 0 deletions go/consensus/tendermint/abci/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ type ApplicationConfig struct {
Pruning PruneConfig
HaltEpochHeight epochtime.EpochTime
MinGasPrice uint64

// OwnTxSigner is the transaction signer identity of the local node.
OwnTxSigner signature.PublicKey
}

// TransactionAuthHandler is the interface for ABCI applications that handle
Expand Down Expand Up @@ -947,6 +950,7 @@ type ApplicationState struct {
haltEpochHeight epochtime.EpochTime

minGasPrice quantity.Quantity
ownTxSigner signature.PublicKey

metricsCloseCh chan struct{}
metricsClosedCh chan struct{}
Expand Down Expand Up @@ -1076,6 +1080,11 @@ func (s *ApplicationState) MinGasPrice() *quantity.Quantity {
return &s.minGasPrice
}

// OwnTxSigner returns the transaction signer identity of the local node.
func (s *ApplicationState) OwnTxSigner() signature.PublicKey {
return s.ownTxSigner
}

func (s *ApplicationState) doCommit(now time.Time) error {
// Save the new version of the persistent tree.
blockHash, blockHeight, err := s.deliverTxTree.SaveVersion()
Expand Down Expand Up @@ -1216,6 +1225,7 @@ func newApplicationState(ctx context.Context, cfg *ApplicationConfig) (*Applicat
blockHeight: blockHeight,
haltEpochHeight: cfg.HaltEpochHeight,
minGasPrice: minGasPrice,
ownTxSigner: cfg.OwnTxSigner,
metricsCloseCh: make(chan struct{}),
metricsClosedCh: make(chan struct{}),
}
Expand Down
10 changes: 6 additions & 4 deletions go/consensus/tendermint/apps/staking/state/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ func AuthenticateAndPayFees(
return transaction.ErrInsufficientFeeBalance
}

// Check fee against minimum gas price if in CheckTx.
// Check fee against minimum gas price if in CheckTx. Always accept own transactions.
// NOTE: This is non-deterministic as it is derived from the local validator
// configuration, but as long as it is only done in CheckTx, this is ok.
callerGasPrice := fee.GasPrice()
if fee.Gas > 0 && callerGasPrice.Cmp(ctx.AppState().MinGasPrice()) < 0 {
return transaction.ErrGasPriceTooLow
if !ctx.AppState().OwnTxSigner().Equal(id) {
callerGasPrice := fee.GasPrice()
if fee.Gas > 0 && callerGasPrice.Cmp(ctx.AppState().MinGasPrice()) < 0 {
return transaction.ErrGasPriceTooLow
}
}

return nil
Expand Down
1 change: 1 addition & 0 deletions go/consensus/tendermint/tendermint.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ func (t *tendermintService) lazyInit() error {
Pruning: pruneCfg,
HaltEpochHeight: t.genesis.HaltEpoch,
MinGasPrice: viper.GetUint64(CfgConsensusMinGasPrice),
OwnTxSigner: t.nodeSigner.Public(),
}
t.mux, err = abci.NewApplicationServer(t.ctx, appConfig)
if err != nil {
Expand Down