Skip to content

Commit

Permalink
fix(protocol): block reward must be minted (#14595)
Browse files Browse the repository at this point in the history
Co-authored-by: adaki2004 <[email protected]>
  • Loading branch information
dantaik and adaki2004 authored Aug 28, 2023
1 parent a42c17a commit e92b1da
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
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);
}
}
}
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++
) {
printVariables("before propose");
TaikoData.BlockMetadata memory meta =
Expand Down

0 comments on commit e92b1da

Please sign in to comment.