Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/base sepolia #421

Merged
merged 18 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contracts/apps/UsingWitnet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ abstract contract UsingWitnet
// Number of nodes in the Witnet blockchain that will take part in solving the data request:
committeeSize: 10,
// Fee in $nanoWIT paid to every node in the Witnet blockchain involved in solving the data request:
witnessingFeeNanoWit: 20 * 10 ** 8 // defaults to 0.2 $WIT
witnessingFeeNanoWit: 2 * 10 ** 8 // defaults to 0.2 $WIT
});

__witnetBaseFeeOverheadPercentage = 10; // defaults to 10%
__witnetBaseFeeOverheadPercentage = 33; // defaults to 33%
}

/// @dev Provides a convenient way for client contracts extending this to block the execution of the main logic of the
Expand Down
9 changes: 6 additions & 3 deletions contracts/apps/WitnetRandomnessV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ contract WitnetRandomnessV2
(100 + __witnetBaseFeeOverheadPercentage)
* __witnet.estimateBaseFee(
_evmGasPrice,
witnetRadHash
uint16(34)
)
) / 100;
}
Expand Down Expand Up @@ -526,10 +526,13 @@ contract WitnetRandomnessV2
);
}

bytes32 private constant _STORAGE_SLOT =
// keccak256("io.witnet.apps.randomness.v20")
0x643778935c57df947f6944f6a5242a3e91445f6337f4b2ec670c8642153b614f;

function __storage() internal pure returns (Storage storage _ptr) {
bytes32 _slothash = keccak256(bytes("io.witnet.apps.randomness.v20"));
assembly {
_ptr.slot := _slothash
_ptr.slot := _STORAGE_SLOT
}
}
}
24 changes: 20 additions & 4 deletions contracts/core/customs/WitnetOracleTrustableOvm2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,28 @@ contract WitnetOracleTrustableOvm2

OVM_GasPriceOracle immutable internal __gasPriceOracleL1;

function _getCurrentL1Fee() virtual internal view returns (uint256) {
function _getCurrentL1Fee(uint16 _resultMaxSize) virtual internal view returns (uint256) {
return __gasPriceOracleL1.getL1Fee(
hex"c8f5cdd500000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000225820ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
abi.encodePacked(
hex"06eb2c42000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000ffffffffff00000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000ff",
_resultMaxBuffer(_resultMaxSize)
)
);
}

function _resultMaxBuffer(uint16 _resultMaxSize) private pure returns (bytes memory) {
unchecked {
uint256[] memory _buffer = new uint256[](_resultMaxSize / 32);
for (uint _ix = 0; _ix < _buffer.length; _ix ++) {
_buffer[_ix] = type(uint256).max;
}
return abi.encodePacked(
_buffer,
uint256((1 << (_resultMaxSize % 32)) - 1)
);
}
}

// ================================================================================================================
// --- Overrides 'IWitnetOracle' ----------------------------------------------------------------------------

Expand All @@ -71,7 +87,7 @@ contract WitnetOracleTrustableOvm2
virtual override
returns (uint256)
{
return _getCurrentL1Fee() + WitnetOracleTrustableDefault.estimateBaseFee(_gasPrice, _resultMaxSize);
return _getCurrentL1Fee(_resultMaxSize) + WitnetOracleTrustableDefault.estimateBaseFee(_gasPrice, _resultMaxSize);
}

/// @notice Estimate the minimum reward required for posting a data request with a callback.
Expand All @@ -82,7 +98,7 @@ contract WitnetOracleTrustableOvm2
virtual override
returns (uint256)
{
return _getCurrentL1Fee() + WitnetOracleTrustableDefault.estimateBaseFeeWithCallback(_gasPrice, _callbackGasLimit);
return _getCurrentL1Fee(32) + WitnetOracleTrustableDefault.estimateBaseFeeWithCallback(_gasPrice, _callbackGasLimit);
}

// ================================================================================================================
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/defaults/WitnetOracleTrustableDefault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ contract WitnetOracleTrustableDefault
return _gasPrice * (
__reportResultGasBase
+ __sstoreFromZeroGas * (
5 + (_resultMaxSize == 0 ? 0 : _resultMaxSize - 1) / 32
4 + (_resultMaxSize == 0 ? 0 : _resultMaxSize - 1) / 32
)
);
}
Expand Down
25 changes: 25 additions & 0 deletions contracts/core/defaults/WitnetPriceFeedsDefault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,23 @@ contract WitnetPriceFeedsDefault
// ================================================================================================================
// --- Implements 'IFeeds' ----------------------------------------------------------------------------------------

