Compare commits

..

3 Commits

Author SHA1 Message Date
HAOYUatHZ
54c28fa512 build: update version (#387) 2023-03-24 09:25:10 +08:00
maskpp
3c7c41e1bb fix(cmd test): add more log to handle error and remove serial execution test (#391) 2023-03-23 16:43:41 +08:00
Péter Garamvölgyi
2962fa4b0e batch proposer: only sleep if we failed to create batch (#388) 2023-03-22 22:16:31 +08:00
8 changed files with 52 additions and 44 deletions

35
Jenkinsfile vendored
View File

@@ -61,44 +61,29 @@ pipeline {
}
stage('Parallel Test') {
parallel{
stage('Test bridge package') {
stage('Race test common package') {
steps {
sh 'go test -v -coverprofile=coverage.bridge.txt -covermode=atomic -p 1 scroll-tech/bridge/...'
}
}
stage('Test common package') {
steps {
sh 'go test -v -coverprofile=coverage.common.txt -covermode=atomic -p 1 scroll-tech/common/...'
}
}
stage('Test coordinator package') {
steps {
sh 'go test -v -coverprofile=coverage.coordinator.txt -covermode=atomic -p 1 scroll-tech/coordinator/...'
}
}
stage('Test database package') {
steps {
sh 'go test -v -coverprofile=coverage.db.txt -covermode=atomic -p 1 scroll-tech/database/...'
}
}
stage('Integration test') {
steps {
sh 'go test -v -tags="mock_prover mock_verifier" -coverprofile=coverage.integration.txt -covermode=atomic -p 1 scroll-tech/integration-test/...'
sh 'go test -v -race -coverprofile=coverage.common.txt -covermode=atomic scroll-tech/common/...'
}
}
stage('Race test bridge package') {
steps {
sh 'go test -v -race -coverprofile=coverage.txt -covermode=atomic scroll-tech/bridge/...'
sh 'go test -v -race -coverprofile=coverage.bridge.txt -covermode=atomic scroll-tech/bridge/...'
}
}
stage('Race test coordinator package') {
steps {
sh 'go test -v -race -coverprofile=coverage.txt -covermode=atomic scroll-tech/coordinator/...'
sh 'go test -v -race -coverprofile=coverage.coordinator.txt -covermode=atomic scroll-tech/coordinator/...'
}
}
stage('Race test database package') {
steps {
sh 'go test -v -race -coverprofile=coverage.txt -covermode=atomic scroll-tech/database/...'
sh 'go test -v -race -coverprofile=coverage.db.txt -covermode=atomic scroll-tech/database/...'
}
}
stage('Integration test') {
steps {
sh 'go test -v -tags="mock_prover mock_verifier" -p 1 scroll-tech/integration-test/...'
}
}
}

View File

@@ -229,14 +229,18 @@ func (p *BatchProposer) tryProposeBatch() {
return
}
p.proposeBatch(blocks)
batchCreated := p.proposeBatch(blocks)
// while size of batchDataBuffer < commitCalldataMinSize,
// proposer keeps fetching and porposing batches.
if p.getBatchDataBufferSize() >= p.commitCalldataMinSize {
return
}
// wait for watcher to insert l2 traces.
time.Sleep(time.Second)
if !batchCreated {
// wait for watcher to insert l2 traces.
time.Sleep(time.Second)
}
}
}
@@ -285,9 +289,9 @@ func (p *BatchProposer) tryCommitBatches() {
}
}
func (p *BatchProposer) proposeBatch(blocks []*types.BlockInfo) {
func (p *BatchProposer) proposeBatch(blocks []*types.BlockInfo) bool {
if len(blocks) == 0 {
return
return false
}
if blocks[0].GasUsed > p.batchGasThreshold {
@@ -300,7 +304,7 @@ func (p *BatchProposer) proposeBatch(blocks []*types.BlockInfo) {
bridgeL2BatchesGasCreatedRateMeter.Mark(int64(blocks[0].GasUsed))
bridgeL2BatchesCreatedRateMeter.Mark(1)
}
return
return true
}
if blocks[0].TxNum > p.batchTxNumThreshold {
@@ -313,7 +317,7 @@ func (p *BatchProposer) proposeBatch(blocks []*types.BlockInfo) {
bridgeL2BatchesGasCreatedRateMeter.Mark(int64(blocks[0].GasUsed))
bridgeL2BatchesCreatedRateMeter.Mark(1)
}
return
return true
}
var gasUsed, txNum uint64
@@ -333,7 +337,7 @@ func (p *BatchProposer) proposeBatch(blocks []*types.BlockInfo) {
// if it's not old enough we will skip proposing the batch,
// otherwise we will still propose a batch
if !reachThreshold && blocks[0].BlockTimestamp+p.batchTimeSec > uint64(time.Now().Unix()) {
return
return false
}
if err := p.createBatchForBlocks(blocks); err != nil {
@@ -343,6 +347,8 @@ func (p *BatchProposer) proposeBatch(blocks []*types.BlockInfo) {
bridgeL2BatchesGasCreatedRateMeter.Mark(int64(gasUsed))
bridgeL2BatchesCreatedRateMeter.Mark(int64(len(blocks)))
}
return true
}
func (p *BatchProposer) createBatchForBlocks(blocks []*types.BlockInfo) error {

View File

@@ -4,7 +4,7 @@ ${GOROOT}/bin/bin/gocover-cobertura < coverage.bridge.txt > coverage.bridge.xml
${GOROOT}/bin/bin/gocover-cobertura < coverage.db.txt > coverage.db.xml
${GOROOT}/bin/bin/gocover-cobertura < coverage.common.txt > coverage.common.xml
${GOROOT}/bin/bin/gocover-cobertura < coverage.coordinator.txt > coverage.coordinator.xml
# ${GOROOT}/bin/bin/gocover-cobertura < coverage.integration.txt > coverage.integration.xml
#${GOROOT}/bin/bin/gocover-cobertura < coverage.integration.txt > coverage.integration.xml
npx cobertura-merge -o cobertura.xml \
package1=coverage.bridge.xml \

View File

@@ -31,8 +31,8 @@ type Cmd struct {
checkFuncs cmap.ConcurrentMap //map[string]checkFunc
//stdout bytes.Buffer
Err error
// error channel
ErrChan chan error
}
// NewCmd create Cmd instance.
@@ -41,6 +41,7 @@ func NewCmd(name string, args ...string) *Cmd {
checkFuncs: cmap.New(),
name: name,
args: args,
ErrChan: make(chan error, 10),
}
}
@@ -58,7 +59,7 @@ func (c *Cmd) runCmd() {
cmd := exec.Command(c.args[0], c.args[1:]...) //nolint:gosec
cmd.Stdout = c
cmd.Stderr = c
_ = cmd.Run()
c.ErrChan <- cmd.Run()
}
// RunCmd parallel running when parallel is true.

View File

@@ -38,9 +38,17 @@ func (c *Cmd) RunApp(waitResult func() bool) {
// WaitExit wait util process exit.
func (c *Cmd) WaitExit() {
// Wait all the check funcs are finished or test status is failed.
for !(c.Err != nil || c.checkFuncs.IsEmpty()) {
<-time.After(time.Millisecond * 500)
// Wait all the check functions are finished, interrupt loop when appear error.
var err error
for err == nil && !c.checkFuncs.IsEmpty() {
select {
case err = <-c.ErrChan:
if err != nil {
fmt.Printf("%s appear error durning running, err: %v\n", c.name, err)
}
default:
<-time.After(time.Millisecond * 500)
}
}
// Send interrupt signal.
@@ -56,7 +64,7 @@ func (c *Cmd) WaitExit() {
// Interrupt send interrupt signal.
func (c *Cmd) Interrupt() {
c.mu.Lock()
c.Err = c.cmd.Process.Signal(os.Interrupt)
c.ErrChan <- c.cmd.Process.Signal(os.Interrupt)
c.mu.Unlock()
}

View File

@@ -114,8 +114,12 @@ func (i *ImgDB) isOk() bool {
i.id = GetContainerID(i.name)
return i.id != ""
})
return i.id != ""
case err := <-i.cmd.ErrChan:
if err != nil {
fmt.Printf("failed to start %s, err: %v\n", i.name, err)
}
case <-time.After(time.Second * 20):
return false
}
return i.id != ""
}

View File

@@ -93,10 +93,14 @@ func (i *ImgGeth) isOk() bool {
i.id = GetContainerID(i.name)
return i.id != ""
})
return i.id != ""
case err := <-i.cmd.ErrChan:
if err != nil {
fmt.Printf("failed to start %s, err: %v\n", i.name, err)
}
case <-time.After(time.Second * 10):
return false
}
return i.id != ""
}
// Stop the docker container.

View File

@@ -5,7 +5,7 @@ import (
"runtime/debug"
)
var tag = "alpha-v2.4"
var tag = "v3.0.0"
var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {