Skip to content

Commit

Permalink
Merge branch 'backup-branch-fee-bumping' into nonevm-706-tx-expiratio…
Browse files Browse the repository at this point in the history
…n-rebroadcast-soak
  • Loading branch information
Farber98 committed Dec 5, 2024
2 parents f738933 + 36ee4ec commit 55ade8c
Show file tree
Hide file tree
Showing 8 changed files with 269 additions and 96 deletions.
2 changes: 1 addition & 1 deletion docs/relay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ chainlink nodes solana create --name=<node-name> --chain-id=<chain-id> --url=<ur
| `TxRetryTimeout` | duration for tx to be rebroadcast to rpc, txm stops rebroadcast after timeout | 10s | |
| `TxConfirmTimeout` | duration when confirming a tx signature before signature is discarded as unconfirmed | 30s |
| `TxExpirationRebroadcast` | enables or disables transaction rebroadcast if expired. Expiration check is performed every `ConfirmPollPeriod`. A transaction is considered expired if the blockhash it was sent with is 150 blocks older than the latest blockhash. | `false` | `true`, `false` |
| `SkipPreflight` | enable or disable preflight checks when sending tx | `true` | `true`, `false` |
| `SkipPreflight` | enables or disables preflight checks when sending tx | `true` | `true`, `false` |
| `Commitment` | Confirmation level for solana state and transactions. ([documentation](https://docs.solana.com/developing/clients/jsonrpc-api#configuring-state-commitment)) | `confirmed` | `processed`, `confirmed`, `finalized` |
| `MaxRetries` | Parameter when sending transactions, how many times the RPC node will automatically rebroadcast a tx, default = `0` for custom txm rebroadcasting method, set to `-1` to use the RPC node's default retry strategy | `0` | |
10 changes: 5 additions & 5 deletions integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ require (
github.com/pelletier/go-toml/v2 v2.2.3
github.com/rs/zerolog v1.33.0
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241127162636-07aa781ee1f4
github.com/smartcontractkit/chainlink-solana v1.1.1-0.20241127210503-88cca3779525
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.17
github.com/smartcontractkit/chainlink-solana v1.1.1-0.20241204153209-c3a71b0eef99
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.18
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.9
github.com/smartcontractkit/chainlink/deployment v0.0.0-20241127192805-54ea74a13bfe
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20241204033247-732cc15aa87d
github.com/smartcontractkit/chainlink/v2 v2.14.0-mercury-20240807.0.20241204033247-732cc15aa87d
github.com/smartcontractkit/chainlink/deployment v0.0.0-20241205144849-138d4c51ad0d
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20241205144849-138d4c51ad0d
github.com/smartcontractkit/chainlink/v2 v2.14.0-mercury-20240807.0.20241205144849-138d4c51ad0d
github.com/smartcontractkit/libocr v0.0.0-20241007185508-adbe57025f12
github.com/stretchr/testify v1.9.0
github.com/testcontainers/testcontainers-go v0.34.0
Expand Down
16 changes: 8 additions & 8 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1429,20 +1429,20 @@ github.com/smartcontractkit/chainlink-protos/orchestrator v0.3.2 h1:onBe3DqNrbtO
github.com/smartcontractkit/chainlink-protos/orchestrator v0.3.2/go.mod h1:m/A3lqD7ms/RsQ9BT5P2uceYY0QX5mIt4KQxT2G6qEo=
github.com/smartcontractkit/chainlink-starknet/relayer v0.1.1-0.20241202202529-2033490e77b8 h1:tNS7U9lrxkFvEuyxQv11HHOiV9LPDGC9wYEy+yM/Jv4=
github.com/smartcontractkit/chainlink-starknet/relayer v0.1.1-0.20241202202529-2033490e77b8/go.mod h1:EBrEgcdIbwepqguClkv8Ohy7CbyWSJaE4EC9aBJlQK0=
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.17 h1:Fw2F8fKa5QdOUzLAj6Y/EB6XFC0QtK2pw5bqQSatL4A=
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.17/go.mod h1:NwmlNKqrb02v4Sci4b5KW644nfH2BW+FrKbWwTN5r6M=
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.18 h1:a3xetGZh2nFO1iX5xd9OuqiCkgbWLvW6fTN6fgVubPo=
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.18/go.mod h1:NwmlNKqrb02v4Sci4b5KW644nfH2BW+FrKbWwTN5r6M=
github.com/smartcontractkit/chainlink-testing-framework/lib/grafana v1.50.0 h1:VIxK8u0Jd0Q/VuhmsNm6Bls6Tb31H/sA3A/rbc5hnhg=
github.com/smartcontractkit/chainlink-testing-framework/lib/grafana v1.50.0/go.mod h1:lyAu+oMXdNUzEDScj2DXB2IueY+SDXPPfyl/kb63tMM=
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.9 h1:yB1x5UXvpZNka+5h57yo1/GrKfXKCqMzChCISpldZx4=
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.9/go.mod h1:lJk0atEJ5Zyo3Tqrmf1Pl9jUEe79EgDb9bD3K5OTUBI=
github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.2 h1:7bCdbTUWzyczQg+kwHCxlx6y07zE8HNB8+ntTne6qd8=
github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.2/go.mod h1:MltlNu3jcXm/DyLN98I5TFNtu/o1NNAcaPAFKMXWk70=
github.com/smartcontractkit/chainlink/deployment v0.0.0-20241127192805-54ea74a13bfe h1:jUS49b8OODR6552wqvzNBMXHwgXV7iPZmz9lmESTsto=
github.com/smartcontractkit/chainlink/deployment v0.0.0-20241127192805-54ea74a13bfe/go.mod h1:ueUOL11tGBu1TTonZcIeD6/3av2iZE5AydxtclG8Dvo=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20241204033247-732cc15aa87d h1:vV41ofCA5TGaHpoD2UHiN/VAR8xRqycWw4Fy75pXQj8=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20241204033247-732cc15aa87d/go.mod h1:xCJuze3GgG6Ec/gLMAS/47FC/SzEa/Y+YiD5g4wvYTM=
github.com/smartcontractkit/chainlink/v2 v2.14.0-mercury-20240807.0.20241204033247-732cc15aa87d h1:W5f72PgRWg1ChYQBcwBZosrypWSwx7ShQNx3TKi7rwI=
github.com/smartcontractkit/chainlink/v2 v2.14.0-mercury-20240807.0.20241204033247-732cc15aa87d/go.mod h1:ofC2S3XuOMdqEew73eCNmV7jgWxayBayuEOLELR1CBM=
github.com/smartcontractkit/chainlink/deployment v0.0.0-20241205144849-138d4c51ad0d h1:nxjwsxk3qZOEFuoYJN9a61xBvwkFZLNMv24Z9QjYlnE=
github.com/smartcontractkit/chainlink/deployment v0.0.0-20241205144849-138d4c51ad0d/go.mod h1:jz4/Ko0lL7fhiuiBsVB53MNX2lEWK0VRfsxz232XRGA=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20241205144849-138d4c51ad0d h1:Sl3/QHSA91H9nSaAVo9biKRpqIfWTKcGAKbCoWO6jr8=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20241205144849-138d4c51ad0d/go.mod h1:iRiKHT+MfvjrIuJuO/cGuWBxULctmlz2DFD3KDDU7oI=
github.com/smartcontractkit/chainlink/v2 v2.14.0-mercury-20240807.0.20241205144849-138d4c51ad0d h1:YSHlmOAuZvaBmjhENcLuyaDRy6+CcVqvsy6bF30Ovxw=
github.com/smartcontractkit/chainlink/v2 v2.14.0-mercury-20240807.0.20241205144849-138d4c51ad0d/go.mod h1:r2inuDnmNVZzUD/AsqgBs9exi9mIYwg8BgAnT+PyXU4=
github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs=
github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7/go.mod h1:FX7/bVdoep147QQhsOPkYsPEXhGZjeYx6lBSaSXtZOA=
github.com/smartcontractkit/libocr v0.0.0-20241007185508-adbe57025f12 h1:NzZGjaqez21I3DU7objl3xExTH4fxYvzTqar8DC6360=
Expand Down
51 changes: 24 additions & 27 deletions pkg/solana/txm/pendingtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ type PendingTxContext interface {
New(msg pendingTx, sig solana.Signature, cancel context.CancelFunc) error
// AddSignature adds a new signature for an existing transaction ID
AddSignature(id string, sig solana.Signature) error
// Remove removes transaction and related signatures from storage if not in finalized or errored state
Remove(sig solana.Signature) (string, error)
// ListAll returns all of the signatures being tracked for all transactions not yet finalized or errored
ListAll() []solana.Signature
// Remove removes transaction, context and related signatures from storage associated to given tx id if not in finalized or errored state
Remove(id string) (string, error)
// ListAllSigs returns all of the signatures being tracked for all transactions not yet finalized or errored
ListAllSigs() []solana.Signature
// ListAllExpiredBroadcastedTxs returns all the txes that are in broadcasted state and have expired for given block height compared against their lastValidBlockHeight.
// Passing maxUint64 as currHeight will return all broadcasted txes.
ListAllExpiredBroadcastedTxs(currHeight uint64) ([]pendingTx, int, int)
ListAllExpiredBroadcastedTxs(currBlockHeight uint64) []pendingTx
// Expired returns whether or not confirmation timeout amount of time has passed since creation
Expired(sig solana.Signature, confirmationTimeout time.Duration) bool
// OnProcessed marks transactions as Processed
Expand Down Expand Up @@ -166,13 +166,8 @@ func (c *pendingTxContext) AddSignature(id string, sig solana.Signature) error {

// returns the id if removed (otherwise returns empty string)
// removes transactions from any state except finalized and errored
func (c *pendingTxContext) Remove(sig solana.Signature) (id string, err error) {
err = c.withReadLock(func() error {
// check if already removed
id, sigExists := c.sigToID[sig]
if !sigExists {
return ErrSigDoesNotExist
}
func (c *pendingTxContext) Remove(id string) (string, error) {
err := c.withReadLock(func() error {
_, broadcastedIDExists := c.broadcastedProcessedTxs[id]
_, confirmedIDExists := c.confirmedTxs[id]
// transcation does not exist in tx maps
Expand All @@ -187,10 +182,6 @@ func (c *pendingTxContext) Remove(sig solana.Signature) (id string, err error) {

// upgrade to write lock if sig does not exist
return c.withWriteLock(func() (string, error) {
id, sigExists := c.sigToID[sig]
if !sigExists {
return id, ErrSigDoesNotExist
}
var tx pendingTx
if tempTx, exists := c.broadcastedProcessedTxs[id]; exists {
tx = tempTx
Expand All @@ -215,24 +206,30 @@ func (c *pendingTxContext) Remove(sig solana.Signature) (id string, err error) {
})
}

func (c *pendingTxContext) ListAll() []solana.Signature {
func (c *pendingTxContext) ListAllSigs() []solana.Signature {
c.lock.RLock()
defer c.lock.RUnlock()
return maps.Keys(c.sigToID)
}

// ListAllExpiredBroadcastedTxs returns all the txes that are in broadcasted state and have expired for given slot height compared against their lastValidBlockHeight.
func (c *pendingTxContext) ListAllTxsIDs() []string {
c.lock.RLock()
defer c.lock.RUnlock()
return maps.Values(c.sigToID)
}

// ListAllExpiredBroadcastedTxs returns all the txes that are in broadcasted state and have expired for given block height compared against their lastValidBlockHeight.
// Passing maxUint64 as currHeight will return all broadcasted txes.
func (c *pendingTxContext) ListAllExpiredBroadcastedTxs(currHeight uint64) ([]pendingTx, int, int) {
func (c *pendingTxContext) ListAllExpiredBroadcastedTxs(currBlockHeight uint64) []pendingTx {
c.lock.RLock()
defer c.lock.RUnlock()
broadcastedTxes := make([]pendingTx, 0, len(c.broadcastedProcessedTxs)) // worst case, all of them
for _, tx := range c.broadcastedProcessedTxs {
if tx.state == Broadcasted && tx.lastValidBlockHeight < currHeight {
if tx.state == Broadcasted && tx.lastValidBlockHeight < currBlockHeight {
broadcastedTxes = append(broadcastedTxes, tx)
}
}
return broadcastedTxes, len(broadcastedTxes), len(c.broadcastedProcessedTxs)
return broadcastedTxes
}

// Expired returns if the timeout for trying to confirm a signature has been reached
Expand Down Expand Up @@ -613,18 +610,18 @@ func (c *pendingTxContextWithProm) OnConfirmed(sig solana.Signature) (string, er
return id, err
}

func (c *pendingTxContextWithProm) Remove(sig solana.Signature) (string, error) {
return c.pendingTx.Remove(sig)
func (c *pendingTxContextWithProm) Remove(id string) (string, error) {
return c.pendingTx.Remove(id)
}

func (c *pendingTxContextWithProm) ListAll() []solana.Signature {
sigs := c.pendingTx.ListAll()
func (c *pendingTxContextWithProm) ListAllSigs() []solana.Signature {
sigs := c.pendingTx.ListAllSigs()
promSolTxmPendingTxs.WithLabelValues(c.chainID).Set(float64(len(sigs)))
return sigs
}

func (c *pendingTxContextWithProm) ListAllExpiredBroadcastedTxs(currHeight uint64) ([]pendingTx, int, int) {
return c.pendingTx.ListAllExpiredBroadcastedTxs(currHeight)
func (c *pendingTxContextWithProm) ListAllExpiredBroadcastedTxs(currBlockHeight uint64) []pendingTx {
return c.pendingTx.ListAllExpiredBroadcastedTxs(currBlockHeight)
}

func (c *pendingTxContextWithProm) Expired(sig solana.Signature, lifespan time.Duration) bool {
Expand Down
Loading

0 comments on commit 55ade8c

Please sign in to comment.