Skip to content

Commit

Permalink
Update proof oracle path for Cosmos 0.47 (#333)
Browse files Browse the repository at this point in the history
* fix proof path

* fix space
  • Loading branch information
RogerKSI authored Feb 15, 2024
1 parent 7f20f43 commit d264e4b
Show file tree
Hide file tree
Showing 6 changed files with 232 additions and 230 deletions.
8 changes: 4 additions & 4 deletions client/grpc/oracle/proof/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ var relayFormat = []byte(`
},
{
"internalType": "bytes32",
"name": "paramsToSlashingStoresMerkleHash",
"name": "ibcToIcahostStoresMerkleHash",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "govToIcahostStoresMerkleHash",
"name": "feegrantToGroupStoresMerkleHash",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "authToFeegrantStoresMerkleHash",
"name": "authToEvidenceStoresMerkleHash",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "stakingToUpgradeStoresMerkleHash",
"name": "paramsToUpgradeStoresMerkleHash",
"type": "bytes32"
}
],
Expand Down
36 changes: 18 additions & 18 deletions client/grpc/oracle/proof/multi_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@ import (

// MultiStoreProofEthereum is an Ethereum version of MultiStoreProof for solidity ABI-encoding.
type MultiStoreProofEthereum struct {
OracleIAVLStateHash common.Hash
MintStoreMerkleHash common.Hash
ParamsToSlashingStoresMerkleHash common.Hash
GovToIcahostStoresMerkleHash common.Hash
AuthToFeegrantStoresMerkleHash common.Hash
StakingToUpgradeStoresMerkleHash common.Hash
OracleIAVLStateHash common.Hash
MintStoreMerkleHash common.Hash
IbcToIcahostStoresMerkleHash common.Hash
FeegrantToGroupStoresMerkleHash common.Hash
AuthToEvidenceStoresMerkleHash common.Hash
ParamsToUpgradeStoresMerkleHash common.Hash
}

func (m *MultiStoreProof) encodeToEthFormat() MultiStoreProofEthereum {
return MultiStoreProofEthereum{
OracleIAVLStateHash: common.BytesToHash(m.OracleIAVLStateHash),
MintStoreMerkleHash: common.BytesToHash(m.MintStoreMerkleHash),
ParamsToSlashingStoresMerkleHash: common.BytesToHash(m.ParamsToSlashingStoresMerkleHash),
GovToIcahostStoresMerkleHash: common.BytesToHash(m.GovToIcahostStoresMerkleHash),
AuthToFeegrantStoresMerkleHash: common.BytesToHash(m.AuthToFeegrantStoresMerkleHash),
StakingToUpgradeStoresMerkleHash: common.BytesToHash(m.StakingToUpgradeStoresMerkleHash),
OracleIAVLStateHash: common.BytesToHash(m.OracleIAVLStateHash),
MintStoreMerkleHash: common.BytesToHash(m.MintStoreMerkleHash),
IbcToIcahostStoresMerkleHash: common.BytesToHash(m.IbcToIcahostStoresMerkleHash),
FeegrantToGroupStoresMerkleHash: common.BytesToHash(m.FeegrantToGroupStoresMerkleHash),
AuthToEvidenceStoresMerkleHash: common.BytesToHash(m.AuthToEvidenceStoresMerkleHash),
ParamsToUpgradeStoresMerkleHash: common.BytesToHash(m.ParamsToUpgradeStoresMerkleHash),
}
}

// GetMultiStoreProof compacts Multi store proof from Tendermint to MultiStoreProof version.
func GetMultiStoreProof(multiStoreEp *ics23.ExistenceProof) MultiStoreProof {
return MultiStoreProof{
OracleIAVLStateHash: tmbytes.HexBytes(multiStoreEp.Value),
MintStoreMerkleHash: tmbytes.HexBytes(multiStoreEp.Path[0].Prefix[1:]),
ParamsToSlashingStoresMerkleHash: tmbytes.HexBytes(multiStoreEp.Path[1].Suffix),
GovToIcahostStoresMerkleHash: tmbytes.HexBytes(multiStoreEp.Path[2].Prefix[1:]),
AuthToFeegrantStoresMerkleHash: tmbytes.HexBytes(multiStoreEp.Path[3].Prefix[1:]),
StakingToUpgradeStoresMerkleHash: tmbytes.HexBytes(multiStoreEp.Path[4].Suffix),
OracleIAVLStateHash: tmbytes.HexBytes(multiStoreEp.Value),
MintStoreMerkleHash: tmbytes.HexBytes(multiStoreEp.Path[0].Prefix[1:]),
IbcToIcahostStoresMerkleHash: tmbytes.HexBytes(multiStoreEp.Path[1].Prefix[1:]),
FeegrantToGroupStoresMerkleHash: tmbytes.HexBytes(multiStoreEp.Path[2].Prefix[1:]),
AuthToEvidenceStoresMerkleHash: tmbytes.HexBytes(multiStoreEp.Path[3].Prefix[1:]),
ParamsToUpgradeStoresMerkleHash: tmbytes.HexBytes(multiStoreEp.Path[4].Suffix),
}
}
14 changes: 7 additions & 7 deletions client/grpc/oracle/proof/multi_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ query at localhost:26657/abci_query?path="/store/oracle/key"&data=0xc00000000000
{
"type": "ics23:iavl",
"key": "wAAAAAAAAAA=",
"data": "EsMDCgjAAAAAAAAAABLpAQoVBQ1eS8RW3fDH5wAMd46Ih4w7Tw0SEhAIARIMCPLi8Z8GEMDCo+ABGgwIARgBIAEqBAAC+CUiKggBEiYCBPglIMOXtvsiuUKm461Mtf/w7SDhGVqba09R5L1VU2Y2HGeOICIsCAESBQQI5CYgGiEgubs5NRGOw8xaesuOPr7hPvlY1LNxamfQ5qwMMKn8l80iKggBEiYGDOQmIAqGoK3PW8B0zAWNvdrvKtLMf9f2nUvJ/8HUfbG+mLCDICIqCAESJgga+isgwVjErYVeGYGfWDSJS9zW6U1GPMLdybMMGp3k+lT5x+ggGsoBCgHwEgZvcmFjbGUaCwgBGAEgASoDAAICIiwIARIFAgTkJiAaISCUHaTOnLkieD5s4z9auzNnWGOptSWVA3As2DTxLWzmZyIqCAESJgQI5CYg5zZMcUYFSwmSAmz9ub37BrR2v3mWJNOfELL/z1YSFJggIioIARImBgzkJiAKhqCtz1vAdMwFjb3a7yrSzH/X9p1Lyf/B1H2xvpiwgyAiKggBEiYIGvorIMFYxK2FXhmBn1g0iUvc1ulNRjzC3cmzDBqd5PpU+cfoIA=="
"data": "EtsCCgjAAAAAAAAAABKyAQoBBhIdCBAQEBiAAiCABChkMNCGA0ADSEZQgOCllrsRWAEaCwgBGAEgASoDAAICIisIARIEAgQCIBohIOtzm7IvSLfzBTqQuiuk/gf6smLK34ZkSJVlxQ/1Bbi9I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at localhost:26657/abci_query?path="/store/oracle/key"&data=0xc00000000000
func TestGetMultiStoreProof(t *testing.T) {
key := []byte("oracle")
data := base64ToBytes(
"CvwBCgZvcmFjbGUSIIM4YL+a7OkzwrQJ6EwUJEt+FIGnboCro+OQiGZs9UAFGgkIARgBIAEqAQAiJQgBEiEBCdlpWuQ2tdx5sWp9VcTA+Y2NRuM1L8YtFLgJeZsaDxUiJwgBEgEBGiCwlrc6YwUsF2ydIB3k9PiBO3bBHhoP0IHOJtO2nDIVPyIlCAESIQFjiuPaA6L1DtVd8DXecpB+lu/MQBzkzCZ6M7j3fc3/8iIlCAESIQGDasyPrY+cK/pMuiQihLx69Ek6gZUDJ+b6v80jTKvZfiInCAESAQEaIP3tTGQiclpWi3Qerkck9TntQJo1rBxSoN6oEp1iFuNJ",
"CvoBCgZvcmFjbGUSIKPQ574oserr40+EoLhlrRgTGdrpgYViYEujG7W9rVBXGgkIARgBIAEqAQAiJQgBEiEBszziiEyGhp8/QWWNpdXqtweFbE6u087DWf5LXq0L+TIiJQgBEiEB3e3II3T8dhCPmDUxvJ1pJX5rydODMevJMyFcgoCkKOoiJQgBEiEBFpkM5/i+rVeuJ7iT04lRhhji55+3UobQFAvRoy5bAaIiJQgBEiEBTbPwtCi+YzaPpM9Zk+1Z73qE27/GXJESOD/JanvndjYiJwgBEgEBGiD3/25dJyNfa+hHLtAoLdyt2kECqzbUMTuiMuTW8f/kbA==",
)

var multistoreOps storetypes.CommitmentOp
Expand All @@ -72,19 +72,19 @@ func TestGetMultiStoreProof(t *testing.T) {

apphash := innerHash(
innerHash(
m.AuthToFeegrantStoresMerkleHash,
m.AuthToEvidenceStoresMerkleHash,
innerHash(
m.GovToIcahostStoresMerkleHash,
m.FeegrantToGroupStoresMerkleHash,
innerHash(
m.IbcToIcahostStoresMerkleHash,
innerHash(
m.MintStoreMerkleHash,
leafHash(append(prefix, tmhash.Sum(m.OracleIAVLStateHash)...)),
),
m.ParamsToSlashingStoresMerkleHash,
),
),
),
m.StakingToUpgradeStoresMerkleHash,
m.ParamsToUpgradeStoresMerkleHash,
)

require.Equal(t, expectAppHash, apphash)
Expand Down
Loading

0 comments on commit d264e4b

Please sign in to comment.