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
4 changes: 2 additions & 2 deletions chains/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/jpillora/backoff v1.0.0
github.com/prometheus/client_golang v1.21.1
github.com/shopspring/decimal v1.4.0
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250521163734-723cad356d85
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250627002929-2cbb7418aaa5
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250115203616-a2ea5e50b260
github.com/stretchr/testify v1.10.0
go.uber.org/multierr v1.11.0
Expand Down Expand Up @@ -42,7 +42,7 @@ require (
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.63.0 // indirect
github.com/prometheus/procfs v0.16.0 // indirect
github.com/smartcontractkit/freeport v0.1.0 // indirect
github.com/smartcontractkit/freeport v0.1.1 // indirect
github.com/smartcontractkit/libocr v0.0.0-20250220133800-f3b940c4f298 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel v1.35.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions chains/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb
github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U=
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250521163734-723cad356d85 h1:EMnHaq7rzuB4m8Ebd+/C/yBVBz088OSrV5JbZV+An04=
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250521163734-723cad356d85/go.mod h1:TF9ZqBV0QA3X1T4BoLGp0FfJpOQOcQ+ggKu1MlsWKYw=
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250627002929-2cbb7418aaa5 h1:ZadFXdmkBFJz3GYPAF20IvtNSHbcRFoLrhCU/LKS9oQ=
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250627002929-2cbb7418aaa5/go.mod h1:mRKPMPyJhg1RBjxtRTL2gHvRhTcZ+nk2Upu/u97Y16M=
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250115203616-a2ea5e50b260 h1:See2isL6KdrTJDlVKWv8qiyYqWhYUcubU2e5yKXV1oY=
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250115203616-a2ea5e50b260/go.mod h1:4JqpgFy01LaqG1yM2iFTzwX3ZgcAvW9WdstBZQgPHzU=
github.com/smartcontractkit/freeport v0.1.0 h1:3MZHeti5m+tSTBCq5R8rhawFHxrnQZYBZVL+xgS1sPo=
github.com/smartcontractkit/freeport v0.1.0/go.mod h1:T4zH9R8R8lVWKfU7tUvYz2o2jMv1OpGCdpY2j2QZXzU=
github.com/smartcontractkit/freeport v0.1.1 h1:B5fhEtmgomdIhw03uPVbVTP6oPv27fBhZsoZZMSIS8I=
github.com/smartcontractkit/freeport v0.1.1/go.mod h1:T4zH9R8R8lVWKfU7tUvYz2o2jMv1OpGCdpY2j2QZXzU=
github.com/smartcontractkit/libocr v0.0.0-20250220133800-f3b940c4f298 h1:PKiqnVOTChlH4a4ljJKL3OKGRgYfIpJS4YD1daAIKks=
github.com/smartcontractkit/libocr v0.0.0-20250220133800-f3b940c4f298/go.mod h1:Mb7+/LC4edz7HyHxX4QkE42pSuov4AV68+AxBXAap0o=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
56 changes: 44 additions & 12 deletions chains/txmgr/txmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type TxManager[CID chains.ID, HEAD chains.Head[BHASH], ADDR chains.Hashable, THA
CountTransactionsByState(ctx context.Context, state txmgrtypes.TxState) (count uint32, err error)
GetTransactionStatus(ctx context.Context, transactionID string) (state commontypes.TransactionStatus, err error)
GetTransactionFee(ctx context.Context, transactionID string) (fee *evmtypes.TransactionFee, err error)
GetTransactionReceipt(ctx context.Context, transactionID string) (receipt *txmgrtypes.ChainReceipt[THASH, BHASH], err error)
CalculateFee(feeParts FeeParts) *big.Int
}

type TxmV2Wrapper[CID chains.ID, HEAD chains.Head[BHASH], ADDR chains.Hashable, THASH chains.Hashable, BHASH chains.Hashable, SEQ chains.Sequence, FEE fees.Fee] interface {
Expand Down Expand Up @@ -733,33 +735,55 @@ func (b *Txm[CID, HEAD, ADDR, THASH, BHASH, R, SEQ, FEE]) GetTransactionStatus(c
}

func (b *Txm[CID, HEAD, ADDR, THASH, BHASH, R, SEQ, FEE]) GetTransactionFee(ctx context.Context, transactionID string) (fee *evmtypes.TransactionFee, err error) {
receipt, err := b.txStore.FindReceiptWithIdempotencyKey(ctx, transactionID, b.chainID)
receipt, err := b.GetTransactionReceipt(ctx, transactionID)

if err != nil {
return fee, fmt.Errorf("failed to find receipt with IdempotencyKey %s: %w", transactionID, err)
return nil, err
}

txFee := b.CalculateFee(FeeParts{
GasUsed: receipt.GetFeeUsed(),
EffectiveGasPrice: receipt.GetEffectiveGasPrice(),
L1Fee: receipt.GetL1Fee(),
})

return &evmtypes.TransactionFee{
TransactionFee: txFee,
}, nil
}

func (b *Txm[CID, HEAD, ADDR, THASH, BHASH, R, SEQ, FEE]) GetTransactionReceipt(ctx context.Context, transactionID string) (receipt txmgrtypes.ChainReceipt[THASH, BHASH], err error) {
foundReceipt, err := b.txStore.FindReceiptWithIdempotencyKey(ctx, transactionID, b.chainID)
if err != nil {
return nil, fmt.Errorf("failed to find receipt with IdempotencyKey %q: %w", transactionID, err)
}
// This check is required since a no-rows error returns nil err
if receipt == nil {
return fee, fmt.Errorf("failed to find receipt with IdempotencyKey %s", transactionID)
if foundReceipt == nil {
return nil, fmt.Errorf("failed to find receipt with IdempotencyKey %q", transactionID)
}
return foundReceipt, nil
}

type FeeParts struct {
GasUsed uint64
EffectiveGasPrice *big.Int
L1Fee *big.Int
}

func (b *Txm[CID, HEAD, ADDR, THASH, BHASH, R, SEQ, FEE]) CalculateFee(feeParts FeeParts) *big.Int {
totalFee := new(big.Int)

gasUsed := new(big.Int).SetUint64(receipt.GetFeeUsed())
price := receipt.GetEffectiveGasPrice()
gasUsed := new(big.Int).SetUint64(feeParts.GasUsed)
price := feeParts.EffectiveGasPrice
if price != nil {
totalFee.Mul(gasUsed, price)
}
l1Fee := receipt.GetL1Fee()
l1Fee := feeParts.L1Fee
if l1Fee != nil {
totalFee.Add(totalFee, l1Fee)
}

fee = &evmtypes.TransactionFee{
TransactionFee: totalFee,
}

return fee, nil
return totalFee
}

// Deprecated: use txmgrtest.ErrTxManager
Expand Down Expand Up @@ -847,6 +871,14 @@ func (n *NullTxManager[CID, HEAD, ADDR, THASH, BHASH, SEQ, FEE]) GetTransactionF
return
}

func (n *NullTxManager[CID, HEAD, ADDR, THASH, BHASH, SEQ, FEE]) CalculateFee(feeParts FeeParts) *big.Int {
return nil
}

func (n *NullTxManager[CID, HEAD, ADDR, THASH, BHASH, SEQ, FEE]) GetTransactionReceipt(ctx context.Context, transactionID string) (receipt *txmgrtypes.ChainReceipt[THASH, BHASH], err error) {
return
}

func (b *Txm[CID, HEAD, ADDR, THASH, BHASH, R, SEQ, FEE]) pruneQueueAndCreateTxn(
ctx context.Context,
txRequest txmgrtypes.TxRequest[ADDR, THASH],
Expand Down
Loading