commit
eea7ef859d
14
go.mod
14
go.mod
@ -3,21 +3,21 @@ module github.com/vulcanize/eth-ipfs-state-validator
|
|||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/ethereum/go-ethereum v1.9.15
|
github.com/ethereum/go-ethereum v1.10.9
|
||||||
github.com/ipfs/go-blockservice v0.1.3
|
github.com/ipfs/go-blockservice v0.1.7
|
||||||
github.com/ipfs/go-cid v0.0.7
|
github.com/ipfs/go-cid v0.0.7
|
||||||
github.com/ipfs/go-filestore v1.0.0 //indirect
|
github.com/ipfs/go-filestore v1.0.0 //indirect
|
||||||
github.com/ipfs/go-ipfs v0.7.0
|
github.com/ipfs/go-ipfs v0.10.0
|
||||||
github.com/ipfs/go-ipfs-blockstore v1.0.0
|
github.com/ipfs/go-ipfs-blockstore v1.0.0
|
||||||
github.com/ipfs/go-ipfs-ds-help v1.0.0
|
github.com/ipfs/go-ipfs-ds-help v1.0.0
|
||||||
github.com/jmoiron/sqlx v1.2.0
|
github.com/jmoiron/sqlx v1.2.0
|
||||||
github.com/lib/pq v1.5.2
|
github.com/lib/pq v1.5.2
|
||||||
github.com/mailgun/groupcache/v2 v2.2.1
|
github.com/mailgun/groupcache/v2 v2.2.1
|
||||||
github.com/multiformats/go-multihash v0.0.14
|
github.com/multiformats/go-multihash v0.0.15
|
||||||
github.com/onsi/ginkgo v1.14.0
|
github.com/onsi/ginkgo v1.16.4
|
||||||
github.com/onsi/gomega v1.10.1
|
github.com/onsi/gomega v1.13.0
|
||||||
github.com/sirupsen/logrus v1.6.0
|
github.com/sirupsen/logrus v1.6.0
|
||||||
github.com/spf13/cobra v1.0.0
|
github.com/spf13/cobra v1.0.0
|
||||||
github.com/spf13/viper v1.7.0
|
github.com/spf13/viper v1.7.0
|
||||||
github.com/vulcanize/ipfs-ethdb v0.0.3
|
github.com/vulcanize/ipfs-ethdb v0.0.5
|
||||||
)
|
)
|
||||||
|
@ -21,8 +21,8 @@ import (
|
|||||||
|
|
||||||
"github.com/ipfs/go-blockservice"
|
"github.com/ipfs/go-blockservice"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/ipfs/go-ipfs-blockstore"
|
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
||||||
"github.com/ipfs/go-ipfs-ds-help"
|
dshelp "github.com/ipfs/go-ipfs-ds-help"
|
||||||
"github.com/ipfs/go-ipfs/core"
|
"github.com/ipfs/go-ipfs/core"
|
||||||
"github.com/ipfs/go-ipfs/repo/fsrepo"
|
"github.com/ipfs/go-ipfs/repo/fsrepo"
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
|
@ -138,3 +138,11 @@ func (v *Validator) ValidateStorageTrie(address common.Address, storageRoot comm
|
|||||||
}
|
}
|
||||||
return it.Error()
|
return it.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close implements io.Closer
|
||||||
|
// it deregisters the groupcache name
|
||||||
|
func (v *Validator) Close() error {
|
||||||
|
groupcache.DeregisterGroup("kv")
|
||||||
|
groupcache.DeregisterGroup("db")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -21,17 +21,17 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ipfs/go-cid/_rsrch/cidiface"
|
cid "github.com/ipfs/go-cid/_rsrch/cidiface"
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
"github.com/multiformats/go-multihash"
|
"github.com/multiformats/go-multihash"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"github.com/vulcanize/eth-ipfs-state-validator/pkg"
|
validator "github.com/vulcanize/eth-ipfs-state-validator/pkg"
|
||||||
"github.com/vulcanize/ipfs-ethdb/postgres"
|
pgipfsethdb "github.com/vulcanize/ipfs-ethdb/postgres"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -65,7 +65,7 @@ var (
|
|||||||
|
|
||||||
mockCode = []byte{1, 2, 3, 4, 5}
|
mockCode = []byte{1, 2, 3, 4, 5}
|
||||||
codeHash = crypto.Keccak256Hash(mockCode)
|
codeHash = crypto.Keccak256Hash(mockCode)
|
||||||
contractAccount, _ = rlp.EncodeToBytes(state.Account{
|
contractAccount, _ = rlp.EncodeToBytes(types.StateAccount{
|
||||||
Nonce: 1,
|
Nonce: 1,
|
||||||
Balance: big.NewInt(0),
|
Balance: big.NewInt(0),
|
||||||
CodeHash: codeHash.Bytes(),
|
CodeHash: codeHash.Bytes(),
|
||||||
@ -76,7 +76,7 @@ var (
|
|||||||
contractAccount,
|
contractAccount,
|
||||||
})
|
})
|
||||||
|
|
||||||
minerAccount, _ = rlp.EncodeToBytes(state.Account{
|
minerAccount, _ = rlp.EncodeToBytes(types.StateAccount{
|
||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
Balance: big.NewInt(1000),
|
Balance: big.NewInt(1000),
|
||||||
CodeHash: nullCodeHash.Bytes(),
|
CodeHash: nullCodeHash.Bytes(),
|
||||||
@ -87,7 +87,7 @@ var (
|
|||||||
minerAccount,
|
minerAccount,
|
||||||
})
|
})
|
||||||
|
|
||||||
account1, _ = rlp.EncodeToBytes(state.Account{
|
account1, _ = rlp.EncodeToBytes(types.StateAccount{
|
||||||
Nonce: 2,
|
Nonce: 2,
|
||||||
Balance: big.NewInt(1000),
|
Balance: big.NewInt(1000),
|
||||||
CodeHash: nullCodeHash.Bytes(),
|
CodeHash: nullCodeHash.Bytes(),
|
||||||
@ -98,7 +98,7 @@ var (
|
|||||||
account1,
|
account1,
|
||||||
})
|
})
|
||||||
|
|
||||||
account2, _ = rlp.EncodeToBytes(state.Account{
|
account2, _ = rlp.EncodeToBytes(types.StateAccount{
|
||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
Balance: big.NewInt(1000),
|
Balance: big.NewInt(1000),
|
||||||
CodeHash: nullCodeHash.Bytes(),
|
CodeHash: nullCodeHash.Bytes(),
|
||||||
@ -109,7 +109,7 @@ var (
|
|||||||
account2,
|
account2,
|
||||||
})
|
})
|
||||||
|
|
||||||
bankAccount, _ = rlp.EncodeToBytes(state.Account{
|
bankAccount, _ = rlp.EncodeToBytes(types.StateAccount{
|
||||||
Nonce: 2,
|
Nonce: 2,
|
||||||
Balance: big.NewInt(1000),
|
Balance: big.NewInt(1000),
|
||||||
CodeHash: nullCodeHash.Bytes(),
|
CodeHash: nullCodeHash.Bytes(),
|
||||||
@ -201,6 +201,9 @@ var _ = Describe("PG-IPFS Validator", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
v = validator.NewPGIPFSValidator(db)
|
v = validator.NewPGIPFSValidator(db)
|
||||||
})
|
})
|
||||||
|
AfterEach(func() {
|
||||||
|
v.Close()
|
||||||
|
})
|
||||||
Describe("ValidateTrie", func() {
|
Describe("ValidateTrie", func() {
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
err = validator.ResetTestDB(db)
|
err = validator.ResetTestDB(db)
|
||||||
@ -236,7 +239,7 @@ var _ = Describe("PG-IPFS Validator", func() {
|
|||||||
loadTrie(trieStateNodes, trieStorageNodes)
|
loadTrie(trieStateNodes, trieStorageNodes)
|
||||||
err = v.ValidateTrie(stateRoot)
|
err = v.ValidateTrie(stateRoot)
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
subStr := fmt.Sprintf("code %s: sql: no rows in result set", codeHash.Hex()[2:])
|
subStr := fmt.Sprintf("code %s: not found", codeHash.Hex()[2:])
|
||||||
Expect(err.Error()).To(ContainSubstring(subStr))
|
Expect(err.Error()).To(ContainSubstring(subStr))
|
||||||
})
|
})
|
||||||
It("Returns no error if the entire state (state trie and storage tries) can be validated", func() {
|
It("Returns no error if the entire state (state trie and storage tries) can be validated", func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user