[go: nahoru, domu]

Skip to content

Commit

Permalink
feat(protocol): invalidBlock must from golden touch address with 0 ga…
Browse files Browse the repository at this point in the history
…sprice (taikoxyz#482)
  • Loading branch information
dantaik committed Dec 24, 2022
1 parent 552cd22 commit ecb9cc5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
7 changes: 7 additions & 0 deletions packages/protocol/contracts/L2/TaikoL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

import "../common/AddressResolver.sol";
import "../common/IHeaderSync.sol";
import "../libs/LibAnchorSignature.sol";
import "../libs/LibInvalidTxList.sol";
import "../libs/LibConstants.sol";
import "../libs/LibTxDecoder.sol";
Expand Down Expand Up @@ -96,6 +97,12 @@ contract TaikoL2 is AddressResolver, ReentrancyGuard, IHeaderSync {
LibInvalidTxList.Reason hint,
uint256 txIdx
) external {
require(
msg.sender == LibAnchorSignature.K_GOLDEN_TOUCH_ADDRESS,
"L2:sender"
);
require(tx.gasprice == 0, "L2:gasPrice");

LibInvalidTxList.Reason reason = LibInvalidTxList.isTxListInvalid({
encoded: txList,
hint: hint,
Expand Down
2 changes: 0 additions & 2 deletions packages/protocol/test/genesis/generate_genesis.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ echo '
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"arrowGlacierBlock": 0,
"clique": {
"period": 0,
"epoch": 30000
Expand Down
22 changes: 20 additions & 2 deletions packages/protocol/test/genesis/generate_genesis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,28 @@ action("Generate Genesis", function () {

const [bytes, txNums] = await generateMaxSizeInvalidTxList(TaikoL2);

const tx = await TaikoL2.invalidateBlock(
await expect(
TaikoL2.invalidateBlock(
bytes,
5, // hint: TX_INVALID_SIG
0
)
).to.be.revertedWith("L2:sender")

const taikoL2WithGoldenTouchSigner = new hre.ethers.Contract(
TaikoL2Alloc.address,
require("../../artifacts/contracts/L2/TaikoL2.sol/TaikoL2.json").abi,
new hre.ethers.Wallet(
"92954368afd3caa1f3ce3ead0069c1af414054aefe1ef9aeacc1bf426222ce38",
provider
)
)

const tx = await taikoL2WithGoldenTouchSigner.invalidateBlock(
bytes,
5, // hint: TX_INVALID_SIG
0
0,
{ gasPrice: 0 }
);

const receipt = await tx.wait();
Expand Down

0 comments on commit ecb9cc5

Please sign in to comment.