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 14 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
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// 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 = 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.boostrapDiscountHalvingPeriod = 180 days;
config.initialUncleDelay = 1 minutes;
config.enableTokenomics = true;
}

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;
}
}
1 change: 1 addition & 0 deletions packages/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"generate:genesis": "ts-node ./utils/generate_genesis/main.ts",
"test:genesis": "./test/genesis/generate_genesis.test.sh",
"test:integration": "./test/test_integration.sh",
"test:tokenomics": "./test/test_tokenomics.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
91 changes: 0 additions & 91 deletions packages/protocol/tasks/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as fs from "fs";
import * as log from "./log";
import { Block, BlockHeader, EthGetProofResponse } from "../test/utils/rpc";
import RLP from "rlp";

async function deployContract(
hre: any,
Expand Down Expand Up @@ -68,105 +66,16 @@ function getDeployments(_fileName: string) {
return JSON.parse(`${json}`);
}

async function getMessageStatusSlot(hre: any, signal: any) {
return hre.ethers.utils.solidityKeccak256(
["string", "bytes"],
["MESSAGE_STATUS", signal]
);
}

async function decode(hre: any, type: any, data: any) {
return hre.ethers.utils.defaultAbiCoder.decode([type], data).toString();
}

function getSignalSlot(hre: any, sender: any, signal: any) {
return hre.ethers.utils.keccak256(
hre.ethers.utils.solidityPack(
["string", "address", "bytes32"],
["SIGNAL", sender, signal]
)
);
}

const MessageStatus = {
NEW: 0,
RETRIABLE: 1,
DONE: 2,
FAILED: 3,
};

async function getLatestBlockHeader(hre: any) {
const block: Block = await hre.ethers.provider.send(
"eth_getBlockByNumber",
["latest", false]
);

const logsBloom = block.logsBloom.toString().substring(2);

const blockHeader: BlockHeader = {
parentHash: block.parentHash,
ommersHash: block.sha3Uncles,
beneficiary: block.miner,
stateRoot: block.stateRoot,
transactionsRoot: block.transactionsRoot,
receiptsRoot: block.receiptsRoot,
logsBloom: logsBloom.match(/.{1,64}/g)!.map((s: string) => "0x" + s),
difficulty: block.difficulty,
height: block.number,
gasLimit: block.gasLimit,
gasUsed: block.gasUsed,
timestamp: block.timestamp,
extraData: block.extraData,
mixHash: block.mixHash,
nonce: block.nonce,
baseFeePerGas: block.baseFeePerGas ? parseInt(block.baseFeePerGas) : 0,
};

return { block, blockHeader };
}

async function getSignalProof(
hre: any,
contractAddress: string,
key: string,
blockNumber: number,
blockHeader: BlockHeader
) {
const proof: EthGetProofResponse = await hre.ethers.provider.send(
"eth_getProof",
[contractAddress, [key], blockNumber]
);

// RLP encode the proof together for LibTrieProof to decode
const encodedProof = hre.ethers.utils.defaultAbiCoder.encode(
["bytes", "bytes"],
[
RLP.encode(proof.accountProof),
RLP.encode(proof.storageProof[0].proof),
]
);
// encode the SignalProof struct from LibBridgeSignal
const signalProof = hre.ethers.utils.defaultAbiCoder.encode(
[
"tuple(tuple(bytes32 parentHash, bytes32 ommersHash, address beneficiary, bytes32 stateRoot, bytes32 transactionsRoot, bytes32 receiptsRoot, bytes32[8] logsBloom, uint256 difficulty, uint128 height, uint64 gasLimit, uint64 gasUsed, uint64 timestamp, bytes extraData, bytes32 mixHash, uint64 nonce, uint256 baseFeePerGas) header, bytes proof)",
],
[{ header: blockHeader, proof: encodedProof }]
);

return signalProof;
}

export {
deployContract,
getDeployer,
waitTx,
getContract,
saveDeployments,
getDeployments,
getMessageStatusSlot,
getSignalSlot,
decode,
MessageStatus,
getLatestBlockHeader,
getSignalProof,
};
Loading