Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit 1bc1eef

Browse files
[MPTWG] Deadcode round (privacy-scaling-explorations#1590)
### Description Remove dead code in MPTWG to improve readability. ### Issue Link ### Type of change Bug fix (non-breaking change which fixes an issue) (wait CI update in privacy-scaling-explorations#1591)
1 parent f36df6e commit 1bc1eef

File tree

8 files changed

+19
-539
lines changed

8 files changed

+19
-539
lines changed

mpt-witness-generator/go.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ module github.com/privacy-scaling-explorations/mpt-witness-generator
33
go 1.16
44

55
require (
6-
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
7-
github.com/ethereum/go-ethereum v1.10.8 // indirect
8-
github.com/holiman/uint256 v1.2.0 // indirect
9-
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
6+
github.com/ethereum/go-ethereum v1.10.8
7+
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
108
)

mpt-witness-generator/go.sum

Lines changed: 17 additions & 8 deletions
Large diffs are not rendered by default.

mpt-witness-generator/witness/gen_witness_from_infura_blockchain_test.go

Lines changed: 0 additions & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,196 +2079,6 @@ func TestLeafWithMoreNibbles(t *testing.T) {
20792079
oracle.PreventHashingInSecureTrie = false
20802080
}
20812081

2082-
// Note: this requires MockProver with config param 11
2083-
/*
2084-
func TestNonHashedBranchInBranch(t *testing.T) {
2085-
blockNum := 0
2086-
blockNumberParent := big.NewInt(int64(blockNum))
2087-
blockHeaderParent := oracle.PrefetchBlock(blockNumberParent, true, nil)
2088-
database := state.NewDatabase(blockHeaderParent)
2089-
statedb, _ := state.New(blockHeaderParent.Root, database, nil)
2090-
addr := common.HexToAddress("0x50efbf12580138bc623c95757286df4e24eb81c9")
2091-
2092-
statedb.DisableLoadingRemoteAccounts()
2093-
2094-
statedb.CreateAccount(addr)
2095-
2096-
oracle.PreventHashingInSecureTrie = true // to store the unchanged key
2097-
2098-
val1 := common.BigToHash(big.NewInt(int64(1)))
2099-
2100-
key1Hex := "0x1000000000000000000000000000000000000000000000000000000000000000"
2101-
key2Hex := "0x2000000000000000000000000000000000000000000000000000000000000000"
2102-
key1 := common.HexToHash(key1Hex)
2103-
key2 := common.HexToHash(key2Hex)
2104-
fmt.Println(key2)
2105-
2106-
statedb.SetState(addr, key2, val1)
2107-
2108-
iters := 57 // making the last branch shorter than 32 bytes
2109-
for i := 0; i < iters; i++ {
2110-
fmt.Println("====")
2111-
fmt.Println(key1)
2112-
2113-
statedb.SetState(addr, key1, val1)
2114-
2115-
if i == iters - 1 {
2116-
break
2117-
}
2118-
2119-
key1Hex = replaceAtIndex(key1Hex, 49, i + 3) // 49 is 1, 50 is 2, ...
2120-
key1 = common.HexToHash(key1Hex)
2121-
}
2122-
2123-
statedb.IntermediateRoot(false)
2124-
2125-
val := common.BigToHash(big.NewInt(int64(17)))
2126-
trieMod := TrieModification{
2127-
Type: StorageChanged,
2128-
Key: key1,
2129-
Value: val,
2130-
Address: addr,
2131-
}
2132-
trieModifications := []TrieModification{trieMod}
2133-
2134-
GenerateProof("NonHashedBranchInBranch", trieModifications, statedb)
2135-
2136-
oracle.PreventHashingInSecureTrie = false
2137-
}
2138-
2139-
func replaceAtIndex(in string, r rune, i int) string {
2140-
out := []rune(in)
2141-
out[i] = r
2142-
return string(out)
2143-
}
2144-
2145-
// Note: this requires MockProver with config param 11
2146-
func TestNonHashedExtensionNodeInBranch(t *testing.T) {
2147-
blockNum := 0
2148-
blockNumberParent := big.NewInt(int64(blockNum))
2149-
blockHeaderParent := oracle.PrefetchBlock(blockNumberParent, true, nil)
2150-
database := state.NewDatabase(blockHeaderParent)
2151-
statedb, _ := state.New(blockHeaderParent.Root, database, nil)
2152-
addr := common.HexToAddress("0x50efbf12580138bc623c95757286df4e24eb81c9")
2153-
2154-
statedb.DisableLoadingRemoteAccounts()
2155-
2156-
statedb.CreateAccount(addr)
2157-
2158-
oracle.PreventHashingInSecureTrie = true // to store the unchanged key
2159-
2160-
val1 := common.BigToHash(big.NewInt(int64(1)))
2161-
2162-
key1Hex := "0x1000000000000000000000000000000000000000000000000000000000000000"
2163-
key2Hex := "0x2000000000000000000000000000000000000000000000000000000000000000"
2164-
key1 := common.HexToHash(key1Hex)
2165-
key2 := common.HexToHash(key2Hex)
2166-
fmt.Println(key2)
2167-
2168-
statedb.SetState(addr, key2, val1)
2169-
2170-
iters := 58 // make the extension node shorter than 32
2171-
for i := 0; i < iters; i++ {
2172-
statedb.SetState(addr, key1, val1)
2173-
2174-
if i == iters - 1 {
2175-
break
2176-
}
2177-
2178-
makeExtension := false
2179-
if i == iters - 2 {
2180-
makeExtension = true
2181-
}
2182-
2183-
if !makeExtension {
2184-
key1Hex = replaceAtIndex(key1Hex, 49, i + 3)
2185-
} else {
2186-
key1Hex = replaceAtIndex(key1Hex, 49, i + 1 + 3)
2187-
}
2188-
2189-
key1 = common.HexToHash(key1Hex)
2190-
}
2191-
2192-
statedb.IntermediateRoot(false)
2193-
2194-
val := common.BigToHash(big.NewInt(int64(17)))
2195-
trieMod := TrieModification{
2196-
Type: StorageChanged,
2197-
Key: key1,
2198-
Value: val,
2199-
Address: addr,
2200-
}
2201-
trieModifications := []TrieModification{trieMod}
2202-
2203-
GenerateProof("NonHashedExtensionNodeInBranch", trieModifications, statedb)
2204-
2205-
oracle.PreventHashingInSecureTrie = false
2206-
}
2207-
2208-
// Note: this requires MockProver with config param 11
2209-
func TestNonHashedExtensionNodeInBranchTwoNibbles(t *testing.T) {
2210-
blockNum := 0
2211-
blockNumberParent := big.NewInt(int64(blockNum))
2212-
blockHeaderParent := oracle.PrefetchBlock(blockNumberParent, true, nil)
2213-
database := state.NewDatabase(blockHeaderParent)
2214-
statedb, _ := state.New(blockHeaderParent.Root, database, nil)
2215-
addr := common.HexToAddress("0x50efbf12580138bc623c95757286df4e24eb81c9")
2216-
2217-
statedb.DisableLoadingRemoteAccounts()
2218-
2219-
statedb.CreateAccount(addr)
2220-
2221-
oracle.PreventHashingInSecureTrie = true // to store the unchanged key
2222-
2223-
val1 := common.BigToHash(big.NewInt(int64(1)))
2224-
2225-
key1Hex := "0x1000000000000000000000000000000000000000000000000000000000000000"
2226-
key2Hex := "0x2000000000000000000000000000000000000000000000000000000000000000"
2227-
key1 := common.HexToHash(key1Hex)
2228-
key2 := common.HexToHash(key2Hex)
2229-
fmt.Println(key2)
2230-
2231-
statedb.SetState(addr, key2, val1)
2232-
2233-
iters := 58 // make the extension node shorter than 32
2234-
for i := 0; i < iters; i++ {
2235-
statedb.SetState(addr, key1, val1)
2236-
2237-
if i == iters - 1 {
2238-
break
2239-
}
2240-
2241-
makeExtension := false
2242-
if i == iters - 2 {
2243-
makeExtension = true
2244-
}
2245-
2246-
if !makeExtension {
2247-
key1Hex = replaceAtIndex(key1Hex, 49, i + 3)
2248-
} else {
2249-
key1Hex = replaceAtIndex(key1Hex, 49, i + 2 + 3) // +2 to have two nibbles
2250-
}
2251-
2252-
key1 = common.HexToHash(key1Hex)
2253-
}
2254-
2255-
statedb.IntermediateRoot(false)
2256-
2257-
val := common.BigToHash(big.NewInt(int64(17)))
2258-
trieMod := TrieModification{
2259-
Type: StorageChanged,
2260-
Key: key1,
2261-
Value: val,
2262-
Address: addr,
2263-
}
2264-
trieModifications := []TrieModification{trieMod}
2265-
2266-
GenerateProof("NonHashedExtensionNodeInBranchTwoNibbles", trieModifications, statedb)
2267-
2268-
oracle.PreventHashingInSecureTrie = false
2269-
}
2270-
*/
2271-
22722082
func TestBranchAfterExtNode(t *testing.T) {
22732083
blockNum := 0
22742084
blockNumberParent := big.NewInt(int64(blockNum))

0 commit comments

Comments
 (0)