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(protocol): block reward must be minted #14595

Merged
merged 3 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/TaikoToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ contract TaikoToken is
uint256 amount
)
public
onlyFromNamed("erc20_vault")
onlyFromNamed2("erc20_vault", "taiko")
{
_mint(to, amount);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,13 @@ library LibProposing {
revert L1_TOO_MANY_BLOCKS();
}

TaikoToken tt = TaikoToken(resolver.resolve("taiko_token", false));
if (state.taikoTokenBalances[assignment.prover] >= config.proofBond) {
unchecked {
state.taikoTokenBalances[assignment.prover] -= config.proofBond;
}
} else {
TaikoToken(resolver.resolve("taiko_token", false)).transferFrom(
assignment.prover, address(this), config.proofBond
);
tt.transferFrom(assignment.prover, address(this), config.proofBond);
}

// Pay prover after verifying assignment
Expand Down Expand Up @@ -138,7 +137,8 @@ library LibProposing {
config.proposerRewardMax
);

state.taikoTokenBalances[input.beneficiary] += reward;
// Reward must be minted
tt.mint(input.beneficiary, reward);
davidtaikocha marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions packages/protocol/contracts/common/AddressResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ abstract contract AddressResolver {
_;
}

/// @dev Modifier that ensures the caller is the resolved address of two
/// given names.
/// @param name1 The first name to check against.
/// @param name2 The second name to check against.
modifier onlyFromNamed2(bytes32 name1, bytes32 name2) {
if (
msg.sender != resolve(name1, true)
&& msg.sender != resolve(name2, true)
) revert RESOLVER_DENIED();
_;
}

/// @notice Resolves a name to its address on the current chain.
/// @param name Name whose address is to be resolved.
/// @param allowZeroAddress If set to true, does not throw if the resolved
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/tokenvault/BridgedERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ contract BridgedERC20 is
uint256 amount
)
public
onlyFromNamed("erc20_vault")
onlyFromNamed2("erc20_vault", "taiko")
{
_mint(account, amount);
emit Transfer(address(0), account, amount);
Expand Down
4 changes: 1 addition & 3 deletions packages/protocol/test/L1/TaikoL1Oracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ contract TaikoL1OracleTest is TaikoL1TestBase {

bytes32 parentHash = GENESIS_BLOCK_HASH;
for (
uint256 blockId = 1;
blockId < conf.blockMaxProposals * 10;
blockId++
uint256 blockId = 1; blockId < conf.blockMaxProposals * 9; blockId++
dantaik marked this conversation as resolved.
Show resolved Hide resolved
) {
printVariables("before propose");
TaikoData.BlockMetadata memory meta =
Expand Down