-
Notifications
You must be signed in to change notification settings - Fork 5
/
execution.go
47 lines (42 loc) · 1.11 KB
/
execution.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package relay
import (
"math/big"
lctypes "github.com/datachainlab/ethereum-ibc-relay-prover/light-clients/ethereum/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
func (pr *Prover) buildAccountUpdate(blockNumber uint64) (*lctypes.AccountUpdate, error) {
proof, err := pr.executionClient.GetProof(
pr.chain.Config().IBCAddress(),
nil,
big.NewInt(int64(blockNumber)),
)
if err != nil {
return nil, err
}
return &lctypes.AccountUpdate{
AccountProof: proof.AccountProofRLP,
AccountStorageRoot: proof.StorageHash[:],
}, nil
}
func (pr *Prover) buildStateProof(path []byte, height int64) ([]byte, error) {
// calculate slot for commitment
slot := crypto.Keccak256Hash(append(
crypto.Keccak256Hash(path).Bytes(),
common.Hash{}.Bytes()...,
))
marshaledSlot, err := slot.MarshalText()
if err != nil {
return nil, err
}
// call eth_getProof
stateProof, err := pr.executionClient.GetProof(
pr.chain.Config().IBCAddress(),
[][]byte{marshaledSlot},
big.NewInt(height),
)
if err != nil {
return nil, err
}
return stateProof.StorageProofRLP[0], nil
}