Skip to content

Commit

Permalink
Merge branch 'develop' into feature/VRF-567-mercury-registry
Browse files Browse the repository at this point in the history
  • Loading branch information
vreff authored Sep 5, 2023
2 parents 84562e0 + 0e2d15a commit 1347e2b
Show file tree
Hide file tree
Showing 63 changed files with 967 additions and 562 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ jobs:
pull-requests: write
id-token: write
contents: read
needs: [build-chainlink, build-test-image]
needs: [build-chainlink]
env:
SELECTED_NETWORKS: ${{ matrix.testnet }}
CHAINLINK_COMMIT_SHA: ${{ github.sha }}
Expand All @@ -812,11 +812,11 @@ jobs:
EVM_KEYS: ${{ secrets.QA_EVM_KEYS }}
TEST_EVM_KEYS: ${{ secrets.QA_EVM_KEYS }}

TEST_OPTIMISM_GOERLI_URLS: ${{ secrets.QA_OPTIMISM_GOERLI_URLS }}
TEST_OPTIMISM_GOERLI_HTTP_URLS: ${{ secrets.QA_OPTIMISM_GOERLI_HTTP_URLS }}
OPTIMISM_GOERLI_URLS: ${{ secrets.QA_OPTIMISM_GOERLI_URLS }}
OPTIMISM_GOERLI_HTTP_URLS: ${{ secrets.QA_OPTIMISM_GOERLI_HTTP_URLS }}

TEST_ARBITRUM_GOERLI_URLS: ${{ secrets.QA_ARBITRUM_GOERLI_URLS }}
TEST_ARBITRUM_GOERLI_HTTP_URLS: ${{ secrets.QA_ARBITRUM_GOERLI_HTTP_URLS }}
ARBITRUM_GOERLI_URLS: ${{ secrets.QA_ARBITRUM_GOERLI_URLS }}
ARBITRUM_GOERLI_HTTP_URLS: ${{ secrets.QA_ARBITRUM_GOERLI_HTTP_URLS }}
strategy:
fail-fast: false
matrix:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/solidity-foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
- 'contracts/src/v0.8/**/*'
- '.github/workflows/solidity-foundry.yml'
- 'contracts/foundry.toml'
- 'contracts/gas-snapshots/*.gas-snapshot'
- '.gitmodules'
- 'contracts/foundry-lib'
tests:
strategy:
Expand Down
15 changes: 15 additions & 0 deletions common/txmgr/txmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package txmgr

import (
"context"
"database/sql"
"fmt"
"math/big"
"sync"
Expand Down Expand Up @@ -435,6 +436,20 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Trigger(ad

// CreateTransaction inserts a new transaction
func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) CreateTransaction(txRequest txmgrtypes.TxRequest[ADDR, TX_HASH], qs ...pg.QOpt) (tx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], err error) {
// Check for existing Tx with IdempotencyKey. If found, return the Tx and do nothing
// Skipping CreateTransaction to avoid double send
if txRequest.IdempotencyKey != nil {
var existingTx *txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]
existingTx, err = b.txStore.FindTxWithIdempotencyKey(*txRequest.IdempotencyKey, b.chainID)
if err != nil && !errors.Is(err, sql.ErrNoRows) {
return tx, errors.Wrap(err, "Failed to search for transaction with IdempotencyKey")
}
if existingTx != nil {
b.logger.Infow("Found a Tx with IdempotencyKey. Returning existing Tx without creating a new one.", "IdempotencyKey", *txRequest.IdempotencyKey)
return *existingTx, nil
}
}

if err = b.checkEnabled(txRequest.FromAddress); err != nil {
return tx, err
}
Expand Down
26 changes: 26 additions & 0 deletions common/txmgr/types/mocks/tx_store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions common/txmgr/types/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ func (s TxAttemptState) String() (str string) {
}

type TxRequest[ADDR types.Hashable, TX_HASH types.Hashable] struct {
// IdempotencyKey is a globally unique ID set by the caller, to prevent accidental creation of duplicated Txs during retries or crash recovery.
// If this field is set, the TXM will first search existing Txs with this field.
// If found, it will return the existing Tx, without creating a new one. TXM will not validate or ensure that existing Tx is same as the incoming TxRequest.
// If not found, TXM will create a new Tx.
// If IdempotencyKey is set to null, TXM will always create a new Tx.
// Since IdempotencyKey has to be globally unique, consider prepending the service or component's name it is being used by
// Such as {service}-{ID}. E.g vrf-12345
IdempotencyKey *string
FromAddress ADDR
ToAddress ADDR
EncodedPayload []byte
Expand Down Expand Up @@ -178,6 +186,7 @@ type Tx[
FEE feetypes.Fee,
] struct {
ID int64
IdempotencyKey *string
Sequence *SEQ
FromAddress ADDR
ToAddress ADDR
Expand Down
3 changes: 3 additions & 0 deletions common/txmgr/types/tx_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ type TransactionStore[
FindTxAttemptsConfirmedMissingReceipt(chainID CHAIN_ID) (attempts []TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], err error)
FindTxAttemptsRequiringReceiptFetch(chainID CHAIN_ID) (attempts []TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], err error)
FindTxAttemptsRequiringResend(olderThan time.Time, maxInFlightTransactions uint32, chainID CHAIN_ID, address ADDR) (attempts []TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], err error)
// Search for Tx using the idempotencyKey and chainID
FindTxWithIdempotencyKey(idempotencyKey string, chainID CHAIN_ID) (tx *Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], err error)
// Search for Tx using the fromAddress and sequence
FindTxWithSequence(fromAddress ADDR, seq SEQ) (etx *Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], err error)
FindNextUnstartedTransactionFromAddress(etx *Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], fromAddress ADDR, chainID CHAIN_ID, qopts ...pg.QOpt) error
FindTransactionsConfirmedInBlockRange(highBlockNumber, lowBlockNumber int64, chainID CHAIN_ID) (etxs []*Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], err error)
Expand Down
13 changes: 11 additions & 2 deletions contracts/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ pnpmdep: ## Install solidity contract dependencies through pnpm
abigen: ## Build & install abigen.
../tools/bin/build_abigen

.PHONY: mockery
mockery: $(mockery) ## Install mockery.
go install github.com/vektra/mockery/[email protected]

.PHONY: foundry-refresh
foundry-refresh:
foundryup
git submodule deinit -f .
git submodule update --init --recursive

# To generate gethwrappers for a specific product, either set the `FOUNDRY_PROFILE`
# env var or call the target with `FOUNDRY_PROFILE=product`
Expand All @@ -43,15 +52,15 @@ abigen: ## Build & install abigen.
# make call example
# make FOUNDRY_PROFILE=llo-feeds wrappers
.PHONY: wrappers
wrappers: pnpmdep abigen ## Recompiles solidity contracts and their go wrappers.
wrappers: pnpmdep mockery abigen ## Recompiles solidity contracts and their go wrappers.
./scripts/native_solc_compile_all_$(FOUNDRY_PROFILE)
go generate ../core/gethwrappers/$(FOUNDRY_PROFILE)

# This call generates all gethwrappers for all products. It does so based on the
# assumption that native_solc_compile_all contains sub-calls to each product, and
# go_generate does the same.
.PHONY: wrappers-all
wrappers-all: pnpmdep abigen ## Recompiles solidity contracts and their go wrappers.
wrappers-all: pnpmdep mockery abigen ## Recompiles solidity contracts and their go wrappers.
# go_generate contains a call to compile all contracts before generating wrappers
go generate ../core/gethwrappers/go_generate.go

Expand Down
6 changes: 3 additions & 3 deletions contracts/gas-snapshots/automation-dev.gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AutomationForwarder_forward:testBasicSuccess() (gas: 87630)
AutomationForwarder_forward:testNotAuthorizedReverts() (gas: 21681)
AutomationForwarder_forward:testNotAuthorizedReverts() (gas: 25427)
AutomationForwarder_forward:testWrongFunctionSelectorSuccess() (gas: 17958)
AutomationForwarder_updateRegistry:testBasicSuccess() (gas: 14577)
AutomationForwarder_updateRegistry:testNotFromRegistryNotAuthorizedReverts() (gas: 13893)
MercuryRegistryTest:testMercuryRegistry() (gas: 951908)
MercuryRegistryTest:testMercuryRegistryBatchUpkeep() (gas: 1728944)
MercuryRegistryTest:testMercuryRegistryBatchUpkeep() (gas: 1728944)
AutomationForwarder_updateRegistry:testNotFromRegistryNotAuthorizedReverts() (gas: 17665)
8 changes: 4 additions & 4 deletions contracts/gas-snapshots/automation.gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
HeartbeatRequester_getAggregatorRequestHeartbeat:testBasicSuccess() (gas: 75412)
HeartbeatRequester_getAggregatorRequestHeartbeat:testHeartbeatNotPermittedReverts() (gas: 21730)
HeartbeatRequester_permitHeartbeat:testBasicDeployerSuccess() (gas: 48280)
HeartbeatRequester_permitHeartbeat:testBasicSuccess() (gas: 45856)
HeartbeatRequester_permitHeartbeat:testOnlyCallableByOwnerReverts() (gas: 13796)
HeartbeatRequester_permitHeartbeat:testBasicDeployerSuccess() (gas: 48229)
HeartbeatRequester_permitHeartbeat:testBasicSuccess() (gas: 45844)
HeartbeatRequester_permitHeartbeat:testOnlyCallableByOwnerReverts() (gas: 17584)
HeartbeatRequester_removeHeartbeat:testBasicSuccess() (gas: 30192)
HeartbeatRequester_removeHeartbeat:testOnlyCallableByOwnerReverts() (gas: 11629)
HeartbeatRequester_removeHeartbeat:testOnlyCallableByOwnerReverts() (gas: 15417)
HeartbeatRequester_removeHeartbeat:testRemoveNoPermitsSuccess() (gas: 15660)
16 changes: 8 additions & 8 deletions contracts/gas-snapshots/functions.gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
FunctionsOracle_sendRequest:testEmptyRequestDataReverts() (gas: 13430)
FunctionsOracle_sendRequest:testEmptyRequestDataReverts() (gas: 13452)
FunctionsOracle_setDONPublicKey:testEmptyPublicKeyReverts() (gas: 10974)
FunctionsOracle_setDONPublicKey:testOnlyOwnerReverts() (gas: 11255)
FunctionsOracle_setDONPublicKey:testSetDONPublicKeySuccess() (gas: 126453)
FunctionsOracle_setDONPublicKey:testSetDONPublicKey_gas() (gas: 97558)
FunctionsOracle_setDONPublicKey:testSetDONPublicKey_gas() (gas: 97580)
FunctionsOracle_setRegistry:testEmptyPublicKeyReverts() (gas: 10635)
FunctionsOracle_setRegistry:testOnlyOwnerReverts() (gas: 10927)
FunctionsOracle_setRegistry:testSetRegistrySuccess() (gas: 35791)
FunctionsOracle_setRegistry:testSetRegistry_gas() (gas: 31987)
FunctionsOracle_typeAndVersion:testTypeAndVersionSuccess() (gas: 6905)
FunctionsRouter_Pause:test_Pause_RevertIfNotOwner() (gas: 13293)
FunctionsRouter_Pause:test_Pause_Success() (gas: 20205)
FunctionsRouter_Unpause:test_Unpause_RevertIfNotOwner() (gas: 13338)
FunctionsRouter_Unpause:test_Unpause_Success() (gas: 77279)
FunctionsSubscriptions_createSubscription:test_CreateSubscription_RevertIfNotAllowedSender() (gas: 26347)
FunctionsSubscriptions_createSubscription:test_CreateSubscription_RevertIfPaused() (gas: 15699)
FunctionsRouter_Pause:test_Pause_RevertIfNotOwner() (gas: 13315)
FunctionsRouter_Pause:test_Pause_Success() (gas: 20254)
FunctionsRouter_Unpause:test_Unpause_RevertIfNotOwner() (gas: 13294)
FunctionsRouter_Unpause:test_Unpause_Success() (gas: 77334)
FunctionsSubscriptions_createSubscription:test_CreateSubscription_RevertIfNotAllowedSender() (gas: 26368)
FunctionsSubscriptions_createSubscription:test_CreateSubscription_RevertIfPaused() (gas: 15714)
FunctionsSubscriptions_createSubscription:test_CreateSubscription_Success() (gas: 152436)
Loading

0 comments on commit 1347e2b

Please sign in to comment.