/// @notice Returns unique hash determined by the combination of data sources being used
/// @notice on non-routed price feeds, and dependencies of routed price feeds.
/// @dev Ergo, `footprint()` changes if any data source is modified, or the dependecy tree
/// @dev on any routed price feed is altered.
function footprint()
virtual override
public view
returns (bytes4 _footprint)
{
if (__storage().ids.length > 0) {
_footprint = _footprintOf(__storage().ids[0]);
for (uint _ix = 1; _ix < __storage().ids.length; _ix ++) {
_footprint ^= _footprintOf(__storage().ids[_ix]);
}
}
}

function hash(string memory caption)
virtual override
public pure
Expand Down Expand Up @@ -657,6 +674,14 @@ contract WitnetPriceFeedsDefault
}
}

function _footprintOf(bytes4 _id4) virtual internal view returns (bytes4) {
if (__records_(_id4).radHash != bytes32(0)) {
return bytes4(keccak256(abi.encode(_id4, __records_(_id4).radHash)));
} else {
return bytes4(keccak256(abi.encode(_id4, __records_(_id4).solverDepsFlag)));
}
}

function _lastValidQueryId(bytes4 feedId)
virtual internal view
returns (uint256)
Expand Down
1 change: 1 addition & 0 deletions contracts/interfaces/IFeeds.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pragma solidity >=0.8.0 <0.9.0;

