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(protocol): implement & simulate tokenomics #376

Merged
merged 93 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
791f33b
making fixtures type-safe
RogerLamTd Nov 22, 2022
a6720e3
Merge branch 'main' into testcleanup
RogerLamTd Nov 22, 2022
854deec
linting
RogerLamTd Nov 22, 2022
f44f86c
fix libsend tests
RogerLamTd Nov 22, 2022
ec70788
Merge branch 'main' into testcleanup
cyberhorsey Nov 23, 2022
2552093
added missing test case LibBridgeRetry
RogerLamTd Nov 24, 2022
1496808
retryMessage tests attempt
RogerLamTd Nov 26, 2022
1d32e2d
Merge branch 'main' into testcleanup
RogerLamTd Nov 26, 2022
0bf5fdd
retriable message
cyberhorsey Nov 28, 2022
d6a1ff8
added setup for testing isSignalReceived()
RogerLamTd Nov 29, 2022
8e5c594
fix
RogerLamTd Nov 30, 2022
085094b
Merge branch 'main' into testcleanup
RogerLamTd Dec 1, 2022
d3b9678
lint
cyberhorsey Dec 2, 2022
89e9d78
Copy impl tokenomics (#373)
dantaik Dec 2, 2022
d51fe1f
undo tokenomics
dantaik Dec 2, 2022
855099e
Revert "undo tokenomics"
dantaik Dec 2, 2022
de14fc5
refactor (#374)
dantaik Dec 2, 2022
4f43bc7
Merge branch 'various_refactor' into tokenomics_implementation
dantaik Dec 2, 2022
87bbb2b
fix
dantaik Dec 2, 2022
76c095d
Update deploy_L1.ts
dantaik Dec 2, 2022
b624ae7
Merge branch 'various_refactor' into tokenomics_implementation
dantaik Dec 2, 2022
1e722ba
Revert "Merge branch 'various_refactor' into tokenomics_implementation"
dantaik Dec 2, 2022
2317572
add simulation code
dantaik Dec 2, 2022
53cc4b9
Update generate_genesis.test.ts
dantaik Dec 2, 2022
8272fe5
Merge branch 'various_refactor' into tokenomics_implementation
dantaik Dec 2, 2022
b45ca43
Merge branch 'main' into various_refactor
dantaik Dec 5, 2022
5ec67bd
Merge branch 'various_refactor' into tokenomics_implementation
dantaik Dec 5, 2022
78d9e8b
switched isSignalReceived test to l1 so eth_getProof is supported
RogerLamTd Dec 5, 2022
731aab2
Merge branch 'main' into testcleanup
RogerLamTd Dec 5, 2022
80098c7
fix isSignalReceived() test
RogerLamTd Dec 5, 2022
f4a8681
fix isSignalReceived() test
RogerLamTd Dec 5, 2022
31938dc
Merge branch 'main' into tokenomics_implementation
dantaik Dec 6, 2022
6049e3b
Update LibConstants.sol
dantaik Dec 6, 2022
714cdbc
format
dantaik Dec 6, 2022
79e62ef
Update LibConstants.sol
dantaik Dec 6, 2022
d90e447
Merge branch 'cleanup_code' into tokenomics_implementation
dantaik Dec 6, 2022
498dd59
Update LibConstants.sol
dantaik Dec 6, 2022
872c65f
Merge branch 'cleanup_code' into tokenomics_implementation
dantaik Dec 6, 2022
86f0adf
finished isSignalReceived tests
RogerLamTd Dec 6, 2022
bb853a7
Merge branch 'main' into testcleanup
cyberhorsey Dec 6, 2022
103ee00
migrated repeated code to fixtures and util functions
RogerLamTd Dec 6, 2022
82b38cf
fix(protocol): fix `BlockVerified` event
davidtaikocha Dec 7, 2022
bc13cc1
Merge branch 'main' into fix-BlockVerified
davidtaikocha Dec 7, 2022
e171753
Merge branch 'fix-BlockVerified' into tokenomics_implementation
dantaik Dec 7, 2022
294254a
Merge branch 'main' into testcleanup
dantaik Dec 7, 2022
8607224
Merge branch 'testcleanup' into tokenomics_implementation
dantaik Dec 7, 2022
9657d41
Merge branch 'main' into tokenomics_implementation
dantaik Dec 7, 2022
64070a2
Update Bridge.test.ts
dantaik Dec 7, 2022
09b2906
Merge branch 'main' into tokenomics_implementation
dantaik Dec 8, 2022
a1f71b6
Merge branch 'main' into tokenomics_implementation
dantaik Dec 8, 2022
930426a
Update V1Proposing.sol
dantaik Dec 8, 2022
1755eaa
Update V1Verifying.sol
dantaik Dec 8, 2022
0b1819d
Merge branch 'updateAvgProofTime' into tokenomics_implementation
dantaik Dec 8, 2022
fbd28ce
Update V1Verifying.sol
dantaik Dec 8, 2022
0fd073f
Update LibConstants.sol
dantaik Dec 8, 2022
94181da
Update V1Utils.sol
dantaik Dec 8, 2022
d5504c3
Merge branch 'updateAvgProofTime' into tokenomics_implementation
dantaik Dec 8, 2022
677894f
update
dantaik Dec 8, 2022
885c660
Merge branch 'tokenomics_implementation' of https://github.com/taikox…
dantaik Dec 8, 2022
e974fd5
Update LibConstants.sol
dantaik Dec 8, 2022
1affc84
more
dantaik Dec 8, 2022
92eeca7
Merge branch 'updateAvgProofTime' into tokenomics_implementation
dantaik Dec 8, 2022
3cc4994
fix David's concern
dantaik Dec 9, 2022
621a45c
Update LibData.sol
dantaik Dec 9, 2022
5439d88
Merge branch 'updateAvgProofTime' into tokenomics_implementation
dantaik Dec 9, 2022
261fcf7
Merge branch 'main' into updateAvgProofTime
dantaik Dec 9, 2022
eb1320b
Merge branch 'updateAvgProofTime' into tokenomics_implementation
dantaik Dec 9, 2022
6d4918d
Merge branch 'updateAvgProofTime' of https://github.com/taikoxyz/taik…
dantaik Dec 9, 2022
c968c6d
Merge branch 'updateAvgProofTime' into tokenomics_implementation
dantaik Dec 9, 2022
ff70d33
Merge branch 'main' into tokenomics_implementation
dantaik Dec 9, 2022
019fa64
Update LibConstants.sol
dantaik Dec 9, 2022
2197b1d
Merge branch 'main' into tokenomics_implementation
dantaik Dec 23, 2022
4d01ce3
Update LibConstants.sol
dantaik Dec 23, 2022
aec27d0
Merge branch 'main' into tokenomics_implementation
dantaik Dec 24, 2022
61be420
refactor(protocol): use a Config object to replace LibConstants (#478)
dantaik Dec 24, 2022
5788dd3
refactor(protocol): reorganize contract files (no logic change) (#484)
dantaik Dec 24, 2022
dcb9ab7
fixed an issue
dantaik Jan 3, 2023
972f527
refactor(protocol): clean up permission code (whitelisting disabled) …
dantaik Jan 3, 2023
cacf8d2
feat(bridge): change pending message for l2 to l1 (#486)
shadab-taiko Dec 26, 2022
de61a6e
feat(website): create testnet docs (#428)
d1onys1us Dec 27, 2022
b4dc363
chore(website): small updates to testnet docs (#488)
d1onys1us Dec 27, 2022
3b96747
fix(relayer): gas limit + use loading as priorioty on bridge form (#487)
cyberhorsey Dec 27, 2022
4af6ae1
feat(bridge): add faucet link to announcement (#485)
shadab-taiko Dec 27, 2022
456a521
feat(docs): improve docs (#1646)
d1onys1us Dec 29, 2022
71a99f9
fix(bridge): ui fixes (#489)
shadab-taiko Dec 30, 2022
5d65ba8
fix(bridge): use metamask wagmi connector (#2080)
shadab-taiko Dec 30, 2022
cf9693b
docs(website): update `deploy-a-contract.md` (#3692)
anipaul2 Jan 3, 2023
8ef7561
chore(branding): add geometry banner (#2532)
d1onys1us Jan 3, 2023
b5ad7a3
chore(docs): update issue template (#2741)
d1onys1us Jan 3, 2023
23ff848
Merge branch 'main' into tokenomics_implementation
dantaik Jan 3, 2023
0cbe6db
refactor(protocol): `i++` to `++i` to reduce 5 gas (#2033)
dantaik Jan 3, 2023
470afdf
refactor(protocol): extract IProofVerifier interface (#6800)
dong77 Jan 3, 2023
3702b49
Merge branch 'main' into tokenomics_implementation
dantaik Jan 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: "16.15"

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
Expand All @@ -46,7 +46,15 @@ jobs:

- name: protocol - Unit Tests
working-directory: ./packages/protocol
run: pnpm install && pnpm clean && pnpm test:coverage && pnpm test:integration && pnpm export:abi
run: pnpm install && pnpm clean && pnpm test

- name: protocol - Integration Tests
working-directory: ./packages/protocol
run: pnpm test:integration

- name: protocol - Test Coverage
working-directory: ./packages/protocol
run: pnpm test:coverage

- name: protocol - Generate Genesis
working-directory: ./packages/protocol
Expand Down
1 change: 1 addition & 0 deletions packages/protocol/.solhintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ contracts/test/TestLibRLPWriter.sol
contracts/libs/Lib1559Math.sol
contracts/libs/LibAddress.sol
contracts/libs/LibMath.sol
contracts/libs/LibUint512Math.sol
**/contracts/thirdparty/**/*.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,42 @@
// ╱╱╰╯╰╯╰┻┻╯╰┻━━╯╰━━━┻╯╰┻━━┻━━╯
pragma solidity ^0.8.9;

import "../libs/LibConstants.sol";

/// @author dantaik <dan@taiko.xyz>
library LibData {
library TaikoData {
struct Config {
uint256 chainId;
// up to 2048 pending blocks
uint256 maxNumBlocks;
uint256 blockHashHistory;
// This number is calculated from maxNumBlocks to make
// the 'the maximum value of the multiplier' close to 20.0
uint256 zkProofsPerBlock;
uint256 maxVerificationsPerTx;
uint256 commitConfirmations;
uint256 maxProofsPerForkChoice;
uint256 blockMaxGasLimit;
uint256 maxTransactionsPerBlock;
uint256 maxBytesPerTxList;
uint256 minTxGasLimit;
uint256 anchorTxGasLimit;
uint256 feePremiumLamda;
uint256 rewardBurnBips;
uint256 proposerDepositPctg;
// Moving average factors
uint256 feeBaseMAF;
uint256 blockTimeMAF;
uint256 proofTimeMAF;
uint64 rewardMultiplierPctg;
uint64 feeGracePeriodPctg;
uint64 feeMaxPeriodPctg;
uint64 blockTimeCap;
uint64 proofTimeCap;
uint64 boostrapDiscountHalvingPeriod;
uint64 initialUncleDelay;
bool enableTokenomics;
bool skipProofValidation;
}

struct BlockMetadata {
uint256 id;
uint256 l1Height;
Expand All @@ -29,6 +61,7 @@ library LibData {
// 3 slots
struct ProposedBlock {
bytes32 metaHash;
uint256 deposit;
address proposer;
uint64 proposedAt;
}
Expand All @@ -42,7 +75,7 @@ library LibData {

// This struct takes 9 slots.
struct State {
// block id => block hash
// block id => block hash (some blocks' hashes won't be persisted)
mapping(uint256 => bytes32) l2Hashes;
// block id => ProposedBlock
mapping(uint256 => ProposedBlock) proposedBlocks;
Expand All @@ -55,6 +88,8 @@ library LibData {
uint64 genesisTimestamp;
uint64 __reservedA1;
uint64 statusBits; // rarely change
// Changed when a block is proposed or proven/finalized
uint256 feeBase;
// Changed when a block is proposed
uint64 nextBlockId;
uint64 lastProposedAt; // Timestamp when the last block is proposed.
Expand All @@ -79,51 +114,4 @@ library LibData {
// // Reserved
uint256[46] __gap;
}

function saveProposedBlock(
LibData.State storage state,
uint256 id,
ProposedBlock memory blk
) internal {
state.proposedBlocks[id % LibConstants.K_MAX_NUM_BLOCKS] = blk;
}

function getProposedBlock(
State storage state,
uint256 id
) internal view returns (ProposedBlock storage) {
return state.proposedBlocks[id % LibConstants.K_MAX_NUM_BLOCKS];
}

function getL2BlockHash(
State storage state,
uint256 number
) internal view returns (bytes32) {
require(number <= state.latestVerifiedHeight, "L1:id");
return state.l2Hashes[number];
}

function getStateVariables(
State storage state
)
internal
view
returns (
uint64 genesisHeight,
uint64 latestVerifiedHeight,
uint64 latestVerifiedId,
uint64 nextBlockId
)
{
genesisHeight = state.genesisHeight;
latestVerifiedHeight = state.latestVerifiedHeight;
latestVerifiedId = state.latestVerifiedId;
nextBlockId = state.nextBlockId;
}

function hashMetadata(
BlockMetadata memory meta
) internal pure returns (bytes32) {
return keccak256(abi.encode(meta));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
// ╱╱╰╯╰╯╰┻┻╯╰┻━━╯╰━━━┻╯╰┻━━┻━━╯
pragma solidity ^0.8.9;

import "../LibData.sol";
import "./TaikoData.sol";

/// @author david <david@taiko.xyz>
abstract contract V1Events {
abstract contract TaikoEvents {
// The following events must match the definitions in other V1 libraries.
event BlockVerified(uint256 indexed id, bytes32 blockHash);

Expand All @@ -21,7 +21,7 @@ abstract contract V1Events {
bytes32 commitHash
);

event BlockProposed(uint256 indexed id, LibData.BlockMetadata meta);
event BlockProposed(uint256 indexed id, TaikoData.BlockMetadata meta);

event BlockProven(
uint256 indexed id,
Expand Down