Skip to content

Commit

Permalink
go/consensus/api: Rename Caller field in EstimateGasRequest type
Browse files Browse the repository at this point in the history
Rename EstimateGasRequest's Caller field to Signer to better describe
the field's value which is the public key of the transaction's signer.
  • Loading branch information
tjanez committed Jun 11, 2020
1 parent fb8a927 commit 7c44974
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .changelog/2940.breaking.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
go/consensus/api: Rename `Caller` field in `EstimateGasRequest` type

Rename `EstimateGasRequest`'s `Caller` field to `Signer` to better describe
the field's value which is the public key of the transaction's signer.
2 changes: 1 addition & 1 deletion go/consensus/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func NewConsensusEvidence(inner interface{}) ConsensusEvidence {

// EstimateGasRequest is a EstimateGas request.
type EstimateGasRequest struct {
Caller signature.PublicKey `json:"caller"`
Signer signature.PublicKey `json:"signer"`
Transaction *transaction.Transaction `json:"transaction"`
}

Expand Down
2 changes: 1 addition & 1 deletion go/consensus/api/submission.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (m *submissionManager) signAndSubmitTx(ctx context.Context, signer signatur
if tx.Fee == nil {
// Estimate amount of gas needed to perform the update.
var gas transaction.Gas
gas, err = m.backend.EstimateGas(ctx, &EstimateGasRequest{Caller: signer.Public(), Transaction: tx})
gas, err = m.backend.EstimateGas(ctx, &EstimateGasRequest{Signer: signer.Public(), Transaction: tx})
if err != nil {
return fmt.Errorf("failed to estimate gas: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion go/consensus/tendermint/tendermint.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ func (t *tendermintService) SubmitEvidence(ctx context.Context, evidence consens
}

func (t *tendermintService) EstimateGas(ctx context.Context, req *consensusAPI.EstimateGasRequest) (transaction.Gas, error) {
return t.mux.EstimateGas(req.Caller, req.Transaction)
return t.mux.EstimateGas(req.Signer, req.Transaction)
}

func (t *tendermintService) Subscribe(subscriber string, query tmpubsub.Query) (tmtypes.Subscription, error) {
Expand Down
2 changes: 1 addition & 1 deletion go/consensus/tests/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func ConsensusImplementationTests(t *testing.T, backend consensus.ClientBackend)
require.True(epoch > 0, "epoch height should be greater than zero")

_, err = backend.EstimateGas(ctx, &consensus.EstimateGasRequest{
Caller: memorySigner.NewTestSigner("estimate gas signer").Public(),
Signer: memorySigner.NewTestSigner("estimate gas signer").Public(),
Transaction: transaction.NewTransaction(0, nil, epochtimemock.MethodSetEpoch, 0),
})
require.NoError(err, "EstimateGas")
Expand Down
2 changes: 1 addition & 1 deletion go/oasis-node/cmd/debug/txsource/workload/commission.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (c *commission) doAmendCommissionSchedule(ctx context.Context, rng *rand.Ra

// Estimate gas.
gas, err := cnsc.EstimateGas(ctx, &consensus.EstimateGasRequest{
Caller: c.signer.Public(),
Signer: c.signer.Public(),
Transaction: tx,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go/oasis-node/cmd/debug/txsource/workload/parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (parallel) Run(
return fmt.Errorf("transfer tokens FromInt64 %d: %w", parallelTxTransferAmount, err)
}
txGasAmount, err = cnsc.EstimateGas(ctx, &consensus.EstimateGasRequest{
Caller: fundingAccount.Public(),
Signer: fundingAccount.Public(),
Transaction: staking.NewTransferTx(0, nil, xfer),
})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions go/oasis-node/cmd/debug/txsource/workload/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func fundSignAndSubmitTx(
// Estimate gas needed if not set.
if tx.Fee.Gas == 0 {
gas, err := cnsc.EstimateGas(ctx, &consensus.EstimateGasRequest{
Caller: caller.Public(),
Signer: caller.Public(),
Transaction: tx,
})
if err != nil {
Expand Down Expand Up @@ -142,7 +142,7 @@ func transferFunds(
tx := staking.NewTransferTx(nonce, &fee, &transfer)
// Estimate fee.
gas, err := cnsc.EstimateGas(ctx, &consensus.EstimateGasRequest{
Caller: from.Public(),
Signer: from.Public(),
Transaction: tx,
})
if err != nil {
Expand Down

0 comments on commit 7c44974

Please sign in to comment.