interface IFeeds {
function footprint() external view returns (bytes4);
function hash(string calldata caption) external pure returns (bytes4);
function lookupCaption(bytes4) external view returns (string memory);
function supportedFeeds() external view returns (bytes4[] memory, string[] memory, bytes32[] memory);
Expand Down
36 changes: 25 additions & 11 deletions migrations/addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,39 @@
"WitnetRequestBytecodes": "0x000B61Fe075F545fd37767f40391658275900000",
"WitnetRequestFactory": "0x000DB36997AF1F02209A6F995883B9B699900000"
},
"base:sepolia": {
"WitnetProxy": "0xaC3E870BF8D13Dc39f76936b6AF8279eF5a9211F",
"WitnetErrorsLib": "0xa57B9dd8420631248c3DFB535f4FC9f7E2f02B4B",
"WitnetEncodingLib": "0x268631E002eE8c23F4C124AfBb6fE5DBbaa6d58c",
"WitnetOracleDataLib": "0x561A6c8F9C9D6e7EbAEcd4963A8f27Ae13568676",
"WitnetPriceFeedsLib": "0x579b4aD5E67E5B491a33A033A02A70769D7AF837",
"WitnetOracleTrustableOvm2": "0x9F02CD498b47B928c5a12FdC7cEa36246d27a638",
"WitnetPriceFeedsDefault": "0xcB61b81a775E56e9Ec8884d2E13352d668294141",
"WitnetRandomnessV2": "0xC0FFEE98AD1434aCbDB894BbB752e138c1006fAB",
"WitnetRequestBytecodesDefault": "0x730a88594d8287Ec898b2B7fE592aB155bE71590",
"WitnetRequestFactoryDefault": "0xe1CDE456D3eC92640711625E01170A6800773b91"
},
"ethereum:sepolia": {
"WitnetProxy": "",
"WitnetErrorsLib": "",
"WitnetEncodingLib": "",
"WitnetPriceFeedsLib": "",
"WitnetOracleTrustableDefault": "",
"WitnetPriceFeedsDefault": "",
"WitnetRequestBytecodesDefault": "",
"WitnetRequestFactoryDefault": ""
"WitnetProxy": "0x21ac85A6c320E6fC89774A98732eAE733032651C",
"WitnetErrorsLib": "0xa57B9dd8420631248c3DFB535f4FC9f7E2f02B4B",
"WitnetEncodingLib": "0x268631E002eE8c23F4C124AfBb6fE5DBbaa6d58c",
"WitnetOracleDataLib": "0x561A6c8F9C9D6e7EbAEcd4963A8f27Ae13568676",
"WitnetPriceFeedsLib": "0x579b4aD5E67E5B491a33A033A02A70769D7AF837",
"WitnetOracleTrustableDefault": "0xE790FdaEa7f1f4C4Bbd74B3493Cf94E79b24396a",
"WitnetPriceFeedsDefault": "0x327470b70d0cCF47cB89a1f3475DE23Ac2437c9e",
"WitnetRandomnessV2": "0xC0FFEE98AD1434aCbDB894BbB752e138c1006fAB",
"WitnetRequestBytecodesDefault": "0x34e6465f23aE086e5701A6ca8547aF7c29e0283C",
"WitnetRequestFactoryDefault": "0x1869A7137dF26397999AA6DB90c7D6D029d13908"
},
"optimism:sepolia": {
"WitnetProxy": "0x58Bd0091748d0438f379bbf7D8BfF3a624CEbc3F",
"WitnetErrorsLib": "0x4f2F381Ed2020095F1a1B5a0BDe5AB30da916BC9",
"WitnetEncodingLib": "0xf321bcD29CFc6134c9Bf42F759f428F3A6010919",
"WitnetPriceFeedsLib": "0x85aa4A0fDa112c47d4216448EE4D49Afd072675e",
"WitnetOracleDataLib": "0x25d57Cf8a047B14172Ba2a929C1441E1A77c3f9D",
"WitnetOracleTrustableOvm2": "0xeE04B260D4aBE8ABb2BB174D33b2C8731d518DdE",
"WitnetPriceFeedsDefault": "0xa07f16b1312d68bcDed1AD1164F644b309F96d06",
"WitnetRandomnessV2": "0xc0ffee84FD3B533C3fA408c993F59828395319A1",
"WitnetOracleTrustableOvm2": "0xc1C158e77A91da158a1A2D0c2A154c68a8C7c0d2",
"WitnetPriceFeedsDefault": "0xA936f7F4909494Ea1F7D898C2759b2324912153d",
"WitnetRandomnessV2": "0xC0FFEE98AD1434aCbDB894BbB752e138c1006fAB",
"WitnetRequestBytecodesDefault": "0x2D8BCBC4F8c97CC227e770d95d19914324baBF2A",
"WitnetRequestFactoryDefault": "0x3D551165020a4014A8d5b9E4b73D2b3Dbe401546"
},
Expand Down
20 changes: 14 additions & 6 deletions migrations/constructorArgs.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
{
"base:sepolia": {
"WitnetRequestBytecodesDefault": "0000000000000000000000000000000000000000000000000000000000000001322e302e31312d38333330636665000000000000000000000000000000000000",
"WitnetRequestFactoryDefault": "00000000000000000000000077703ae126b971c9946d562f41dd47071da00777000000000000000000000000000b61fe075f545fd37767f403916582759000000000000000000000000000000000000000000000000000000000000000000001322e302e31312d38333330636665000000000000000000000000000000000000",
"WitnetOracleTrustableOvm2": "000000000000000000000000000db36997af1f02209a6f995883b9b699900000000000000000000000000000000b61fe075f545fd37767f403916582759000000000000000000000000000000000000000000000000000000000000000000001322e302e31322d61653734633030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e3aa000000000000000000000000000000000000000000000000000000000000fef90000000000000000000000000000000000000000000000000000000000010faa0000000000000000000000000000000000000000000000000000000000004e20",
"WitnetPriceFeedsDefault": "00000000000000000000000077703ae126b971c9946d562f41dd47071da007770000000000000000000000000000000000000000000000000000000000000001322e302e31312d38333330636665000000000000000000000000000000000000",
"WitnetRandomnessV2": "00000000000000000000000077703ae126b971c9946d562f41dd47071da00777000000000000000000000000f121b71715e71dded592f1125a06d4ed06f0694d"
},
"ethereum:sepolia": {
"WitnetRequestBytecodesDefault": "",
"WitnetRequestFactoryDefault": "",
"WitnetOracleTrustableDefault": "",
"WitnetPriceFeedsDefault": ""
"WitnetRequestBytecodesDefault": "0000000000000000000000000000000000000000000000000000000000000001322e302e31322d35616362653333000000000000000000000000000000000000",
"WitnetRequestFactoryDefault": "00000000000000000000000077703ae126b971c9946d562f41dd47071da00777000000000000000000000000000b61fe075f545fd37767f403916582759000000000000000000000000000000000000000000000000000000000000000000001322e302e31322d35616362653333000000000000000000000000000000000000",
"WitnetOracleTrustableDefault": "000000000000000000000000000db36997af1f02209a6f995883b9b699900000000000000000000000000000000b61fe075f545fd37767f403916582759000000000000000000000000000000000000000000000000000000000000000000001322e302e31322d35616362653333000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e3aa000000000000000000000000000000000000000000000000000000000000fef90000000000000000000000000000000000000000000000000000000000010faa0000000000000000000000000000000000000000000000000000000000004e20",
"WitnetPriceFeedsDefault": "00000000000000000000000077703ae126b971c9946d562f41dd47071da007770000000000000000000000000000000000000000000000000000000000000001322e302e31322d32636532363233000000000000000000000000000000000000",
"WitnetRandomnessV2": "00000000000000000000000077703ae126b971c9946d562f41dd47071da00777000000000000000000000000f121b71715e71dded592f1125a06d4ed06f0694d"
},
"optimism:sepolia": {
"WitnetRandomnessV2": "00000000000000000000000077703ae126b971c9946d562f41dd47071da00777000000000000000000000000f121b71715e71dded592f1125a06d4ed06f0694d",
"WitnetRequestBytecodesDefault": "0000000000000000000000000000000000000000000000000000000000000001322e302e382d3465626434366300000000000000000000000000000000000000",
"WitnetRequestFactoryDefault": "00000000000000000000000077703ae126b971c9946d562f41dd47071da00777000000000000000000000000000b61fe075f545fd37767f403916582759000000000000000000000000000000000000000000000000000000000000000000001322e302e382d3465626434366300000000000000000000000000000000000000",
"WitnetOracleTrustableOvm2": "000000000000000000000000000db36997af1f02209a6f995883b9b699900000000000000000000000000000000b61fe075f545fd37767f403916582759000000000000000000000000000000000000000000000000000000000000000000001322e302e382d3465626434366300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e3aa000000000000000000000000000000000000000000000000000000000000fef90000000000000000000000000000000000000000000000000000000000010faa0000000000000000000000000000000000000000000000000000000000004e20",
"WitnetPriceFeedsDefault": "00000000000000000000000077703ae126b971c9946d562f41dd47071da007770000000000000000000000000000000000000000000000000000000000000001322e302e382d3465626434366300000000000000000000000000000000000000"
"WitnetOracleTrustableOvm2": "000000000000000000000000000db36997af1f02209a6f995883b9b699900000000000000000000000000000000b61fe075f545fd37767f403916582759000000000000000000000000000000000000000000000000000000000000000000001322e302e31322d35616362653333000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e3aa000000000000000000000000000000000000000000000000000000000000fef90000000000000000000000000000000000000000000000000000000000010faa0000000000000000000000000000000000000000000000000000000000004e20",
"WitnetPriceFeedsDefault": "00000000000000000000000077703ae126b971c9946d562f41dd47071da007770000000000000000000000000000000000000000000000000000000000000001322e302e31322d35616362653333000000000000000000000000000000000000"
},
"ten:testnet": {
"WitnetRequestBytecodesDefault": "0000000000000000000000000000000000000000000000000000000000000001322e302e372d3033346663383100000000000000000000000000000000000000",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "witnet-solidity-bridge",
"version": "2.0.10",
"version": "2.0.12",
"description": "Witnet Solidity Bridge contracts for EVM-compatible chains",
"author": "Witnet Foundation <info@witnet.foundation>",
"license": "MIT",
Expand Down Expand Up @@ -53,6 +53,7 @@
"ops:rng:sla": "npx truffle migrate --migrations_directory ./migrations/ops/rng/sla --network",
"prepare": "npx truffle compile --all && npx hardhat compile --force && node ./scripts/prepare.js",
"test": "pnpm run clean && npx truffle test",
"verify:apps": "node ./scripts/verify-apps.js 2>&1",
"verify:core": "node ./scripts/verify-core.js 2>&1",
"verify:libs": "node ./scripts/verify-libs.js 2>&1",
"verify:impls": "node ./scripts/verify-impls.js 2>&1"
Expand Down
7 changes: 5 additions & 2 deletions scripts/verify-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ console.info()
utils.traceVerify(network, "WitnetDeployer")
utils.traceVerify(network, "WitnetProxy")

const addresses = require("../migrations/addresses.json")
const singletons = [
"WitnetOracle",
"WitnetPriceFeeds",
"WitnetRequestBytecodes",
"witnetRequestFactory",
"WitnetRequestFactory",
]
for (const index in singletons) {
utils.traceVerify(network, `${singletons[index]} --custom-proxy WitnetProxy`)
utils.traceVerify(network, `WitnetProxy@${
addresses[network][singletons[index]] || addresses.default[singletons[index]]
} --custom-proxy WitnetProxy`)
}
3 changes: 3 additions & 0 deletions settings/artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ module.exports = {
WitnetPriceFeedsLib: "WitnetPriceFeedsLib",
WitnetOracleDataLib: "WitnetOracleDataLib",
},
base: {
WitnetOracle: "WitnetOracleTrustableOvm2",
},
boba: {
WitnetOracle: "WitnetOracleTrustableOvm2",
},
Expand Down
9 changes: 9 additions & 0 deletions settings/networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ module.exports = {
browserURL: "https://arbiscan.io/",
},
},
"base:sepolia": {
network_id: 84532,
port: 8502,
verify: {
apiKey: "MY_API_KEY",
apiUrl: "https://base-sepolia.blockscout.com/api",
browserURL: "https://base-sepolia.blockscout.com/",
},
},
"boba:bnb:testnet": {
network_id: 9728,
port: 8510,
Expand Down
2 changes: 1 addition & 1 deletion settings/solidity.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
default: {
version: "0.8.23",
version: "0.8.25",
settings: {
optimizer: {
enabled: true,
Expand Down
2 changes: 1 addition & 1 deletion settings/specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
},
WitnetRandomness: {
from: "0xF121b71715E71DDeD592F1125a06D4ED06F0694D",
vanity: 26475657, // 0xc0ffee84FD3B533C3fA408c993F59828395319A1
vanity: 1060132513, // 0xC0FFEE98AD1434aCbDB894BbB752e138c1006fAB
},
WitnetRequestBytecodes: {
libs: ["WitnetEncodingLib"],
Expand Down