diff --git a/core/state_processor.go b/core/state_processor.go index 9601357813..15e34d40cf 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -416,6 +416,7 @@ func ApplyStakingTransaction( receipt = types.NewReceipt(root, false, *usedGas) receipt.TxHash = tx.Hash() receipt.GasUsed = gas + receipt.EffectiveGasPrice = tx.EffectiveGasPrice(big.NewInt(0), nil) if config.IsReceiptLog(header.Epoch()) { receipt.Logs = statedb.GetLogs(tx.Hash(), header.Number().Uint64(), header.Hash()) diff --git a/rpc/harmony/v1/types.go b/rpc/harmony/v1/types.go index 0a8e02acfb..fa9369f4d2 100644 --- a/rpc/harmony/v1/types.go +++ b/rpc/harmony/v1/types.go @@ -206,6 +206,7 @@ type StakingTxReceipt struct { Type hexutil.Uint64 `json:"type"` Root hexutil.Bytes `json:"root"` Status hexutil.Uint `json:"status"` + EffectiveGasPrice hexutil.Big `json:"effectiveGasPrice"` } // CxReceipt represents a CxReceipt that will serialize to the RPC representation of a CxReceipt @@ -403,6 +404,7 @@ func NewStakingTxReceipt( Type: hexutil.Uint64(tx.StakingType()), Root: receipt.PostState, Status: hexutil.Uint(receipt.Status), + EffectiveGasPrice: hexutil.Big(*receipt.EffectiveGasPrice), } // Set empty array for empty logs diff --git a/rpc/harmony/v2/types.go b/rpc/harmony/v2/types.go index 003a690861..64a15ccdaf 100644 --- a/rpc/harmony/v2/types.go +++ b/rpc/harmony/v2/types.go @@ -236,6 +236,7 @@ type StakingTxReceipt struct { Type staking.Directive `json:"type"` Root hexutil.Bytes `json:"root"` Status uint `json:"status"` + EffectiveGasPrice hexutil.Big `json:"effectiveGasPrice"` } // CxReceipt represents a CxReceipt that will serialize to the RPC representation of a CxReceipt @@ -439,6 +440,7 @@ func NewStakingTxReceipt( Type: tx.StakingType(), Root: receipt.PostState, Status: uint(receipt.Status), + EffectiveGasPrice: hexutil.Big(*receipt.EffectiveGasPrice), } // Set empty array for empty logs diff --git a/staking/types/transaction.go b/staking/types/transaction.go index ba93aefe6f..c9923bcdfe 100644 --- a/staking/types/transaction.go +++ b/staking/types/transaction.go @@ -57,6 +57,10 @@ func (d *txdata) CopyFrom(d2 *txdata) { d.Hash = copyHash(d2.Hash) } +func (d *txdata) effectiveGasPrice(dst *big.Int, baseFee *big.Int) *big.Int { + return dst.Set(d.Price) +} + func copyHash(hash *common.Hash) *common.Hash { if hash == nil { return nil @@ -263,6 +267,11 @@ func (tx *StakingTransaction) IsEthCompatible() bool { return false } +// EffectiveGasPrice returns the effective gas price of the transaction. +func (tx *StakingTransaction) EffectiveGasPrice(dst *big.Int, baseFee *big.Int) *big.Int { + return tx.data.effectiveGasPrice(dst, baseFee) +} + type writeCounter common.StorageSize func (c *writeCounter) Write(b []byte) (int, error) {