Compare commits

..

8 Commits

Author SHA1 Message Date
Steven
09d7764dcb fix: upgrade libzkp to use scroll-prover v0.5.6 (#744) 2023-08-07 12:26:19 +08:00
Xi Lin
4cd199b3b3 test(contracts): add unit tests when num txs < num L1 msgs (#742)
Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
2023-08-07 05:13:04 +02:00
Péter Garamvölgyi
ced64e8563 refactor: remove debug log (#743) 2023-08-06 21:56:43 +02:00
Péter Garamvölgyi
336d76e0dc fix: Consider skipped messages in block.numTransaction encoding (#741) 2023-08-06 21:45:58 +02:00
Péter Garamvölgyi
a0ca0e6295 feat: commit batch extra logs (#740) 2023-08-06 21:06:35 +02:00
HAOYUatHZ
9f73554b31 fix(libzkp): pin ethers-core version (#739)
Co-authored-by: Your Name <you@example.com>
2023-08-07 01:03:27 +08:00
Péter Garamvölgyi
44c7d75544 refactor: make failed batch proof log more explicit (#738)
Co-authored-by: georgehao <haohongfan@gmail.com>
2023-08-06 18:09:05 +02:00
Xi Lin
f1073e7d13 refactor(contracts): OZ-L1-N03 Events Should Emit Old and New Value (#673)
Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
2023-08-06 14:18:13 +02:00
36 changed files with 272 additions and 172 deletions

View File

@@ -496,6 +496,25 @@ func (r *Layer2Relayer) ProcessCommittedBatches() {
success = true
r.processingFinalization.Store(txID, hash)
case types.ProvingTaskFailed:
// We were unable to prove this batch. There are two possibilities:
// (a) Prover bug. In this case, we should fix and redeploy the prover.
// In the meantime, we continue to commit batches to L1 as well as
// proposing and proving chunks and batches.
// (b) Unprovable batch, e.g. proof overflow. In this case we need to
// stop the ledger, fix the limit, revert all the violating blocks,
// chunks and batches and all subsequent ones, and resume, i.e. this
// case requires manual resolution.
log.Error(
"batch proving failed",
"Index", batch.Index,
"Hash", batch.Hash,
"ProverAssignedAt", batch.ProverAssignedAt,
"ProvedAt", batch.ProvedAt,
"ProofTimeSec", batch.ProofTimeSec,
)
return
default:
log.Error("encounter unreachable case in ProcessCommittedBatches", "proving status", status)
}

View File

@@ -32,7 +32,7 @@ dependencies = [
[[package]]
name = "aggregator"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.3#2c8c749b3e4a61e89028289f4ff93157c5671d7b"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.6#aa2d252c260781e5ddfa309b36f7543df68d142e"
dependencies = [
"ark-std",
"env_logger 0.10.0",
@@ -432,7 +432,7 @@ checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1"
[[package]]
name = "bus-mapping"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.3#2c8c749b3e4a61e89028289f4ff93157c5671d7b"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.6#aa2d252c260781e5ddfa309b36f7543df68d142e"
dependencies = [
"eth-types",
"ethers-core",
@@ -630,9 +630,12 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
[[package]]
name = "convert_case"
version = "0.5.0"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb4a24b1aaf0fd0ce8b45161144d6f42cd91677fd5940fd431183eb023b3a2b8"
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "core-foundation-sys"
@@ -1045,7 +1048,7 @@ dependencies = [
[[package]]
name = "eth-types"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.3#2c8c749b3e4a61e89028289f4ff93157c5671d7b"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.6#aa2d252c260781e5ddfa309b36f7543df68d142e"
dependencies = [
"ethers-core",
"ethers-signers",
@@ -1138,13 +1141,12 @@ dependencies = [
[[package]]
name = "ethers-core"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ebdd63c828f58aa067f40f9adcbea5e114fb1f90144b3a1e2858e0c9b1ff4e8"
source = "git+https://github.com/scroll-tech/ethers-rs.git?branch=v0.17.0#739ec9a0df8daf536937739c87e85612bd73212f"
dependencies = [
"arrayvec",
"bytes",
"chrono",
"convert_case 0.5.0",
"convert_case 0.6.0",
"elliptic-curve",
"ethabi",
"fastrlp",
@@ -1223,7 +1225,7 @@ dependencies = [
[[package]]
name = "external-tracer"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.3#2c8c749b3e4a61e89028289f4ff93157c5671d7b"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.6#aa2d252c260781e5ddfa309b36f7543df68d142e"
dependencies = [
"eth-types",
"geth-utils",
@@ -1436,7 +1438,7 @@ dependencies = [
[[package]]
name = "gadgets"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.3#2c8c749b3e4a61e89028289f4ff93157c5671d7b"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.6#aa2d252c260781e5ddfa309b36f7543df68d142e"
dependencies = [
"digest 0.7.6",
"eth-types",
@@ -1476,7 +1478,7 @@ dependencies = [
[[package]]
name = "geth-utils"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.3#2c8c749b3e4a61e89028289f4ff93157c5671d7b"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.6#aa2d252c260781e5ddfa309b36f7543df68d142e"
dependencies = [
"env_logger 0.9.3",
"gobuild 0.1.0-alpha.2 (git+https://github.com/scroll-tech/gobuild.git)",
@@ -2074,7 +2076,7 @@ dependencies = [
[[package]]
name = "keccak256"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.3#2c8c749b3e4a61e89028289f4ff93157c5671d7b"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.6#aa2d252c260781e5ddfa309b36f7543df68d142e"
dependencies = [
"env_logger 0.9.3",
"eth-types",
@@ -2261,7 +2263,7 @@ dependencies = [
[[package]]
name = "mock"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.3#2c8c749b3e4a61e89028289f4ff93157c5671d7b"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.6#aa2d252c260781e5ddfa309b36f7543df68d142e"
dependencies = [
"eth-types",
"ethers-core",
@@ -2276,7 +2278,7 @@ dependencies = [
[[package]]
name = "mpt-zktrie"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.3#2c8c749b3e4a61e89028289f4ff93157c5671d7b"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.6#aa2d252c260781e5ddfa309b36f7543df68d142e"
dependencies = [
"bus-mapping",
"eth-types",
@@ -2752,7 +2754,7 @@ dependencies = [
[[package]]
name = "prover"
version = "0.4.0"
source = "git+https://github.com/scroll-tech/scroll-prover?tag=v0.5.3#337089ac40bac756d88b9ae30a3be1f82538b216"
source = "git+https://github.com/scroll-tech/scroll-prover?tag=v0.5.6#e4ac08a856684de12ce4fe8ce4f3fb7f45f87043"
dependencies = [
"aggregator",
"anyhow",
@@ -4037,7 +4039,7 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]]
name = "types"
version = "0.4.0"
source = "git+https://github.com/scroll-tech/scroll-prover?tag=v0.5.3#337089ac40bac756d88b9ae30a3be1f82538b216"
source = "git+https://github.com/scroll-tech/scroll-prover?tag=v0.5.6#e4ac08a856684de12ce4fe8ce4f3fb7f45f87043"
dependencies = [
"base64 0.13.1",
"blake2",
@@ -4082,6 +4084,12 @@ dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-segmentation"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
[[package]]
name = "unicode-xid"
version = "0.2.4"
@@ -4482,7 +4490,7 @@ checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9"
[[package]]
name = "zkevm-circuits"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.3#2c8c749b3e4a61e89028289f4ff93157c5671d7b"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.6#aa2d252c260781e5ddfa309b36f7543df68d142e"
dependencies = [
"array-init",
"bus-mapping",

View File

@@ -7,6 +7,8 @@ edition = "2021"
[lib]
crate-type = ["cdylib"]
[patch.crates-io]
ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v0.17.0" }
[patch."https://github.com/privacy-scaling-explorations/halo2.git"]
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "develop" }
[patch."https://github.com/privacy-scaling-explorations/poseidon.git"]
@@ -18,8 +20,8 @@ maingate = { git = "https://github.com/scroll-tech/halo2wrong", branch = "halo2-
halo2curves = { git = "https://github.com/scroll-tech/halo2curves.git", branch = "0.3.1-derive-serde" }
[dependencies]
prover = { git = "https://github.com/scroll-tech/scroll-prover", tag = "v0.5.3" }
types = { git = "https://github.com/scroll-tech/scroll-prover", tag = "v0.5.3" }
prover = { git = "https://github.com/scroll-tech/scroll-prover", tag = "v0.5.6" }
types = { git = "https://github.com/scroll-tech/scroll-prover", tag = "v0.5.6" }
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "develop" }
log = "0.4"

View File

@@ -169,7 +169,7 @@ func TestBatchHeaderEncode(t *testing.T) {
assert.NotNil(t, batchHeader)
bytes = batchHeader.Encode()
assert.Equal(t, 121, len(bytes))
assert.Equal(t, "010000000000000001000000000000000b000000000000000b457a9e90e8e51ba2de2f66c6b589540b88cf594dac7fa7d04b99cdcfecf24e384136709aabc8a23aa17fbcc833da2f7857d3c2884feec9aae73429c135f9498500000000000000000000000000000000000000000000000000000000000003ff", common.Bytes2Hex(bytes))
assert.Equal(t, "010000000000000001000000000000000b000000000000000b34f419ce7e882295bdb5aec6cce56ffa788a5fed4744d7fbd77e4acbf409f1ca4136709aabc8a23aa17fbcc833da2f7857d3c2884feec9aae73429c135f9498500000000000000000000000000000000000000000000000000000000000003ff", common.Bytes2Hex(bytes))
}
func TestBatchHeaderHash(t *testing.T) {
@@ -230,7 +230,7 @@ func TestBatchHeaderHash(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, batchHeader)
hash = batchHeader.Hash()
assert.Equal(t, "0ec9547c6645d5f0c1254e121f49e93f54525cfda5bfb2236440fb3470f48902", common.Bytes2Hex(hash.Bytes()))
assert.Equal(t, "1c3007880f0eafe74572ede7d164ff1ee5376e9ac9bff6f7fb837b2630cddc9a", common.Bytes2Hex(hash.Bytes()))
}
func TestBatchHeaderDecode(t *testing.T) {

View File

@@ -36,6 +36,17 @@ func (w *WrappedBlock) NumL1Messages(totalL1MessagePoppedBefore uint64) uint64 {
return *lastQueueIndex - totalL1MessagePoppedBefore + 1
}
// NumL2Transactions returns the number of L2 transactions in this block.
func (w *WrappedBlock) NumL2Transactions() uint64 {
var count uint64
for _, txData := range w.Transactions {
if txData.Type != types.L1MessageTxType {
count++
}
}
return count
}
// Encode encodes the WrappedBlock into RollupV2 BlockContext Encoding.
func (w *WrappedBlock) Encode(totalL1MessagePoppedBefore uint64) ([]byte, error) {
bytes := make([]byte, 60)
@@ -43,20 +54,25 @@ func (w *WrappedBlock) Encode(totalL1MessagePoppedBefore uint64) ([]byte, error)
if !w.Header.Number.IsUint64() {
return nil, errors.New("block number is not uint64")
}
if len(w.Transactions) > math.MaxUint16 {
return nil, errors.New("number of transactions exceeds max uint16")
}
// note: numL1Messages includes skipped messages
numL1Messages := w.NumL1Messages(totalL1MessagePoppedBefore)
if numL1Messages > math.MaxUint16 {
return nil, errors.New("number of L1 messages exceeds max uint16")
}
// note: numTransactions includes skipped messages
numL2Transactions := w.NumL2Transactions()
numTransactions := numL1Messages + numL2Transactions
if numTransactions > math.MaxUint16 {
return nil, errors.New("number of transactions exceeds max uint16")
}
binary.BigEndian.PutUint64(bytes[0:], w.Header.Number.Uint64())
binary.BigEndian.PutUint64(bytes[8:], w.Header.Time)
// TODO: [16:47] Currently, baseFee is 0, because we disable EIP-1559.
binary.BigEndian.PutUint64(bytes[48:], w.Header.GasLimit)
binary.BigEndian.PutUint16(bytes[56:], uint16(len(w.Transactions)))
binary.BigEndian.PutUint16(bytes[56:], uint16(numTransactions))
binary.BigEndian.PutUint16(bytes[58:], uint16(numL1Messages))
return bytes, nil

View File

@@ -65,9 +65,10 @@ func TestChunkEncode(t *testing.T) {
hexString = hex.EncodeToString(bytes)
assert.NoError(t, err)
assert.Equal(t, 97, len(bytes))
assert.Equal(t, "01000000000000000d00000000646b6e13000000000000000000000000000000000000000000000000000000000000000000000000007a12000002000b00000020df0b80825dc0941a258d17bf244c4df02d40343a7626a9d321e1058080808080", hexString)
assert.Equal(t, "01000000000000000d00000000646b6e13000000000000000000000000000000000000000000000000000000000000000000000000007a1200000c000b00000020df0b80825dc0941a258d17bf244c4df02d40343a7626a9d321e1058080808080", hexString)
// Test case 5: when the chunk contains two blocks each with 1 L1MsgTx
// TODO: revise this test, we cannot reuse the same L1MsgTx twice
chunk = &Chunk{
Blocks: []*WrappedBlock{
wrappedBlock2,
@@ -78,7 +79,7 @@ func TestChunkEncode(t *testing.T) {
hexString = hex.EncodeToString(bytes)
assert.NoError(t, err)
assert.Equal(t, 193, len(bytes))
assert.Equal(t, "02000000000000000d00000000646b6e13000000000000000000000000000000000000000000000000000000000000000000000000007a12000002000b000000000000000d00000000646b6e13000000000000000000000000000000000000000000000000000000000000000000000000007a12000002000000000020df0b80825dc0941a258d17bf244c4df02d40343a7626a9d321e105808080808000000020df0b80825dc0941a258d17bf244c4df02d40343a7626a9d321e1058080808080", hexString)
assert.Equal(t, "02000000000000000d00000000646b6e13000000000000000000000000000000000000000000000000000000000000000000000000007a1200000c000b000000000000000d00000000646b6e13000000000000000000000000000000000000000000000000000000000000000000000000007a12000001000000000020df0b80825dc0941a258d17bf244c4df02d40343a7626a9d321e105808080808000000020df0b80825dc0941a258d17bf244c4df02d40343a7626a9d321e1058080808080", hexString)
}
func TestChunkHash(t *testing.T) {
@@ -133,5 +134,5 @@ func TestChunkHash(t *testing.T) {
}
hash, err = chunk.Hash(0)
assert.NoError(t, err)
assert.Equal(t, "0x42967825696a129e7a83f082097aca982747480956dcaa448c9296e795c9a91a", hash.Hex())
assert.Equal(t, "0x2eb7dd63bf8fc29a0f8c10d16c2ae6f9da446907c79d50f5c164d30dc8526b60", hash.Hex())
}

View File

@@ -5,7 +5,7 @@ import (
"runtime/debug"
)
var tag = "v4.1.12"
var tag = "v4.1.18"
var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {

View File

@@ -533,7 +533,7 @@ Emitted when some ERC1155 token is refunded.
### UpdateTokenMapping
```solidity
event UpdateTokenMapping(address _l1Token, address _l2Token)
event UpdateTokenMapping(address indexed l1Token, address indexed oldL2Token, address indexed newL2Token)
```
Emitted when token mapping for ERC1155 token is updated.
@@ -544,8 +544,9 @@ Emitted when token mapping for ERC1155 token is updated.
| Name | Type | Description |
|---|---|---|
| _l1Token | address | The address of ERC1155 token on layer 1. |
| _l2Token | address | The address of corresponding ERC1155 token on layer 2. |
| l1Token `indexed` | address | The address of ERC1155 token in layer 1. |
| oldL2Token `indexed` | address | The address of the old corresponding ERC1155 token in layer 2. |
| newL2Token `indexed` | address | The address of the new corresponding ERC1155 token in layer 2. |

View File

@@ -472,7 +472,7 @@ Emitted when some ERC721 token is refunded.
### UpdateTokenMapping
```solidity
event UpdateTokenMapping(address _l1Token, address _l2Token)
event UpdateTokenMapping(address indexed l1Token, address indexed oldL2Token, address indexed newL2Token)
```
Emitted when token mapping for ERC721 token is updated.
@@ -483,8 +483,9 @@ Emitted when token mapping for ERC721 token is updated.
| Name | Type | Description |
|---|---|---|
| _l1Token | address | The address of ERC721 token on layer 1. |
| _l2Token | address | The address of corresponding ERC721 token on layer 2. |
| l1Token `indexed` | address | The address of ERC721 token in layer 1. |
| oldL2Token `indexed` | address | The address of the old corresponding ERC721 token in layer 2. |
| newL2Token `indexed` | address | The address of the new corresponding ERC721 token in layer 2. |

View File

@@ -350,7 +350,7 @@ Request ERC20 token transfer from users to gateways.
### setDefaultERC20Gateway
```solidity
function setDefaultERC20Gateway(address _defaultERC20Gateway) external nonpayable
function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external nonpayable
```
Update the address of default ERC20 gateway contract.
@@ -361,7 +361,7 @@ Update the address of default ERC20 gateway contract.
| Name | Type | Description |
|---|---|---|
| _defaultERC20Gateway | address | The address to update. |
| _newDefaultERC20Gateway | address | undefined |
### setERC20Gateway
@@ -383,7 +383,7 @@ Update the mapping from token address to gateway address.
### setETHGateway
```solidity
function setETHGateway(address _ethGateway) external nonpayable
function setETHGateway(address _newEthGateway) external nonpayable
```
Update the address of ETH gateway contract.
@@ -394,7 +394,7 @@ Update the address of ETH gateway contract.
| Name | Type | Description |
|---|---|---|
| _ethGateway | address | The address to update. |
| _newEthGateway | address | undefined |
### transferOwnership
@@ -567,7 +567,7 @@ Emitted when some ETH is refunded.
### SetDefaultERC20Gateway
```solidity
event SetDefaultERC20Gateway(address indexed defaultERC20Gateway)
event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway)
```
Emitted when the address of default ERC20 Gateway is updated.
@@ -578,12 +578,13 @@ Emitted when the address of default ERC20 Gateway is updated.
| Name | Type | Description |
|---|---|---|
| defaultERC20Gateway `indexed` | address | undefined |
| oldDefaultERC20Gateway `indexed` | address | undefined |
| newDefaultERC20Gateway `indexed` | address | undefined |
### SetERC20Gateway
```solidity
event SetERC20Gateway(address indexed token, address indexed gateway)
event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway)
```
Emitted when the `gateway` for `token` is updated.
@@ -595,12 +596,13 @@ Emitted when the `gateway` for `token` is updated.
| Name | Type | Description |
|---|---|---|
| token `indexed` | address | undefined |
| gateway `indexed` | address | undefined |
| oldGateway `indexed` | address | undefined |
| newGateway `indexed` | address | undefined |
### SetETHGateway
```solidity
event SetETHGateway(address indexed ethGateway)
event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway)
```
Emitted when the address of ETH Gateway is updated.
@@ -611,7 +613,8 @@ Emitted when the address of ETH Gateway is updated.
| Name | Type | Description |
|---|---|---|
| ethGateway `indexed` | address | undefined |
| oldETHGateway `indexed` | address | undefined |
| newEthGateway `indexed` | address | undefined |

View File

@@ -423,7 +423,7 @@ Update fee vault contract.
### updateMaxReplayTimes
```solidity
function updateMaxReplayTimes(uint256 _maxReplayTimes) external nonpayable
function updateMaxReplayTimes(uint256 _newMaxReplayTimes) external nonpayable
```
Update max replay times.
@@ -434,7 +434,7 @@ Update max replay times.
| Name | Type | Description |
|---|---|---|
| _maxReplayTimes | uint256 | The new max replay times. |
| _newMaxReplayTimes | uint256 | The new max replay times. |
### xDomainMessageSender
@@ -595,7 +595,7 @@ Emitted when owner updates fee vault contract.
### UpdateMaxReplayTimes
```solidity
event UpdateMaxReplayTimes(uint256 maxReplayTimes)
event UpdateMaxReplayTimes(uint256 oldMaxReplayTimes, uint256 newMaxReplayTimes)
```
Emitted when the maximum number of times each message can be replayed is updated.
@@ -606,7 +606,8 @@ Emitted when the maximum number of times each message can be replayed is updated
| Name | Type | Description |
|---|---|---|
| maxReplayTimes | uint256 | undefined |
| oldMaxReplayTimes | uint256 | undefined |
| newMaxReplayTimes | uint256 | undefined |

View File

@@ -458,7 +458,7 @@ event OwnershipTransferred(address indexed previousOwner, address indexed newOwn
### UpdateTokenMapping
```solidity
event UpdateTokenMapping(address _l2Token, address _l1Token)
event UpdateTokenMapping(address indexed l2Token, address indexed oldL1Token, address indexed newL1Token)
```
Emitted when token mapping for ERC1155 token is updated.
@@ -469,8 +469,9 @@ Emitted when token mapping for ERC1155 token is updated.
| Name | Type | Description |
|---|---|---|
| _l2Token | address | The address of corresponding ERC1155 token on layer 2. |
| _l1Token | address | The address of ERC1155 token on layer 1. |
| l2Token `indexed` | address | The address of corresponding ERC1155 token in layer 2. |
| oldL1Token `indexed` | address | The address of the old corresponding ERC1155 token in layer 1. |
| newL1Token `indexed` | address | The address of the new corresponding ERC1155 token in layer 1. |
### WithdrawERC1155

View File

@@ -400,7 +400,7 @@ event OwnershipTransferred(address indexed previousOwner, address indexed newOwn
### UpdateTokenMapping
```solidity
event UpdateTokenMapping(address _l2Token, address _l1Token)
event UpdateTokenMapping(address indexed l2Token, address indexed oldL1Token, address indexed newL1Token)
```
Emitted when token mapping for ERC721 token is updated.
@@ -411,8 +411,9 @@ Emitted when token mapping for ERC721 token is updated.
| Name | Type | Description |
|---|---|---|
| _l2Token | address | The address of corresponding ERC721 token on layer 2. |
| _l1Token | address | The address of ERC721 token on layer 1. |
| l2Token `indexed` | address | The address of corresponding ERC721 token in layer 2. |
| oldL1Token `indexed` | address | The address of the old corresponding ERC721 token in layer 1. |
| newL1Token `indexed` | address | The address of the new corresponding ERC721 token in layer 1. |
### WithdrawERC721

View File

@@ -220,7 +220,7 @@ function renounceOwnership() external nonpayable
### setDefaultERC20Gateway
```solidity
function setDefaultERC20Gateway(address _defaultERC20Gateway) external nonpayable
function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external nonpayable
```
Update the address of default ERC20 gateway contract.
@@ -231,7 +231,7 @@ Update the address of default ERC20 gateway contract.
| Name | Type | Description |
|---|---|---|
| _defaultERC20Gateway | address | The address to update. |
| _newDefaultERC20Gateway | address | The address to update. |
### setERC20Gateway
@@ -253,7 +253,7 @@ Update the mapping from token address to gateway address.
### setETHGateway
```solidity
function setETHGateway(address _ethGateway) external nonpayable
function setETHGateway(address _newEthGateway) external nonpayable
```
Update the address of ETH gateway contract.
@@ -264,7 +264,7 @@ Update the address of ETH gateway contract.
| Name | Type | Description |
|---|---|---|
| _ethGateway | address | The address to update. |
| _newEthGateway | address | The address to update. |
### transferOwnership
@@ -473,7 +473,7 @@ event OwnershipTransferred(address indexed previousOwner, address indexed newOwn
### SetDefaultERC20Gateway
```solidity
event SetDefaultERC20Gateway(address indexed defaultERC20Gateway)
event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway)
```
Emitted when the address of default ERC20 Gateway is updated.
@@ -484,12 +484,13 @@ Emitted when the address of default ERC20 Gateway is updated.
| Name | Type | Description |
|---|---|---|
| defaultERC20Gateway `indexed` | address | undefined |
| oldDefaultERC20Gateway `indexed` | address | undefined |
| newDefaultERC20Gateway `indexed` | address | undefined |
### SetERC20Gateway
```solidity
event SetERC20Gateway(address indexed token, address indexed gateway)
event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway)
```
Emitted when the `gateway` for `token` is updated.
@@ -501,12 +502,13 @@ Emitted when the `gateway` for `token` is updated.
| Name | Type | Description |
|---|---|---|
| token `indexed` | address | undefined |
| gateway `indexed` | address | undefined |
| oldGateway `indexed` | address | undefined |
| newGateway `indexed` | address | undefined |
### SetETHGateway
```solidity
event SetETHGateway(address indexed ethGateway)
event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway)
```
Emitted when the address of ETH Gateway is updated.
@@ -517,7 +519,8 @@ Emitted when the address of ETH Gateway is updated.
| Name | Type | Description |
|---|---|---|
| ethGateway `indexed` | address | undefined |
| oldETHGateway `indexed` | address | undefined |
| newEthGateway `indexed` | address | undefined |
### WithdrawERC20

View File

@@ -315,7 +315,7 @@ Update fee vault contract.
### updateMaxFailedExecutionTimes
```solidity
function updateMaxFailedExecutionTimes(uint256 _maxFailedExecutionTimes) external nonpayable
function updateMaxFailedExecutionTimes(uint256 _newMaxFailedExecutionTimes) external nonpayable
```
Update max failed execution times.
@@ -326,7 +326,7 @@ Update max failed execution times.
| Name | Type | Description |
|---|---|---|
| _maxFailedExecutionTimes | uint256 | The new max failed execution times. |
| _newMaxFailedExecutionTimes | uint256 | The new max failed execution times. |
### xDomainMessageSender
@@ -487,7 +487,7 @@ Emitted when owner updates fee vault contract.
### UpdateMaxFailedExecutionTimes
```solidity
event UpdateMaxFailedExecutionTimes(uint256 maxFailedExecutionTimes)
event UpdateMaxFailedExecutionTimes(uint256 oldMaxFailedExecutionTimes, uint256 newMaxFailedExecutionTimes)
```
Emitted when the maximum number of times each message can fail in L2 is updated.
@@ -498,7 +498,8 @@ Emitted when the maximum number of times each message can fail in L2 is updated.
| Name | Type | Description |
|---|---|---|
| maxFailedExecutionTimes | uint256 | The new maximum number of times each message can fail in L2. |
| oldMaxFailedExecutionTimes | uint256 | undefined |
| newMaxFailedExecutionTimes | uint256 | undefined |

View File

@@ -10,8 +10,9 @@ interface IL1ScrollMessenger is IScrollMessenger {
**********/
/// @notice Emitted when the maximum number of times each message can be replayed is updated.
/// @param maxReplayTimes The new maximum number of times each message can be replayed.
event UpdateMaxReplayTimes(uint256 maxReplayTimes);
/// @param oldMaxReplayTimes The old maximum number of times each message can be replayed.
/// @param newMaxReplayTimes The new maximum number of times each message can be replayed.
event UpdateMaxReplayTimes(uint256 oldMaxReplayTimes, uint256 newMaxReplayTimes);
/***********
* Structs *

View File

@@ -293,11 +293,12 @@ contract L1ScrollMessenger is ScrollMessengerBase, IL1ScrollMessenger {
/// @notice Update max replay times.
/// @dev This function can only called by contract owner.
/// @param _maxReplayTimes The new max replay times.
function updateMaxReplayTimes(uint256 _maxReplayTimes) external onlyOwner {
maxReplayTimes = _maxReplayTimes;
/// @param _newMaxReplayTimes The new max replay times.
function updateMaxReplayTimes(uint256 _newMaxReplayTimes) external onlyOwner {
uint256 _oldMaxReplayTimes = maxReplayTimes;
maxReplayTimes = _newMaxReplayTimes;
emit UpdateMaxReplayTimes(_maxReplayTimes);
emit UpdateMaxReplayTimes(_oldMaxReplayTimes, _newMaxReplayTimes);
}
/**********************

View File

@@ -11,17 +11,20 @@ interface IL1GatewayRouter is IL1ETHGateway, IL1ERC20Gateway {
**********/
/// @notice Emitted when the address of ETH Gateway is updated.
/// @param ethGateway The address of new ETH Gateway.
event SetETHGateway(address indexed ethGateway);
/// @param oldETHGateway The address of the old ETH Gateway.
/// @param newEthGateway The address of the new ETH Gateway.
event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway);
/// @notice Emitted when the address of default ERC20 Gateway is updated.
/// @param defaultERC20Gateway The address of new default ERC20 Gateway.
event SetDefaultERC20Gateway(address indexed defaultERC20Gateway);
/// @param oldDefaultERC20Gateway The address of the old default ERC20 Gateway.
/// @param newDefaultERC20Gateway The address of the new default ERC20 Gateway.
event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway);
/// @notice Emitted when the `gateway` for `token` is updated.
/// @param token The address of token updated.
/// @param gateway The corresponding address of gateway updated.
event SetERC20Gateway(address indexed token, address indexed gateway);
/// @param oldGateway The corresponding address of the old gateway.
/// @param newGateway The corresponding address of the new gateway.
event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway);
/*************************
* Public View Functions *

View File

@@ -25,9 +25,10 @@ contract L1CustomERC20Gateway is L1ERC20Gateway {
**********/
/// @notice Emitted when token mapping for ERC20 token is updated.
/// @param _l1Token The address of ERC20 token on layer 1.
/// @param _l2Token The address of corresponding ERC20 token on layer 2.
event UpdateTokenMapping(address _l1Token, address _l2Token);
/// @param l1Token The address of ERC20 token in layer 1.
/// @param oldL2Token The address of the old corresponding ERC20 token in layer 2.
/// @param newL2Token The address of the new corresponding ERC20 token in layer 2.
event UpdateTokenMapping(address indexed l1Token, address indexed oldL2Token, address indexed newL2Token);
/*************
* Variables *
@@ -77,9 +78,10 @@ contract L1CustomERC20Gateway is L1ERC20Gateway {
function updateTokenMapping(address _l1Token, address _l2Token) external onlyOwner {
require(_l2Token != address(0), "token address cannot be 0");
address _oldL2Token = tokenMapping[_l1Token];
tokenMapping[_l1Token] = _l2Token;
emit UpdateTokenMapping(_l1Token, _l2Token);
emit UpdateTokenMapping(_l1Token, _oldL2Token, _l2Token);
}
/**********************

View File

@@ -25,9 +25,10 @@ contract L1ERC1155Gateway is ERC1155HolderUpgradeable, ScrollGatewayBase, IL1ERC
**********/
/// @notice Emitted when token mapping for ERC1155 token is updated.
/// @param _l1Token The address of ERC1155 token on layer 1.
/// @param _l2Token The address of corresponding ERC1155 token on layer 2.
event UpdateTokenMapping(address _l1Token, address _l2Token);
/// @param l1Token The address of ERC1155 token in layer 1.
/// @param oldL2Token The address of the old corresponding ERC1155 token in layer 2.
/// @param newL2Token The address of the new corresponding ERC1155 token in layer 2.
event UpdateTokenMapping(address indexed l1Token, address indexed oldL2Token, address indexed newL2Token);
/*************
* Variables *
@@ -169,9 +170,10 @@ contract L1ERC1155Gateway is ERC1155HolderUpgradeable, ScrollGatewayBase, IL1ERC
function updateTokenMapping(address _l1Token, address _l2Token) external onlyOwner {
require(_l2Token != address(0), "token address cannot be 0");
address _oldL2Token = tokenMapping[_l1Token];
tokenMapping[_l1Token] = _l2Token;
emit UpdateTokenMapping(_l1Token, _l2Token);
emit UpdateTokenMapping(_l1Token, _oldL2Token, _l2Token);
}
/**********************

View File

@@ -25,9 +25,10 @@ contract L1ERC721Gateway is ERC721HolderUpgradeable, ScrollGatewayBase, IL1ERC72
**********/
/// @notice Emitted when token mapping for ERC721 token is updated.
/// @param _l1Token The address of ERC721 token on layer 1.
/// @param _l2Token The address of corresponding ERC721 token on layer 2.
event UpdateTokenMapping(address _l1Token, address _l2Token);
/// @param l1Token The address of ERC721 token in layer 1.
/// @param oldL2Token The address of the old corresponding ERC721 token in layer 2.
/// @param newL2Token The address of the new corresponding ERC721 token in layer 2.
event UpdateTokenMapping(address indexed l1Token, address indexed oldL2Token, address indexed newL2Token);
/*************
* Variables *
@@ -165,9 +166,10 @@ contract L1ERC721Gateway is ERC721HolderUpgradeable, ScrollGatewayBase, IL1ERC72
function updateTokenMapping(address _l1Token, address _l2Token) external onlyOwner {
require(_l2Token != address(0), "token address cannot be 0");
address _oldL2Token = tokenMapping[_l1Token];
tokenMapping[_l1Token] = _l2Token;
emit UpdateTokenMapping(_l1Token, _l2Token);
emit UpdateTokenMapping(_l1Token, _oldL2Token, _l2Token);
}
/**********************

View File

@@ -66,13 +66,13 @@ contract L1GatewayRouter is OwnableUpgradeable, IL1GatewayRouter {
// it can be zero during initialization
if (_defaultERC20Gateway != address(0)) {
defaultERC20Gateway = _defaultERC20Gateway;
emit SetDefaultERC20Gateway(_defaultERC20Gateway);
emit SetDefaultERC20Gateway(address(0), _defaultERC20Gateway);
}
// it can be zero during initialization
if (_ethGateway != address(0)) {
ethGateway = _ethGateway;
emit SetETHGateway(_ethGateway);
emit SetETHGateway(address(0), _ethGateway);
}
}
@@ -223,17 +223,19 @@ contract L1GatewayRouter is OwnableUpgradeable, IL1GatewayRouter {
************************/
/// @inheritdoc IL1GatewayRouter
function setETHGateway(address _ethGateway) external onlyOwner {
ethGateway = _ethGateway;
function setETHGateway(address _newEthGateway) external onlyOwner {
address _oldETHGateway = ethGateway;
ethGateway = _newEthGateway;
emit SetETHGateway(_ethGateway);
emit SetETHGateway(_oldETHGateway, _newEthGateway);
}
/// @inheritdoc IL1GatewayRouter
function setDefaultERC20Gateway(address _defaultERC20Gateway) external onlyOwner {
defaultERC20Gateway = _defaultERC20Gateway;
function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external onlyOwner {
address _oldDefaultERC20Gateway = defaultERC20Gateway;
defaultERC20Gateway = _newDefaultERC20Gateway;
emit SetDefaultERC20Gateway(_defaultERC20Gateway);
emit SetDefaultERC20Gateway(_oldDefaultERC20Gateway, _newDefaultERC20Gateway);
}
/// @inheritdoc IL1GatewayRouter
@@ -241,9 +243,10 @@ contract L1GatewayRouter is OwnableUpgradeable, IL1GatewayRouter {
require(_tokens.length == _gateways.length, "length mismatch");
for (uint256 i = 0; i < _tokens.length; i++) {
address _oldGateway = ERC20Gateway[_tokens[i]];
ERC20Gateway[_tokens[i]] = _gateways[i];
emit SetERC20Gateway(_tokens[i], _gateways[i]);
emit SetERC20Gateway(_tokens[i], _oldGateway, _gateways[i]);
}
}
}

View File

@@ -24,12 +24,12 @@ contract L1MessageQueue is OwnableUpgradeable, IL1MessageQueue {
/// @notice Emitted when owner updates gas oracle contract.
/// @param _oldGasOracle The address of old gas oracle contract.
/// @param _newGasOracle The address of new gas oracle contract.
event UpdateGasOracle(address _oldGasOracle, address _newGasOracle);
event UpdateGasOracle(address indexed _oldGasOracle, address indexed _newGasOracle);
/// @notice Emitted when owner updates EnforcedTxGateway contract.
/// @param _oldGateway The address of old EnforcedTxGateway contract.
/// @param _newGateway The address of new EnforcedTxGateway contract.
event UpdateEnforcedTxGateway(address _oldGateway, address _newGateway);
event UpdateEnforcedTxGateway(address indexed _oldGateway, address indexed _newGateway);
/// @notice Emitted when owner updates max gas limit.
/// @param _oldMaxGasLimit The old max gas limit.

View File

@@ -19,8 +19,9 @@ contract L2GasPriceOracle is OwnableUpgradeable, IL2GasPriceOracle {
event UpdateWhitelist(address _oldWhitelist, address _newWhitelist);
/// @notice Emitted when current l2 base fee is updated.
/// @param l2BaseFee The current l2 base fee updated.
event L2BaseFeeUpdated(uint256 l2BaseFee);
/// @param oldL2BaseFee The original l2 base fee before update.
/// @param newL2BaseFee The current l2 base fee updated.
event L2BaseFeeUpdated(uint256 oldL2BaseFee, uint256 newL2BaseFee);
/// @notice Emitted when intrinsic params are updated.
/// @param txGas The intrinsic gas for transaction.
@@ -130,13 +131,14 @@ contract L2GasPriceOracle is OwnableUpgradeable, IL2GasPriceOracle {
}
/// @notice Allows the owner to modify the l2 base fee.
/// @param _l2BaseFee The new l2 base fee.
function setL2BaseFee(uint256 _l2BaseFee) external {
/// @param _newL2BaseFee The new l2 base fee.
function setL2BaseFee(uint256 _newL2BaseFee) external {
require(whitelist.isSenderAllowed(msg.sender), "Not whitelisted sender");
l2BaseFee = _l2BaseFee;
uint256 _oldL2BaseFee = l2BaseFee;
l2BaseFee = _newL2BaseFee;
emit L2BaseFeeUpdated(_l2BaseFee);
emit L2BaseFeeUpdated(_oldL2BaseFee, _newL2BaseFee);
}
/************************

View File

@@ -34,7 +34,7 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
/// @notice Emitted when the address of rollup verifier is updated.
/// @param oldVerifier The address of old rollup verifier.
/// @param newVerifier The address of new rollup verifier.
event UpdateVerifier(address oldVerifier, address newVerifier);
event UpdateVerifier(address indexed oldVerifier, address indexed newVerifier);
/// @notice Emitted when the value of `maxNumL2TxInChunk` is updated.
/// @param oldMaxNumL2TxInChunk The old value of `maxNumL2TxInChunk`.
@@ -492,6 +492,7 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
// concatenate l2 transaction hashes
uint256 _numTransactionsInBlock = ChunkCodec.numTransactions(blockPtr);
require(_numTransactionsInBlock >= _numL1MessagesInBlock, "num txs less than num L1 msgs");
for (uint256 j = _numL1MessagesInBlock; j < _numTransactionsInBlock; j++) {
bytes32 txHash;
(txHash, l2TxPtr) = ChunkCodec.loadL2TxHash(l2TxPtr);

View File

@@ -5,6 +5,15 @@ pragma solidity ^0.8.16;
import {IScrollMessenger} from "../libraries/IScrollMessenger.sol";
interface IL2ScrollMessenger is IScrollMessenger {
/**********
* Events *
**********/
/// @notice Emitted when the maximum number of times each message can fail in L2 is updated.
/// @param oldMaxFailedExecutionTimes The old maximum number of times each message can fail in L2.
/// @param newMaxFailedExecutionTimes The new maximum number of times each message can fail in L2.
event UpdateMaxFailedExecutionTimes(uint256 oldMaxFailedExecutionTimes, uint256 newMaxFailedExecutionTimes);
/*****************************
* Public Mutating Functions *
*****************************/

View File

@@ -23,14 +23,6 @@ import {ScrollMessengerBase} from "../libraries/ScrollMessengerBase.sol";
/// @dev It should be a predeployed contract on layer 2 and should hold infinite amount
/// of Ether (Specifically, `uint256(-1)`), which can be initialized in Genesis Block.
contract L2ScrollMessenger is ScrollMessengerBase, IL2ScrollMessenger {
/**********
* Events *
**********/
/// @notice Emitted when the maximum number of times each message can fail in L2 is updated.
/// @param maxFailedExecutionTimes The new maximum number of times each message can fail in L2.
event UpdateMaxFailedExecutionTimes(uint256 maxFailedExecutionTimes);
/*************
* Constants *
*************/
@@ -119,13 +111,14 @@ contract L2ScrollMessenger is ScrollMessengerBase, IL2ScrollMessenger {
/// @notice Update max failed execution times.
/// @dev This function can only called by contract owner.
/// @param _maxFailedExecutionTimes The new max failed execution times.
function updateMaxFailedExecutionTimes(uint256 _maxFailedExecutionTimes) external onlyOwner {
require(_maxFailedExecutionTimes > 0, "maxFailedExecutionTimes cannot be zero");
/// @param _newMaxFailedExecutionTimes The new max failed execution times.
function updateMaxFailedExecutionTimes(uint256 _newMaxFailedExecutionTimes) external onlyOwner {
require(_newMaxFailedExecutionTimes > 0, "maxFailedExecutionTimes cannot be zero");
maxFailedExecutionTimes = _maxFailedExecutionTimes;
uint256 _oldMaxFailedExecutionTimes = maxFailedExecutionTimes;
maxFailedExecutionTimes = _newMaxFailedExecutionTimes;
emit UpdateMaxFailedExecutionTimes(_maxFailedExecutionTimes);
emit UpdateMaxFailedExecutionTimes(_oldMaxFailedExecutionTimes, _newMaxFailedExecutionTimes);
}
/**********************

View File

@@ -11,15 +11,18 @@ interface IL2GatewayRouter is IL2ETHGateway, IL2ERC20Gateway {
**********/
/// @notice Emitted when the address of ETH Gateway is updated.
/// @param ethGateway The address of new ETH Gateway.
event SetETHGateway(address indexed ethGateway);
/// @param oldETHGateway The address of the old ETH Gateway.
/// @param newEthGateway The address of the new ETH Gateway.
event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway);
/// @notice Emitted when the address of default ERC20 Gateway is updated.
/// @param defaultERC20Gateway The address of new default ERC20 Gateway.
event SetDefaultERC20Gateway(address indexed defaultERC20Gateway);
/// @param oldDefaultERC20Gateway The address of the old default ERC20 Gateway.
/// @param newDefaultERC20Gateway The address of the new default ERC20 Gateway.
event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway);
/// @notice Emitted when the `gateway` for `token` is updated.
/// @param token The address of token updated.
/// @param gateway The corresponding address of gateway updated.
event SetERC20Gateway(address indexed token, address indexed gateway);
/// @param oldGateway The corresponding address of the old gateway.
/// @param newGateway The corresponding address of the new gateway.
event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway);
}

View File

@@ -19,9 +19,10 @@ contract L2CustomERC20Gateway is L2ERC20Gateway {
**********/
/// @notice Emitted when token mapping for ERC20 token is updated.
/// @param _l2Token The address of corresponding ERC20 token on layer 2.
/// @param _l1Token The address of ERC20 token on layer 1.
event UpdateTokenMapping(address _l2Token, address _l1Token);
/// @param l2Token The address of corresponding ERC20 token in layer 2.
/// @param oldL1Token The address of the old corresponding ERC20 token in layer 1.
/// @param newL1Token The address of the new corresponding ERC20 token in layer 1.
event UpdateTokenMapping(address indexed l2Token, address indexed oldL1Token, address indexed newL1Token);
/*************
* Variables *
@@ -96,9 +97,10 @@ contract L2CustomERC20Gateway is L2ERC20Gateway {
function updateTokenMapping(address _l2Token, address _l1Token) external onlyOwner {
require(_l1Token != address(0), "token address cannot be 0");
address _oldL1Token = tokenMapping[_l2Token];
tokenMapping[_l2Token] = _l1Token;
emit UpdateTokenMapping(_l2Token, _l1Token);
emit UpdateTokenMapping(_l2Token, _oldL1Token, _l1Token);
}
/**********************

View File

@@ -23,9 +23,10 @@ contract L2ERC1155Gateway is ERC1155HolderUpgradeable, ScrollGatewayBase, IL2ERC
**********/
/// @notice Emitted when token mapping for ERC1155 token is updated.
/// @param _l2Token The address of corresponding ERC1155 token on layer 2.
/// @param _l1Token The address of ERC1155 token on layer 1.
event UpdateTokenMapping(address _l2Token, address _l1Token);
/// @param l2Token The address of corresponding ERC1155 token in layer 2.
/// @param oldL1Token The address of the old corresponding ERC1155 token in layer 1.
/// @param newL1Token The address of the new corresponding ERC1155 token in layer 1.
event UpdateTokenMapping(address indexed l2Token, address indexed oldL1Token, address indexed newL1Token);
/*************
* Variables *
@@ -139,9 +140,10 @@ contract L2ERC1155Gateway is ERC1155HolderUpgradeable, ScrollGatewayBase, IL2ERC
function updateTokenMapping(address _l2Token, address _l1Token) external onlyOwner {
require(_l1Token != address(0), "token address cannot be 0");
address _oldL1Token = tokenMapping[_l2Token];
tokenMapping[_l2Token] = _l1Token;
emit UpdateTokenMapping(_l2Token, _l1Token);
emit UpdateTokenMapping(_l2Token, _oldL1Token, _l1Token);
}
/**********************

View File

@@ -23,9 +23,10 @@ contract L2ERC721Gateway is ERC721HolderUpgradeable, ScrollGatewayBase, IL2ERC72
**********/
/// @notice Emitted when token mapping for ERC721 token is updated.
/// @param _l2Token The address of corresponding ERC721 token on layer 2.
/// @param _l1Token The address of ERC721 token on layer 1.
event UpdateTokenMapping(address _l2Token, address _l1Token);
/// @param l2Token The address of corresponding ERC721 token in layer 2.
/// @param oldL1Token The address of the old corresponding ERC721 token in layer 1.
/// @param newL1Token The address of the new corresponding ERC721 token in layer 1.
event UpdateTokenMapping(address indexed l2Token, address indexed oldL1Token, address indexed newL1Token);
/*************
* Variables *
@@ -134,9 +135,10 @@ contract L2ERC721Gateway is ERC721HolderUpgradeable, ScrollGatewayBase, IL2ERC72
function updateTokenMapping(address _l2Token, address _l1Token) external onlyOwner {
require(_l1Token != address(0), "token address cannot be 0");
address _oldL1Token = tokenMapping[_l2Token];
tokenMapping[_l2Token] = _l1Token;
emit UpdateTokenMapping(_l2Token, _l1Token);
emit UpdateTokenMapping(_l2Token, _oldL1Token, _l1Token);
}
/**********************

View File

@@ -42,13 +42,13 @@ contract L2GatewayRouter is OwnableUpgradeable, IL2GatewayRouter {
// it can be zero during initialization
if (_defaultERC20Gateway != address(0)) {
defaultERC20Gateway = _defaultERC20Gateway;
emit SetDefaultERC20Gateway(_defaultERC20Gateway);
emit SetDefaultERC20Gateway(address(0), _defaultERC20Gateway);
}
// it can be zero during initialization
if (_ethGateway != address(0)) {
ethGateway = _ethGateway;
emit SetETHGateway(_ethGateway);
emit SetETHGateway(address(0), _ethGateway);
}
}
@@ -179,20 +179,22 @@ contract L2GatewayRouter is OwnableUpgradeable, IL2GatewayRouter {
/// @notice Update the address of ETH gateway contract.
/// @dev This function should only be called by contract owner.
/// @param _ethGateway The address to update.
function setETHGateway(address _ethGateway) external onlyOwner {
ethGateway = _ethGateway;
/// @param _newEthGateway The address to update.
function setETHGateway(address _newEthGateway) external onlyOwner {
address _oldEthGateway = ethGateway;
ethGateway = _newEthGateway;
emit SetETHGateway(_ethGateway);
emit SetETHGateway(_oldEthGateway, _newEthGateway);
}
/// @notice Update the address of default ERC20 gateway contract.
/// @dev This function should only be called by contract owner.
/// @param _defaultERC20Gateway The address to update.
function setDefaultERC20Gateway(address _defaultERC20Gateway) external onlyOwner {
defaultERC20Gateway = _defaultERC20Gateway;
/// @param _newDefaultERC20Gateway The address to update.
function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external onlyOwner {
address _oldDefaultERC20Gateway = defaultERC20Gateway;
defaultERC20Gateway = _newDefaultERC20Gateway;
emit SetDefaultERC20Gateway(_defaultERC20Gateway);
emit SetDefaultERC20Gateway(_oldDefaultERC20Gateway, _newDefaultERC20Gateway);
}
/// @notice Update the mapping from token address to gateway address.
@@ -203,9 +205,10 @@ contract L2GatewayRouter is OwnableUpgradeable, IL2GatewayRouter {
require(_tokens.length == _gateways.length, "length mismatch");
for (uint256 i = 0; i < _tokens.length; i++) {
address _oldGateway = ERC20Gateway[_tokens[i]];
ERC20Gateway[_tokens[i]] = _gateways[i];
emit SetERC20Gateway(_tokens[i], _gateways[i]);
emit SetERC20Gateway(_tokens[i], _oldGateway, _gateways[i]);
}
}
}

View File

@@ -20,9 +20,9 @@ import {TransferReentrantToken} from "./mocks/tokens/TransferReentrantToken.sol"
contract L1GatewayRouterTest is L1GatewayTestBase {
// from L1GatewayRouter
event SetETHGateway(address indexed ethGateway);
event SetDefaultERC20Gateway(address indexed defaultERC20Gateway);
event SetERC20Gateway(address indexed token, address indexed gateway);
event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway);
event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway);
event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway);
ScrollStandardERC20 private template;
ScrollStandardERC20Factory private factory;
@@ -94,8 +94,8 @@ contract L1GatewayRouterTest is L1GatewayTestBase {
hevm.stopPrank();
// set by owner, should succeed
hevm.expectEmit(true, false, false, true);
emit SetDefaultERC20Gateway(address(l1StandardERC20Gateway));
hevm.expectEmit(true, true, false, true);
emit SetDefaultERC20Gateway(address(0), address(l1StandardERC20Gateway));
assertEq(address(0), router.getERC20Gateway(address(l1Token)));
assertEq(address(0), router.defaultERC20Gateway());
@@ -121,8 +121,8 @@ contract L1GatewayRouterTest is L1GatewayTestBase {
_tokens[0] = address(l1Token);
_gateways[0] = address(l1StandardERC20Gateway);
hevm.expectEmit(true, true, false, true);
emit SetERC20Gateway(address(l1Token), address(l1StandardERC20Gateway));
hevm.expectEmit(true, true, true, true);
emit SetERC20Gateway(address(l1Token), address(0), address(l1StandardERC20Gateway));
assertEq(address(0), router.getERC20Gateway(address(l1Token)));
router.setERC20Gateway(_tokens, _gateways);

View File

@@ -16,7 +16,7 @@ import {L1GatewayTestBase} from "./L1GatewayTestBase.t.sol";
contract L1ScrollMessengerTest is L1GatewayTestBase {
event OnDropMessageCalled(bytes);
event UpdateMaxReplayTimes(uint256 maxReplayTimes);
event UpdateMaxReplayTimes(uint256 oldMaxReplayTimes, uint256 newMaxReplayTimes);
function setUp() public {
L1GatewayTestBase.setUpBase();
@@ -159,7 +159,7 @@ contract L1ScrollMessengerTest is L1GatewayTestBase {
hevm.stopPrank();
hevm.expectEmit(false, false, false, true);
emit UpdateMaxReplayTimes(_maxReplayTimes);
emit UpdateMaxReplayTimes(0, _maxReplayTimes);
assertEq(l1Messenger.maxReplayTimes(), 0);
l1Messenger.updateMaxReplayTimes(_maxReplayTimes);

View File

@@ -19,10 +19,10 @@ import {ScrollStandardERC20Factory} from "../libraries/token/ScrollStandardERC20
import {L2GatewayTestBase} from "./L2GatewayTestBase.t.sol";
contract L2GatewayRouterTest is L2GatewayTestBase {
// from L1GatewayRouter
event SetETHGateway(address indexed ethGateway);
event SetDefaultERC20Gateway(address indexed defaultERC20Gateway);
event SetERC20Gateway(address indexed token, address indexed gateway);
// from L2GatewayRouter
event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway);
event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway);
event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway);
ScrollStandardERC20 private template;
ScrollStandardERC20Factory private factory;
@@ -89,8 +89,8 @@ contract L2GatewayRouterTest is L2GatewayTestBase {
hevm.stopPrank();
// set by owner, should succeed
hevm.expectEmit(true, false, false, true);
emit SetDefaultERC20Gateway(address(l2StandardERC20Gateway));
hevm.expectEmit(true, true, false, true);
emit SetDefaultERC20Gateway(address(0), address(l2StandardERC20Gateway));
assertEq(address(0), router.getERC20Gateway(address(l1Token)));
assertEq(address(0), router.defaultERC20Gateway());
@@ -116,8 +116,8 @@ contract L2GatewayRouterTest is L2GatewayTestBase {
_tokens[0] = address(l1Token);
_gateways[0] = address(l2StandardERC20Gateway);
hevm.expectEmit(true, true, false, true);
emit SetERC20Gateway(address(l1Token), address(l2StandardERC20Gateway));
hevm.expectEmit(true, true, true, true);
emit SetERC20Gateway(address(l1Token), address(0), address(l2StandardERC20Gateway));
assertEq(address(0), router.getERC20Gateway(address(l1Token)));
router.setERC20Gateway(_tokens, _gateways);

View File

@@ -18,7 +18,7 @@ contract ScrollChainTest is DSTestPlus {
// from ScrollChain
event UpdateSequencer(address indexed account, bool status);
event UpdateProver(address indexed account, bool status);
event UpdateVerifier(address oldVerifier, address newVerifier);
event UpdateVerifier(address indexed oldVerifier, address indexed newVerifier);
event UpdateMaxNumL2TxInChunk(uint256 oldMaxNumL2TxInChunk, uint256 newMaxNumL2TxInChunk);
event CommitBatch(uint256 indexed batchIndex, bytes32 indexed batchHash);
@@ -106,6 +106,17 @@ contract ScrollChainTest is DSTestPlus {
hevm.expectRevert("invalid chunk length");
rollup.commitBatch(0, batchHeader0, chunks, new bytes(0));
// num txs less than num L1 msgs, revert
chunk0 = new bytes(1 + 60);
bytes memory bitmap = new bytes(32);
chunk0[0] = bytes1(uint8(1)); // one block in this chunk
chunk0[58] = bytes1(uint8(1)); // numTransactions = 1
chunk0[60] = bytes1(uint8(3)); // numL1Messages = 3
bitmap[31] = bytes1(uint8(7));
chunks[0] = chunk0;
hevm.expectRevert("num txs less than num L1 msgs");
rollup.commitBatch(0, batchHeader0, chunks, bitmap);
// incomplete l2 transaction data, revert
chunk0 = new bytes(1 + 60 + 1);
chunk0[0] = bytes1(uint8(1)); // one block in this chunk
@@ -596,7 +607,7 @@ contract ScrollChainTest is DSTestPlus {
hevm.stopPrank();
// change to random operator
hevm.expectEmit(false, false, false, true);
hevm.expectEmit(true, true, false, true);
emit UpdateVerifier(address(verifier), _newVerifier);
assertEq(rollup.verifier(), address(verifier));