• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lmittmann / w3 / 7997657861

22 Feb 2024 12:42AM UTC coverage: 74.867%. Remained the same
7997657861

Pull #113

github

web-flow
build(deps): bump github.com/ethereum/go-ethereum in /examples

Bumps [github.com/ethereum/go-ethereum](https://github.com/ethereum/go-ethereum) from 1.13.11 to 1.13.13.
- [Release notes](https://github.com/ethereum/go-ethereum/releases)
- [Commits](https://github.com/ethereum/go-ethereum/compare/v1.13.11...v1.13.13)

---
updated-dependencies:
- dependency-name: github.com/ethereum/go-ethereum
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #113: build(deps): bump github.com/ethereum/go-ethereum from 1.13.11 to 1.13.13 in /examples

1966 of 2626 relevant lines covered (74.87%)

1349.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.0
/w3vm/db.go
1
package w3vm
2

3
import (
4
        "errors"
5

6
        "github.com/ethereum/go-ethereum/common"
7
        gethState "github.com/ethereum/go-ethereum/core/state"
8
        "github.com/ethereum/go-ethereum/core/types"
9
        "github.com/ethereum/go-ethereum/ethdb"
10
        "github.com/ethereum/go-ethereum/trie"
11
        "github.com/ethereum/go-ethereum/trie/trienode"
12
        "github.com/holiman/uint256"
13
        "github.com/lmittmann/w3/internal/crypto"
14
)
15

16
var errNotFound = errors.New("not found")
17

18
// db implements the [state.Database] and [state.Trie] interfaces.
19
type db struct {
20
        fetcher Fetcher
21
}
22

23
func newDB(fetcher Fetcher) *db {
52✔
24
        return &db{
52✔
25
                fetcher: fetcher,
52✔
26
        }
52✔
27
}
52✔
28

29
////////////////////////////////////////////////////////////////////////////////////////////////////
30
// state.Database methods //////////////////////////////////////////////////////////////////////////
31
////////////////////////////////////////////////////////////////////////////////////////////////////
32

33
func (db *db) OpenTrie(root common.Hash) (gethState.Trie, error) { return db, nil }
52✔
34

35
func (db *db) OpenStorageTrie(stateRoot common.Hash, addr common.Address, root common.Hash, trie gethState.Trie) (gethState.Trie, error) {
4,198✔
36
        return db, nil
4,198✔
37
}
4,198✔
38

39
func (*db) CopyTrie(gethState.Trie) gethState.Trie { panic("not implemented") }
×
40

41
func (db *db) ContractCode(addr common.Address, codeHash common.Hash) ([]byte, error) {
7,335✔
42
        if db.fetcher == nil {
7,335✔
43
                return []byte{}, nil
×
44
        }
×
45

46
        code, err := db.fetcher.Code(addr)
7,335✔
47
        if err != nil {
7,335✔
48
                return nil, errNotFound
×
49
        }
×
50
        return code, nil
7,335✔
51
}
52

53
func (db *db) ContractCodeSize(addr common.Address, codeHash common.Hash) (int, error) {
2,074✔
54
        code, err := db.ContractCode(addr, codeHash)
2,074✔
55
        if err != nil {
2,074✔
56
                return 0, err
×
57
        }
×
58
        return len(code), nil
2,074✔
59
}
60

61
func (*db) DiskDB() ethdb.KeyValueStore { panic("not implemented") }
×
62

63
func (*db) TrieDB() *trie.Database { panic("not implemented") }
×
64

65
////////////////////////////////////////////////////////////////////////////////////////////////////
66
// state.Trie methods //////////////////////////////////////////////////////////////////////////////
67
////////////////////////////////////////////////////////////////////////////////////////////////////
68

69
func (*db) GetKey([]byte) []byte { panic("not implemented") }
×
70

71
func (db *db) GetStorage(addr common.Address, key []byte) ([]byte, error) {
34,133✔
72
        if db.fetcher == nil {
34,138✔
73
                return []byte{}, nil
5✔
74
        }
5✔
75

76
        storageKey := common.BytesToHash(key)
34,128✔
77
        storageVal, err := db.fetcher.StorageAt(addr, storageKey)
34,128✔
78
        if err != nil {
34,128✔
79
                return nil, err
×
80
        }
×
81
        return storageVal.Bytes(), nil
34,128✔
82
}
83

84
func (db *db) GetAccount(addr common.Address) (*types.StateAccount, error) {
11,369✔
85
        if db.fetcher == nil {
11,393✔
86
                return &types.StateAccount{
24✔
87
                        Balance:  new(uint256.Int),
24✔
88
                        CodeHash: types.EmptyCodeHash[:],
24✔
89
                }, nil
24✔
90
        }
24✔
91

92
        nonce, err := db.fetcher.Nonce(addr)
11,345✔
93
        if err != nil {
11,349✔
94
                return nil, err
4✔
95
        }
4✔
96
        balance, err := db.fetcher.Balance(addr)
11,341✔
97
        if err != nil {
11,341✔
98
                return nil, err
×
99
        }
×
100
        code, err := db.fetcher.Code(addr)
11,341✔
101
        if err != nil {
11,341✔
102
                return nil, err
×
103
        }
×
104

105
        var codeHash []byte
11,341✔
106
        if len(code) == 0 {
17,416✔
107
                codeHash = types.EmptyCodeHash[:]
6,075✔
108
        } else {
11,341✔
109
                codeHash = crypto.Keccak256(code)
5,266✔
110
        }
5,266✔
111

112
        return &types.StateAccount{
11,341✔
113
                Nonce:    nonce,
11,341✔
114
                Balance:  uint256.MustFromBig(balance),
11,341✔
115
                CodeHash: codeHash,
11,341✔
116
        }, nil
11,341✔
117
}
118

119
func (*db) UpdateStorage(addr common.Address, key, value []byte) error { panic("not implemented") }
×
120

121
func (*db) UpdateAccount(addr common.Address, acc *types.StateAccount) error {
×
122
        panic("not implemented")
×
123
}
124

125
func (*db) UpdateContractCode(addr common.Address, codeHash common.Hash, code []byte) error {
×
126
        panic("not implemented")
×
127
}
128

129
func (*db) DeleteStorage(addr common.Address, key []byte) error { panic("not implemented") }
×
130

131
func (*db) DeleteAccount(addr common.Address) error { panic("not implemented") }
×
132

133
func (*db) Hash() common.Hash { panic("not implemented") }
×
134

135
func (*db) Commit(collectLeaf bool) (common.Hash, *trienode.NodeSet, error) {
×
136
        panic("not implemented")
×
137
}
138

139
func (*db) NodeIterator(startKey []byte) (trie.NodeIterator, error) { panic("not implemented") }
×
140

141
func (*db) Prove(key []byte, proofDb ethdb.KeyValueWriter) error { panic("not implemented") }
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc