Skip to content

Commit 328ab95

Browse files
authored
Merge pull request #227 from deep-stack/pm-v4-merge
Merge branch 'v1.10.17-statediff-3.2.1' into v4
2 parents cef1fc4 + 41c9ea0 commit 328ab95

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

.github/workflows/on-master.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
- statediff
88
- statediff-v2
99
- statediff-v3
10+
- v1.10.17-statediff-v4
1011
- v1.10.17-statediff-v3
1112
- v1.10.16-statediff-v3
1213
- v1.10.15-statediff-v3

statediff/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ func (p *Params) ComputeWatchedAddressesLeafKeys() {
6666
}
6767
}
6868

69+
func (p *Params) WatchedAddressesLeafKeys() map[common.Hash]struct{} {
70+
return p.watchedAddressesLeafKeys
71+
}
72+
6973
// ParamsWithMutex allows to lock the parameters while they are being updated | read from
7074
type ParamsWithMutex struct {
7175
Params

statediff/helpers.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// VulcanizeDB
2+
// Copyright © 2022 Vulcanize
3+
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
package statediff
18+
19+
import (
20+
"encoding/json"
21+
"fmt"
22+
"os"
23+
24+
"github.com/ethereum/go-ethereum/log"
25+
26+
"github.com/ethereum/go-ethereum/params"
27+
)
28+
29+
// LoadConfig loads chain config from json file
30+
func LoadConfig(chainConfigPath string) (*params.ChainConfig, error) {
31+
file, err := os.Open(chainConfigPath)
32+
if err != nil {
33+
log.Error(fmt.Sprintf("Failed to read chain config file: %v", err))
34+
35+
return nil, err
36+
}
37+
defer file.Close()
38+
39+
chainConfig := new(params.ChainConfig)
40+
if err := json.NewDecoder(file).Decode(chainConfig); err != nil {
41+
log.Error(fmt.Sprintf("invalid chain config file: %v", err))
42+
43+
return nil, err
44+
}
45+
46+
log.Info(fmt.Sprintf("Using chain config from %s file. Content %+v", chainConfigPath, chainConfig))
47+
48+
return chainConfig, nil
49+
}
50+
51+
// ChainConfig returns the appropriate ethereum chain config for the provided chain id
52+
func ChainConfig(chainID uint64) (*params.ChainConfig, error) {
53+
switch chainID {
54+
case 1:
55+
return params.MainnetChainConfig, nil
56+
case 3:
57+
return params.RopstenChainConfig, nil
58+
case 4:
59+
return params.RinkebyChainConfig, nil
60+
case 5:
61+
return params.GoerliChainConfig, nil
62+
default:
63+
return nil, fmt.Errorf("chain config for chainid %d not available", chainID)
64+
}
65+
}

0 commit comments

Comments
 (0)