Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
ab9ff72
Add ics23 integration
h5law Jun 19, 2023
b47402d
Add SMT proof conversion to ics23 Existence and Exclusion proofs with…
h5law Jun 19, 2023
20fa2fc
Add ICS23 docs
h5law Jun 19, 2023
52e62e4
Fix errors
h5law Jun 21, 2023
0656658
Update next error comment
h5law Jun 27, 2023
d631bb3
Address comments in docs
h5law Jun 27, 2023
1beb4bd
Add names back to tests
h5law Jun 27, 2023
9a7a578
Address comments
h5law Jun 27, 2023
327ed96
Address comments
h5law Jun 29, 2023
bc5a878
add isLeft helper and use smt.GetPathBit()
h5law Jun 29, 2023
2f67dcd
go.mod
h5law Jun 29, 2023
17e2419
Fix SMT repo
h5law Jun 29, 2023
cf92d93
Add IBC proto types to protogen
h5law Jun 20, 2023
a194cef
Add provable stores and HandleMessage
h5law Jun 20, 2023
c7206fc
Export treestore trees
h5law Jun 20, 2023
8c9f38a
Add IBC message handling
h5law Jun 20, 2023
9b3d286
Add ibc message types
h5law Jun 20, 2023
797ac03
Add provable stores and HandleMessage
h5law Jun 20, 2023
b1f9a88
Add more IBC errors
h5law Jun 20, 2023
1dca7d8
Add GetProvableStore
h5law Jun 20, 2023
ff2d440
Implement provableStore
h5law Jun 20, 2023
83fb7a1
Add private key to ibc config
h5law Jun 20, 2023
aa56b42
Allow conversion of IbcMessage to Transaction
h5law Jun 20, 2023
454db6e
HandleEvent adds ibc message to TxMempool
h5law Jun 20, 2023
0d867f3
Add signer to messages
h5law Jun 20, 2023
a3178e4
Implement utility Message interface for IbcMessage types
h5law Jun 20, 2023
3570e52
Update IBC config to have a private key
h5law Jun 20, 2023
22970b1
Add IBC nil field errors
h5law Jun 20, 2023
f72f513
Add IbcMessage Tx handling logic
h5law Jun 20, 2023
c7176e8
Add techdebt comment
h5law Jun 20, 2023
5c2bbc5
Remove duplicate method
h5law Jun 20, 2023
c05ab8e
Add IBC store change related postgres DB sql code
h5law Jun 20, 2023
3732091
Add update IBC state tree logic from postgres DB changes
h5law Jun 20, 2023
5ffa511
Remove prefix field from ibc messages
h5law Jun 20, 2023
eee1a18
Add IBC postgres db update error
h5law Jun 20, 2023
cdec8ca
Add SetIBCStoreEntry method to PostgresContext
h5law Jun 20, 2023
ac619b4
Address linter errors
h5law Jun 21, 2023
ff447f7
Add HandleMessage unit tests
h5law Jun 22, 2023
6e4a510
Simplify tests as covered in utility
h5law Jun 22, 2023
895dfd0
Update validation testcases
h5law Jun 22, 2023
ac2a974
Fix importing twice
h5law Jun 22, 2023
dbf7f2b
Add nolint comments
h5law Jun 22, 2023
0c05028
Check msg equality in test mempool test
h5law Jun 22, 2023
2cf0ff2
Add new issue comments
h5law Jun 22, 2023
7cbbe6e
Add mockgen flag for ProvableStore
h5law Jun 23, 2023
a1edf4b
Address comments
h5law Jun 23, 2023
416682b
Add diagrams
h5law Jun 23, 2023
953a146
Update state hashes
h5law Jun 26, 2023
c39ea1d
fixup: runtime key addition
h5law Jun 26, 2023
89550be
fixup: remove prefixes from IbcMessages
h5law Jun 26, 2023
4766802
Clear IBC table state between tests
h5law Jun 26, 2023
ed94086
Improve unit test cases
h5law Jun 26, 2023
32964cb
Add no valuehashing to state trees
h5law Jun 26, 2023
1d84d08
Add ibc.feature text file to track upcoming tests to be added
h5law Jun 26, 2023
f7e7c0c
Update docs
h5law Jun 26, 2023
be48d99
Fix proto naming
h5law Jun 29, 2023
e54be28
Add signer comments
h5law Jun 29, 2023
9ccc197
Prefix errors with IBC
h5law Jun 29, 2023
fbadb8d
Update docs
h5law Jun 29, 2023
65f647f
Address comments
h5law Jun 29, 2023
6414094
Update IBC errors
h5law Jun 29, 2023
681a328
Remove no value hashing from state trees
h5law Jun 29, 2023
128cee5
Reword IBC stores
h5law Jun 29, 2023
ccea884
Update interfaces
h5law Jun 29, 2023
d27211d
Add storesDir to IBC config and pass to host and storemanger
h5law Jun 29, 2023
d476191
golint error
h5law Jun 29, 2023
9cb2bdd
Reorganise
h5law Jun 29, 2023
6b74a5f
Update docs on data retrieval
h5law Jun 29, 2023
9ba683a
Update docs on provable stores and caching
h5law Jun 29, 2023
5bb0adf
Prefix errors
h5law Jun 30, 2023
157f3c9
Merge branch 'main' into ibc/initial_stores
h5law Jun 30, 2023
e94f4a9
linter error
h5law Jun 30, 2023
e6b53fe
Address comments
h5law Jul 4, 2023
a6aaa50
del: squash and merge submodule PR & add TreeStore to bus
h5law Jun 30, 2023
782a09b
squash and merge submodule PR
h5law Jul 5, 2023
ca110fa
squash and merge submodule PR
h5law Jul 8, 2023
f948f34
Make host a submodule
h5law Jun 30, 2023
fbe18f3
Add event broadcasting logic
h5law Jun 30, 2023
db6d287
Pass bus to storemanager
h5law Jun 30, 2023
c4b37c4
Add consensus module to prepare environment
h5law Jun 30, 2023
bf166a0
Add comment around signatures
h5law Jun 30, 2023
3db3d60
Add godoc comments
h5law Jun 30, 2023
fa3e337
Remove SQL injectors as emit handles these
h5law Jun 30, 2023
9c7f8b0
Add bus to store manager and getallstores function
h5law Jun 30, 2023
1fddfdd
Add emit update store message event test
h5law Jun 30, 2023
12c6ff6
Update emitter functions to handle the msg locally first
h5law Jun 30, 2023
129d987
golint errors
h5law Jun 30, 2023
65e83cf
Add IBC messages as presigned transactions to utility mempool directly
h5law Jul 1, 2023
f28b193
Fix mocks, remove HandleMessage calls and IBC message type
h5law Jul 3, 2023
5ae0b1d
Consolidate tests
h5law Jul 3, 2023
bda216d
Give host submodule a config
h5law Jul 4, 2023
ad09c34
Remove redundant functions from host module
h5law Jul 4, 2023
90109d8
Rename module.go to submodule.go
h5law Jul 4, 2023
365a62f
Make storeManager => BulkStoreCacher submodule
h5law Jul 4, 2023
cfc844b
Add mutex and techdebt comment
h5law Jul 4, 2023
d77d2c9
linter errors
h5law Jul 4, 2023
688e8a2
Rename IBCHostModule to IBCHostSubmodule
h5law Jul 5, 2023
fa8a26d
Rename letter => poktEnvelope
h5law Jul 5, 2023
1d02438
rename ibc_host_module.go => ibc_host_submodule.go
h5law Jul 5, 2023
eb71ffa
Add BulkStoreCacher config and background flushing task
h5law Jul 5, 2023
4de98ca
emmitter.go => emitter.go
h5law Jul 5, 2023
4e02f45
Add comment to host in ibcModule struct
h5law Jul 5, 2023
89bea23
Add spacing to give better readability
h5law Jul 5, 2023
d9093c6
Mock TreeStore
h5law Jul 6, 2023
ba859d8
rename module files
h5law Jul 6, 2023
668799c
Add provable store unit tests
h5law Jul 6, 2023
6191406
fix linter errors
h5law Jul 6, 2023
a970009
Remove debug log line
h5law Jul 6, 2023
68e28a3
Flush cache on new height event
h5law Jul 6, 2023
70e7f14
Update mocks
h5law Jul 6, 2023
77b41ca
Prefix cache entries with store name
h5law Jul 6, 2023
94815d6
Capitalise log lines
h5law Jul 7, 2023
3824933
Stop consensus module in cleanup
h5law Jul 7, 2023
d5bd28c
Remove 1 validator from test env
h5law Jul 7, 2023
08c74cc
Implement Is() for error comparison
h5law Jul 7, 2023
d907843
Move nil value check to persistence layer
h5law Jul 7, 2023
5017d02
Make value not null
h5law Jul 7, 2023
3e18676
Add persistence IBC method tests
h5law Jul 7, 2023
2588a8d
Handle consensus new height events in the IBC module
h5law Jul 8, 2023
3a2dae9
Add height to cache restoration
h5law Jul 8, 2023
53bc07e
Add research comment
h5law Jul 8, 2023
9739f84
Update docs
h5law Jul 8, 2023
99111eb
Fix linter error
h5law Jul 8, 2023
d00ac54
Address comments
h5law Jul 11, 2023
733f53b
merge: squash and merge main
h5law Jul 11, 2023
3668f1b
merge: squash and merge ibc/initial_stores
h5law Jul 11, 2023
4f112b8
Merge branch 'ibc/initial_stores' into ibc/host_submodule
h5law Jul 11, 2023
cac0ea6
Fix spelling error
h5law Jul 11, 2023
3edbf67
use multierr
h5law Jul 11, 2023
99db8db
Add tests for pruning and flushing on new heights
h5law Jul 11, 2023
0e0b3a4
add nolint comment
h5law Jul 11, 2023
7994828
Merge branch 'main' into ibc/initial_stores
h5law Jul 11, 2023
99c3815
rename MaxHeightStored => MaxHeightCached
h5law Jul 11, 2023
1f45a82
Address comments on test
h5law Jul 11, 2023
35cb54a
Add mermaid diagram
h5law Jul 12, 2023
57c6b92
address comments
h5law Jul 12, 2023
03b83c5
address comments
h5law Jul 12, 2023
9c73e71
Merge branch 'ibc/initial_stores' into ibc/host_submodule
h5law Jul 12, 2023
7278aba
add comments, use filepath.Join
h5law Jul 13, 2023
4a26267
Merge branch 'main' into ibc/host_submodule
h5law Jul 13, 2023
a0dee48
remove artifacts from merge
h5law Jul 13, 2023
229242f
remove old files from merge
h5law Jul 13, 2023
8e75455
fix cache dir name
h5law Jul 13, 2023
e8f0600
make persistence test deterministic again
h5law Jul 13, 2023
56dd0e3
remove unused mutex
h5law Jul 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions ibc/docs/ics24.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,38 @@ Upon making a local change to the IBC store the host will:
4. Add the `Transaction` to the local mempool
5. Broadcast the `Transaction` via the `P2P` module for the other nodes to include it in their mempools

