mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
fix: update row estimation with scroll-prover v0.7.2 (#475)
* Fix row estimation. * Update libzkp. * more * prepare * finish * upgrade * bump version * fix tests * Update to scroll-prover `v0.7.2`. * fix tests * Update miner/worker.go Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * Update miner/worker.go Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * Reset ccc when skips first tx. * do not unnecessarily skip L1 message * fix ccc reset and improve code readability * seal block on circuitcapacitychecker.ErrUnknown --------- Co-authored-by: HAOYUatHZ <haoyu@protonmail.com> Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
This commit is contained in:
parent
727f88bc5f
commit
6992cfe8c5
8 changed files with 86 additions and 77 deletions
|
|
@ -1068,40 +1068,38 @@ loop:
|
||||||
log.Trace("Skipping unsupported transaction type", "sender", from, "type", tx.Type())
|
log.Trace("Skipping unsupported transaction type", "sender", from, "type", tx.Type())
|
||||||
txs.Pop()
|
txs.Pop()
|
||||||
|
|
||||||
|
// Circuit capacity check
|
||||||
case errors.Is(err, circuitcapacitychecker.ErrBlockRowConsumptionOverflow):
|
case errors.Is(err, circuitcapacitychecker.ErrBlockRowConsumptionOverflow):
|
||||||
// Circuit capacity check: circuit capacity limit reached in a block,
|
if w.current.tcount >= 1 {
|
||||||
// don't pop or shift, just quit the loop immediately;
|
// 1. Circuit capacity limit reached in a block, and it's not the first tx:
|
||||||
// though it might still be possible to add some "smaller" txs,
|
// don't pop or shift, just quit the loop immediately;
|
||||||
// but it's a trade-off between tracing overhead & block usage rate
|
// though it might still be possible to add some "smaller" txs,
|
||||||
log.Trace("Circuit capacity limit reached in a block", "acc_rows", w.current.accRows, "tx", tx.Hash().String())
|
// but it's a trade-off between tracing overhead & block usage rate
|
||||||
circuitCapacityReached = true
|
log.Trace("Circuit capacity limit reached in a block", "acc_rows", w.current.accRows, "tx", tx.Hash().String())
|
||||||
break loop
|
circuitCapacityReached = true
|
||||||
|
break loop
|
||||||
|
} else {
|
||||||
|
// 2. Circuit capacity limit reached in a block, and it's the first tx: skip the tx
|
||||||
|
log.Trace("Circuit capacity limit reached for a single tx", "tx", tx.Hash().String())
|
||||||
|
|
||||||
case (errors.Is(err, circuitcapacitychecker.ErrTxRowConsumptionOverflow) && tx.IsL1MessageTx()):
|
if tx.IsL1MessageTx() {
|
||||||
// Circuit capacity check: L1MessageTx row consumption too high, shift to the next from the account,
|
// Skip L1 message transaction,
|
||||||
// because we shouldn't skip the entire txs from the same account.
|
// shift to the next from the account because we shouldn't skip the entire txs from the same account
|
||||||
// This is also useful for skipping "problematic" L1MessageTxs.
|
txs.Shift()
|
||||||
queueIndex := tx.AsL1MessageTx().QueueIndex
|
|
||||||
log.Trace("Circuit capacity limit reached for a single tx", "tx", tx.Hash().String(), "queueIndex", queueIndex)
|
|
||||||
log.Info("Skipping L1 message", "queueIndex", queueIndex, "tx", tx.Hash().String(), "block", w.current.header.Number, "reason", "row consumption overflow")
|
|
||||||
w.current.nextL1MsgIndex = queueIndex + 1
|
|
||||||
|
|
||||||
// after `ErrTxRowConsumptionOverflow`, ccc might not revert updates
|
queueIndex := tx.AsL1MessageTx().QueueIndex
|
||||||
// associated with this transaction so we cannot pack more transactions.
|
log.Info("Skipping L1 message", "queueIndex", queueIndex, "tx", tx.Hash().String(), "block", w.current.header.Number, "reason", "row consumption overflow")
|
||||||
// TODO: fix this in ccc and change these lines back to `txs.Shift()`
|
w.current.nextL1MsgIndex = queueIndex + 1
|
||||||
circuitCapacityReached = true
|
} else {
|
||||||
break loop
|
// Skip L2 transaction and all other transactions from the same sender account
|
||||||
|
txs.Pop()
|
||||||
|
}
|
||||||
|
|
||||||
case (errors.Is(err, circuitcapacitychecker.ErrTxRowConsumptionOverflow) && !tx.IsL1MessageTx()):
|
// Reset ccc so that we can process other transactions for this block
|
||||||
// Circuit capacity check: L2MessageTx row consumption too high, skip the account.
|
w.circuitCapacityChecker.Reset()
|
||||||
// This is also useful for skipping "problematic" L2MessageTxs.
|
log.Trace("Worker reset ccc", "id", w.circuitCapacityChecker.ID)
|
||||||
log.Trace("Circuit capacity limit reached for a single tx", "tx", tx.Hash().String())
|
circuitCapacityReached = false
|
||||||
|
}
|
||||||
// after `ErrTxRowConsumptionOverflow`, ccc might not revert updates
|
|
||||||
// associated with this transaction so we cannot pack more transactions.
|
|
||||||
// TODO: fix this in ccc and change these lines back to `txs.Pop()`
|
|
||||||
circuitCapacityReached = true
|
|
||||||
break loop
|
|
||||||
|
|
||||||
case (errors.Is(err, circuitcapacitychecker.ErrUnknown) && tx.IsL1MessageTx()):
|
case (errors.Is(err, circuitcapacitychecker.ErrUnknown) && tx.IsL1MessageTx()):
|
||||||
// Circuit capacity check: unknown circuit capacity checker error for L1MessageTx,
|
// Circuit capacity check: unknown circuit capacity checker error for L1MessageTx,
|
||||||
|
|
@ -1111,9 +1109,9 @@ loop:
|
||||||
log.Info("Skipping L1 message", "queueIndex", queueIndex, "tx", tx.Hash().String(), "block", w.current.header.Number, "reason", "unknown row consumption error")
|
log.Info("Skipping L1 message", "queueIndex", queueIndex, "tx", tx.Hash().String(), "block", w.current.header.Number, "reason", "unknown row consumption error")
|
||||||
w.current.nextL1MsgIndex = queueIndex + 1
|
w.current.nextL1MsgIndex = queueIndex + 1
|
||||||
|
|
||||||
// after `ErrUnknown`, ccc might not revert updates associated
|
// Normally we would do `txs.Shift()` here.
|
||||||
// with this transaction so we cannot pack more transactions.
|
// However, after `ErrUnknown`, ccc might remain in an
|
||||||
// TODO: fix this in ccc and change these lines back to `txs.Shift()`
|
// inconsistent state, so we cannot pack more transactions.
|
||||||
circuitCapacityReached = true
|
circuitCapacityReached = true
|
||||||
break loop
|
break loop
|
||||||
|
|
||||||
|
|
@ -1121,9 +1119,9 @@ loop:
|
||||||
// Circuit capacity check: unknown circuit capacity checker error for L2MessageTx, skip the account
|
// Circuit capacity check: unknown circuit capacity checker error for L2MessageTx, skip the account
|
||||||
log.Trace("Unknown circuit capacity checker error for L2MessageTx", "tx", tx.Hash().String())
|
log.Trace("Unknown circuit capacity checker error for L2MessageTx", "tx", tx.Hash().String())
|
||||||
|
|
||||||
// after `ErrUnknown`, ccc might not revert updates associated
|
// Normally we would do `txs.Pop()` here.
|
||||||
// with this transaction so we cannot pack more transactions.
|
// However, after `ErrUnknown`, ccc might remain in an
|
||||||
// TODO: fix this in ccc and change these lines back to `txs.Pop()`
|
// inconsistent state, so we cannot pack more transactions.
|
||||||
circuitCapacityReached = true
|
circuitCapacityReached = true
|
||||||
break loop
|
break loop
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1010,10 +1010,10 @@ func TestOversizedTxThenNormal(t *testing.T) {
|
||||||
switch blockNum {
|
switch blockNum {
|
||||||
case 0:
|
case 0:
|
||||||
// schedule to skip 2nd call to ccc
|
// schedule to skip 2nd call to ccc
|
||||||
w.getCCC().ScheduleError(2, circuitcapacitychecker.ErrTxRowConsumptionOverflow)
|
w.getCCC().ScheduleError(2, circuitcapacitychecker.ErrBlockRowConsumptionOverflow)
|
||||||
return false
|
return false
|
||||||
case 1:
|
case 1:
|
||||||
// include #0, skip #1, then terminate
|
// include #0, fail on #1, then seal the block
|
||||||
assert.Equal(1, len(block.Transactions()))
|
assert.Equal(1, len(block.Transactions()))
|
||||||
|
|
||||||
assert.True(block.Transactions()[0].IsL1MessageTx())
|
assert.True(block.Transactions()[0].IsL1MessageTx())
|
||||||
|
|
@ -1022,7 +1022,23 @@ func TestOversizedTxThenNormal(t *testing.T) {
|
||||||
// db is updated correctly
|
// db is updated correctly
|
||||||
queueIndex := rawdb.ReadFirstQueueIndexNotInL2Block(db, block.Hash())
|
queueIndex := rawdb.ReadFirstQueueIndexNotInL2Block(db, block.Hash())
|
||||||
assert.NotNil(queueIndex)
|
assert.NotNil(queueIndex)
|
||||||
assert.Equal(uint64(2), *queueIndex)
|
assert.Equal(uint64(1), *queueIndex)
|
||||||
|
|
||||||
|
// schedule to skip next call to ccc
|
||||||
|
w.getCCC().ScheduleError(1, circuitcapacitychecker.ErrBlockRowConsumptionOverflow)
|
||||||
|
|
||||||
|
return false
|
||||||
|
case 2:
|
||||||
|
// skip #1, include #2, then seal the block
|
||||||
|
assert.Equal(1, len(block.Transactions()))
|
||||||
|
|
||||||
|
assert.True(block.Transactions()[0].IsL1MessageTx())
|
||||||
|
assert.Equal(uint64(2), block.Transactions()[0].AsL1MessageTx().QueueIndex)
|
||||||
|
|
||||||
|
// db is updated correctly
|
||||||
|
queueIndex := rawdb.ReadFirstQueueIndexNotInL2Block(db, block.Hash())
|
||||||
|
assert.NotNil(queueIndex)
|
||||||
|
assert.Equal(uint64(3), *queueIndex)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
const (
|
const (
|
||||||
VersionMajor = 4 // Major version component of the current release
|
VersionMajor = 4 // Major version component of the current release
|
||||||
VersionMinor = 3 // Minor version component of the current release
|
VersionMinor = 3 // Minor version component of the current release
|
||||||
VersionPatch = 47 // Patch version component of the current release
|
VersionPatch = 48 // Patch version component of the current release
|
||||||
VersionMeta = "sepolia" // Version metadata to append to the version string
|
VersionMeta = "sepolia" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,17 +87,13 @@ func (ccc *CircuitCapacityChecker) ApplyTransaction(traces *types.BlockTrace) (*
|
||||||
log.Error("fail to apply_tx in CircuitCapacityChecker", "id", ccc.ID, "TxHash", traces.Transactions[0].TxHash, "err", result.Error)
|
log.Error("fail to apply_tx in CircuitCapacityChecker", "id", ccc.ID, "TxHash", traces.Transactions[0].TxHash, "err", result.Error)
|
||||||
return nil, ErrUnknown
|
return nil, ErrUnknown
|
||||||
}
|
}
|
||||||
if result.TxRowUsage == nil || result.AccRowUsage == nil {
|
if result.AccRowUsage == nil {
|
||||||
log.Error("fail to apply_tx in CircuitCapacityChecker",
|
log.Error("fail to apply_tx in CircuitCapacityChecker",
|
||||||
"id", ccc.ID, "TxHash", traces.Transactions[0].TxHash,
|
"id", ccc.ID, "TxHash", traces.Transactions[0].TxHash,
|
||||||
"result.TxRowUsage==nil", result.TxRowUsage == nil,
|
|
||||||
"result.AccRowUsage == nil", result.AccRowUsage == nil,
|
"result.AccRowUsage == nil", result.AccRowUsage == nil,
|
||||||
"err", "TxRowUsage or AccRowUsage is empty unexpectedly")
|
"err", "AccRowUsage is empty unexpectedly")
|
||||||
return nil, ErrUnknown
|
return nil, ErrUnknown
|
||||||
}
|
}
|
||||||
if !result.TxRowUsage.IsOk {
|
|
||||||
return nil, ErrTxRowConsumptionOverflow
|
|
||||||
}
|
|
||||||
if !result.AccRowUsage.IsOk {
|
if !result.AccRowUsage.IsOk {
|
||||||
return nil, ErrBlockRowConsumptionOverflow
|
return nil, ErrBlockRowConsumptionOverflow
|
||||||
}
|
}
|
||||||
|
|
|
||||||
28
rollup/circuitcapacitychecker/libzkp/Cargo.lock
generated
28
rollup/circuitcapacitychecker/libzkp/Cargo.lock
generated
|
|
@ -23,7 +23,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aggregator"
|
name = "aggregator"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.6.4#5af677cdd3e3b52afc9672ddb8bdedb3e21c7d82"
|
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.7.2#194216272f813944a7013f14d73d1de19375d2ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ark-std",
|
"ark-std",
|
||||||
"env_logger 0.10.0",
|
"env_logger 0.10.0",
|
||||||
|
|
@ -397,7 +397,7 @@ checksum = "3c6ed94e98ecff0c12dd1b04c15ec0d7d9458ca8fe806cea6f12954efe74c63b"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bus-mapping"
|
name = "bus-mapping"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.6.4#5af677cdd3e3b52afc9672ddb8bdedb3e21c7d82"
|
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.7.2#194216272f813944a7013f14d73d1de19375d2ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"eth-types",
|
"eth-types",
|
||||||
"ethers-core",
|
"ethers-core",
|
||||||
|
|
@ -1061,7 +1061,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "eth-types"
|
name = "eth-types"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.6.4#5af677cdd3e3b52afc9672ddb8bdedb3e21c7d82"
|
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.7.2#194216272f813944a7013f14d73d1de19375d2ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ethers-core",
|
"ethers-core",
|
||||||
"ethers-signers",
|
"ethers-signers",
|
||||||
|
|
@ -1238,7 +1238,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "external-tracer"
|
name = "external-tracer"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.6.4#5af677cdd3e3b52afc9672ddb8bdedb3e21c7d82"
|
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.7.2#194216272f813944a7013f14d73d1de19375d2ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"eth-types",
|
"eth-types",
|
||||||
"geth-utils",
|
"geth-utils",
|
||||||
|
|
@ -1451,7 +1451,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gadgets"
|
name = "gadgets"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.6.4#5af677cdd3e3b52afc9672ddb8bdedb3e21c7d82"
|
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.7.2#194216272f813944a7013f14d73d1de19375d2ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"digest 0.7.6",
|
"digest 0.7.6",
|
||||||
"eth-types",
|
"eth-types",
|
||||||
|
|
@ -1491,7 +1491,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "geth-utils"
|
name = "geth-utils"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.6.4#5af677cdd3e3b52afc9672ddb8bdedb3e21c7d82"
|
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.7.2#194216272f813944a7013f14d73d1de19375d2ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"env_logger 0.9.3",
|
"env_logger 0.9.3",
|
||||||
"gobuild 0.1.0-alpha.2 (git+https://github.com/scroll-tech/gobuild.git)",
|
"gobuild 0.1.0-alpha.2 (git+https://github.com/scroll-tech/gobuild.git)",
|
||||||
|
|
@ -2088,7 +2088,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "keccak256"
|
name = "keccak256"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.6.4#5af677cdd3e3b52afc9672ddb8bdedb3e21c7d82"
|
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.7.2#194216272f813944a7013f14d73d1de19375d2ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"env_logger 0.9.3",
|
"env_logger 0.9.3",
|
||||||
"eth-types",
|
"eth-types",
|
||||||
|
|
@ -2288,7 +2288,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mock"
|
name = "mock"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.6.4#5af677cdd3e3b52afc9672ddb8bdedb3e21c7d82"
|
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.7.2#194216272f813944a7013f14d73d1de19375d2ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"eth-types",
|
"eth-types",
|
||||||
"ethers-core",
|
"ethers-core",
|
||||||
|
|
@ -2303,7 +2303,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mpt-zktrie"
|
name = "mpt-zktrie"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.6.4#5af677cdd3e3b52afc9672ddb8bdedb3e21c7d82"
|
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.7.2#194216272f813944a7013f14d73d1de19375d2ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bus-mapping",
|
"bus-mapping",
|
||||||
"eth-types",
|
"eth-types",
|
||||||
|
|
@ -2769,8 +2769,8 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "prover"
|
name = "prover"
|
||||||
version = "0.6.4"
|
version = "0.7.2"
|
||||||
source = "git+https://github.com/scroll-tech/scroll-prover?tag=v0.6.4#e81455aed85873dbf3d2779035ae9068cde0e612"
|
source = "git+https://github.com/scroll-tech/scroll-prover?tag=v0.7.2#a29cbaae9cb52b0eb61a4418caf6fbb6eb5d28f4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aggregator",
|
"aggregator",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
|
@ -4010,8 +4010,8 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "types"
|
name = "types"
|
||||||
version = "0.6.4"
|
version = "0.7.2"
|
||||||
source = "git+https://github.com/scroll-tech/scroll-prover?tag=v0.6.4#e81455aed85873dbf3d2779035ae9068cde0e612"
|
source = "git+https://github.com/scroll-tech/scroll-prover?tag=v0.7.2#a29cbaae9cb52b0eb61a4418caf6fbb6eb5d28f4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.13.1",
|
"base64 0.13.1",
|
||||||
"blake2",
|
"blake2",
|
||||||
|
|
@ -4487,7 +4487,7 @@ checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zkevm-circuits"
|
name = "zkevm-circuits"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.6.4#5af677cdd3e3b52afc9672ddb8bdedb3e21c7d82"
|
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.7.2#194216272f813944a7013f14d73d1de19375d2ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"array-init",
|
"array-init",
|
||||||
"bus-mapping",
|
"bus-mapping",
|
||||||
|
|
|
||||||
|
|
@ -20,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" }
|
halo2curves = { git = "https://github.com/scroll-tech/halo2curves.git", branch = "0.3.1-derive-serde" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
prover = { git = "https://github.com/scroll-tech/scroll-prover", tag = "v0.6.4" }
|
prover = { git = "https://github.com/scroll-tech/scroll-prover", tag = "v0.7.2" }
|
||||||
types = { git = "https://github.com/scroll-tech/scroll-prover", tag = "v0.6.4" }
|
types = { git = "https://github.com/scroll-tech/scroll-prover", tag = "v0.7.2" }
|
||||||
|
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
env_logger = "0.9.0"
|
env_logger = "0.9.0"
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ pub mod checker {
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct RowUsageResult {
|
pub struct RowUsageResult {
|
||||||
pub acc_row_usage: Option<RowUsage>,
|
pub acc_row_usage: Option<RowUsage>,
|
||||||
pub tx_row_usage: Option<RowUsage>,
|
|
||||||
pub error: Option<String>,
|
pub error: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,7 +58,11 @@ pub mod checker {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn apply_tx(id: u64, tx_traces: *const c_char) -> *const c_char {
|
pub unsafe extern "C" fn apply_tx(id: u64, tx_traces: *const c_char) -> *const c_char {
|
||||||
let result = panic::catch_unwind(|| {
|
let result = panic::catch_unwind(|| {
|
||||||
log::debug!("ccc apply_tx raw input, id: {:?}, tx_traces: {:?}", id, c_char_to_str(tx_traces));
|
log::debug!(
|
||||||
|
"ccc apply_tx raw input, id: {:?}, tx_traces: {:?}",
|
||||||
|
id,
|
||||||
|
c_char_to_str(tx_traces)
|
||||||
|
);
|
||||||
let tx_traces_vec = c_char_to_vec(tx_traces);
|
let tx_traces_vec = c_char_to_vec(tx_traces);
|
||||||
let traces = serde_json::from_slice::<BlockTrace>(&tx_traces_vec)
|
let traces = serde_json::from_slice::<BlockTrace>(&tx_traces_vec)
|
||||||
.unwrap_or_else(|_| panic!("id: {id:?}, fail to deserialize tx_traces"));
|
.unwrap_or_else(|_| panic!("id: {id:?}, fail to deserialize tx_traces"));
|
||||||
|
|
@ -88,22 +91,19 @@ pub mod checker {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
let r = match result {
|
let r = match result {
|
||||||
Ok((acc_row_usage, tx_row_usage)) => {
|
Ok(acc_row_usage) => {
|
||||||
log::debug!(
|
log::debug!(
|
||||||
"id: {:?}, acc_row_usage: {:?}, tx_row_usage: {:?}",
|
"id: {:?}, acc_row_usage: {:?}",
|
||||||
id,
|
id,
|
||||||
acc_row_usage.row_number,
|
acc_row_usage.row_number,
|
||||||
tx_row_usage.row_number
|
|
||||||
);
|
);
|
||||||
RowUsageResult {
|
RowUsageResult {
|
||||||
acc_row_usage: Some(acc_row_usage),
|
acc_row_usage: Some(acc_row_usage),
|
||||||
tx_row_usage: Some(tx_row_usage),
|
|
||||||
error: None,
|
error: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => RowUsageResult {
|
Err(e) => RowUsageResult {
|
||||||
acc_row_usage: None,
|
acc_row_usage: None,
|
||||||
tx_row_usage: None,
|
|
||||||
error: Some(format!("{e:?}")),
|
error: Some(format!("{e:?}")),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -114,7 +114,11 @@ pub mod checker {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn apply_block(id: u64, block_trace: *const c_char) -> *const c_char {
|
pub unsafe extern "C" fn apply_block(id: u64, block_trace: *const c_char) -> *const c_char {
|
||||||
let result = panic::catch_unwind(|| {
|
let result = panic::catch_unwind(|| {
|
||||||
log::debug!("ccc apply_block raw input, id: {:?}, block_trace: {:?}", id, c_char_to_str(block_trace));
|
log::debug!(
|
||||||
|
"ccc apply_block raw input, id: {:?}, block_trace: {:?}",
|
||||||
|
id,
|
||||||
|
c_char_to_str(block_trace)
|
||||||
|
);
|
||||||
let block_trace = c_char_to_vec(block_trace);
|
let block_trace = c_char_to_vec(block_trace);
|
||||||
let traces = serde_json::from_slice::<BlockTrace>(&block_trace)
|
let traces = serde_json::from_slice::<BlockTrace>(&block_trace)
|
||||||
.unwrap_or_else(|_| panic!("id: {id:?}, fail to deserialize block_trace"));
|
.unwrap_or_else(|_| panic!("id: {id:?}, fail to deserialize block_trace"));
|
||||||
|
|
@ -136,22 +140,19 @@ pub mod checker {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
let r = match result {
|
let r = match result {
|
||||||
Ok((acc_row_usage, tx_row_usage)) => {
|
Ok(acc_row_usage) => {
|
||||||
log::debug!(
|
log::debug!(
|
||||||
"id: {:?}, acc_row_usage: {:?}, tx_row_usage: {:?}",
|
"id: {:?}, acc_row_usage: {:?}",
|
||||||
id,
|
id,
|
||||||
acc_row_usage.row_number,
|
acc_row_usage.row_number,
|
||||||
tx_row_usage.row_number
|
|
||||||
);
|
);
|
||||||
RowUsageResult {
|
RowUsageResult {
|
||||||
acc_row_usage: Some(acc_row_usage),
|
acc_row_usage: Some(acc_row_usage),
|
||||||
tx_row_usage: Some(tx_row_usage),
|
|
||||||
error: None,
|
error: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => RowUsageResult {
|
Err(e) => RowUsageResult {
|
||||||
acc_row_usage: None,
|
acc_row_usage: None,
|
||||||
tx_row_usage: None,
|
|
||||||
error: Some(format!("{e:?}")),
|
error: Some(format!("{e:?}")),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,10 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrUnknown = errors.New("unknown circuit capacity checker error")
|
ErrUnknown = errors.New("unknown circuit capacity checker error")
|
||||||
ErrTxRowConsumptionOverflow = errors.New("tx row consumption oveflow")
|
|
||||||
ErrBlockRowConsumptionOverflow = errors.New("block row consumption oveflow")
|
ErrBlockRowConsumptionOverflow = errors.New("block row consumption oveflow")
|
||||||
)
|
)
|
||||||
|
|
||||||
type WrappedRowUsage struct {
|
type WrappedRowUsage struct {
|
||||||
AccRowUsage *types.RowUsage `json:"acc_row_usage,omitempty"`
|
AccRowUsage *types.RowUsage `json:"acc_row_usage,omitempty"`
|
||||||
TxRowUsage *types.RowUsage `json:"tx_row_usage,omitempty"`
|
|
||||||
Error string `json:"error,omitempty"`
|
Error string `json:"error,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue