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

Copy impl tokenomics #373

Merged
merged 82 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
e655c91
Optimize commitBlock gas usage
dantaik Nov 23, 2022
314b03a
more
dantaik Nov 23, 2022
52a9037
more
dantaik Nov 23, 2022
7fcedf5
Update LibData.sol
dantaik Nov 23, 2022
59f9b20
Update V1Proposing.sol
dantaik Nov 23, 2022
e244a20
Update V1Events.sol
dantaik Nov 23, 2022
a7f81de
more
dantaik Nov 23, 2022
2570c99
feat(protocol): implement tokenomics v1 (#243)
dantaik Nov 23, 2022
5c83410
Revert "feat(protocol): implement tokenomics v1 (#243)"
dantaik Nov 23, 2022
95dc73f
Revert "Revert "feat(protocol): implement tokenomics v1 (#243)""
dantaik Nov 23, 2022
8aad364
update TaikoL1.sol (no ci)
dantaik Nov 23, 2022
d50ced0
Update LibData.sol
dantaik Nov 23, 2022
9b54351
type
dantaik Nov 23, 2022
01f2669
Update V1Proposing.sol
dantaik Nov 23, 2022
11c2263
rename
dantaik Nov 23, 2022
2046794
Merge branch 'optimize_commit_gascost' into implement-tokenomics-v1_pr
dantaik Nov 23, 2022
9a98e47
Update V1Proposing.sol
dantaik Nov 23, 2022
d827527
Update V1Proposing.sol
dantaik Nov 23, 2022
0d225c8
feat(protocol): make `TaikoL1/V1TaikoL2.getConstants()` returning `K_…
davidtaikocha Nov 23, 2022
03e7781
Merge branch 'main' into optimize_commit_gascost
dantaik Nov 23, 2022
327a38a
Merge branch 'optimize_commit_gascost' into implement-tokenomics-v1_pr
dantaik Nov 23, 2022
2e612ed
use asserts (#339)
dantaik Nov 25, 2022
548e85d
Update V1Proposing.sol
dantaik Nov 25, 2022
8f2cb79
use asserts (#339)
dantaik Nov 25, 2022
d82ef8b
Update V1Proposing.sol
dantaik Nov 25, 2022
2503068
Revert "Revert "feat(protocol): implement tokenomics v1 (#243)""
dantaik Nov 23, 2022
695cc19
Merge branch 'optimize_commit_gascost' into implement-tokenomics-v1_pr
dantaik Nov 25, 2022
e53cfca
fix lint
dantaik Nov 25, 2022
dc44ce6
chore(all): update license
d1onys1us Nov 25, 2022
48ba2d9
Merge branch 'main' into implement-tokenomics-v1_pr
dantaik Nov 26, 2022
34134a6
more constants and fix tests
dantaik Nov 26, 2022
dc21c88
Update deploy_L1.ts
dantaik Nov 26, 2022
c0b1c0f
Merge branch 'main' into implement-tokenomics-v1_pr
dantaik Nov 27, 2022
3f4fe0a
refactor(protocol): optimize implementation and improve code readabil…
dantaik Nov 27, 2022
0412970
Merge branch 'main' into mit-style
Nov 28, 2022
a531337
Merge branch 'main' into implement-tokenomics-v1_pr
dantaik Nov 29, 2022
69621e4
Update LibBridgeData.test.ts
dantaik Nov 29, 2022
2d3f263
Merge branch 'main' into mit-style
Nov 29, 2022
6bcf936
chore: move license to top
d1onys1us Nov 29, 2022
f50f344
chore: cleanup header comments
d1onys1us Nov 29, 2022
4d948e9
chore: rename library and function names
d1onys1us Nov 29, 2022
d0789ae
chore: change public to internal function
d1onys1us Nov 29, 2022
d8f1822
chore: try fix tests
d1onys1us Nov 29, 2022
b782f65
chore: try fix tests (deploy script)
d1onys1us Nov 29, 2022
0c784f5
test
d1onys1us Nov 29, 2022
a6ae64d
revert
d1onys1us Nov 29, 2022
20c8304
move file (#363)
dantaik Nov 30, 2022
580e1b5
enable proposer whitelisting
dantaik Nov 30, 2022
f0628df
Merge branch 'main' into whitelist_proposers_as_well
dantaik Nov 30, 2022
f05387f
Update TaikoL1.sol
dantaik Nov 30, 2022
915e0ea
Update BridgedERC20.test.ts
dantaik Nov 30, 2022
f00c1c3
more
dantaik Nov 30, 2022
666c210
Merge branch 'whitelist_proposers_as_well' of https://github.com/taik…
dantaik Nov 30, 2022
597b72c
Merge branch 'main' into implement-tokenomics-v1_pr
dantaik Nov 30, 2022
9ee36af
Merge branch 'main' into whitelist_proposers_as_well
dantaik Nov 30, 2022
48ad1d3
Merge branch 'whitelist_proposers_as_well' into implement-tokenomics-…
dantaik Nov 30, 2022
b4a0f75
more
dantaik Nov 30, 2022
6eff492
lint
dantaik Nov 30, 2022
8b3bd11
Update V1Utils.sol
dantaik Nov 30, 2022
d293c08
Update V1Utils.sol
dantaik Nov 30, 2022
47db6e3
rename
dantaik Nov 30, 2022
0f96f6a
rename
dantaik Nov 30, 2022
8f62ee5
Update V1Utils.sol
dantaik Nov 30, 2022
e11583c
Update TaikoL1.sol
dantaik Nov 30, 2022
7ac0e40
Update TaikoL1.sol
dantaik Nov 30, 2022
b68452c
Update main.tex
dantaik Nov 30, 2022
9a4130a
feat(tokenomics): charge more fees for blocks that are harder to prov…
dantaik Nov 30, 2022
2565661
Merge branch 'main' into whitelist_proposers_as_well
dantaik Dec 1, 2022
d260039
Update BridgedERC20.test.ts
dantaik Dec 1, 2022
5f3a3aa
Update BridgedERC20.test.ts
dantaik Dec 1, 2022
81cd098
Merge branch 'whitelist_proposers_as_well' into implement-tokenomics-…
dantaik Dec 1, 2022
d7c07c9
rename
dantaik Dec 1, 2022
bc8d635
Update TaikoL1.sol
dantaik Dec 1, 2022
a49ae35
Update TaikoL1.sol
dantaik Dec 1, 2022
2164d02
Update TkoToken.sol
dantaik Dec 1, 2022
2d84da8
Update TkoToken.sol
dantaik Dec 1, 2022
cd4c2b6
error messages
dantaik Dec 1, 2022
4080ba6
Revert "error messages"
dantaik Dec 1, 2022
69e6dc7
Revert "Update TkoToken.sol"
dantaik Dec 1, 2022
d24464d
more
dantaik Dec 1, 2022
9c335dc
more
dantaik Dec 1, 2022
b422d69
Merge branch 'tokenomics_impl' into copy_impl_tokenomics
dantaik Dec 2, 2022
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,8 @@ dist
# vscode
.vscode/

.pdf
# python
__pycache__/

# whitepaper
.pdf
2 changes: 2 additions & 0 deletions packages/protocol/.solhintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ contracts/aux/tokens/ERC20Upgradeable.sol
contracts/test/TestLibRLPReader.sol
contracts/test/TestLibRLPWriter.sol
contracts/libs/Lib1559Math.sol
contracts/libs/LibAddress.sol
contracts/libs/LibMath.sol
**/contracts/thirdparty/**/*.sol
59 changes: 43 additions & 16 deletions packages/protocol/contracts/L1/LibData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,22 @@ library LibData {
uint64 commitSlot;
}

// 3 slots
struct ProposedBlock {
bytes32 metaHash;
uint256 deposit;
address proposer;
uint64 proposedAt;
}

// 3 + n slots
struct ForkChoice {
bytes32 blockHash;
uint64 proposedAt;
uint64 provenAt;
address[] provers;
}

// This struct takes 9 slots.
struct State {
// block id => block hash
mapping(uint256 => bytes32) l2Hashes;
Expand All @@ -46,39 +51,61 @@ library LibData {
mapping(uint256 => mapping(bytes32 => ForkChoice)) forkChoices;
// proposer => commitSlot => hash(commitHash, commitHeight)
mapping(address => mapping(uint256 => bytes32)) commits;
mapping(address => bool) provers; // Whitelisted provers
uint64 statusBits;
// Never or rarely changed
uint64 genesisHeight;
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.
uint64 avgBlockTime; // The block time moving average
uint64 __avgGasLimit; // the block gaslimit moving average, not updated.
// Changed when a block is proven/finalized
uint64 latestVerifiedHeight;
uint64 latestVerifiedId;
uint64 nextBlockId;
uint64 avgProofTime; // the proof time moving average
uint64 __reservedC1;
// Reserved
uint256[42] __gap;
}

struct TentativeState {
mapping(address => bool) proposers; // Whitelisted proposers
mapping(address => bool) provers; // Whitelisted provers
bool whitelistProposers;
bool whitelistProvers;
// // Reserved
uint256[46] __gap;
}

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

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

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

function getStateVariables(
State storage s
State storage state
)
internal
view
Expand All @@ -89,10 +116,10 @@ library LibData {
uint64 nextBlockId
)
{
genesisHeight = s.genesisHeight;
latestVerifiedHeight = s.latestVerifiedHeight;
latestVerifiedId = s.latestVerifiedId;
nextBlockId = s.nextBlockId;
genesisHeight = state.genesisHeight;
latestVerifiedHeight = state.latestVerifiedHeight;
latestVerifiedId = state.latestVerifiedId;
nextBlockId = state.nextBlockId;
}

function hashMetadata(
Expand Down
Loading