From 9f143b47b25bd27dbe4773bd9394221f4d2a3584 Mon Sep 17 00:00:00 2001 From: Zhang Zhuo Date: Wed, 22 Nov 2023 14:44:08 +0800 Subject: [PATCH] feat (`libzkp-v0.9.8`): recordStorageDetail even when LogConfig.DisableStorage == true (#564) * trace: recordStorageDetail even when LogConfig.DisableStorage == true * Set `DisableStorage` to true. * Update libzkp to zkevm-circuits `feat/remove-step-storage-from-trace` branch. * Add `strict-ccc` feature to libzkp. * Upgrade libzkp to use prover `v0.9.8`. * Update params version. * Update params version. --------- Co-authored-by: Steven Gu --- core/trace.go | 1 + core/vm/logger.go | 22 +++++++++---------- params/version.go | 2 +- .../circuitcapacitychecker/libzkp/Cargo.lock | 22 +++++++++---------- .../circuitcapacitychecker/libzkp/Cargo.toml | 2 +- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/core/trace.go b/core/trace.go index ee1f060391..39ab388195 100644 --- a/core/trace.go +++ b/core/trace.go @@ -119,6 +119,7 @@ func CreateTraceEnv(chainConfig *params.ChainConfig, chainContext ChainContext, env := CreateTraceEnvHelper( chainConfig, &vm.LogConfig{ + DisableStorage: true, EnableMemory: false, EnableReturnData: true, }, diff --git a/core/vm/logger.go b/core/vm/logger.go index 14104b69be..3c909a13d3 100644 --- a/core/vm/logger.go +++ b/core/vm/logger.go @@ -234,16 +234,14 @@ func (l *StructLogger) CaptureState(pc uint64, op OpCode, gas, cost uint64, scop storageKey common.Hash storageValue common.Hash ) - if !l.cfg.DisableStorage { - if op == SLOAD && stack.len() >= 1 { - recordStorageDetail = true - storageKey = stack.data[stack.len()-1].Bytes32() - storageValue = l.env.StateDB.GetState(contract.Address(), storageKey) - } else if op == SSTORE && stack.len() >= 2 { - recordStorageDetail = true - storageKey = stack.data[stack.len()-1].Bytes32() - storageValue = stack.data[stack.len()-2].Bytes32() - } + if op == SLOAD && stack.len() >= 1 { + recordStorageDetail = true + storageKey = stack.data[stack.len()-1].Bytes32() + storageValue = l.env.StateDB.GetState(contract.Address(), storageKey) + } else if op == SSTORE && stack.len() >= 2 { + recordStorageDetail = true + storageKey = stack.data[stack.len()-1].Bytes32() + storageValue = stack.data[stack.len()-2].Bytes32() } if recordStorageDetail { contractAddress := contract.Address() @@ -251,7 +249,9 @@ func (l *StructLogger) CaptureState(pc uint64, op OpCode, gas, cost uint64, scop l.storage[contractAddress] = make(Storage) } l.storage[contractAddress][storageKey] = storageValue - structLog.Storage = l.storage[contractAddress].Copy() + if !l.cfg.DisableStorage { + structLog.Storage = l.storage[contractAddress].Copy() + } if err := traceStorage(l, scope, structLog.getOrInitExtraData()); err != nil { log.Error("Failed to trace data", "opcode", op.String(), "err", err) diff --git a/params/version.go b/params/version.go index b67e360e1b..d5b99d3bad 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 5 // Major version component of the current release VersionMinor = 1 // Minor version component of the current release - VersionPatch = 4 // Patch version component of the current release + VersionPatch = 5 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string ) diff --git a/rollup/circuitcapacitychecker/libzkp/Cargo.lock b/rollup/circuitcapacitychecker/libzkp/Cargo.lock index 1febfcac86..bfa2cfa3bf 100644 --- a/rollup/circuitcapacitychecker/libzkp/Cargo.lock +++ b/rollup/circuitcapacitychecker/libzkp/Cargo.lock @@ -16,7 +16,7 @@ dependencies = [ [[package]] name = "aggregator" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.7#2055cc0bb970aa28d597c945b6078e2469af8862" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.8#8f17df87ba70f5a8fcaa23f4fcb7fb112f5a815a" dependencies = [ "ark-std", "env_logger 0.10.0", @@ -297,7 +297,7 @@ checksum = "3c6ed94e98ecff0c12dd1b04c15ec0d7d9458ca8fe806cea6f12954efe74c63b" [[package]] name = "bus-mapping" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.7#2055cc0bb970aa28d597c945b6078e2469af8862" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.8#8f17df87ba70f5a8fcaa23f4fcb7fb112f5a815a" dependencies = [ "eth-types", "ethers-core", @@ -971,7 +971,7 @@ dependencies = [ [[package]] name = "eth-types" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.7#2055cc0bb970aa28d597c945b6078e2469af8862" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.8#8f17df87ba70f5a8fcaa23f4fcb7fb112f5a815a" dependencies = [ "ethers-core", "ethers-signers", @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "external-tracer" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.7#2055cc0bb970aa28d597c945b6078e2469af8862" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.8#8f17df87ba70f5a8fcaa23f4fcb7fb112f5a815a" dependencies = [ "eth-types", "geth-utils", @@ -1308,7 +1308,7 @@ dependencies = [ [[package]] name = "gadgets" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.7#2055cc0bb970aa28d597c945b6078e2469af8862" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.8#8f17df87ba70f5a8fcaa23f4fcb7fb112f5a815a" dependencies = [ "digest 0.7.6", "eth-types", @@ -1340,7 +1340,7 @@ dependencies = [ [[package]] name = "geth-utils" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.7#2055cc0bb970aa28d597c945b6078e2469af8862" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.8#8f17df87ba70f5a8fcaa23f4fcb7fb112f5a815a" dependencies = [ "env_logger 0.9.3", "gobuild 0.1.0-alpha.2 (git+https://github.com/scroll-tech/gobuild.git)", @@ -1949,7 +1949,7 @@ dependencies = [ [[package]] name = "keccak256" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.7#2055cc0bb970aa28d597c945b6078e2469af8862" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.8#8f17df87ba70f5a8fcaa23f4fcb7fb112f5a815a" dependencies = [ "env_logger 0.9.3", "eth-types", @@ -2157,7 +2157,7 @@ dependencies = [ [[package]] name = "mock" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.7#2055cc0bb970aa28d597c945b6078e2469af8862" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.8#8f17df87ba70f5a8fcaa23f4fcb7fb112f5a815a" dependencies = [ "eth-types", "ethers-core", @@ -2173,7 +2173,7 @@ dependencies = [ [[package]] name = "mpt-zktrie" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.7#2055cc0bb970aa28d597c945b6078e2469af8862" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.8#8f17df87ba70f5a8fcaa23f4fcb7fb112f5a815a" dependencies = [ "eth-types", "halo2-mpt-circuits", @@ -2595,7 +2595,7 @@ dependencies = [ [[package]] name = "prover" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.7#2055cc0bb970aa28d597c945b6078e2469af8862" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.8#8f17df87ba70f5a8fcaa23f4fcb7fb112f5a815a" dependencies = [ "aggregator", "anyhow", @@ -4212,7 +4212,7 @@ checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" [[package]] name = "zkevm-circuits" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.7#2055cc0bb970aa28d597c945b6078e2469af8862" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.9.8#8f17df87ba70f5a8fcaa23f4fcb7fb112f5a815a" dependencies = [ "array-init", "bus-mapping", diff --git a/rollup/circuitcapacitychecker/libzkp/Cargo.toml b/rollup/circuitcapacitychecker/libzkp/Cargo.toml index 4750c45e75..cc0960d010 100644 --- a/rollup/circuitcapacitychecker/libzkp/Cargo.toml +++ b/rollup/circuitcapacitychecker/libzkp/Cargo.toml @@ -20,7 +20,7 @@ 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/zkevm-circuits.git", tag = "v0.9.7", default-features = false, features = ["parallel_syn", "scroll", "shanghai"] } +prover = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.9.8", default-features = false, features = ["parallel_syn", "scroll", "shanghai", "strict-ccc"] } anyhow = "1.0" log = "0.4"