mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-11 23:18:07 -05:00
Compare commits
11 Commits
alpha-v1.1
...
test-v1.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7732b0c3f8 | ||
|
|
c9c849a56e | ||
|
|
257bc88a87 | ||
|
|
04552240e3 | ||
|
|
2aff8a1ad1 | ||
|
|
f75f4afb60 | ||
|
|
f979964d04 | ||
|
|
3507c419b4 | ||
|
|
8d55e83239 | ||
|
|
2d20ee639f | ||
|
|
08bf938e19 |
@@ -24,7 +24,6 @@
|
||||
"min_gas_price": 0,
|
||||
"gas_price_diff": 50000
|
||||
},
|
||||
"finalize_batch_interval_sec": 0,
|
||||
"message_sender_private_keys": [
|
||||
"1212121212121212121212121212121212121212121212121212121212121212"
|
||||
],
|
||||
@@ -57,7 +56,6 @@
|
||||
"min_gas_price": 0,
|
||||
"gas_price_diff": 50000
|
||||
},
|
||||
"finalize_batch_interval_sec": 0,
|
||||
"message_sender_private_keys": [
|
||||
"1212121212121212121212121212121212121212121212121212121212121212"
|
||||
],
|
||||
|
||||
@@ -47,8 +47,6 @@ type RelayerConfig struct {
|
||||
SenderConfig *SenderConfig `json:"sender_config"`
|
||||
// gas oracle config
|
||||
GasOracleConfig *GasOracleConfig `json:"gas_oracle_config"`
|
||||
// The interval in which we send finalize batch transactions.
|
||||
FinalizeBatchIntervalSec uint64 `json:"finalize_batch_interval_sec"`
|
||||
// The private key of the relayer
|
||||
MessageSenderPrivateKeys []*ecdsa.PrivateKey `json:"-"`
|
||||
GasOracleSenderPrivateKeys []*ecdsa.PrivateKey `json:"-"`
|
||||
|
||||
@@ -354,29 +354,22 @@ func (r *Layer2Relayer) ProcessCommittedBatches() {
|
||||
}
|
||||
|
||||
// batches are sorted by batch index in increasing order
|
||||
batchHashes, err := r.db.GetCommittedBatches(1)
|
||||
batches, err := r.db.GetCommittedBatches(1)
|
||||
if err != nil {
|
||||
log.Error("Failed to fetch committed L2 batches", "err", err)
|
||||
return
|
||||
}
|
||||
if len(batchHashes) == 0 {
|
||||
if len(batches) == 0 {
|
||||
return
|
||||
}
|
||||
hash := batchHashes[0]
|
||||
hash := batches[0]
|
||||
// @todo add support to relay multiple batches
|
||||
|
||||
batches, err := r.db.GetBlockBatches(map[string]interface{}{"hash": hash}, "LIMIT 1")
|
||||
status, err := r.db.GetProvingStatusByHash(hash)
|
||||
if err != nil {
|
||||
log.Error("Failed to fetch committed L2 batch", "hash", hash, "err", err)
|
||||
log.Error("GetProvingStatusByHash failed", "hash", hash, "err", err)
|
||||
return
|
||||
}
|
||||
if len(batches) == 0 {
|
||||
log.Error("Unexpected result for GetBlockBatches", "hash", hash, "len", 0)
|
||||
return
|
||||
}
|
||||
|
||||
batch := batches[0]
|
||||
status := batch.ProvingStatus
|
||||
|
||||
switch status {
|
||||
case types.ProvingTaskUnassigned, types.ProvingTaskAssigned:
|
||||
@@ -399,34 +392,6 @@ func (r *Layer2Relayer) ProcessCommittedBatches() {
|
||||
log.Info("Start to roll up zk proof", "hash", hash)
|
||||
success := false
|
||||
|
||||
previousBatch, err := r.db.GetLatestFinalizingOrFinalizedBatch()
|
||||
|
||||
// skip submitting proof
|
||||
if err == nil && uint64(batch.CreatedAt.Sub(*previousBatch.CreatedAt).Seconds()) < r.cfg.FinalizeBatchIntervalSec {
|
||||
log.Info(
|
||||
"Not enough time passed, skipping",
|
||||
"hash", hash,
|
||||
"createdAt", batch.CreatedAt,
|
||||
"lastFinalizingHash", previousBatch.Hash,
|
||||
"lastFinalizingStatus", previousBatch.RollupStatus,
|
||||
"lastFinalizingCreatedAt", previousBatch.CreatedAt,
|
||||
)
|
||||
|
||||
if err = r.db.UpdateRollupStatus(r.ctx, hash, types.RollupFinalizationSkipped); err != nil {
|
||||
log.Warn("UpdateRollupStatus failed", "hash", hash, "err", err)
|
||||
} else {
|
||||
success = true
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// handle unexpected db error
|
||||
if err != nil && err.Error() != "sql: no rows in result set" {
|
||||
log.Error("Failed to get latest finalized batch", "err", err)
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
// TODO: need to revisit this and have a more fine-grained error handling
|
||||
if !success {
|
||||
|
||||
@@ -41,38 +41,21 @@ pipeline {
|
||||
if (TAGNAME == ""){
|
||||
return;
|
||||
}
|
||||
def brigeImageName = "scrolltech/bridge:$TAGNAME"
|
||||
sh "docker login --username=$dockerUser --password=$dockerPassword"
|
||||
catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
|
||||
script {
|
||||
try {
|
||||
sh "docker manifest inspect scrolltech/bridge:$TAGNAME > /dev/null"
|
||||
} catch (e) {
|
||||
// only build if the tag non existed
|
||||
//sh "docker login --username=${dockerUser} --password=${dockerPassword}"
|
||||
sh "make -C bridge docker"
|
||||
sh "docker tag scrolltech/bridge:latest scrolltech/bridge:${TAGNAME}"
|
||||
sh "docker push scrolltech/bridge:${TAGNAME}"
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
|
||||
script {
|
||||
try {
|
||||
sh "docker manifest inspect scrolltech/coordinator:$TAGNAME > /dev/null"
|
||||
} catch (e) {
|
||||
// only build if the tag non existed
|
||||
//sh "docker login --username=${dockerUser} --password=${dockerPassword}"
|
||||
sh "make -C coordinator docker"
|
||||
sh "docker tag scrolltech/coordinator:latest scrolltech/coordinator:${TAGNAME}"
|
||||
sh "docker push scrolltech/coordinator:${TAGNAME}"
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
sh "echo $brigeImageName"
|
||||
sh "docker manifest inspect scrolltech/bridge:$TAGNAME > /dev/null"
|
||||
sh "echo $?"
|
||||
// sh "docker login --username=${dockerUser} --password=${dockerPassword}"
|
||||
// sh "make -C bridge docker"
|
||||
// sh "make -C coordinator docker"
|
||||
// sh "docker tag scrolltech/bridge:latest scrolltech/bridge:${TAGNAME}"
|
||||
// sh "docker tag scrolltech/coordinator:latest scrolltech/coordinator:${TAGNAME}"
|
||||
// sh "docker push scrolltech/bridge:${TAGNAME}"
|
||||
// sh "docker push scrolltech/coordinator:${TAGNAME}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
common/libzkp/impl/Cargo.lock
generated
12
common/libzkp/impl/Cargo.lock
generated
@@ -368,9 +368,9 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae"
|
||||
|
||||
[[package]]
|
||||
name = "bounded-collections"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de2aff4807e40f478132150d80b031f2461d88f061851afcab537d7600c24120"
|
||||
checksum = "a071c348a5ef6da1d3a87166b408170b46002382b1dda83992b5c2208cefb370"
|
||||
dependencies = [
|
||||
"log",
|
||||
"parity-scale-codec",
|
||||
@@ -2902,9 +2902,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "parity-scale-codec"
|
||||
version = "3.3.0"
|
||||
version = "3.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3840933452adf7b3b9145e27086a5a3376c619dca1a21b1e5a5af0d54979bed"
|
||||
checksum = "637935964ff85a605d114591d4d2c13c5d1ba2806dae97cea6bf180238a749ac"
|
||||
dependencies = [
|
||||
"arrayvec 0.7.2",
|
||||
"bitvec 1.0.1",
|
||||
@@ -5014,7 +5014,7 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
|
||||
[[package]]
|
||||
name = "types"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/scroll-tech/scroll-zkevm?branch=goerli-0215#1f7a3c7da2370860087555a11346bd5d96f609fd"
|
||||
source = "git+https://github.com/scroll-tech/scroll-zkevm?branch=goerli-0215#d0d3338663a0b3eee51e9d044ab96a7899d70252"
|
||||
dependencies = [
|
||||
"base64 0.13.0",
|
||||
"blake2",
|
||||
@@ -5682,7 +5682,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "zkevm"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/scroll-tech/scroll-zkevm?branch=goerli-0215#1f7a3c7da2370860087555a11346bd5d96f609fd"
|
||||
source = "git+https://github.com/scroll-tech/scroll-zkevm?branch=goerli-0215#d0d3338663a0b3eee51e9d044ab96a7899d70252"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"blake2",
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
var tag = "alpha-v1.15"
|
||||
var tag = "alpha-v1.11"
|
||||
|
||||
var commit = func() string {
|
||||
if info, ok := debug.ReadBuildInfo(); ok {
|
||||
|
||||
@@ -262,9 +262,7 @@ contract L2ScrollMessenger is ScrollMessengerBase, PausableUpgradeable, IL2Scrol
|
||||
bytes memory _message,
|
||||
bytes32 _xDomainCalldataHash
|
||||
) internal {
|
||||
// @todo check more `_to` address to avoid attack.
|
||||
require(_to != messageQueue, "Forbid to call message queue");
|
||||
require(_to != address(this), "Forbid to call self");
|
||||
// @todo check `_to` address to avoid attack.
|
||||
|
||||
// @note This usually will never happen, just in case.
|
||||
require(_from != xDomainMessageSender, "Invalid message sender");
|
||||
|
||||
@@ -237,7 +237,6 @@ contract L2CustomERC20GatewayTest is L2GatewayTestBase {
|
||||
) public {
|
||||
// blacklist some addresses
|
||||
hevm.assume(recipient != address(0));
|
||||
hevm.assume(recipient != address(gateway));
|
||||
|
||||
gateway.updateTokenMapping(address(l2Token), address(l1Token));
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import { DSTestPlus } from "solmate/test/utils/DSTestPlus.sol";
|
||||
|
||||
import { L1BlockContainer } from "../L2/predeploys/L1BlockContainer.sol";
|
||||
import { L1GasPriceOracle } from "../L2/predeploys/L1GasPriceOracle.sol";
|
||||
import { L2MessageQueue } from "../L2/predeploys/L2MessageQueue.sol";
|
||||
import { Whitelist } from "../L2/predeploys/Whitelist.sol";
|
||||
import { L1ScrollMessenger } from "../L1/L1ScrollMessenger.sol";
|
||||
import { L2ScrollMessenger } from "../L2/L2ScrollMessenger.sol";
|
||||
|
||||
contract L2ScrollMessengerTest is DSTestPlus {
|
||||
L1ScrollMessenger internal l1Messenger;
|
||||
|
||||
address internal feeVault;
|
||||
Whitelist private whitelist;
|
||||
|
||||
L2ScrollMessenger internal l2Messenger;
|
||||
L1BlockContainer internal l1BlockContainer;
|
||||
L2MessageQueue internal l2MessageQueue;
|
||||
L1GasPriceOracle internal l1GasOracle;
|
||||
|
||||
function setUp() public {
|
||||
// Deploy L1 contracts
|
||||
l1Messenger = new L1ScrollMessenger();
|
||||
|
||||
// Deploy L2 contracts
|
||||
whitelist = new Whitelist(address(this));
|
||||
l1BlockContainer = new L1BlockContainer(address(this));
|
||||
l2MessageQueue = new L2MessageQueue(address(this));
|
||||
l1GasOracle = new L1GasPriceOracle(address(this));
|
||||
l2Messenger = new L2ScrollMessenger(address(l1BlockContainer), address(l1GasOracle), address(l2MessageQueue));
|
||||
|
||||
// Initialize L2 contracts
|
||||
l2Messenger.initialize(address(l1Messenger), feeVault);
|
||||
l2MessageQueue.initialize();
|
||||
l2MessageQueue.updateMessenger(address(l2Messenger));
|
||||
l1GasOracle.updateWhitelist(address(whitelist));
|
||||
}
|
||||
|
||||
function testForbidCallFromL1() external {
|
||||
hevm.expectRevert("Forbid to call message queue");
|
||||
l2Messenger.relayMessage(address(this), address(l2MessageQueue), 0, 0, new bytes(0));
|
||||
|
||||
hevm.expectRevert("Forbid to call self");
|
||||
l2Messenger.relayMessage(address(this), address(l2Messenger), 0, 0, new bytes(0));
|
||||
}
|
||||
}
|
||||
@@ -269,7 +269,6 @@ contract L2StandardERC20GatewayTest is L2GatewayTestBase {
|
||||
) public {
|
||||
// blacklist some addresses
|
||||
hevm.assume(recipient != address(0));
|
||||
hevm.assume(recipient != address(gateway));
|
||||
|
||||
amount = bound(amount, 1, l2Token.balanceOf(address(this)));
|
||||
|
||||
|
||||
@@ -223,7 +223,6 @@ contract L2WETHGatewayTest is L2GatewayTestBase {
|
||||
) public {
|
||||
// blacklist some addresses
|
||||
hevm.assume(recipient != address(0));
|
||||
hevm.assume(recipient != address(gateway));
|
||||
|
||||
amount = bound(amount, 1, l2weth.balanceOf(address(this)));
|
||||
|
||||
|
||||
@@ -194,15 +194,6 @@ func (o *blockBatchOrm) GetLatestFinalizedBatch() (*types.BlockBatch, error) {
|
||||
return batch, nil
|
||||
}
|
||||
|
||||
func (o *blockBatchOrm) GetLatestFinalizingOrFinalizedBatch() (*types.BlockBatch, error) {
|
||||
row := o.db.QueryRowx(`select * from block_batch where index = (select max(index) from block_batch where rollup_status = $1 or rollup_status = $2);`, types.RollupFinalizing, types.RollupFinalized)
|
||||
batch := &types.BlockBatch{}
|
||||
if err := row.StructScan(batch); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return batch, nil
|
||||
}
|
||||
|
||||
func (o *blockBatchOrm) GetCommittedBatches(limit uint64) ([]string, error) {
|
||||
rows, err := o.db.Queryx(`SELECT hash FROM block_batch WHERE rollup_status = $1 ORDER BY index ASC LIMIT $2`, types.RollupCommitted, limit)
|
||||
if err != nil {
|
||||
|
||||
@@ -63,7 +63,6 @@ type BlockBatchOrm interface {
|
||||
GetLatestBatch() (*types.BlockBatch, error)
|
||||
GetLatestCommittedBatch() (*types.BlockBatch, error)
|
||||
GetLatestFinalizedBatch() (*types.BlockBatch, error)
|
||||
GetLatestFinalizingOrFinalizedBatch() (*types.BlockBatch, error)
|
||||
UpdateRollupStatus(ctx context.Context, hash string, status types.RollupStatus) error
|
||||
UpdateCommitTxHashAndRollupStatus(ctx context.Context, hash string, commitTxHash string, status types.RollupStatus) error
|
||||
UpdateFinalizeTxHashAndRollupStatus(ctx context.Context, hash string, finalizeTxHash string, status types.RollupStatus) error
|
||||
|
||||
@@ -241,7 +241,7 @@ func (r *Roller) prove() error {
|
||||
}
|
||||
} else {
|
||||
// when the roller has more than 3 times panic,
|
||||
// it will omit to prove the task, submit StatusProofError and then Delete the task.
|
||||
// it will omit to prove the task, submit StatusProofError and then Pop the task.
|
||||
proofMsg = &message.ProofDetail{
|
||||
Status: message.StatusProofError,
|
||||
Error: "zk proving panic",
|
||||
@@ -251,7 +251,7 @@ func (r *Roller) prove() error {
|
||||
}
|
||||
|
||||
defer func() {
|
||||
err = r.stack.Delete(task.Task.ID)
|
||||
_, err = r.stack.Pop()
|
||||
if err != nil {
|
||||
log.Error("roller stack pop failed!", "err", err)
|
||||
}
|
||||
|
||||
@@ -81,12 +81,28 @@ func (s *Stack) Peek() (*ProvingTask, error) {
|
||||
return traces, nil
|
||||
}
|
||||
|
||||
// Delete pops the proving-task on the top of Stack.
|
||||
func (s *Stack) Delete(taskID string) error {
|
||||
return s.Update(func(tx *bbolt.Tx) error {
|
||||
// Pop pops the proving-task on the top of Stack.
|
||||
func (s *Stack) Pop() (*ProvingTask, error) {
|
||||
var value []byte
|
||||
if err := s.Update(func(tx *bbolt.Tx) error {
|
||||
var key []byte
|
||||
bu := tx.Bucket(bucket)
|
||||
return bu.Delete([]byte(taskID))
|
||||
})
|
||||
c := bu.Cursor()
|
||||
key, value = c.Last()
|
||||
return bu.Delete(key)
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(value) == 0 {
|
||||
return nil, ErrEmpty
|
||||
}
|
||||
|
||||
task := &ProvingTask{}
|
||||
err := json.Unmarshal(value, task)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return task, nil
|
||||
}
|
||||
|
||||
// UpdateTimes udpates the roller prove times of the proving task.
|
||||
|
||||
@@ -36,12 +36,10 @@ func TestStack(t *testing.T) {
|
||||
}
|
||||
|
||||
for i := 2; i >= 0; i-- {
|
||||
var peek *ProvingTask
|
||||
peek, err = s.Peek()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, strconv.Itoa(i), peek.Task.ID)
|
||||
err = s.Delete(strconv.Itoa(i))
|
||||
var pop *ProvingTask
|
||||
pop, err = s.Pop()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, strconv.Itoa(i), pop.Task.ID)
|
||||
}
|
||||
|
||||
// test times
|
||||
@@ -54,13 +52,18 @@ func TestStack(t *testing.T) {
|
||||
}
|
||||
err = s.Push(task)
|
||||
assert.NoError(t, err)
|
||||
peek, err := s.Peek()
|
||||
pop, err := s.Pop()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 0, peek.Times)
|
||||
err = s.UpdateTimes(peek, 3)
|
||||
err = s.Push(pop)
|
||||
assert.NoError(t, err)
|
||||
|
||||
peek2, err := s.Peek()
|
||||
peek, err := s.Peek()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 3, peek2.Times)
|
||||
pop2, err := s.Pop()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, peek, pop2)
|
||||
|
||||
s.UpdateTimes(pop2, 1)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, pop2.Times)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user