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): disable contracts as msg.sender #13206

Merged
merged 2 commits into from
Feb 23, 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: 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