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

fix(tests): cleanup tests to prepare for tokenomics testing #11316

Merged
merged 49 commits into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
b67e080
cleanup TaikoL1 tests with refactored code to utils folders before at…
cyberhorsey Jan 6, 2023
777179f
separate bridge and bridge integration tests, move deployBridge
cyberhorsey Jan 6, 2023
3beee08
additional bridge test refactoring
cyberhorsey Jan 6, 2023
931e1ef
move ethervault/tokenvautl to own folders, addtl refactors from task/…
cyberhorsey Jan 6, 2023
7fd5c31
folder names match contract names
cyberhorsey Jan 6, 2023
4c0aab4
undo folder structure, should match contracts tree imo
cyberhorsey Jan 6, 2023
377324e
Update TkoToken.test.ts
dantaik Jan 7, 2023
47beee7
Merge branch 'main' into test_cleanup
cyberhorsey Jan 9, 2023
be41408
check status/receipt
cyberhorsey Jan 9, 2023
751492c
wip
cyberhorsey Jan 10, 2023
e2be1a0
merge main
cyberhorsey Jan 10, 2023
ad60e97
Merge branch 'test_cleanup' of github.com:taikochain/taiko-mono into …
cyberhorsey Jan 10, 2023
e9e210b
merge main
cyberhorsey Jan 10, 2023
47e88eb
merge main, tests passing
cyberhorsey Jan 10, 2023
1c8a532
chmod test tokenomics
cyberhorsey Jan 10, 2023
e701ac5
Update packages/protocol/test/L1/TaikoL1.integration.test.ts
cyberhorsey Jan 10, 2023
cbdc1fa
some refactors for reusabel deploy functions, beginning of tokenomcis…
cyberhorsey Jan 12, 2023
c7a3edc
Merge branch 'test_cleanup' of github.com:taikochain/taiko-mono into …
cyberhorsey Jan 12, 2023
0ace5d2
Merge branch 'main' into test_cleanup
cyberhorsey Jan 12, 2023
f980093
add test assertions on block prosal for reward and fees
cyberhorsey Jan 12, 2023
dbeb9e5
expect doesnt work in the event listener
cyberhorsey Jan 12, 2023
c989190
refactor to an onNewL2Block
cyberhorsey Jan 12, 2023
1555436
Merge branch 'test_cleanup' of github.com:taikochain/taiko-mono into …
cyberhorsey Jan 13, 2023
a388095
tests for bootstrap halving
cyberhorsey Jan 13, 2023
c6ee1ef
bridge test cleanup more
cyberhorsey Jan 13, 2023
44a0705
block max gas limit usage in test
cyberhorsey Jan 13, 2023
b9ae690
remove prover
cyberhorsey Jan 13, 2023
7010a24
comment out prove test.
cyberhorsey Jan 13, 2023
074b5bd
use automine
cyberhorsey Jan 13, 2023
822a725
add todo
cyberhorsey Jan 13, 2023
539c6df
remove 0 check
cyberhorsey Jan 13, 2023
7735570
resolve test issue?
cyberhorsey Jan 13, 2023
2cc7b03
Update packages/protocol/test/L1/TaikoL1.integration.test.ts
cyberhorsey Jan 13, 2023
4298830
addressManager utils functions, l1/l2 provider, l2signer
cyberhorsey Jan 13, 2023
71eec5d
Merge branch 'test_cleanup' of github.com:taikochain/taiko-mono into …
cyberhorsey Jan 13, 2023
afdbe9c
set taikoL2 on taikoL1
cyberhorsey Jan 13, 2023
97fbb70
set taiko
cyberhorsey Jan 13, 2023
7efe07e
Merge branch 'main' into test_cleanup
cyberhorsey Jan 13, 2023
2627e97
put tokenomics utils functions in own file
cyberhorsey Jan 13, 2023
7aa50b1
Merge branch 'test_cleanup' of github.com:taikochain/taiko-mono into …
cyberhorsey Jan 13, 2023
0e71695
dont need prove tests yet
cyberhorsey Jan 13, 2023
c142873
testtaikoL2
cyberhorsey Jan 14, 2023
81d671b
WIP on proving, anchoring
cyberhorsey Jan 14, 2023
9e24c88
await sendtx
cyberhorsey Jan 14, 2023
18801d6
taikol2 test contracts
cyberhorsey Jan 14, 2023
471f871
contract type
cyberhorsey Jan 14, 2023
65697ba
disable public inputs
cyberhorsey Jan 14, 2023
b1358dd
wip cleanup
cyberhorsey Jan 14, 2023
34ff709
Update TaikoL2.sol
dantaik Jan 14, 2023
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: 4 additions & 0 deletions .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ jobs:
working-directory: ./packages/protocol
run: pnpm test:integration

- name: protocol - Tokenomics Tests
working-directory: ./packages/protocol
run: pnpm test:tokenomics

- name: protocol - Test Coverage
working-directory: ./packages/protocol
run: pnpm test:coverage
Expand Down
3 changes: 2 additions & 1 deletion packages/protocol/contracts/L1/TaikoData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ library TaikoData {
uint64 feeMaxPeriodPctg;
uint64 blockTimeCap;
uint64 proofTimeCap;
uint64 boostrapDiscountHalvingPeriod;
uint64 bootstrapDiscountHalvingPeriod;
uint64 initialUncleDelay;
bool enableTokenomics;
bool enablePublicInputsCheck;
}

struct BlockMetadata {
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/libs/LibUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ library LibUtils {
uint256 feeBase
) internal view returns (uint256) {
uint256 halves = uint256(block.timestamp - state.genesisTimestamp) /
config.boostrapDiscountHalvingPeriod;
config.bootstrapDiscountHalvingPeriod;
uint256 gamma = 1024 - (1024 >> halves);
return (feeBase * gamma) / 1024;
}
Expand Down
13 changes: 10 additions & 3 deletions packages/protocol/contracts/L2/TaikoL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ contract TaikoL2 is AddressResolver, ReentrancyGuard, IHeaderSync {
* @param l1Hash The latest L1 block hash when this block was proposed.
*/
function anchor(uint256 l1Height, bytes32 l1Hash) external {
_checkPublicInputs();
TaikoData.Config memory config = getConfig();
if (config.enablePublicInputsCheck) {
_checkPublicInputs();
}

l1Hashes[l1Height] = l1Hash;
latestSyncedHeader = l1Hash;
Expand All @@ -102,15 +105,18 @@ contract TaikoL2 is AddressResolver, ReentrancyGuard, IHeaderSync {
);
require(tx.gasprice == 0, "L2:gasPrice");

TaikoData.Config memory config = getConfig();
LibInvalidTxList.Reason reason = LibInvalidTxList.isTxListInvalid({
config: getConfig(),
config: config,
encoded: txList,
hint: hint,
txIdx: txIdx
});
require(reason != LibInvalidTxList.Reason.OK, "L2:reason");

_checkPublicInputs();
if (config.enablePublicInputsCheck) {
_checkPublicInputs();
}

emit BlockInvalidated(txList.hashTxList());
}
Expand Down Expand Up @@ -159,6 +165,7 @@ contract TaikoL2 is AddressResolver, ReentrancyGuard, IHeaderSync {
uint256 number = block.number;
uint256 chainId = block.chainid;

// from 2 to 256, while nnumber is greater than that number
for (uint256 i = 2; i <= 256 && number >= i; ++i) {
ancestors[(number - i) % 255] = blockhash(number - i);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/bridge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Let's go deeper into the steps that occur when bridging ETH from srcChain to des
User initiates a bridge transaction with `sendMessage` on the source chain which includes:

- `depositValue`, `callValue`, and `processingFee` -- these must sum to `msg.value`.
- The destination chain's ID (must be enabled via `Bridge.enableDestChain()`).
- The destination chain's ID (must be enabled via setting `addressResolver` for `${chainID}.bridge`).

Inside the `sendMessage` call, the `msg.value` amount of Ether is sent to the srcChain `EtherVault` contract. Next, a `signal` is created from the message, and a `key` is stored on the srcChain bridge contract address. The `key` is a hash of the `signal` and the srcChain bridge contract address. The `key` is stored on the `Bridge` contract with a value of `1`, and a `MessageSent` event is emitted for the relayer to pick up.

Expand Down
5 changes: 3 additions & 2 deletions packages/protocol/contracts/libs/LibSharedConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ library LibSharedConfig {
feeMaxPeriodPctg: 375, // 375%
blockTimeCap: 48 seconds,
proofTimeCap: 60 minutes,
boostrapDiscountHalvingPeriod: 180 days,
bootstrapDiscountHalvingPeriod: 180 days,
initialUncleDelay: 60 minutes,
enableTokenomics: false
enableTokenomics: false,
enablePublicInputsCheck: true
});
}
}
3 changes: 2 additions & 1 deletion packages/protocol/contracts/test/L1/TestTaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ contract TestTaikoL1 is TaikoL1, IProofVerifier {
config.feeMaxPeriodPctg = 375; // 375%
config.blockTimeCap = 48 seconds;
config.proofTimeCap = 60 minutes;
config.boostrapDiscountHalvingPeriod = 180 days;
config.bootstrapDiscountHalvingPeriod = 180 days;
config.initialUncleDelay = 1 minutes;
config.enableTokenomics = false;
config.enablePublicInputsCheck = true;
}

function verifyZKP(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// SPDX-License-Identifier: MIT
//
// ╭━━━━╮╱╱╭╮╱╱╱╱╱╭╮╱╱╱╱╱╭╮
// ┃╭╮╭╮┃╱╱┃┃╱╱╱╱╱┃┃╱╱╱╱╱┃┃
// ╰╯┃┃┣┻━┳┫┃╭┳━━╮┃┃╱╱╭━━┫╰━┳━━╮
// ╱╱┃┃┃╭╮┣┫╰╯┫╭╮┃┃┃╱╭┫╭╮┃╭╮┃━━┫
// ╱╱┃┃┃╭╮┃┃╭╮┫╰╯┃┃╰━╯┃╭╮┃╰╯┣━━┃
// ╱╱╰╯╰╯╰┻┻╯╰┻━━╯╰━━━┻╯╰┻━━┻━━╯
pragma solidity ^0.8.9;

import {IProofVerifier} from "../../L1/ProofVerifier.sol";
import "../../L1/TaikoL1.sol";

contract TestTaikoL1EnableTokenomics is TaikoL1, IProofVerifier {
function getConfig()
public
pure
override
returns (TaikoData.Config memory config)
{
config.chainId = 167;
// up to 2048 pending blocks
config.maxNumBlocks = 2048;
config.blockHashHistory = 3;
// This number is calculated from maxNumBlocks to make
// the 'the maximum value of the multiplier' close to 20.0
config.zkProofsPerBlock = 1;
config.maxVerificationsPerTx = 2;
config.commitConfirmations = 1;
config.maxProofsPerForkChoice = 5;
config.blockMaxGasLimit = 30000000; // TODO
config.maxTransactionsPerBlock = 20; // TODO
config.maxBytesPerTxList = 10240; // TODO
config.minTxGasLimit = 21000; // TODO
config.anchorTxGasLimit = 250000;
config.feePremiumLamda = 590;
config.rewardBurnBips = 100; // 100 basis points or 1%
config.proposerDepositPctg = 25; // 25%

// Moving average factors
config.feeBaseMAF = 1024;
config.blockTimeMAF = 64;
config.proofTimeMAF = 64;

config.rewardMultiplierPctg = 400; // 400%
config.feeGracePeriodPctg = 125; // 125%
config.feeMaxPeriodPctg = 375; // 375%
config.blockTimeCap = 48 seconds;
config.proofTimeCap = 5 seconds;
config.bootstrapDiscountHalvingPeriod = 1 seconds;
config.initialUncleDelay = 1 seconds;
config.enableTokenomics = true;
config.enablePublicInputsCheck = false;
}

function verifyZKP(
bytes memory /*verificationKey*/,
bytes calldata /*zkproof*/,
bytes32 /*blockHash*/,
address /*prover*/,
bytes32 /*txListHash*/
) public pure override returns (bool) {
return true;
}

function verifyMKP(
bytes memory /*key*/,
bytes memory /*value*/,
bytes memory /*proof*/,
bytes32 /*root*/
) public pure override returns (bool) {
return true;
}
}
56 changes: 56 additions & 0 deletions packages/protocol/contracts/test/L1/TestTaikoL2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// SPDX-License-Identifier: MIT
//
// ╭━━━━╮╱╱╭╮╱╱╱╱╱╭╮╱╱╱╱╱╭╮
// ┃╭╮╭╮┃╱╱┃┃╱╱╱╱╱┃┃╱╱╱╱╱┃┃
// ╰╯┃┃┣┻━┳┫┃╭┳━━╮┃┃╱╱╭━━┫╰━┳━━╮
// ╱╱┃┃┃╭╮┣┫╰╯┫╭╮┃┃┃╱╭┫╭╮┃╭╮┃━━┫
// ╱╱┃┃┃╭╮┃┃╭╮┫╰╯┃┃╰━╯┃╭╮┃╰╯┣━━┃
// ╱╱╰╯╰╯╰┻┻╯╰┻━━╯╰━━━┻╯╰┻━━┻━━╯
pragma solidity ^0.8.9;

import "../../L2/TaikoL2.sol";

contract TestTaikoL2 is TaikoL2 {
constructor(address _addressManager) TaikoL2(_addressManager) {}

function getConfig()
public
pure
override
returns (TaikoData.Config memory config)
{
config.chainId = 167;
// up to 2048 pending blocks
config.maxNumBlocks = 4;
config.blockHashHistory = 3;
// This number is calculated from maxNumBlocks to make
// the 'the maximum value of the multiplier' close to 20.0
config.zkProofsPerBlock = 1;
config.maxVerificationsPerTx = 2;
config.commitConfirmations = 1;
config.maxProofsPerForkChoice = 5;
config.blockMaxGasLimit = 30000000; // TODO
config.maxTransactionsPerBlock = 20; // TODO
config.maxBytesPerTxList = 10240; // TODO
config.minTxGasLimit = 21000; // TODO
config.anchorTxGasLimit = 250000;
config.feePremiumLamda = 590;
config.rewardBurnBips = 100; // 100 basis points or 1%
config.proposerDepositPctg = 25; // 25%

// Moving average factors
config.feeBaseMAF = 1024;
config.blockTimeMAF = 64;
config.proofTimeMAF = 64;

config.rewardMultiplierPctg = 400; // 400%
config.feeGracePeriodPctg = 125; // 125%
config.feeMaxPeriodPctg = 375; // 375%
config.blockTimeCap = 48 seconds;
config.proofTimeCap = 60 minutes;
config.bootstrapDiscountHalvingPeriod = 180 days;
config.initialUncleDelay = 1 minutes;
config.enableTokenomics = true;
config.enablePublicInputsCheck = false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// SPDX-License-Identifier: MIT
//
// ╭━━━━╮╱╱╭╮╱╱╱╱╱╭╮╱╱╱╱╱╭╮
// ┃╭╮╭╮┃╱╱┃┃╱╱╱╱╱┃┃╱╱╱╱╱┃┃
// ╰╯┃┃┣┻━┳┫┃╭┳━━╮┃┃╱╱╭━━┫╰━┳━━╮
// ╱╱┃┃┃╭╮┣┫╰╯┫╭╮┃┃┃╱╭┫╭╮┃╭╮┃━━┫
// ╱╱┃┃┃╭╮┃┃╭╮┫╰╯┃┃╰━╯┃╭╮┃╰╯┣━━┃
// ╱╱╰╯╰╯╰┻┻╯╰┻━━╯╰━━━┻╯╰┻━━┻━━╯
pragma solidity ^0.8.9;

import "../../L2/TaikoL2.sol";

contract TestTaikoL2EnablePublicInputsCheck is TaikoL2 {
constructor(address _addressManager) TaikoL2(_addressManager) {}

function getConfig()
public
pure
override
returns (TaikoData.Config memory config)
{
config.chainId = 167;
// up to 2048 pending blocks
config.maxNumBlocks = 4;
config.blockHashHistory = 3;
// This number is calculated from maxNumBlocks to make
// the 'the maximum value of the multiplier' close to 20.0
config.zkProofsPerBlock = 1;
config.maxVerificationsPerTx = 2;
config.commitConfirmations = 1;
config.maxProofsPerForkChoice = 5;
config.blockMaxGasLimit = 30000000; // TODO
config.maxTransactionsPerBlock = 20; // TODO
config.maxBytesPerTxList = 10240; // TODO
config.minTxGasLimit = 21000; // TODO
config.anchorTxGasLimit = 250000;
config.feePremiumLamda = 590;
config.rewardBurnBips = 100; // 100 basis points or 1%
config.proposerDepositPctg = 25; // 25%

// Moving average factors
config.feeBaseMAF = 1024;
config.blockTimeMAF = 64;
config.proofTimeMAF = 64;

config.rewardMultiplierPctg = 400; // 400%
config.feeGracePeriodPctg = 125; // 125%
config.feeMaxPeriodPctg = 375; // 375%
config.blockTimeCap = 48 seconds;
config.proofTimeCap = 60 minutes;
config.bootstrapDiscountHalvingPeriod = 180 days;
config.initialUncleDelay = 1 minutes;
config.enableTokenomics = true;
config.enablePublicInputsCheck = true;
}
}
9 changes: 9 additions & 0 deletions packages/protocol/contracts/test/thirdparty/TestTKOToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "../../L1/TkoToken.sol";

contract TestTkoToken is TkoToken {
function mintAnyone(address account, uint256 amount) public {
_mint(account, amount);
}
}
3 changes: 2 additions & 1 deletion packages/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"test:coverage": "pnpm coverage",
"generate:genesis": "ts-node ./utils/generate_genesis/main.ts",
"test:genesis": "./test/genesis/generate_genesis.test.sh",
"test:integration": "./test/test_integration.sh",
"test:integration": "TEST_TYPE=integration ./test/test_integration.sh",
"test:tokenomics": "TEST_TYPE=tokenomics ./test/test_integration.sh",
"deploy:hardhat": "LOG_LEVEL=debug pnpm hardhat deploy_L1 --network hardhat --dao-vault 0xdf08f82de32b8d460adbe8d72043e3a7e25a3b39 --team-vault 0xdf08f82de32b8d460adbe8d72043e3a7e25a3b39 --l2-genesis-block-hash 0xee1950562d42f0da28bd4550d88886bc90894c77c9c9eaefef775d4c8223f259 --bridge-funder-private-key ddbf12f72c946bb1e6de5eaf580c51db51828ba198d9b0dba9c7d48ec748dc04 --bridge-fund 0xff --confirmations 1",
"lint-staged": "lint-staged --allow-empty"
},
Expand Down
Loading