Skip to content
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
1 change: 1 addition & 0 deletions relayer/txm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ type TronTxmConfig struct {
BroadcastChanSize uint
ConfirmPollSecs uint
EnergyMultiplier float64
FixedEnergyValue int64
}
6 changes: 3 additions & 3 deletions relayer/txm/txm.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ func (t *TronTxm) TriggerSmartContract(ctx context.Context, tx *TronTx) (*fullno
tx.Params,
paddedFeeLimit,
/* tAmount= (TRX amount) */ 0)

if err != nil {
return nil, fmt.Errorf("failed to call TriggerSmartContract: %+w", err)
}
Expand Down Expand Up @@ -265,7 +264,6 @@ func (t *TronTxm) broadcastTx(tx *common.Transaction) (*fullnode.BroadcastRespon
// do not retry on other broadcast errors. the error message and code is encoded in `err`.
return nil, err
}

}
}
if err != nil {
Expand Down Expand Up @@ -389,6 +387,9 @@ func (t *TronTxm) InflightCount() (int, int) {
}

func (t *TronTxm) estimateEnergy(tx *TronTx) (int64, error) {
if t.Config.FixedEnergyValue != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be worth having a nil check somewhere here or applying 0 as the default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be nil? not sure if go typecasts an empty value to 0 (maybe?)

Copy link
Contributor Author

@HelloKashif HelloKashif Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, Golang initializes int64 types as zero by default. Here's a sample demo
https://go.dev/play/p/SftdRsxCrxU

return t.Config.FixedEnergyValue, nil
}

if t.EstimateEnergyEnabled {
estimateEnergyMessage, err := t.GetClient().EstimateEnergy(
Expand All @@ -413,7 +414,6 @@ func (t *TronTxm) estimateEnergy(tx *TronTx) (int64, error) {

// Using TriggerConstantContract as EstimateEnergy is unsupported or failed.
triggerResponse, err := t.GetClient().TriggerConstantContract(tx.FromAddress, tx.ContractAddress, tx.Method, tx.Params)

if err != nil {
return 0, fmt.Errorf("failed to call TriggerConstantContract: %w", err)
}
Expand Down
Loading