Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into TT-414-e2e-docker-…
Browse files Browse the repository at this point in the history
…conversion
  • Loading branch information
tateexon committed Sep 27, 2023
2 parents 8e497bf + f684afc commit 453048e
Show file tree
Hide file tree
Showing 58 changed files with 775 additions and 350 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ jobs:
- run: echo "this exists so we don't have to run anything else if the build is skipped"
if: needs.changes.outputs.src == 'false' || needs.solana-test-image-exists.outputs.exists == 'true'

solana-smoke-tests:
solana-smoke-tests-matrix:
if: ${{ !contains(join(github.event.pull_request.labels.*.name, ' '), 'skip-smoke-tests') }}
environment: integration
permissions:
Expand All @@ -674,7 +674,7 @@ jobs:
strategy:
matrix:
image:
- name: ""
- name: (base)
tag-suffix: ""
- name: (plugins)
tag-suffix: -plugins
Expand Down Expand Up @@ -732,6 +732,26 @@ jobs:
path: /tmp/gotest.log
retention-days: 7
continue-on-error: true

### Used to check the required checks box when the matrix completes
solana-smoke-tests:
if: always()
runs-on: ubuntu-latest
name: Solana Smoke Tests
needs: [solana-smoke-tests-matrix]
steps:
- name: Check smoke test matrix status
if: needs.solana-smoke-tests-matrix.result != 'success'
run: exit 1
- name: Collect Metrics
if: always()
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@d2c2b7bdc9012651230b2608a1bcb0c48538b6ec
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: Solana Smoke Tests
continue-on-error: true
### End Solana Section

