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): add more protocol/tokenomics tests #12988

Merged
merged 66 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
bd967bf
wip
cyberhorsey Jan 19, 2023
fcf37e7
merge main
cyberhorsey Jan 19, 2023
fcca784
Merge branch 'main' into prover_tests
cyberhorsey Jan 20, 2023
9dba09f
wip
cyberhorsey Jan 20, 2023
f5c9a96
wip: verification largely working
cyberhorsey Jan 21, 2023
44d5371
Merge branch 'main' into prover_tests
cyberhorsey Jan 21, 2023
197ac8e
test to make sure _rewardProvers issues 1 wei when owner has no tko b…
cyberhorsey Jan 21, 2023
f64d08f
send TKO to the prover for tests
cyberhorsey Jan 21, 2023
6873409
Merge branch 'prover_tests' of github.com:taikochain/taiko-mono into …
cyberhorsey Jan 21, 2023
c763aed
Merge branch 'main' into prover_tests
dantaik Jan 24, 2023
b9e9176
wip
cyberhorsey Jan 24, 2023
f6b0a2d
Merge branch 'prover_tests' of github.com:taikochain/taiko-mono into …
cyberhorsey Jan 24, 2023
098df43
tests pass. need refactor + addtl coverage but commit, propose, prove…
cyberhorsey Jan 24, 2023
61f5efb
rm getblockprovers
cyberhorsey Jan 24, 2023
e929e80
add sleep delay utils method, rename some variables
cyberhorsey Jan 24, 2023
1b6383c
helpers
cyberhorsey Jan 24, 2023
def8ae0
clean up tests
cyberhorsey Jan 24, 2023
3f17e2e
rm +1
cyberhorsey Jan 24, 2023
38e9a77
wip
cyberhorsey Jan 24, 2023
365288b
lower blocks so test runs faster, disable auto verification, comment …
cyberhorsey Jan 25, 2023
04792f1
remove async event nature of tests
cyberhorsey Jan 25, 2023
5942f88
Merge branch 'main' into prover_tests
cyberhorsey Jan 25, 2023
cf12914
add multiple proposer/prover test, addtl utils methods
cyberhorsey Jan 26, 2023
4422317
Merge branch 'prover_tests' of github.com:taikochain/taiko-mono into …
cyberhorsey Jan 26, 2023
2036417
merge main
cyberhorsey Jan 26, 2023
59072c0
Update protocol.yml
RogerLamTd Jan 26, 2023
fed052f
Update packages/protocol/test/tokenomics/proofReward.test.ts
cyberhorsey Jan 26, 2023
1730126
test names
cyberhorsey Jan 26, 2023
55787ce
Merge branch 'prover_tests' of github.com:taikochain/taiko-mono into …
cyberhorsey Jan 26, 2023
29bb42c
switch to event emitters
cyberhorsey Jan 26, 2023
ee8cf23
refactor listeners to utils methods
cyberhorsey Jan 26, 2023
6fa8eae
bubble up errors from eventhandlers to main thread
cyberhorsey Jan 26, 2023
07173db
refactor tests to root utils folder so we can reuse this code for Tai…
cyberhorsey Jan 27, 2023
a5dcb69
add taikol1 integration tests and begin refactorign them for more reu…
cyberhorsey Jan 27, 2023
33c8c28
Update packages/protocol/test/tokenomics/proofReward.test.ts
dantaik Jan 30, 2023
0e7ad12
Update packages/protocol/test/tokenomics/blockFee.test.ts
dantaik Jan 30, 2023
01e92d3
Merge branch 'main' into prover_tests
cyberhorsey Jan 30, 2023
1e54971
Merge branch 'main' into prover_tests
cyberhorsey Jan 30, 2023
829ffb9
Merge branch 'prover_tests' of github.com:taikochain/taiko-mono into …
cyberhorsey Jan 30, 2023
b849452
add circuits in to evidence
cyberhorsey Jan 30, 2023
3553849
.
cyberhorsey Jan 30, 2023
9f90310
change logging
cyberhorsey Jan 31, 2023
8fd36e5
forkchoice tests
cyberhorsey Jan 31, 2023
b3f6e51
small change
cyberhorsey Jan 31, 2023
bf3d85f
add channels, much cleaner than events i think?
cyberhorsey Jan 31, 2023
f301a44
simplify tests and refactor to use channels
cyberhorsey Jan 31, 2023
925a1de
Merge branch 'main' into prover_tests
cyberhorsey Jan 31, 2023
5c90d63
fix taikoL1 test for uncle delay
cyberhorsey Jan 31, 2023
fbd23fa
Merge branch 'prover_tests' of github.com:taikochain/taiko-mono into …
cyberhorsey Jan 31, 2023
729d21b
resolve merge conflicts
cyberhorsey Jan 31, 2023
69fc388
Merge branch 'main' into prover_tests
cyberhorsey Feb 1, 2023
0c85966
blockfee uses channel too
cyberhorsey Feb 1, 2023
bc2ff33
libproving + blockfee
cyberhorsey Feb 1, 2023
c4dafbc
Merge branch 'prover_tests' of github.com:taikochain/taiko-mono into …
cyberhorsey Feb 1, 2023
e607137
Merge branch 'main' into prover_tests
cyberhorsey Feb 2, 2023
ab92e88
Merge branch 'main' into prover_tests
dantaik Feb 2, 2023
c3a56e6
comments
cyberhorsey Feb 2, 2023
88aa015
try finally in proposer
cyberhorsey Feb 2, 2023
005d5f5
Merge branch 'prover_tests' of github.com:taikochain/taiko-mono into …
cyberhorsey Feb 2, 2023
08ef465
reusable integration fixture, test for latestSyncedHeader bug regress…
cyberhorsey Feb 2, 2023
de2b215
add test:all script so all tests can be run before pushing to verify …
cyberhorsey Feb 2, 2023
ba94085
propose/verify halt tests, refactor, halt utils method
cyberhorsey Feb 2, 2023
cdc70d8
chan/config to integrations fixture
cyberhorsey Feb 2, 2023
6de3a2c
add proposer/prover to fixture for re-use
cyberhorsey Feb 2, 2023
a064c56
test fix
cyberhorsey Feb 3, 2023
b965a57
test check maxnum
cyberhorsey Feb 3, 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
Prev Previous commit
Next Next commit
add proposer/prover to fixture for re-use
  • Loading branch information
cyberhorsey committed Feb 2, 2023
commit 6de3a2c93dab4ea5502e8eaff0e4ccedbefe4a38
12 changes: 2 additions & 10 deletions packages/protocol/test/tokenomics/blockFee.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe("tokenomics: blockFee", function () {
let chan: SimpleChannel<number>;
/* eslint-disable-next-line */
let config: Awaited<ReturnType<TaikoL1["getConfig"]>>;
let proposer: Proposer;

beforeEach(async () => {
({
Expand All @@ -36,6 +37,7 @@ describe("tokenomics: blockFee", function () {
interval,
chan,
config,
proposer,
} = await initIntegrationFixture(true, true));
});

Expand Down Expand Up @@ -65,16 +67,6 @@ describe("tokenomics: blockFee", function () {
});

it("proposes blocks on interval, blockFee should increase, proposer's balance for TKOToken should decrease as it pays proposer fee, proofReward should increase since more slots are used and no proofs have been submitted", async function () {
// set up a proposer to continually propose new blocks
const proposer = new Proposer(
taikoL1.connect(proposerSigner),
l2Provider,
config.commitConfirmations.toNumber(),
config.maxNumBlocks.toNumber(),
0,
proposerSigner
);

// get the initial tkoBalance, which should decrease every block proposal
let lastProposerTkoBalance = await tkoTokenL1.balanceOf(
await proposerSigner.getAddress()
Expand Down
27 changes: 4 additions & 23 deletions packages/protocol/test/tokenomics/proofReward.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ describe("tokenomics: proofReward", function () {
let taikoL1: TaikoL1;
let l2Provider: ethers.providers.JsonRpcProvider;
let l1Signer: any;
let proposerSigner: any;
let proverSigner: any;
let genesisHeight: number;
let tkoTokenL1: TestTkoToken;
let interval: any;
let chan: SimpleChannel<number>;
let proposer: Proposer;
let prover: Prover;

/* eslint-disable-next-line */
let config: Awaited<ReturnType<TaikoL1["getConfig"]>>;
Expand All @@ -30,13 +31,14 @@ describe("tokenomics: proofReward", function () {
taikoL1,
l2Provider,
l1Signer,
proposerSigner,
proverSigner,
genesisHeight,
tkoTokenL1,
interval,
chan,
config,
proposer,
prover,
} = await initIntegrationFixture(true, true));
});

Expand All @@ -47,16 +49,6 @@ describe("tokenomics: proofReward", function () {
});

it(`proofReward is 1 wei if the prover does not hold any tkoTokens on L1`, async function () {
const proposer = new Proposer(
taikoL1.connect(proposerSigner),
l2Provider,
config.commitConfirmations.toNumber(),
config.maxNumBlocks.toNumber(),
0,
proposerSigner
);

const prover = new Prover(taikoL1, l2Provider, proverSigner);
let proposed: boolean = false;
l2Provider.on("block", function (blockNumber: number) {
if (proposed) {
Expand Down Expand Up @@ -100,17 +92,6 @@ describe("tokenomics: proofReward", function () {
the provers TKO balance should increase as the blocks are verified and
they receive the proofReward.
the proposer should receive a refund on his deposit because he holds a tkoBalance > 0 at time of verification.`, async function () {
const proposer = new Proposer(
taikoL1.connect(proposerSigner),
l2Provider,
config.commitConfirmations.toNumber(),
config.maxNumBlocks.toNumber(),
0,
proposerSigner
);

const prover = new Prover(taikoL1, l2Provider, proverSigner);

// prover needs TKO or their reward will be cut down to 1 wei.
await (
await tkoTokenL1
Expand Down
15 changes: 15 additions & 0 deletions packages/protocol/test/utils/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import deployTkoToken from "./tkoToken";
import { ethers as hardhatEthers } from "hardhat";
import { createAndSeedWallets, sendTinyEtherToZeroAddress } from "./seed";
import { SimpleChannel } from "channel-ts";
import Proposer from "./proposer";
import Prover from "./prover";

async function initIntegrationFixture(
mintTkoToProposer: boolean,
Expand Down Expand Up @@ -97,6 +99,17 @@ async function initIntegrationFixture(

const chan = new SimpleChannel<number>();
const config = await taikoL1.getConfig();

const proposer = new Proposer(
taikoL1.connect(proposerSigner),
l2Provider,
config.commitConfirmations.toNumber(),
config.maxNumBlocks.toNumber(),
0,
proposerSigner
);

const prover = new Prover(taikoL1, l2Provider, proverSigner);
return {
taikoL1,
taikoL2,
Expand All @@ -113,6 +126,8 @@ async function initIntegrationFixture(
interval,
chan,
config,
proposer,
prover,
};
}

Expand Down