Skip to content

Commit

Permalink
Merge branch 'develop' into AUTO-9027
Browse files Browse the repository at this point in the history
  • Loading branch information
shileiwill authored Feb 20, 2024
2 parents f8128de + 6039298 commit 8b94464
Show file tree
Hide file tree
Showing 12 changed files with 142 additions and 36 deletions.
26 changes: 11 additions & 15 deletions contracts/src/v0.8/vrf/dev/VRFCoordinatorV2_5.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus {
uint256 outputSeed,
uint256 indexed subId,
uint96 payment,
bool nativePayment,
bool success,
bool onlyPremium
);
Expand Down Expand Up @@ -457,28 +458,23 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus {
}
}

uint256 requestId = output.requestId;
delete s_requestCommitments[requestId];
bool success = _deliverRandomness(requestId, rc, randomWords);
delete s_requestCommitments[output.requestId];
bool success = _deliverRandomness(output.requestId, rc, randomWords);

// Increment the req count for the subscription.
uint256 subId = rc.subId;
++s_subscriptions[subId].reqCount;
++s_subscriptions[rc.subId].reqCount;

// stack too deep error
{
bool nativePayment = uint8(rc.extraArgs[rc.extraArgs.length - 1]) == 1;
bool nativePayment = uint8(rc.extraArgs[rc.extraArgs.length - 1]) == 1;

// We want to charge users exactly for how much gas they use in their callback.
// The gasAfterPaymentCalculation is meant to cover these additional operations where we
// decrement the subscription balance and increment the oracles withdrawable balance.
payment = _calculatePaymentAmount(startGas, gasPrice, nativePayment, onlyPremium);
// We want to charge users exactly for how much gas they use in their callback.
// The gasAfterPaymentCalculation is meant to cover these additional operations where we
// decrement the subscription balance and increment the oracles withdrawable balance.
payment = _calculatePaymentAmount(startGas, gasPrice, nativePayment, onlyPremium);

_chargePayment(payment, nativePayment, subId);
}
_chargePayment(payment, nativePayment, rc.subId);

// Include payment in the event for tracking costs.
emit RandomWordsFulfilled(requestId, randomness, subId, payment, success, onlyPremium);
emit RandomWordsFulfilled(output.requestId, randomness, rc.subId, payment, nativePayment, success, onlyPremium);

return payment;
}
Expand Down
8 changes: 4 additions & 4 deletions contracts/test/v0.8/foundry/vrf/VRFV2Plus.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ contract VRFV2Plus is BaseTest {
VmSafe.Log[] memory entries = vm.getRecordedLogs();
assertEq(entries[0].topics[1], bytes32(uint256(requestId)));
assertEq(entries[0].topics[2], bytes32(uint256(subId)));
(uint256 loggedOutputSeed, , bool loggedSuccess) = abi.decode(entries[0].data, (uint256, uint256, bool));
(uint256 loggedOutputSeed, , , bool loggedSuccess) = abi.decode(entries[0].data, (uint256, uint256, bool, bool));
assertEq(loggedOutputSeed, outputSeed);
assertEq(loggedSuccess, true);

Expand Down Expand Up @@ -374,7 +374,7 @@ contract VRFV2Plus is BaseTest {
VmSafe.Log[] memory entries = vm.getRecordedLogs();
assertEq(entries[0].topics[1], bytes32(uint256(requestId)));
assertEq(entries[0].topics[2], bytes32(uint256(subId)));
(uint256 loggedOutputSeed, , bool loggedSuccess) = abi.decode(entries[0].data, (uint256, uint256, bool));
(uint256 loggedOutputSeed, , , bool loggedSuccess) = abi.decode(entries[0].data, (uint256, uint256, bool, bool));
assertEq(loggedOutputSeed, outputSeed);
assertEq(loggedSuccess, true);

Expand Down Expand Up @@ -624,7 +624,7 @@ contract VRFV2Plus is BaseTest {
VmSafe.Log[] memory entries = vm.getRecordedLogs();
assertEq(entries[0].topics[1], bytes32(uint256(requestId)));
assertEq(entries[0].topics[2], bytes32(uint256(subId)));
(uint256 loggedOutputSeed, , bool loggedSuccess) = abi.decode(entries[0].data, (uint256, uint256, bool));
(uint256 loggedOutputSeed, , , bool loggedSuccess) = abi.decode(entries[0].data, (uint256, uint256, bool, bool));
assertEq(loggedOutputSeed, outputSeed);
assertEq(loggedSuccess, true);

Expand Down Expand Up @@ -671,7 +671,7 @@ contract VRFV2Plus is BaseTest {
VmSafe.Log[] memory entries = vm.getRecordedLogs();
assertEq(entries[0].topics[1], bytes32(uint256(requestId)));
assertEq(entries[0].topics[2], bytes32(uint256(subId)));
(uint256 loggedOutputSeed, , bool loggedSuccess) = abi.decode(entries[0].data, (uint256, uint256, bool));
(uint256 loggedOutputSeed, , , bool loggedSuccess) = abi.decode(entries[0].data, (uint256, uint256, bool, bool));
assertEq(loggedOutputSeed, outputSeed);
assertEq(loggedSuccess, true);

Expand Down
11 changes: 11 additions & 0 deletions core/chains/evm/config/toml/defaults/Gnosis_Chiado.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ChainID = '10200'
# Gnoisis Finality is approx 8 minutes @ 12 blocks per minute, so 96 blocks
FinalityDepth = 100
ChainType = 'xdai'
LogPollInterval = '5s'

[GasEstimator]
EIP1559DynamicFees = true
PriceMax = '500 gwei'
# 15s delay since feeds update every minute in volatile situations
BumpThreshold = 3

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ vrf_consumer_v2_upgradeable_example: ../../contracts/solc/v0.8.6/VRFConsumerV2Up
vrf_coordinator_mock: ../../contracts/solc/v0.8.6/VRFCoordinatorMock/VRFCoordinatorMock.abi ../../contracts/solc/v0.8.6/VRFCoordinatorMock/VRFCoordinatorMock.bin 5c495cf8df1f46d8736b9150cdf174cce358cb8352f60f0d5bb9581e23920501
vrf_coordinator_test_v2: ../../contracts/solc/v0.8.6/VRFCoordinatorTestV2/VRFCoordinatorTestV2.abi ../../contracts/solc/v0.8.6/VRFCoordinatorTestV2/VRFCoordinatorTestV2.bin eaefd785c38bac67fb11a7fc2737ab2da68c988ca170e7db8ff235c80893e01c
vrf_coordinator_v2: ../../contracts/solc/v0.8.6/VRFCoordinatorV2/VRFCoordinatorV2.abi ../../contracts/solc/v0.8.6/VRFCoordinatorV2/VRFCoordinatorV2.bin 295f35ce282060317dfd01f45959f5a2b05ba26913e422fbd4fb6bf90b107006
vrf_coordinator_v2_5: ../../contracts/solc/v0.8.6/VRFCoordinatorV2_5/VRFCoordinatorV2_5.abi ../../contracts/solc/v0.8.6/VRFCoordinatorV2_5/VRFCoordinatorV2_5.bin aa5875f42461b4f128483ee0fd8b1f1b72a395ee857e6153197e92bcb21d149f
vrf_coordinator_v2_5: ../../contracts/solc/v0.8.6/VRFCoordinatorV2_5/VRFCoordinatorV2_5.abi ../../contracts/solc/v0.8.6/VRFCoordinatorV2_5/VRFCoordinatorV2_5.bin 3230631b7920236588ccd4ad8795e52ede6222cac7a70fa477c7240da0955a5e
vrf_coordinator_v2_plus_v2_example: ../../contracts/solc/v0.8.6/VRFCoordinatorV2Plus_V2Example/VRFCoordinatorV2Plus_V2Example.abi ../../contracts/solc/v0.8.6/VRFCoordinatorV2Plus_V2Example/VRFCoordinatorV2Plus_V2Example.bin 4a5b86701983b1b65f0a8dfa116b3f6d75f8f706fa274004b57bdf5992e4cec3
vrf_coordinator_v2plus_interface: ../../contracts/solc/v0.8.6/IVRFCoordinatorV2PlusInternal/IVRFCoordinatorV2PlusInternal.abi ../../contracts/solc/v0.8.6/IVRFCoordinatorV2PlusInternal/IVRFCoordinatorV2PlusInternal.bin 86b8e23aab28c5b98e3d2384dc4f702b093e382dc985c88101278e6e4bf6f7b8
vrf_external_sub_owner_example: ../../contracts/solc/v0.8.6/VRFExternalSubOwnerExample/VRFExternalSubOwnerExample.abi ../../contracts/solc/v0.8.6/VRFExternalSubOwnerExample/VRFExternalSubOwnerExample.bin 14f888eb313930b50233a6f01ea31eba0206b7f41a41f6311670da8bb8a26963
Expand Down
4 changes: 4 additions & 0 deletions core/services/vrf/v2/coordinator_v2x_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,10 @@ func (rwf *v2_5RandomWordsFulfilled) Raw() types.Log {
return rwf.event.Raw
}

func (rwf *v2_5RandomWordsFulfilled) NativePayment() bool {
return rwf.event.NativePayment
}

var (
_ SubscriptionCreatedIterator = (*v2SubscriptionCreatedIterator)(nil)
_ SubscriptionCreatedIterator = (*v2_5SubscriptionCreatedIterator)(nil)
Expand Down
83 changes: 82 additions & 1 deletion docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2564,7 +2564,7 @@ GasLimit = 5400000

</p></details>

<details><summary>xDai Mainnet (100)</summary><p>
<details><summary>Gnosis Mainnet (100)</summary><p>

```toml
AutoCreateKey = true
Expand Down Expand Up @@ -4181,6 +4181,87 @@ GasLimit = 6500000

</p></details>

<details><summary>Gnosis Chiado (10200)</summary><p>

```toml
AutoCreateKey = true
BlockBackfillDepth = 10
BlockBackfillSkip = false
ChainType = 'xdai'
FinalityDepth = 100
FinalityTagEnabled = false
LogBackfillBatchSize = 1000
LogPollInterval = '5s'
LogKeepBlocksDepth = 100000
MinIncomingConfirmations = 3
MinContractPayment = '0.00001 link'
NonceAutoSync = true
NoNewHeadsThreshold = '3m0s'
RPCDefaultBatchSize = 250
RPCBlockQueryDelay = 1

[Transactions]
ForwardersEnabled = false
MaxInFlight = 16
MaxQueued = 250
ReaperInterval = '1h0m0s'
ReaperThreshold = '168h0m0s'
ResendAfterThreshold = '1m0s'

[BalanceMonitor]
Enabled = true

[GasEstimator]
Mode = 'BlockHistory'
PriceDefault = '20 gwei'
PriceMax = '500 gwei'
PriceMin = '1 gwei'
LimitDefault = 500000
LimitMax = 500000
LimitMultiplier = '1'
LimitTransfer = 21000
BumpMin = '5 gwei'
BumpPercent = 20
BumpThreshold = 3
EIP1559DynamicFees = true
FeeCapDefault = '100 gwei'
TipCapDefault = '1 wei'
TipCapMin = '1 wei'

[GasEstimator.BlockHistory]
BatchSize = 25
BlockHistorySize = 8
CheckInclusionBlocks = 12
CheckInclusionPercentile = 90
TransactionPercentile = 60

[HeadTracker]
HistoryDepth = 100
MaxBufferSize = 3
SamplingInterval = '1s'

[NodePool]
PollFailureThreshold = 5
PollInterval = '10s'
SelectionMode = 'HighestHead'
SyncThreshold = 5
LeaseDuration = '0s'

[OCR]
ContractConfirmations = 4
ContractTransmitterTransmitTimeout = '10s'
DatabaseTimeout = '10s'
DeltaCOverride = '168h0m0s'
DeltaCJitterOverride = '1h0m0s'
ObservationGracePeriod = '1s'

[OCR2]
[OCR2.Automation]
GasLimit = 5400000
```

</p></details>

<details><summary>Arbitrum Mainnet (42161)</summary><p>

```toml
Expand Down
6 changes: 6 additions & 0 deletions integration-tests/contracts/contract_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ func NewContractDeployer(bcClient blockchain.EVMClient, logger zerolog.Logger) (
return &KromaContractDeployer{NewEthereumContractDeployer(clientImpl, logger)}, nil
case *blockchain.WeMixClient:
return &WeMixContractDeployer{NewEthereumContractDeployer(clientImpl, logger)}, nil
case *blockchain.GnosisClient:
return &GnosisContractDeployer{NewEthereumContractDeployer(clientImpl, logger)}, nil
}
return nil, errors.New("unknown blockchain client implementation for contract deployer, register blockchain client in NewContractDeployer")
}
Expand Down Expand Up @@ -268,6 +270,10 @@ type WeMixContractDeployer struct {
*EthereumContractDeployer
}

type GnosisContractDeployer struct {
*EthereumContractDeployer
}

// NewEthereumContractDeployer returns an instantiated instance of the ETH contract deployer
func NewEthereumContractDeployer(ethClient blockchain.EVMClient, logger zerolog.Logger) *EthereumContractDeployer {
return &EthereumContractDeployer{
Expand Down
7 changes: 7 additions & 0 deletions integration-tests/contracts/contract_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ func NewContractLoader(bcClient blockchain.EVMClient, logger zerolog.Logger) (Co
return &FantomContractLoader{NewEthereumContractLoader(clientImpl, logger)}, nil
case *blockchain.BSCClient:
return &BSCContractLoader{NewEthereumContractLoader(clientImpl, logger)}, nil
case *blockchain.GnosisClient:
return &GnosisContractLoader{NewEthereumContractLoader(clientImpl, logger)}, nil
}
return nil, errors.New("unknown blockchain client implementation for contract Loader, register blockchain client in NewContractLoader")
}
Expand Down Expand Up @@ -154,6 +156,11 @@ type BSCContractLoader struct {
*EthereumContractLoader
}

// GnosisContractLoader wraps for Gnosis
type GnosisContractLoader struct {
*EthereumContractLoader
}

// NewEthereumContractLoader returns an instantiated instance of the ETH contract Loader
func NewEthereumContractLoader(ethClient blockchain.EVMClient, logger zerolog.Logger) *EthereumContractLoader {
return &EthereumContractLoader{
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/slack-go/slack v0.12.2
github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240118014648-1ab6a88c9429
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240219152510-85226a0fbdc1
github.com/smartcontractkit/chainlink-testing-framework v1.23.2
github.com/smartcontractkit/chainlink-testing-framework v1.23.5
github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868
github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000
github.com/smartcontractkit/libocr v0.0.0-20240215150045-fe2ba71b2f0a
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1473,8 +1473,8 @@ github.com/segmentio/ksuid v1.0.4/go.mod h1:/XUiZBD3kVx5SmUOl55voK5yeAbBNNIed+2O
github.com/sercand/kuberesolver/v5 v5.1.1 h1:CYH+d67G0sGBj7q5wLK61yzqJJ8gLLC8aeprPTHb6yY=
github.com/sercand/kuberesolver/v5 v5.1.1/go.mod h1:Fs1KbKhVRnB2aDWN12NjKCB+RgYMWZJ294T3BtmVCpQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/sethvargo/go-retry v0.2.4 h1:T+jHEQy/zKJf5s95UkguisicE0zuF9y7+/vgz08Ocec=
github.com/sethvargo/go-retry v0.2.4/go.mod h1:1afjQuvh7s4gflMObvjLPaWgluLLyhA1wmVZ6KLpICw=
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
Expand Down Expand Up @@ -1517,8 +1517,8 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240213161921-c4d342b761b
github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240213161921-c4d342b761b0/go.mod h1:JiykN+8W5TA4UD2ClrzQCVvcH3NcyLEVv7RwY0busrw=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240213121419-1272736c2ac0 h1:7m9PVtccb8/pvKTXMaGuyceFno1icRyC2SFH7KG7+70=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240213121419-1272736c2ac0/go.mod h1:SZ899lZYQ0maUulWbZg+SWqabHQ1wTbyk3jT8wJfyo8=
github.com/smartcontractkit/chainlink-testing-framework v1.23.2 h1:haXPd9Pg++Zs5/QIZnhFd9RElmz/d0+4nNeletUg9ZM=
github.com/smartcontractkit/chainlink-testing-framework v1.23.2/go.mod h1:StIOdxvwd8AMO6xuBtmD6FQfJXktEn/mJJEr7728BTc=
github.com/smartcontractkit/chainlink-testing-framework v1.23.5 h1:bymN/mr4Tbx3DQ7EMB/z81+pCLhJkiYgxJDgAeTo9/w=
github.com/smartcontractkit/chainlink-testing-framework v1.23.5/go.mod h1:lGaqSnCB36n49fZNdTGXMrxhPu9w5+2n3c9V1Fqz1hM=
github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 h1:FFdvEzlYwcuVHkdZ8YnZR/XomeMGbz5E2F2HZI3I3w8=
github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868/go.mod h1:Kn1Hape05UzFZ7bOUnm3GVsHzP0TNrVmpfXYNHdqGGs=
github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16 h1:TFe+FvzxClblt6qRfqEhUfa4kFQx5UobuoFGO2W4mMo=
Expand Down

0 comments on commit 8b94464

Please sign in to comment.