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 reward and fee fields to events #13808

Merged
merged 2 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions packages/protocol/contracts/L1/TaikoEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {TaikoData} from "./TaikoData.sol";

abstract contract TaikoEvents {
// The following events must match the definitions in corresponding L1 libraries.
event BlockProposed(uint256 indexed id, TaikoData.BlockMetadata meta);
event BlockProposed(uint256 indexed id, TaikoData.BlockMetadata meta, uint64 blockFee);

event BlockProven(
uint256 indexed id,
Expand All @@ -21,7 +21,7 @@ abstract contract TaikoEvents {
uint32 parentGasUsed
);

event BlockVerified(uint256 indexed id, bytes32 blockHash);
event BlockVerified(uint256 indexed id, bytes32 blockHash, uint64 reward);

event EthDeposited(TaikoData.EthDeposit deposit);

Expand Down
11 changes: 6 additions & 5 deletions packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ library LibProposing {
using LibAddress for address payable;
using LibUtils for TaikoData.State;

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

error L1_BLOCK_ID();
error L1_INSUFFICIENT_TOKEN();
Expand Down Expand Up @@ -78,17 +78,18 @@ library LibProposing {
blk.metaHash = LibUtils.hashMetadata(meta);
blk.proposer = msg.sender;

if (state.taikoTokenBalances[msg.sender] < state.blockFee) {
uint64 blockFee = state.blockFee;
if (state.taikoTokenBalances[msg.sender] < blockFee) {
revert L1_INSUFFICIENT_TOKEN();
}

unchecked {
state.taikoTokenBalances[msg.sender] -= state.blockFee;
state.accBlockFees += state.blockFee;
state.taikoTokenBalances[msg.sender] -= blockFee;
state.accBlockFees += blockFee;
state.accProposedAt += meta.timestamp;
}

emit BlockProposed(state.numBlocks, meta);
emit BlockProposed(state.numBlocks, meta, blockFee);
unchecked {
++state.numBlocks;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/protocol/contracts/L1/libs/LibVerifying.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ library LibVerifying {
using SafeCastUpgradeable for uint256;
using LibUtils for TaikoData.State;

event BlockVerified(uint256 indexed id, bytes32 blockHash);
event BlockVerified(uint256 indexed id, bytes32 blockHash, uint64 reward);

event CrossChainSynced(uint256 indexed srcHeight, bytes32 blockHash, bytes32 signalRoot);

Expand Down Expand Up @@ -65,7 +65,7 @@ library LibVerifying {
fc.blockHash = genesisBlockHash;
fc.provenAt = timeNow;

emit BlockVerified(0, genesisBlockHash);
emit BlockVerified(0, genesisBlockHash, 0);
}

function verifyBlocks(
Expand Down Expand Up @@ -183,6 +183,6 @@ library LibVerifying {
blk.nextForkChoiceId = 1;
blk.verifiedForkChoiceId = fcId;

emit BlockVerified(blk.blockId, fc.blockHash);
emit BlockVerified(blk.blockId, fc.blockHash, reward);
}
}