Skip to content

Commit

Permalink
feat(protocol): disable contracts as msg.sender (#13206)
Browse files Browse the repository at this point in the history
Co-authored-by: jeff <113397187+cyberhorsey@users.noreply.github.com>
  • Loading branch information
dantaik and cyberhorsey committed Feb 23, 2023
1 parent 8908d8d commit 66316e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/protocol/contracts/L1/TaikoCustomErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ abstract contract TaikoCustomErrors {
error L1_CIRCUIT_LENGTH();
error L1_COMMITTED();
error L1_CONFLICT_PROOF();
error L1_CONTRACT_NOT_ALLOWED();
error L1_DUP_PROVERS();
error L1_EXTRA_DATA();
error L1_GAS_LIMIT();
error L1_HALTED();
error L1_HALT_CONDITION();
error L1_ID();
error L1_INPUT_SIZE();
error L1_INVALID_PARAM();
error L1_METADATA_FIELD();
error L1_META_MISMATCH();
error L1_NOT_COMMITTED();
Expand Down
15 changes: 10 additions & 5 deletions packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ contract TaikoL1 is
TaikoData.State public state;
uint256[100] private __gap;

error L1_INVALID_PARAM();
modifier onlyFromEOA() {
if (msg.sender != tx.origin) revert L1_CONTRACT_NOT_ALLOWED();
_;
}

function init(
address _addressManager,
Expand Down Expand Up @@ -83,7 +86,9 @@ contract TaikoL1 is
* n transactions in `txList`, then there will be up to n+1
* transactions in the L2 block.
*/
function proposeBlock(bytes[] calldata inputs) external nonReentrant {
function proposeBlock(
bytes[] calldata inputs
) external onlyFromEOA nonReentrant {
TaikoData.Config memory config = getConfig();
LibProposing.proposeBlock({
state: state,
Expand Down Expand Up @@ -118,7 +123,7 @@ contract TaikoL1 is
function proveBlock(
uint256 blockId,
bytes[] calldata inputs
) external nonReentrant {
) external onlyFromEOA nonReentrant {
TaikoData.Config memory config = getConfig();
LibProving.proveBlock({
state: state,
Expand Down Expand Up @@ -153,7 +158,7 @@ contract TaikoL1 is
function proveBlockInvalid(
uint256 blockId,
bytes[] calldata inputs
) external nonReentrant {
) external onlyFromEOA nonReentrant {
TaikoData.Config memory config = getConfig();

LibProving.proveBlockInvalid({
Expand All @@ -176,7 +181,7 @@ contract TaikoL1 is
* Verify up to N blocks.
* @param maxBlocks Max number of blocks to verify.
*/
function verifyBlocks(uint256 maxBlocks) external nonReentrant {
function verifyBlocks(uint256 maxBlocks) external onlyFromEOA nonReentrant {
if (maxBlocks == 0) revert L1_INVALID_PARAM();
LibVerifying.verifyBlocks({
state: state,
Expand Down

0 comments on commit 66316e9

Please sign in to comment.