### Start Live Testnet Section
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.0
2.6.0
22 changes: 14 additions & 8 deletions contracts/src/v0.8/ChainSpecificUtil.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ library ChainSpecificUtil {

function getBlockhash(uint64 blockNumber) internal view returns (bytes32) {
uint256 chainid = block.chainid;
if (
chainid == ARB_MAINNET_CHAIN_ID ||
chainid == ARB_GOERLI_TESTNET_CHAIN_ID ||
chainid == ARB_SEPOLIA_TESTNET_CHAIN_ID
) {
if (isArbitrumChainId(chainid)) {
if ((getBlockNumber() - blockNumber) > 256 || blockNumber >= getBlockNumber()) {
return "";
}
Expand All @@ -33,15 +29,15 @@ library ChainSpecificUtil {

function getBlockNumber() internal view returns (uint256) {
uint256 chainid = block.chainid;
if (chainid == ARB_MAINNET_CHAIN_ID || chainid == ARB_GOERLI_TESTNET_CHAIN_ID) {
if (isArbitrumChainId(chainid)) {
return ARBSYS.arbBlockNumber();
}
return block.number;
}

function getCurrentTxL1GasFees() internal view returns (uint256) {
uint256 chainid = block.chainid;
if (chainid == ARB_MAINNET_CHAIN_ID || chainid == ARB_GOERLI_TESTNET_CHAIN_ID) {
if (isArbitrumChainId(chainid)) {
return ARBGAS.getCurrentTxL1GasFees();
}
return 0;
Expand All @@ -53,12 +49,22 @@ library ChainSpecificUtil {
*/
function getL1CalldataGasCost(uint256 calldataSizeBytes) internal view returns (uint256) {
uint256 chainid = block.chainid;
if (chainid == ARB_MAINNET_CHAIN_ID || chainid == ARB_GOERLI_TESTNET_CHAIN_ID) {
if (isArbitrumChainId(chainid)) {
(, uint256 l1PricePerByte, , , , ) = ARBGAS.getPricesInWei();
// see https://developer.arbitrum.io/devs-how-tos/how-to-estimate-gas#where-do-we-get-all-this-information-from
// for the justification behind the 140 number.
return l1PricePerByte * (calldataSizeBytes + 140);
}
return 0;
}

/**
* @notice Return true if and only if the provided chain ID is an Arbitrum chain ID.
*/
function isArbitrumChainId(uint256 chainId) internal pure returns (bool) {
return
chainId == ARB_MAINNET_CHAIN_ID ||
chainId == ARB_GOERLI_TESTNET_CHAIN_ID ||
chainId == ARB_SEPOLIA_TESTNET_CHAIN_ID;
}
}
117 changes: 64 additions & 53 deletions contracts/src/v0.8/dev/vrf/VRFV2PlusWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,35 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume
error LinkAlreadySet();
error FailedToTransferLink();

LinkTokenInterface public s_link;
AggregatorV3Interface public s_linkNativeFeed;
ExtendedVRFCoordinatorV2PlusInterface public immutable COORDINATOR;
/* Storage Slot 1: BEGIN */
// s_keyHash is the key hash to use when requesting randomness. Fees are paid based on current gas
// fees, so this should be set to the highest gas lane on the network.
bytes32 s_keyHash;
/* Storage Slot 1: END */

/* Storage Slot 2: BEGIN */
uint256 public immutable SUBSCRIPTION_ID;
/// @dev this is the size of a VRF v2 fulfillment's calldata abi-encoded in bytes.
/// @dev proofSize = 13 words = 13 * 256 = 3328 bits
/// @dev commitmentSize = 5 words = 5 * 256 = 1280 bits
/// @dev dataSize = proofSize + commitmentSize = 4608 bits
/// @dev selector = 32 bits
/// @dev total data size = 4608 bits + 32 bits = 4640 bits = 580 bytes
uint32 public s_fulfillmentTxSizeBytes = 580;
/* Storage Slot 2: END */

/* Storage Slot 3: BEGIN */
// 5k is plenty for an EXTCODESIZE call (2600) + warm CALL (100)
// and some arithmetic operations.
uint256 private constant GAS_FOR_CALL_EXACT_CHECK = 5_000;
/* Storage Slot 3: END */

/* Storage Slot 4: BEGIN */
// lastRequestId is the request ID of the most recent VRF V2 request made by this wrapper. This
// should only be relied on within the same transaction the request was made.
uint256 public override lastRequestId;
/* Storage Slot 4: END */

// Configuration fetched from VRFCoordinatorV2

// s_configured tracks whether this contract has been configured. If not configured, randomness
// requests cannot be made.
bool public s_configured;

// s_disabled disables the contract when true. When disabled, new VRF requests cannot be made
// but existing ones can still be fulfilled.
bool public s_disabled;

/* Storage Slot 5: BEGIN */
// s_fallbackWeiPerUnitLink is the backup LINK exchange rate used when the LINK/NATIVE feed is
// stale.
int256 private s_fallbackWeiPerUnitLink;
/* Storage Slot 5: END */

/* Storage Slot 6: BEGIN */
// s_stalenessSeconds is the number of seconds before we consider the feed price to be stale and
// fallback to fallbackWeiPerUnitLink.
uint32 private s_stalenessSeconds;
Expand All @@ -67,49 +62,76 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume
// charges.
uint32 private s_fulfillmentFlatFeeNativePPM;

// Other configuration
LinkTokenInterface public s_link;
/* Storage Slot 6: END */

/* Storage Slot 7: BEGIN */
// s_wrapperGasOverhead reflects the gas overhead of the wrapper's fulfillRandomWords
// function. The cost for this gas is passed to the user.
uint32 private s_wrapperGasOverhead;

// Configuration fetched from VRFCoordinatorV2

/// @dev this is the size of a VRF v2 fulfillment's calldata abi-encoded in bytes.
/// @dev proofSize = 13 words = 13 * 256 = 3328 bits
/// @dev commitmentSize = 5 words = 5 * 256 = 1280 bits
/// @dev dataSize = proofSize + commitmentSize = 4608 bits
/// @dev selector = 32 bits
/// @dev total data size = 4608 bits + 32 bits = 4640 bits = 580 bytes
uint32 public s_fulfillmentTxSizeBytes = 580;

// s_coordinatorGasOverhead reflects the gas overhead of the coordinator's fulfillRandomWords
// function. The cost for this gas is billed to the subscription, and must therefor be included
// in the pricing for wrapped requests. This includes the gas costs of proof verification and
// payment calculation in the coordinator.
uint32 private s_coordinatorGasOverhead;

AggregatorV3Interface public s_linkNativeFeed;
/* Storage Slot 7: END */

/* Storage Slot 8: BEGIN */
// s_configured tracks whether this contract has been configured. If not configured, randomness
// requests cannot be made.
bool public s_configured;

// s_disabled disables the contract when true. When disabled, new VRF requests cannot be made
// but existing ones can still be fulfilled.
bool public s_disabled;

// s_wrapperPremiumPercentage is the premium ratio in percentage. For example, a value of 0
// indicates no premium. A value of 15 indicates a 15 percent premium.
uint8 private s_wrapperPremiumPercentage;

// s_keyHash is the key hash to use when requesting randomness. Fees are paid based on current gas
// fees, so this should be set to the highest gas lane on the network.
bytes32 s_keyHash;

// s_maxNumWords is the max number of words that can be requested in a single wrapped VRF request.
uint8 s_maxNumWords;
/* Storage Slot 8: END */

struct Callback {
address callbackAddress;
uint32 callbackGasLimit;
uint256 requestGasPrice;
// Reducing requestGasPrice from uint256 to uint64 slots Callback struct
// into a single word, thus saving an entire SSTORE and leading to 21K
// gas cost saving. 18 ETH would be the max gas price we can process.
// GasPrice is unlikely to be more than 14 ETH on most chains
uint64 requestGasPrice;
}
/* Storage Slot 9: BEGIN */
mapping(uint256 => Callback) /* requestID */ /* callback */ public s_callbacks;

/* Storage Slot 9: END */

constructor(address _link, address _linkNativeFeed, address _coordinator) VRFConsumerBaseV2Plus(_coordinator) {
if (_link != address(0)) {
s_link = LinkTokenInterface(_link);
}
if (_linkNativeFeed != address(0)) {
s_linkNativeFeed = AggregatorV3Interface(_linkNativeFeed);
}
COORDINATOR = ExtendedVRFCoordinatorV2PlusInterface(_coordinator);

// Create this wrapper's subscription and add itself as a consumer.
uint256 subId = ExtendedVRFCoordinatorV2PlusInterface(_coordinator).createSubscription();
uint256 subId = s_vrfCoordinator.createSubscription();
SUBSCRIPTION_ID = subId;
ExtendedVRFCoordinatorV2PlusInterface(_coordinator).addConsumer(subId, address(this));
s_vrfCoordinator.addConsumer(subId, address(this));
}

/**
Expand Down Expand Up @@ -161,7 +183,11 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume
uint32 _coordinatorGasOverhead,
uint8 _wrapperPremiumPercentage,
bytes32 _keyHash,
uint8 _maxNumWords
uint8 _maxNumWords,
uint32 stalenessSeconds,
int256 fallbackWeiPerUnitLink,
uint32 fulfillmentFlatFeeLinkPPM,
uint32 fulfillmentFlatFeeNativePPM
) external onlyOwner {
s_wrapperGasOverhead = _wrapperGasOverhead;
s_coordinatorGasOverhead = _coordinatorGasOverhead;
Expand All @@ -171,9 +197,10 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume
s_configured = true;

// Get other configuration from coordinator
(, , s_stalenessSeconds, ) = COORDINATOR.s_config();
s_fallbackWeiPerUnitLink = COORDINATOR.s_fallbackWeiPerUnitLink();
(s_fulfillmentFlatFeeLinkPPM, s_fulfillmentFlatFeeNativePPM) = COORDINATOR.s_feeConfig();
s_stalenessSeconds = stalenessSeconds;
s_fallbackWeiPerUnitLink = fallbackWeiPerUnitLink;
s_fulfillmentFlatFeeLinkPPM = fulfillmentFlatFeeLinkPPM;
s_fulfillmentFlatFeeNativePPM = fulfillmentFlatFeeNativePPM;
}

/**
Expand Down Expand Up @@ -348,11 +375,11 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume
numWords: numWords,
extraArgs: "" // empty extraArgs defaults to link payment
});
uint256 requestId = COORDINATOR.requestRandomWords(req);
uint256 requestId = s_vrfCoordinator.requestRandomWords(req);
s_callbacks[requestId] = Callback({
callbackAddress: _sender,
callbackGasLimit: callbackGasLimit,
requestGasPrice: tx.gasprice
requestGasPrice: uint64(tx.gasprice)
});
lastRequestId = requestId;
}
Expand All @@ -374,11 +401,11 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume
numWords: _numWords,
extraArgs: VRFV2PlusClient._argsToBytes(VRFV2PlusClient.ExtraArgsV1({nativePayment: true}))
});
requestId = COORDINATOR.requestRandomWords(req);
requestId = s_vrfCoordinator.requestRandomWords(req);
s_callbacks[requestId] = Callback({
callbackAddress: msg.sender,
callbackGasLimit: _callbackGasLimit,
requestGasPrice: tx.gasprice
requestGasPrice: uint64(tx.gasprice)
});

return requestId;
Expand Down Expand Up @@ -502,19 +529,3 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume
_;
}
}

interface ExtendedVRFCoordinatorV2PlusInterface is IVRFCoordinatorV2Plus {
function s_config()
external
view
returns (
uint16 minimumRequestConfirmations,
uint32 maxGasLimit,
uint32 stalenessSeconds,
uint32 gasAfterPaymentCalculation
);

function s_fallbackWeiPerUnitLink() external view returns (int256);

function s_feeConfig() external view returns (uint32 fulfillmentFlatFeeLinkPPM, uint32 fulfillmentFlatFeeNativePPM);
}
6 changes: 5 additions & 1 deletion contracts/test/v0.8/foundry/vrf/VRFV2Wrapper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ contract VRFV2PlusWrapperTest is BaseTest {
coordinatorGasOverhead, // coordinator gas overhead
0, // premium percentage
vrfKeyHash, // keyHash
10 // max number of words
10, // max number of words,
1, // stalenessSeconds
50000000000000000, // fallbackWeiPerUnitLink
0, // fulfillmentFlatFeeLinkPPM
0 // fulfillmentFlatFeeNativePPM
);
(
,
Expand Down
6 changes: 1 addition & 5 deletions core/chains/evm/config/toml/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,5 @@ func (n *Node) SetFrom(f *Node) {
}

func ChainIDInt64(cid relay.ChainID) (int64, error) {
i, err := strconv.Atoi(cid)
if err != nil {
return int64(0), err
}
return int64(i), nil
return strconv.ParseInt(cid, 10, 64)
}
2 changes: 1 addition & 1 deletion core/chains/evm/logpoller/log_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ func (lp *logPoller) LogsWithSigs(start, end int64, eventSigs []common.Hash, add
}

func (lp *logPoller) LogsCreatedAfter(eventSig common.Hash, address common.Address, after time.Time, confs int, qopts ...pg.QOpt) ([]Log, error) {
return lp.orm.SelectLogsCreatedAfter(eventSig[:], address, after, confs, qopts...)
return lp.orm.SelectLogsCreatedAfter(address, eventSig, after, confs, qopts...)
}

// IndexedLogs finds all the logs that have a topic value in topicValues at index topicIndex.
Expand Down
Loading

0 comments on commit 453048e

Please sign in to comment.