```mermaid
graph TD
subgraph Update
A[Key]
B[Value]
end
subgraph UpdateIBCStore
C[Signer]
D[Key]
E[Value]
end
subgraph IBCMessage
F[Event]
end
subgraph Transaction
G[Msg]
H[Nonce]
I[Signature]
end
subgraph Mempool
J[Txs]
end
subgraph P2P
K[Broadcast]
end
Update -- "Update(Key, Value)" --> UpdateIBCStore
UpdateIBCStore -- UpdateIBCStore --> IBCMessage
IBCMessage -- Message --> Transaction
Transaction -- Tx --> Mempool
Transaction -- Tx --> P2P
```

See: [emitter.go](../store/emitter.go) for the specific implementation details.

### Mempool
Expand Down
92 changes: 35 additions & 57 deletions ibc/ibc_handle_event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestHandleEvent_FlushCaches(t *testing.T) {
require.NoError(t, cache.Stop())
}

// using MaxStoredHeight = 3
// using MaxHeightCached = 3
func TestHandleEvent_PruneCaches(t *testing.T) {
mgr, _, _, _, ibcMod := prepareEnvironment(t, 1, 0, 0, 0)
tmpDir := mgr.GetConfig().IBC.StoresDir + "/caches"
Expand Down Expand Up @@ -125,49 +125,49 @@ func TestHandleEvent_PruneCaches(t *testing.T) {
}

testCases := []struct {
name string
heights []uint64
expectedHeights []uint64
length int
name string
heightsStored []uint64 // the different heights where entries are written to the cache
expectedHeightsCached []uint64 // the different heights expected in the cache after pruning
cacheLength int // the length of the cache after pruning
}{
{
name: "No pruning after single height increase",
heights: []uint64{1, 2},
expectedHeights: []uint64{1},
length: 4,
name: "No pruning after single height increase",
heightsStored: []uint64{1, 2},
expectedHeightsCached: []uint64{1},
cacheLength: 4,
},
{
name: "No pruning after two height increase",
heights: []uint64{1, 2, 3},
expectedHeights: []uint64{1, 2},
length: 8,
name: "No pruning after two height increase",
heightsStored: []uint64{1, 2, 3},
expectedHeightsCached: []uint64{1, 2},
cacheLength: 8,
},
{
name: "No pruning at max height stored = 3",
heights: []uint64{1, 2, 3, 4},
expectedHeights: []uint64{1, 2, 3},
length: 12,
name: "No pruning at max height stored = 3",
heightsStored: []uint64{1, 2, 3, 4},
expectedHeightsCached: []uint64{1, 2, 3},
cacheLength: 12,
},
{
name: "Pruning after 4 height increase",
heights: []uint64{1, 2, 3, 4, 5},
expectedHeights: []uint64{2, 3, 4},
length: 12,
name: "Pruning after 4 height increase",
heightsStored: []uint64{1, 2, 3, 4, 5},
expectedHeightsCached: []uint64{2, 3, 4},
cacheLength: 12,
},
{
name: "Pruning after 5 height increase",
heights: []uint64{1, 2, 3, 4, 5, 6},
expectedHeights: []uint64{3, 4, 5},
length: 12,
name: "Pruning after 5 height increase",
heightsStored: []uint64{1, 2, 3, 4, 5, 6},
expectedHeightsCached: []uint64{3, 4, 5},
cacheLength: 12,
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
// set height
publishNewHeightEvent(t, ibcMod.GetBus(), tc.heights[0])
publishNewHeightEvent(t, ibcMod.GetBus(), tc.heightsStored[0])

for _, height := range tc.heights[1:] {
for _, height := range tc.heightsStored[1:] {
for _, kv := range kvs {
if kv.value != nil {
require.NoError(t, store.Set(kv.key, kv.value))
Expand All @@ -186,13 +186,14 @@ func TestHandleEvent_PruneCaches(t *testing.T) {
require.NoError(t, err)
keys, values, err := cache.GetAll([]byte{}, false)
require.NoError(t, err)
require.Len(t, keys, tc.length)
require.Len(t, values, tc.length)

// iterate over the expected heights and check the keys and values are correct
for i, height := range tc.expectedHeights {
for j, key := range keys[i*4 : (i+1)*4] {
require.Equal(t, string(key), prepareCacheKey(height, kvs[j%4].key))
require.Len(t, keys, tc.cacheLength)
require.Len(t, values, tc.cacheLength)

// iterate over all the keys in batches of 4 (for each expected height) confirming the expected height
// is the same as the height stored in the cache for each batch
for i, height := range tc.expectedHeightsCached {
for j, key := range keys[i*4 : (i+1)*4] { // split keys into batches of 4 per height expected
require.Equal(t, string(key), prepareCacheKey(height, kvs[j%4].key)) // validate the expected height is the actual height
if kvs[j%4].value == nil {
require.Equal(t, values[j], []byte{})
continue
Expand All @@ -201,29 +202,6 @@ func TestHandleEvent_PruneCaches(t *testing.T) {
}
}

err = cache.ClearAll()
require.NoError(t, err)

newKeys, newValues, err := cache.GetAll([]byte{}, false)
require.NoError(t, err)
require.Len(t, newKeys, 0)
require.Len(t, newValues, 0)

require.NoError(t, cache.Stop())

// flush the cache
err = ibcHost.GetBus().GetBulkStoreCacher().FlushAllEntries()
require.NoError(t, err)

cache, err = kvstore.NewKVStore(tmpDir)
require.NoError(t, err)

// check in memory cache was cleared (ie nothing flushed)
newKeys, newValues, err = cache.GetAll([]byte{}, false)
require.NoError(t, err)
require.Len(t, newKeys, 0)
require.Len(t, newValues, 0)

require.NoError(t, cache.Stop())
})
}
Expand Down
2 changes: 1 addition & 1 deletion ibc/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func newTestRuntimeConfig(
Host: &configs.IBCHostConfig{
PrivateKey: "0ca1a40ddecdab4f5b04fa0bfed1d235beaa2b8082e7554425607516f0862075dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e",
BulkStoreCacher: &configs.BulkStoreCacherConfig{
MaxHeightStored: 3,
MaxHeightCached: 3,
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions ibc/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ func (m *ibcModule) HandleEvent(event *anypb.Any) error {
return err
}
// Prune old cache entries
if currHeight <= m.cfg.Host.BulkStoreCacher.MaxHeightStored {
if currHeight <= m.cfg.Host.BulkStoreCacher.MaxHeightCached {
break
}
pruneHeight := currHeight - m.cfg.Host.BulkStoreCacher.MaxHeightStored
pruneHeight := currHeight - m.cfg.Host.BulkStoreCacher.MaxHeightCached
if err := bsc.PruneCaches(pruneHeight); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func NewDefaultConfig(options ...func(*Config)) *Config {
StoresDir: defaults.DefaultIBCStoresDir,
Host: &IBCHostConfig{
BulkStoreCacher: &BulkStoreCacherConfig{
MaxHeightStored: defaults.DefaultIBCCacheMaxHeightStored,
MaxHeightCached: defaults.DefaultIBCCacheMaxHeightCached,
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion runtime/configs/proto/ibc_config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ message IBCHostConfig {

message BulkStoreCacherConfig {
// INVESTIGATE: Should we cap the cache size by size (bytes) instead of heights which could, theoretically, grow unbounded
uint64 max_height_stored = 1; // maximum number of heights to be stored in the cache before pruning
// For example, if num_heights_cached=5, then at height=100, we would cache heights [96,100], and at height=101, we would drop 96 and add 101
uint64 max_height_cached = 1; // maximum number of heights to be stored in the cache before pruning
}
2 changes: 1 addition & 1 deletion runtime/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var (
// ibc
DefaultIBCEnabled = false
DefaultIBCStoresDir = "/var/ibc"
DefaultIBCCacheMaxHeightStored = uint64(5)
DefaultIBCCacheMaxHeightCached = uint64(5)
)

var (
Expand Down
2 changes: 1 addition & 1 deletion runtime/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1826,7 +1826,7 @@ func TestNewManagerFromReaders(t *testing.T) {
Host: &configs.IBCHostConfig{
PrivateKey: "0ca1a40ddecdab4f5b04fa0bfed1d235beaa2b8082e7554425607516f0862075dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e",
BulkStoreCacher: &configs.BulkStoreCacherConfig{
MaxHeightStored: defaults.DefaultIBCCacheMaxHeightStored,
MaxHeightCached: defaults.DefaultIBCCacheMaxHeightCached,
},
},
},
Expand Down