Skip to content

Commit 283fc6d

Browse files
authored
Merge pull request #49 from vulcanize/v1.9.25-statediff-0.0.13
update github actions
2 parents f84b908 + 4d8d410 commit 283fc6d

File tree

14 files changed

+87
-75
lines changed

14 files changed

+87
-75
lines changed

.github/workflows/on-master.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Docker Build and publish to Github
33
on:
44
push:
55
branches:
6+
- v1.9.25-statediff
67
- v1.9.24-statediff
78
- v1.9.23-statediff
89
- v1.9.11-statediff

cmd/geth/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ import (
2424
"reflect"
2525
"unicode"
2626

27-
"gopkg.in/urfave/cli.v1"
2827
"github.com/ethereum/go-ethereum/eth/downloader"
2928
"github.com/ethereum/go-ethereum/statediff"
29+
"gopkg.in/urfave/cli.v1"
3030

3131
"github.com/ethereum/go-ethereum/cmd/utils"
3232
"github.com/ethereum/go-ethereum/eth"

core/blockchain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ type CacheConfig struct {
132132
Preimages bool // Whether to store preimage of trie key to the disk
133133

134134
SnapshotWait bool // Wait for snapshot construction on startup. TODO(karalabe): This is a dirty hack for testing, nuke it
135-
StateDiffing bool // Whether or not the statediffing service is running
135+
StateDiffing bool // Whether or not the statediffing service is running
136136
}
137137

138138
// defaultCacheConfig are the default caching values if none are specified by the

crypto/signify/signify_fuzz.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"log"
2626
"os"
2727
"os/exec"
28-
"runtime"
2928

3029
fuzz "github.com/google/gofuzz"
3130
"github.com/jedisct1/go-minisign"

internal/ethapi/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNrOr
935935
timeout := 5 * time.Second
936936
d, ok := ctx.Deadline()
937937
if ok {
938-
timeout = d.Sub(time.Now())
938+
timeout = time.Until(d)
939939
}
940940
result, err := DoCall(ctx, s.b, args, blockNrOrHash, accounts, vm.Config{}, timeout, s.b.RPCGasCap())
941941
if err != nil {

params/version.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import (
2121
)
2222

2323
const (
24-
VersionMajor = 1 // Major version component of the current release
25-
VersionMinor = 9 // Minor version component of the current release
26-
VersionPatch = 25 // Patch version component of the current release
24+
VersionMajor = 1 // Major version component of the current release
25+
VersionMinor = 9 // Minor version component of the current release
26+
VersionPatch = 25 // Patch version component of the current release
2727
VersionMeta = "statediff-0.0.13" // Version metadata to append to the version string
2828
)
2929

statediff/indexer/indexer.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ import (
3131
"github.com/ethereum/go-ethereum/metrics"
3232
"github.com/ethereum/go-ethereum/params"
3333
"github.com/ethereum/go-ethereum/rlp"
34-
35-
node "github.com/ipfs/go-ipld-format"
36-
"github.com/jmoiron/sqlx"
37-
"github.com/multiformats/go-multihash"
38-
3934
"github.com/ethereum/go-ethereum/statediff/indexer/ipfs/ipld"
4035
"github.com/ethereum/go-ethereum/statediff/indexer/models"
4136
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
4237
"github.com/ethereum/go-ethereum/statediff/indexer/shared"
4338
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
39+
40+
node "github.com/ipfs/go-ipld-format"
41+
"github.com/jmoiron/sqlx"
42+
"github.com/multiformats/go-multihash"
4443
)
4544

4645
var (
@@ -135,21 +134,21 @@ func (sdi *StateDiffIndexer) PushBlock(block *types.Block, receipts types.Receip
135134
shared.Rollback(tx)
136135
panic(p)
137136
} else {
138-
tDiff := time.Now().Sub(t)
137+
tDiff := time.Since(t)
139138
indexerMetrics.tStateStoreCodeProcessing.Update(tDiff)
140139
traceMsg += fmt.Sprintf("state, storage, and code storage processing time: %s\r\n", tDiff.String())
141140
t = time.Now()
142141
err = tx.Commit()
143-
tDiff = time.Now().Sub(t)
142+
tDiff = time.Since(t)
144143
indexerMetrics.tPostgresCommit.Update(tDiff)
145144
traceMsg += fmt.Sprintf("postgres transaction commit duration: %s\r\n", tDiff.String())
146145
}
147-
traceMsg += fmt.Sprintf(" TOTAL PROCESSING DURATION: %s\r\n", time.Now().Sub(start).String())
146+
traceMsg += fmt.Sprintf(" TOTAL PROCESSING DURATION: %s\r\n", time.Since(start).String())
148147
log.Debug(traceMsg)
149148
return err
150149
},
151150
}
152-
tDiff := time.Now().Sub(t)
151+
tDiff := time.Since(t)
153152
indexerMetrics.tFreePostgres.Update(tDiff)
154153

155154
traceMsg += fmt.Sprintf("time spent waiting for free postgres tx: %s:\r\n", tDiff.String())
@@ -160,15 +159,15 @@ func (sdi *StateDiffIndexer) PushBlock(block *types.Block, receipts types.Receip
160159
if err != nil {
161160
return nil, err
162161
}
163-
tDiff = time.Now().Sub(t)
162+
tDiff = time.Since(t)
164163
indexerMetrics.tHeaderProcessing.Update(tDiff)
165164
traceMsg += fmt.Sprintf("header processing time: %s\r\n", tDiff.String())
166165
t = time.Now()
167166
// Publish and index uncles
168167
if err := sdi.processUncles(tx, headerID, height, uncleNodes); err != nil {
169168
return nil, err
170169
}
171-
tDiff = time.Now().Sub(t)
170+
tDiff = time.Since(t)
172171
indexerMetrics.tUncleProcessing.Update(tDiff)
173172
traceMsg += fmt.Sprintf("uncle processing time: %s\r\n", tDiff.String())
174173
t = time.Now()
@@ -185,7 +184,7 @@ func (sdi *StateDiffIndexer) PushBlock(block *types.Block, receipts types.Receip
185184
}); err != nil {
186185
return nil, err
187186
}
188-
tDiff = time.Now().Sub(t)
187+
tDiff = time.Since(t)
189188
indexerMetrics.tTxAndRecProcessing.Update(tDiff)
190189
traceMsg += fmt.Sprintf("tx and receipt processing time: %s\r\n", tDiff.String())
191190
t = time.Now()
@@ -241,7 +240,7 @@ func (sdi *StateDiffIndexer) processUncles(tx *sqlx.Tx, headerID int64, blockNum
241240
return nil
242241
}
243242

244-
// processArgs bundles arugments to processReceiptsAndTxs
243+
// processArgs bundles arguments to processReceiptsAndTxs
245244
type processArgs struct {
246245
headerID int64
247246
blockNumber *big.Int

statediff/indexer/indexer_test.go

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ import (
2121

2222
"github.com/ethereum/go-ethereum/common"
2323
"github.com/ethereum/go-ethereum/params"
24-
"github.com/ipfs/go-cid"
25-
"github.com/ipfs/go-ipfs-blockstore"
26-
"github.com/ipfs/go-ipfs-ds-help"
27-
28-
ind "github.com/ethereum/go-ethereum/statediff/indexer"
24+
"github.com/ethereum/go-ethereum/statediff/indexer"
2925
"github.com/ethereum/go-ethereum/statediff/indexer/mocks"
30-
eth "github.com/ethereum/go-ethereum/statediff/indexer/models"
26+
"github.com/ethereum/go-ethereum/statediff/indexer/models"
3127
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
3228
"github.com/ethereum/go-ethereum/statediff/indexer/shared"
29+
30+
"github.com/ipfs/go-cid"
31+
blockstore "github.com/ipfs/go-ipfs-blockstore"
32+
dshelp "github.com/ipfs/go-ipfs-ds-help"
3333
)
3434

3535
var (
3636
db *postgres.DB
3737
err error
38-
indexer *ind.StateDiffIndexer
38+
ind *indexer.StateDiffIndexer
3939
ipfsPgGet = `SELECT data FROM public.blocks
4040
WHERE key = $1`
4141
)
@@ -51,9 +51,9 @@ func setup(t *testing.T) {
5151
if err != nil {
5252
t.Fatal(err)
5353
}
54-
indexer = ind.NewStateDiffIndexer(params.MainnetChainConfig, db)
55-
var tx *ind.BlockTx
56-
tx, err = indexer.PushBlock(
54+
ind = indexer.NewStateDiffIndexer(params.MainnetChainConfig, db)
55+
var tx *indexer.BlockTx
56+
tx, err = ind.PushBlock(
5757
mocks.MockBlock,
5858
mocks.MockReceipts,
5959
mocks.MockBlock.Difficulty())
@@ -62,7 +62,7 @@ func setup(t *testing.T) {
6262
}
6363
defer tx.Close()
6464
for _, node := range mocks.StateDiffs {
65-
err = indexer.PushStateNode(tx, node)
65+
err = ind.PushStateNode(tx, node)
6666
if err != nil {
6767
t.Fatal(err)
6868
}
@@ -72,7 +72,7 @@ func setup(t *testing.T) {
7272
}
7373

7474
func tearDown(t *testing.T) {
75-
ind.TearDownDB(t, db)
75+
indexer.TearDownDB(t, db)
7676
}
7777

7878
func TestPublishAndIndexer(t *testing.T) {
@@ -195,7 +195,7 @@ func TestPublishAndIndexer(t *testing.T) {
195195
setup(t)
196196
defer tearDown(t)
197197
// check that state nodes were properly indexed and published
198-
stateNodes := make([]eth.StateNodeModel, 0)
198+
stateNodes := make([]models.StateNodeModel, 0)
199199
pgStr := `SELECT state_cids.id, state_cids.cid, state_cids.state_leaf_key, state_cids.node_type, state_cids.state_path, state_cids.header_id
200200
FROM eth.state_cids INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.id)
201201
WHERE header_cids.block_number = $1`
@@ -217,7 +217,7 @@ func TestPublishAndIndexer(t *testing.T) {
217217
t.Fatal(err)
218218
}
219219
pgStr = `SELECT * from eth.state_accounts WHERE state_id = $1`
220-
var account eth.StateAccountModel
220+
var account models.StateAccountModel
221221
err = db.Get(&account, pgStr, stateNode.ID)
222222
if err != nil {
223223
t.Fatal(err)
@@ -227,7 +227,7 @@ func TestPublishAndIndexer(t *testing.T) {
227227
shared.ExpectEqual(t, stateNode.StateKey, common.BytesToHash(mocks.ContractLeafKey).Hex())
228228
shared.ExpectEqual(t, stateNode.Path, []byte{'\x06'})
229229
shared.ExpectEqual(t, data, mocks.ContractLeafNode)
230-
shared.ExpectEqual(t, account, eth.StateAccountModel{
230+
shared.ExpectEqual(t, account, models.StateAccountModel{
231231
ID: account.ID,
232232
StateID: stateNode.ID,
233233
Balance: "0",
@@ -241,7 +241,7 @@ func TestPublishAndIndexer(t *testing.T) {
241241
shared.ExpectEqual(t, stateNode.StateKey, common.BytesToHash(mocks.AccountLeafKey).Hex())
242242
shared.ExpectEqual(t, stateNode.Path, []byte{'\x0c'})
243243
shared.ExpectEqual(t, data, mocks.AccountLeafNode)
244-
shared.ExpectEqual(t, account, eth.StateAccountModel{
244+
shared.ExpectEqual(t, account, models.StateAccountModel{
245245
ID: account.ID,
246246
StateID: stateNode.ID,
247247
Balance: "1000",
@@ -251,14 +251,13 @@ func TestPublishAndIndexer(t *testing.T) {
251251
})
252252
}
253253
}
254-
pgStr = `SELECT * from eth.state_accounts WHERE state_id = $1`
255254
})
256255

257256
t.Run("Publish and index storage IPLDs in a single tx", func(t *testing.T) {
258257
setup(t)
259258
defer tearDown(t)
260259
// check that storage nodes were properly indexed
261-
storageNodes := make([]eth.StorageNodeWithStateKeyModel, 0)
260+
storageNodes := make([]models.StorageNodeWithStateKeyModel, 0)
262261
pgStr := `SELECT storage_cids.cid, state_cids.state_leaf_key, storage_cids.storage_leaf_key, storage_cids.node_type, storage_cids.storage_path
263262
FROM eth.storage_cids, eth.state_cids, eth.header_cids
264263
WHERE storage_cids.state_id = state_cids.id
@@ -269,7 +268,7 @@ func TestPublishAndIndexer(t *testing.T) {
269268
t.Fatal(err)
270269
}
271270
shared.ExpectEqual(t, len(storageNodes), 1)
272-
shared.ExpectEqual(t, storageNodes[0], eth.StorageNodeWithStateKeyModel{
271+
shared.ExpectEqual(t, storageNodes[0], models.StorageNodeWithStateKeyModel{
273272
CID: mocks.StorageCID.String(),
274273
NodeType: 2,
275274
StorageKey: common.BytesToHash(mocks.StorageLeafKey).Hex(),

statediff/indexer/ipfs/ipld/trie_node.go

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ import (
2525
node "github.com/ipfs/go-ipld-format"
2626
)
2727

28+
const (
29+
extension = "extension"
30+
leaf = "leaf"
31+
branch = "branch"
32+
)
33+
2834
// TrieNode is the general abstraction for
2935
//ethereum IPLD trie nodes.
3036
type TrieNode struct {
@@ -68,17 +74,23 @@ func decodeTrieNode(c cid.Cid, b []byte,
6874
return nil, err
6975
}
7076

71-
if nodeKind == "extension" {
77+
if nodeKind == extension {
7278
elements, err = parseTrieNodeExtension(decoded, codec)
79+
if err != nil {
80+
return nil, err
81+
}
7382
}
74-
if nodeKind == "leaf" {
83+
if nodeKind == leaf {
7584
elements, err = leafDecoder(decoded)
85+
if err != nil {
86+
return nil, err
87+
}
7688
}
77-
if nodeKind != "extension" && nodeKind != "leaf" {
89+
if nodeKind != extension && nodeKind != leaf {
7890
return nil, fmt.Errorf("unexpected nodeKind returned from decoder")
7991
}
8092
case 17:
81-
nodeKind = "branch"
93+
nodeKind = branch
8294
elements, err = parseTrieNodeBranch(i, codec)
8395
if err != nil {
8496
return nil, err
@@ -102,22 +114,22 @@ func decodeCompactKey(i []interface{}) (string, []interface{}, error) {
102114

103115
switch first[0] / 16 {
104116
case '\x00':
105-
return "extension", []interface{}{
117+
return extension, []interface{}{
106118
nibbleToByte(first)[2:],
107119
last,
108120
}, nil
109121
case '\x01':
110-
return "extension", []interface{}{
122+
return extension, []interface{}{
111123
nibbleToByte(first)[1:],
112124
last,
113125
}, nil
114126
case '\x02':
115-
return "leaf", []interface{}{
127+
return leaf, []interface{}{
116128
nibbleToByte(first)[2:],
117129
last,
118130
}, nil
119131
case '\x03':
120-
return "leaf", []interface{}{
132+
return leaf, []interface{}{
121133
nibbleToByte(first)[1:],
122134
last,
123135
}, nil
@@ -167,11 +179,11 @@ func parseTrieNodeBranch(i []interface{}, codec uint64) ([]interface{}, error) {
167179
// and returning the object found as well as the remaining path to traverse
168180
func (t *TrieNode) Resolve(p []string) (interface{}, []string, error) {
169181
switch t.nodeKind {
170-
case "extension":
182+
case extension:
171183
return t.resolveTrieNodeExtension(p)
172-
case "leaf":
184+
case leaf:
173185
return t.resolveTrieNodeLeaf(p)
174-
case "branch":
186+
case branch:
175187
return t.resolveTrieNodeBranch(p)
176188
default:
177189
return nil, nil, fmt.Errorf("nodeKind case not implemented")
@@ -188,13 +200,13 @@ func (t *TrieNode) Tree(p string, depth int) []string {
188200
var out []string
189201

190202
switch t.nodeKind {
191-
case "extension":
203+
case extension:
192204
var val string
193205
for _, e := range t.elements[0].([]byte) {
194206
val += fmt.Sprintf("%x", e)
195207
}
196208
return []string{val}
197-
case "branch":
209+
case branch:
198210
for i, elem := range t.elements {
199211
if _, ok := elem.(*cid.Cid); ok {
200212
out = append(out, fmt.Sprintf("%x", i))
@@ -261,9 +273,9 @@ func (t *TrieNode) MarshalJSON() ([]byte, error) {
261273
var out map[string]interface{}
262274

263275
switch t.nodeKind {
264-
case "extension":
276+
case extension:
265277
fallthrough
266-
case "leaf":
278+
case leaf:
267279
var hexPrefix string
268280
for _, e := range t.elements[0].([]byte) {
269281
hexPrefix += fmt.Sprintf("%x", e)
@@ -285,9 +297,9 @@ func (t *TrieNode) MarshalJSON() ([]byte, error) {
285297
hexPrefix: t.elements[1],
286298
}
287299

288-
case "branch":
300+
case branch:
289301
out = map[string]interface{}{
290-
"type": "branch",
302+
"type": branch,
291303
"0": t.elements[0],
292304
"1": t.elements[1],
293305
"2": t.elements[2],
@@ -432,7 +444,7 @@ func getHexIndex(s string) int {
432444
return -1
433445
}
434446

435-
c := byte(s[0])
447+
c := s[0]
436448
switch {
437449
case '0' <= c && c <= '9':
438450
return int(c - '0')

0 commit comments

Comments
 (0)