Skip to content

Commit

Permalink
Merge branch 'develop' into golangci-lint-2023-10-11
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 authored Oct 16, 2023
2 parents cb0b0c5 + 4519370 commit aa97b97
Show file tree
Hide file tree
Showing 82 changed files with 1,876 additions and 1,910 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- name: Check for changed files
id: changedfiles
uses: umani/changed-files@0239328a3a6268aad16af7c3e4efc78e32d6c0f0 # Version 4.0.1
uses: umani/changed-files@d7f842d11479940a6036e3aacc6d35523e6ba978 # Version 4.1.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
pattern: '^docs/CHANGELOG.*$'
Expand Down
23 changes: 18 additions & 5 deletions .github/workflows/on-demand-vrfv2plus-load-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ jobs:
id-token: write
contents: read
env:
LOKI_URL: ${{ secrets.LOKI_URL }}
LOKI_TOKEN: ${{ secrets.LOKI_TOKEN }}
SELECTED_NETWORKS: ${{ inputs.network }}
VRFV2PLUS_TEST_DURATION: ${{ inputs.testDuration }}
VRFV2PLUS_RATE_LIMIT_UNIT_DURATION: 1m
Expand Down Expand Up @@ -104,8 +106,19 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Run E2E soak tests
run: |
cd integration-tests/load/vrfv2plus
go test -v -timeout 8h -run TestVRFV2PlusLoad/vrfv2plus_soak_test
- name: Run Tests
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/run-tests@eccde1970eca69f079d3efb3409938a72ade8497 # v2.2.13
with:
test_command_to_run: cd ./integration-tests && go test -v -count=1 -timeout 6h -run TestVRFV2PlusLoad/vrfv2plus_soak_test ./load/vrfv2plus
test_download_vendor_packages_command: cd ./integration-tests && go mod download
cl_repo: ${{ inputs.chainlinkImage }}
cl_image_tag: ${{ inputs.chainlinkVersion }}
aws_registries: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}
artifacts_name: vrf-test-logs
artifacts_location: ./integration-tests/load/logs/
token: ${{ secrets.GITHUB_TOKEN }}
go_mod_path: ./integration-tests/go.mod
should_cleanup: false
QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }}
QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
QA_KUBECONFIG: ${{ secrets.QA_KUBECONFIG }}
2 changes: 1 addition & 1 deletion .github/workflows/readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- name: Check for changed files
id: changedfiles
uses: umani/changed-files@0239328a3a6268aad16af7c3e4efc78e32d6c0f0 # Version 4.0.1
uses: umani/changed-files@d7f842d11479940a6036e3aacc6d35523e6ba978 # Version 4.1.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
pattern: '^(?!.*node_modules).*README\.md$'
Expand Down
29 changes: 16 additions & 13 deletions common/txmgr/txmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package txmgr
import (
"context"
"database/sql"
"errors"
"fmt"
"math/big"
"sync"
"time"

"github.com/google/uuid"
"github.com/pkg/errors"
pkgerrors "github.com/pkg/errors"

feetypes "github.com/smartcontractkit/chainlink/v2/common/fee/types"
txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types"
Expand Down Expand Up @@ -164,14 +165,14 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Start(ctx
return b.StartOnce("Txm", func() error {
var ms services.MultiStart
if err := ms.Start(ctx, b.broadcaster); err != nil {
return errors.Wrap(err, "Txm: Broadcaster failed to start")
return pkgerrors.Wrap(err, "Txm: Broadcaster failed to start")
}
if err := ms.Start(ctx, b.confirmer); err != nil {
return errors.Wrap(err, "Txm: Confirmer failed to start")
return pkgerrors.Wrap(err, "Txm: Confirmer failed to start")
}

if err := ms.Start(ctx, b.txAttemptBuilder); err != nil {
return errors.Wrap(err, "Txm: Estimator failed to start")
return pkgerrors.Wrap(err, "Txm: Estimator failed to start")
}

b.wg.Add(1)
Expand All @@ -188,7 +189,7 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Start(ctx

if b.fwdMgr != nil {
if err := ms.Start(ctx, b.fwdMgr); err != nil {
return errors.Wrap(err, "Txm: ForwarderManager failed to start")
return pkgerrors.Wrap(err, "Txm: ForwarderManager failed to start")
}
}

Expand Down Expand Up @@ -222,7 +223,7 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) abandon(ad
ctx, cancel := utils.StopChan(b.chStop).NewCtx()
defer cancel()
err = b.txStore.Abandon(ctx, b.chainID, addr)
return errors.Wrapf(err, "abandon failed to update txes for key %s", addr.String())
return pkgerrors.Wrapf(err, "abandon failed to update txes for key %s", addr.String())
}

func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Close() (merr error) {
Expand All @@ -239,13 +240,15 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Close() (m
}
if b.fwdMgr != nil {
if err := b.fwdMgr.Close(); err != nil {
return errors.Wrap(err, "Txm: failed to stop ForwarderManager")
merr = errors.Join(merr, pkgerrors.Wrap(err, "Txm: failed to stop ForwarderManager"))
}
}

b.wg.Wait()

b.txAttemptBuilder.Close()
if err := b.txAttemptBuilder.Close(); err != nil {
merr = errors.Join(merr, pkgerrors.Wrap(err, "Txm: failed to close TxAttemptBuilder"))
}

return nil
})
Expand Down Expand Up @@ -440,7 +443,7 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) CreateTran
var existingTx *txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]
existingTx, err = b.txStore.FindTxWithIdempotencyKey(ctx, *txRequest.IdempotencyKey, b.chainID)
if err != nil && !errors.Is(err, sql.ErrNoRows) {
return tx, errors.Wrap(err, "Failed to search for transaction with IdempotencyKey")
return tx, pkgerrors.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)
Expand Down Expand Up @@ -472,7 +475,7 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) CreateTran

err = b.txStore.CheckTxQueueCapacity(ctx, txRequest.FromAddress, b.txConfig.MaxQueued(), b.chainID)
if err != nil {
return tx, errors.Wrap(err, "Txm#CreateTransaction")
return tx, pkgerrors.Wrap(err, "Txm#CreateTransaction")
}

tx, err = b.txStore.CreateTransaction(ctx, txRequest, b.chainID)
Expand All @@ -482,15 +485,15 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) CreateTran
// Calls forwarderMgr to get a proper forwarder for a given EOA.
func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) GetForwarderForEOA(eoa ADDR) (forwarder ADDR, err error) {
if !b.txConfig.ForwardersEnabled() {
return forwarder, errors.Errorf("Forwarding is not enabled, to enable set Transactions.ForwardersEnabled =true")
return forwarder, pkgerrors.Errorf("Forwarding is not enabled, to enable set Transactions.ForwardersEnabled =true")
}
forwarder, err = b.fwdMgr.ForwarderFor(eoa)
return
}

func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) checkEnabled(addr ADDR) error {
err := b.keyStore.CheckEnabled(addr, b.chainID)
return errors.Wrapf(err, "cannot send transaction from %s on chain ID %s", addr, b.chainID.String())
return pkgerrors.Wrapf(err, "cannot send transaction from %s on chain ID %s", addr, b.chainID.String())
}

// SendNativeToken creates a transaction that transfers the given value of native tokens
Expand All @@ -507,7 +510,7 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) SendNative
Strategy: NewSendEveryStrategy(),
}
etx, err = b.txStore.CreateTransaction(ctx, txRequest, chainID)
return etx, errors.Wrap(err, "SendNativeToken failed to insert tx")
return etx, pkgerrors.Wrap(err, "SendNativeToken failed to insert tx")
}

type NullTxManager[
Expand Down
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"prepublishOnly": "pnpm compile && ./scripts/prepublish_generate_abi_folder",
"publish-beta": "pnpm publish --tag beta",
"publish-prod": "npm dist-tag add @chainlink/[email protected] latest",
"solhint": "solhint --max-warnings 502 \"./src/v0.8/**/*.sol\""
"solhint": "solhint --max-warnings 493 \"./src/v0.8/**/*.sol\""
},
"files": [
"src/v0.8",
Expand Down
3 changes: 0 additions & 3 deletions contracts/scripts/native_solc_compile_all_feeds
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,3 @@ compileContract () {
compileContract interfaces/AggregatorV2V3Interface.sol
compileContract Chainlink.sol
compileContract ChainlinkClient.sol

# Feeds
compileContract dev/DerivedPriceFeed.sol
87 changes: 0 additions & 87 deletions contracts/src/v0.8/dev/DerivedPriceFeed.sol

This file was deleted.

5 changes: 2 additions & 3 deletions contracts/src/v0.8/vrf/BatchBlockhashStore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract BatchBlockhashStore {
for (uint256 i = 0; i < blockNumbers.length; i++) {
// skip the block if it's not storeable, the caller will have to check
// after the transaction is mined to see if the blockhash was truly stored.
if (!storeableBlock(blockNumbers[i])) {
if (!_storeableBlock(blockNumbers[i])) {
continue;
}
BHS.store(blockNumbers[i]);
Expand Down Expand Up @@ -73,8 +73,7 @@ contract BatchBlockhashStore {
* using the blockhash() instruction.
* @param blockNumber the block number to check if it's storeable with blockhash()
*/
// solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore
function storeableBlock(uint256 blockNumber) private view returns (bool) {
function _storeableBlock(uint256 blockNumber) private view returns (bool) {
// handle edge case on simulated chains which possibly have < 256 blocks total.
return
ChainSpecificUtil._getBlockNumber() <= 256 ? true : blockNumber >= (ChainSpecificUtil._getBlockNumber() - 256);
Expand Down
12 changes: 5 additions & 7 deletions contracts/src/v0.8/vrf/BatchVRFCoordinatorV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ contract BatchVRFCoordinatorV2 {
try COORDINATOR.fulfillRandomWords(proofs[i], rcs[i]) returns (uint96 /* payment */) {
continue;
} catch Error(string memory reason) {
uint256 requestId = getRequestIdFromProof(proofs[i]);
uint256 requestId = _getRequestIdFromProof(proofs[i]);
emit ErrorReturned(requestId, reason);
} catch (bytes memory lowLevelData) {
uint256 requestId = getRequestIdFromProof(proofs[i]);
uint256 requestId = _getRequestIdFromProof(proofs[i]);
emit RawErrorReturned(requestId, lowLevelData);
}
}
Expand All @@ -45,18 +45,16 @@ contract BatchVRFCoordinatorV2 {
* @notice Returns the proving key hash associated with this public key.
* @param publicKey the key to return the hash of.
*/
// solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore
function hashOfKey(uint256[2] memory publicKey) internal pure returns (bytes32) {
function _hashOfKey(uint256[2] memory publicKey) internal pure returns (bytes32) {
return keccak256(abi.encode(publicKey));
}

/**
* @notice Returns the request ID of the request associated with the given proof.
* @param proof the VRF proof provided by the VRF oracle.
*/
// solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore
function getRequestIdFromProof(VRFTypes.Proof memory proof) internal pure returns (uint256) {
bytes32 keyHash = hashOfKey(proof.pk);
function _getRequestIdFromProof(VRFTypes.Proof memory proof) internal pure returns (uint256) {
bytes32 keyHash = _hashOfKey(proof.pk);
return uint256(keccak256(abi.encode(keyHash, proof.seed)));
}
}
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/v0.8/vrf/KeepersVRFConsumer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {VRFConsumerBaseV2} from "./VRFConsumerBaseV2.sol";
import {VRFCoordinatorV2Interface} from "./interfaces/VRFCoordinatorV2Interface.sol";

// solhint-disable chainlink-solidity/prefix-immutable-variables-with-i
// solhint-disable chainlink-solidity/prefix-internal-functions-with-underscore

/**
* @title KeepersVRFConsumer
Expand Down Expand Up @@ -76,7 +75,7 @@ contract KeepersVRFConsumer is KeeperCompatibleInterface, VRFConsumerBaseV2 {
if ((block.timestamp - s_lastTimeStamp) > UPKEEP_INTERVAL) {
s_lastTimeStamp = block.timestamp;

requestRandomWords();
_requestRandomWords();
}
}

Expand All @@ -85,6 +84,7 @@ contract KeepersVRFConsumer is KeeperCompatibleInterface, VRFConsumerBaseV2 {
* @param requestId the VRF V2 request ID, provided at request time.
* @param randomWords the randomness provided by Chainlink VRF.
*/
// solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore
function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal override {
// Check that the request exists. If not, revert.
RequestRecord memory record = s_requests[requestId];
Expand All @@ -99,7 +99,7 @@ contract KeepersVRFConsumer is KeeperCompatibleInterface, VRFConsumerBaseV2 {
/**
* @notice Requests random words from Chainlink VRF.
*/
function requestRandomWords() internal {
function _requestRandomWords() internal {
uint256 requestId = COORDINATOR.requestRandomWords(
KEY_HASH,
SUBSCRIPTION_ID,
Expand Down
Loading

0 comments on commit aa97b97

Please sign in to comment.