diff --git a/stubchain/genesis.json b/stubchain/genesis.json index 30f2d3033..5756a0f70 100644 --- a/stubchain/genesis.json +++ b/stubchain/genesis.json @@ -1,8 +1,8 @@ { "app_name": "symd", - "app_version": "0.46.0-beta2-4046-g23eb1fe157", - "genesis_time": "2024-09-24T13:43:43.558692Z", - "chain_id": "chain-DY1Nch", + "app_version": "0.46.0-beta2-4051-gdb91927a6b", + "genesis_time": "2024-09-26T14:02:57.334459Z", + "chain_id": "chain-D6yfsZ", "initial_height": 1, "app_hash": null, "app_state": { @@ -21,70 +21,70 @@ "accounts": [ { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "cosmos1m9m85vq9ya0eyrhhaqp097rfkqgudtrga5kqws", + "address": "cosmos1yjqtrftlv0q7sj686s5mytuvu7ql8czyk642ph", "pub_key": null, "account_number": "0", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "cosmos1uckl8lu9nasgnns9jkx4p3ktn387rg0vfr3qjn", + "address": "cosmos1zag6g46z57cslzvday43936dffj7lwpvtry2r0", "pub_key": null, "account_number": "0", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "cosmos1k80z2pmpfpl7edqd8ndltqgxpccvhyjr6lemu2", + "address": "cosmos125q86stp8e2e5ku5t89d8rv6l32d6htpp0fa23", "pub_key": null, "account_number": "0", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "cosmos1z24matkhkz56l2j4tf4pmsr9u9mfr5jtwq9rqh", + "address": "cosmos15cjlsn5hnn8pfz2kzhn5kp3mnfwc03qwynna58", "pub_key": null, "account_number": "0", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "cosmos1rsjvsf9hu8fwza8fs5fxuycxlrt3g4jg6tjlvm", + "address": "cosmos1h25xp7uggjd5nf934qyfhwqv54scc3fn2zuvhx", "pub_key": null, "account_number": "0", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "cosmos1k68sttf37ycefltmvs32vntf3x3enu6q9tah5d", + "address": "cosmos1eqlv0eruwh36t5jq82p0c36qpqphfs0uhtw4rd", "pub_key": null, "account_number": "0", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "cosmos1xpggmrc5s06s22t9xvz7nkj7a9ek0mm536gwx6", + "address": "cosmos1n4x4ermq84lvgs0a9smppc2nf2z2skleyp7g0y", "pub_key": null, "account_number": "0", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "cosmos12ecl3dddqsuht4h204me005hswkr4v07ln6mjz", + "address": "cosmos1d70rpx40wjgzfys99fxdhe0kf4q37fszfyw9d0", "pub_key": null, "account_number": "0", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "cosmos1pnx7hgczgj90gduy66pegus7g8nsfsxxuw6ef3", + "address": "cosmos1qdll8d758n8cmyyq9eewqn7tx9hc0j4jlaz736", "pub_key": null, "account_number": "0", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "cosmos1pjj9feed9l0s0urx7458zfmcdxep4rgk4dwhzw", + "address": "cosmos1j8uu0cpg7ddemt5nzhr6uyhms9nwsldjupeeg0", "pub_key": null, "account_number": "0", "sequence": "0" @@ -101,7 +101,7 @@ }, "balances": [ { - "address": "cosmos1pjj9feed9l0s0urx7458zfmcdxep4rgk4dwhzw", + "address": "cosmos1qdll8d758n8cmyyq9eewqn7tx9hc0j4jlaz736", "coins": [ { "denom": "testtoken", @@ -110,7 +110,7 @@ ] }, { - "address": "cosmos1pnx7hgczgj90gduy66pegus7g8nsfsxxuw6ef3", + "address": "cosmos1zag6g46z57cslzvday43936dffj7lwpvtry2r0", "coins": [ { "denom": "testtoken", @@ -119,7 +119,7 @@ ] }, { - "address": "cosmos1z24matkhkz56l2j4tf4pmsr9u9mfr5jtwq9rqh", + "address": "cosmos1yjqtrftlv0q7sj686s5mytuvu7ql8czyk642ph", "coins": [ { "denom": "testtoken", @@ -128,7 +128,7 @@ ] }, { - "address": "cosmos1rsjvsf9hu8fwza8fs5fxuycxlrt3g4jg6tjlvm", + "address": "cosmos125q86stp8e2e5ku5t89d8rv6l32d6htpp0fa23", "coins": [ { "denom": "testtoken", @@ -137,7 +137,7 @@ ] }, { - "address": "cosmos1xpggmrc5s06s22t9xvz7nkj7a9ek0mm536gwx6", + "address": "cosmos1d70rpx40wjgzfys99fxdhe0kf4q37fszfyw9d0", "coins": [ { "denom": "testtoken", @@ -146,7 +146,7 @@ ] }, { - "address": "cosmos12ecl3dddqsuht4h204me005hswkr4v07ln6mjz", + "address": "cosmos1j8uu0cpg7ddemt5nzhr6uyhms9nwsldjupeeg0", "coins": [ { "denom": "testtoken", @@ -155,7 +155,7 @@ ] }, { - "address": "cosmos1k80z2pmpfpl7edqd8ndltqgxpccvhyjr6lemu2", + "address": "cosmos1n4x4ermq84lvgs0a9smppc2nf2z2skleyp7g0y", "coins": [ { "denom": "testtoken", @@ -164,7 +164,7 @@ ] }, { - "address": "cosmos1k68sttf37ycefltmvs32vntf3x3enu6q9tah5d", + "address": "cosmos15cjlsn5hnn8pfz2kzhn5kp3mnfwc03qwynna58", "coins": [ { "denom": "testtoken", @@ -173,7 +173,7 @@ ] }, { - "address": "cosmos1m9m85vq9ya0eyrhhaqp097rfkqgudtrga5kqws", + "address": "cosmos1h25xp7uggjd5nf934qyfhwqv54scc3fn2zuvhx", "coins": [ { "denom": "testtoken", @@ -182,7 +182,7 @@ ] }, { - "address": "cosmos1uckl8lu9nasgnns9jkx4p3ktn387rg0vfr3qjn", + "address": "cosmos1eqlv0eruwh36t5jq82p0c36qpqphfs0uhtw4rd", "coins": [ { "denom": "testtoken", @@ -280,7 +280,7 @@ "max_rate": "1000000000000000000", "max_change_rate": "1000000000000000000" }, - "validator_address": "cosmosvaloper1m9m85vq9ya0eyrhhaqp097rfkqgudtrgcqz4zr", + "validator_address": "cosmosvaloper1yjqtrftlv0q7sj686s5mytuvu7ql8czynwpldy", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", "key": "iRs6mPSjU7lvzbNHaL0U0WTbMWfX0841e3w8TYaSYsQ=" @@ -294,7 +294,7 @@ { "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "AxXukGRfLMGl0lyseFvb7dn2CtV08J5ir/IBExR9jN5Q" + "key": "Ap3EpCuavb1zqTlEuoapTF7b40umabwK77Wfgs6xH4EL" }, "mode_info": { "single": { @@ -306,7 +306,7 @@ "fee": {} }, "signatures": [ - "U6mZVfrJ91RKpXo5kE5dT/rOxP1MHKCGpYWrkXVEw8FomaQGIlYLXNjeujGI+SqKoF/JQooneuIAHZvIlmxcAg==" + "VyY4vacVnw2EeFYoE0Hu7x5bdulnw8VrQFCck8Aqtd89OcHkJ+hed+oJLhTKW57bBiE5o672AgA9N/xIIHBeQA==" ] }, { @@ -322,7 +322,7 @@ "max_rate": "1000000000000000000", "max_change_rate": "1000000000000000000" }, - "validator_address": "cosmosvaloper1uckl8lu9nasgnns9jkx4p3ktn387rg0vvh947q", + "validator_address": "cosmosvaloper1zag6g46z57cslzvday43936dffj7lwpvwhsl0u", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", "key": "JnuO4gLYIxkeFuNsflHIa3oJnDOaflkulmBJyBYRZBY=" @@ -336,7 +336,7 @@ { "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "Au5TqNCvpog5DWrnZpYZXNbYzFuSxXLVMJAOpnIkiSRi" + "key": "Aicv1Yu9lVrnKc425bZ0lkz4njmco/ON3dqyX/UHbIaM" }, "mode_info": { "single": { @@ -348,7 +348,7 @@ "fee": {} }, "signatures": [ - "5YhZFUVKBlfirA+M9jbvbfoKLVFdrWq9bIxqEd+WBRgFRH5bWAsYqZjD7F81NgnZNGo3FvfN3Uyownu3XA7K8A==" + "zay7rmL1pQhYL34EcVEPthi66cFYViKHpMeEXeude/o9OE6YFuBw5vXZdeMr1iIUe9R50uQd9sMse8IzujWsXg==" ] }, { @@ -364,7 +364,7 @@ "max_rate": "1000000000000000000", "max_change_rate": "1000000000000000000" }, - "validator_address": "cosmosvaloper1k80z2pmpfpl7edqd8ndltqgxpccvhyjrltdwse", + "validator_address": "cosmosvaloper125q86stp8e2e5ku5t89d8rv6l32d6htpymagxz", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", "key": "jxqni3l0rtFEtRn+rh9/xwNBXZAH/JeMv+GKqy8oQNs=" @@ -378,7 +378,7 @@ { "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "AyxZZyYgyce5kfyC6IJx3FPldwd4ik0quydN9QsBxFuP" + "key": "A50gW7rTK2iWEOia5GQrnOVrIlaPVMk6Oqp+z3Z76znl" }, "mode_info": { "single": { @@ -390,7 +390,7 @@ "fee": {} }, "signatures": [ - "9LF+8VoNbBzSkLBdT7mhYNs+zfd42U232beBRuYP6K5E8irwdFa+JRi0zd1qRykh8K0aFCpLopus2kmYo0cQ0w==" + "61Hyq09xHdOMxpxDRG01w25dPK5Qid6yRu3gQdsrWKgHSNR9xscyzyAOC8P5BRtBXR7yAqcvgucdvmMYuZiAsw==" ] }, { @@ -406,7 +406,7 @@ "max_rate": "1000000000000000000", "max_change_rate": "1000000000000000000" }, - "validator_address": "cosmosvaloper1z24matkhkz56l2j4tf4pmsr9u9mfr5jtt53kvy", + "validator_address": "cosmosvaloper15cjlsn5hnn8pfz2kzhn5kp3mnfwc03qwp88gc5", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", "key": "pIrkx6DXsAdrrf/THO/Jo0KSaAU85JXfWL4et+8RO/c=" @@ -420,7 +420,7 @@ { "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "Axth80TcgI7sFy8embImgMeUO7VsiQW6keTeu+AZsE4y" + "key": "Ah3skRuoXgr3oErhnapdJXTlMNUNZLp1vznKywpvvVOW" }, "mode_info": { "single": { @@ -432,7 +432,7 @@ "fee": {} }, "signatures": [ - "lbMdJBlMjsA7xZBYHO1Jg1F/egWOgxaP3SGLLG3gzQYj1gSXA2brGOht40WvJiZf8oGhjdfm1HzsvKCs1WXGiw==" + "POM5baejF0YMfQ7G7Pc8vlqncIZPtDzXnQUHofLOi9dAZoBsAAe5oPWYk2tT05mgBumqvT0fPVG3+Ym4hNmL1g==" ] }, { @@ -448,7 +448,7 @@ "max_rate": "1000000000000000000", "max_change_rate": "1000000000000000000" }, - "validator_address": "cosmosvaloper1rsjvsf9hu8fwza8fs5fxuycxlrt3g4jgllx2qg", + "validator_address": "cosmosvaloper1h25xp7uggjd5nf934qyfhwqv54scc3fn0kgem4", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", "key": "QWYoFrX622+5ySIVAlSReoB6rVOVCqO7lY/oJjUz0lA=" @@ -462,7 +462,7 @@ { "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "A+JH4V+9qgzBJeuhlG9AD/KZvnVS1j17TTIGkCfhMCAO" + "key": "AxNOglFyZ7VsjZpdQ1scwNIY4wXVY4aeQGaSVDDPHo6d" }, "mode_info": { "single": { @@ -474,7 +474,7 @@ "fee": {} }, "signatures": [ - "K5P3ObBLmm9D39VpFyq5uQj0QSqBptUz3hIc4qH9eMQsqnPiDBoz+kGFTRaPjMxcfme4AOWle14ArCjMH43nWw==" + "aiLrBRIWuTAyZ/qEirQpRs1kx5YeJdrHOB0mBFEOy4MihuRkX9PkKpgm4DJ+r3qxCkvjnPgysCw3jY3Qw5ZdyQ==" ] }, { @@ -490,7 +490,7 @@ "max_rate": "1000000000000000000", "max_change_rate": "1000000000000000000" }, - "validator_address": "cosmosvaloper1k68sttf37ycefltmvs32vntf3x3enu6qqlfzc7", + "validator_address": "cosmosvaloper1eqlv0eruwh36t5jq82p0c36qpqphfs0ujl6q07", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", "key": "8LeN02ZamQ//prP9nyHPA6UnimOkjrMFYBUQliRVk4c=" @@ -504,7 +504,7 @@ { "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "AhxI/uufUDh6D8LeUHPQXZnXrt9XMf1sfGX5ivnR/1JM" + "key": "AoQVImTiY4aCkzigPfPmo/Upx5hKbvGmTbi/mdWGuM/s" }, "mode_info": { "single": { @@ -516,7 +516,7 @@ "fee": {} }, "signatures": [ - "ORSJcA1IHvpYqwEuShxYa5JFOUopbDyWlD6KQKSoPhc2/9AAQ+/3khojRoz4Na/01boNxashkDoVWRgnRkk2Zw==" + "IHug32EvcAWamarYTBfBSgXPcUluLe7ubXk93ZOsglQm6SjZY1fnoFByTkYzPx2owV9lFlkwpI7rVca2uF8BBg==" ] }, { @@ -532,7 +532,7 @@ "max_rate": "1000000000000000000", "max_change_rate": "1000000000000000000" }, - "validator_address": "cosmosvaloper1xpggmrc5s06s22t9xvz7nkj7a9ek0mm55wum2f", + "validator_address": "cosmosvaloper1n4x4ermq84lvgs0a9smppc2nf2z2sklep42arh", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", "key": "QsXNG44Bj+XltZDC9eQTaBRzbSFOj8D6/qgTSDtky2E=" @@ -546,7 +546,7 @@ { "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "AhAT1A+AjVknQCPsdgVxgKWLcqgVcaQvoZbz4q0RFslr" + "key": "A3uXZ8e15GyLo5zfHQllFtEXn3HNz+Tc3EyR3BiUD2uV" }, "mode_info": { "single": { @@ -558,7 +558,7 @@ "fee": {} }, "signatures": [ - "8hTZxNepEeL9byUBPu/a/UaHN06eNkoj0b+W5a+AnWYcJOcTXK8gOY1Pv1P6prJIsdscAW7B5RRMQeIysRdFaA==" + "WhFcny3o2G4p7FQdm7InhFUfSma1EZmszWbSq73XcHdaJ4hQ32lIzIyYrmFajM9D9gVqRJbKB7Og2B7MsMnV+Q==" ] }, { @@ -574,7 +574,7 @@ "max_rate": "1000000000000000000", "max_change_rate": "1000000000000000000" }, - "validator_address": "cosmosvaloper12ecl3dddqsuht4h204me005hswkr4v0768ww73", + "validator_address": "cosmosvaloper1d70rpx40wjgzfys99fxdhe0kf4q37fszvs6spu", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", "key": "JUgFVHF19EZAOFAs5tkeBhaHtlaIW7KMV3qrEewA81E=" @@ -588,7 +588,7 @@ { "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "A+Hd2HvgCAUmVsHr39oxhJDbWuUycC0Yhk1NMeWe0Nf8" + "key": "A3nRyEkMyto09hxg/5s6h4NxZqCvSq4gFXw6dndC+4fR" }, "mode_info": { "single": { @@ -600,7 +600,7 @@ "fee": {} }, "signatures": [ - "VL9DoyA5KzmZhK4s+LV7IZ2tn++N1Y7o71ppVxsPct0BqZhwo9a/3nCKJbva/wo0q88QJa3m9chqerO9Pfk1jQ==" + "yJj487CGVtn6aVogTiA+Q3YVCNvHLlgNlchBzOfredBIhCw7Vpr6rN1XNy7En57LKAQAknF5t55dGEHhO8SWZg==" ] }, { @@ -616,7 +616,7 @@ "max_rate": "1000000000000000000", "max_change_rate": "1000000000000000000" }, - "validator_address": "cosmosvaloper1pnx7hgczgj90gduy66pegus7g8nsfsxxe6wv9z", + "validator_address": "cosmosvaloper1qdll8d758n8cmyyq9eewqn7tx9hc0j4j6fktaf", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", "key": "G6jiSL6UIdRIZ396zTGDwrYxTH8TRzDY4DvoknNlI4o=" @@ -630,7 +630,7 @@ { "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "AuDsUmmX0WoHtuzC5q4c0NoV9WhshPrft50i4CXWz2bB" + "key": "AsMynYJZ7kW2WZPsEnY20OloqOUEyojbxpNbEuCZL0kd" }, "mode_info": { "single": { @@ -642,7 +642,7 @@ "fee": {} }, "signatures": [ - "yTGzt5o1tyrHmW/OAG2+DoFuHG1AyzXdGyMopQNciD9tJa1O2cS0JgpPXvnKEPpmEQwurts3ZQ+rYKAZfvvbLg==" + "Q077Xve3VTNb1nFrSoe51ZF5iTU+DoPP9U6MCuV2QLZXDmas3E7nfU0RSJR0rxZ4xGhH5h9tD9p33BQcEfO55A==" ] }, { @@ -658,7 +658,7 @@ "max_rate": "1000000000000000000", "max_change_rate": "1000000000000000000" }, - "validator_address": "cosmosvaloper1pjj9feed9l0s0urx7458zfmcdxep4rgkse6zwa", + "validator_address": "cosmosvaloper1j8uu0cpg7ddemt5nzhr6uyhms9nwsldje4dvyu", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", "key": "mIeRbGM0RPerYPY6iKJIz5VIfdefNATH8JLcqgfJ5fQ=" @@ -672,7 +672,7 @@ { "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "AqnBF0h5nODJS9J+FjPiBF+KzNVgvyF+gs8aTYRlH1s5" + "key": "ArXPRLBxuvLqX6BFQiKp9FOA+fJs4sUqVJijROGjm0fj" }, "mode_info": { "single": { @@ -684,7 +684,7 @@ "fee": {} }, "signatures": [ - "RprHlWvzEouBfE1nj35bmGjwP0hLKJPCTprXIm2SLzECaszW4gj+U9K5leR1eMsdNmjkfIZghkN4gaDW9VAehg==" + "KAiIdWN8IL02H1Qa3TrV43oSCwG1xzsAgj4aE+2ae/oAiBJ7qG6TduozGEfkpVzjVtrUgOo4SZnXGH5Z8YfmqA==" ] } ], diff --git a/symapp/app_di.go b/symapp/app_di.go index 53c7cba48..569ed5f4b 100644 --- a/symapp/app_di.go +++ b/symapp/app_di.go @@ -4,15 +4,12 @@ package symapp import ( "cosmossdk.io/x/symStaking/abci" - stakingtypes "cosmossdk.io/x/symStaking/types" _ "embed" "fmt" - "io" - "path/filepath" - "strings" - dbm "github.com/cosmos/cosmos-db" "github.com/spf13/cast" + "io" + "path/filepath" clienthelpers "cosmossdk.io/client/v2/helpers" "cosmossdk.io/core/appmodule" @@ -228,7 +225,6 @@ func NewSymApp( ba.SetVerifyVoteExtensionHandler(voteExtensionHandler.VerifyVoteExtension()) ba.SetPrepareProposal(abciPropHandler.PrepareProposal()) ba.SetPreBlocker(abciPropHandler.PreBlocker()) - ba.AddRunTxRecoveryHandler(RecoverHandler) }) app.App = appBuilder.Build(db, traceStore, baseAppOptions...) @@ -437,19 +433,3 @@ func BlockedAddresses() map[string]bool { return result } - -// we use this handler to restart on failure on our errors -func RecoverHandler(recoveryObj interface{}) error { - err, ok := recoveryObj.(error) - if !ok || err == nil { - return nil - } - if stakingtypes.ErrSymbioticValUpdate.Is(err) { - panic(fmt.Errorf("symbiotic panic: %w", err)) - } - // IDK after this error node stops receiving blocks - if strings.Contains(err.Error(), "peer is not sending us data fast enough") { - panic(fmt.Errorf("Consensus peer error: %w", err)) - } - return err -} diff --git a/x/symGenutil/gentx.go b/x/symGenutil/gentx.go index 793f71bdb..bff6c5e8c 100644 --- a/x/symGenutil/gentx.go +++ b/x/symGenutil/gentx.go @@ -111,7 +111,9 @@ func DeliverGenTxs( } } - stakingKeeper.CacheBlockHash(initBlockHash, 0) + if err := stakingKeeper.CacheBlockHash(ctx, stakingtypes.CachedBlockHash{BlockHash: initBlockHash, Height: 0}); err != nil { + return nil, fmt.Errorf("failed to cache block hash %w", err) + } return stakingKeeper.BlockValidatorUpdates(ctx) } diff --git a/x/symGenutil/types/expected_keepers.go b/x/symGenutil/types/expected_keepers.go index 6d5eb8318..bf39bd8d2 100644 --- a/x/symGenutil/types/expected_keepers.go +++ b/x/symGenutil/types/expected_keepers.go @@ -4,6 +4,7 @@ import ( "context" "cosmossdk.io/core/appmodule" bankexported "cosmossdk.io/x/bank/exported" + stakingtypes "cosmossdk.io/x/symStaking/types" "encoding/json" "github.com/cosmos/cosmos-sdk/codec" @@ -12,7 +13,7 @@ import ( // StakingKeeper defines the expected staking keeper (noalias) type StakingKeeper interface { - CacheBlockHash(blockHash string, height int64) + CacheBlockHash(ctx context.Context, blockHash stakingtypes.CachedBlockHash) error BlockValidatorUpdates(ctx context.Context) ([]appmodule.ValidatorUpdate, error) } diff --git a/x/symStaking/abci/proposal.go b/x/symStaking/abci/proposal.go index f6fa6f981..bcdd7bee1 100644 --- a/x/symStaking/abci/proposal.go +++ b/x/symStaking/abci/proposal.go @@ -3,7 +3,7 @@ package abci import ( "cosmossdk.io/log" keeper2 "cosmossdk.io/x/symStaking/keeper" - "cosmossdk.io/x/symStaking/types" + stakingtypes "cosmossdk.io/x/symStaking/types" "encoding/json" "errors" abci "github.com/cometbft/cometbft/abci/types" @@ -25,78 +25,64 @@ func NewProposalHandler(logger log.Logger, keeper *keeper2.Keeper) *ProposalHand func (h *ProposalHandler) PrepareProposal() sdk.PrepareProposalHandler { return func(ctx sdk.Context, req *abci.PrepareProposalRequest) (*abci.PrepareProposalResponse, error) { - resp, err := h.internalPrepareProposal(ctx, req) - if err != nil { - panic(errors.Join(types.ErrSymbioticValUpdate, err)) - } + proposalTxs := req.Txs - return resp, nil - } -} + if req.Height%keeper2.SYMBIOTIC_SYNC_PERIOD != 0 { + return &abci.PrepareProposalResponse{ + Txs: proposalTxs, + }, nil + } -func (h *ProposalHandler) PreBlocker() sdk.PreBlocker { - return func(ctx sdk.Context, req *abci.FinalizeBlockRequest) error { - if err := h.internalPreBlocker(ctx, req); err != nil { - panic(errors.Join(types.ErrSymbioticValUpdate, err)) + blockHash, err := h.keeper.GetFinalizedBlockHash(ctx) + if err != nil { + // anyway recovers in baseapp.abci so just skip + blockHash = keeper2.INVALID_BLOCKHASH } - return nil - } -} + // NOTE: We use stdlib JSON encoding, but an application may choose to use + // a performant mechanism. This is for demo purposes only. + bz, err := json.Marshal(blockHash) + if err != nil { + return nil, errors.New("failed to encode injected vote extension tx") + } -func (h *ProposalHandler) internalPrepareProposal(ctx sdk.Context, req *abci.PrepareProposalRequest) (*abci.PrepareProposalResponse, error) { - proposalTxs := req.Txs + // Inject a "fake" tx into the proposal s.t. validators can decode, verify, + // and store the canonical stake-weighted average prices. + proposalTxs = append([][]byte{bz}, proposalTxs...) - if req.Height%keeper2.SYMBIOTIC_SYNC_PERIOD != 0 { return &abci.PrepareProposalResponse{ Txs: proposalTxs, }, nil } +} - blockHash, err := h.keeper.GetFinalizedBlockHash(ctx) - if err != nil { - return nil, err - } - - // NOTE: We use stdlib JSON encoding, but an application may choose to use - // a performant mechanism. This is for demo purposes only. - bz, err := json.Marshal(blockHash) - if err != nil { - return nil, errors.New("failed to encode injected vote extension tx") - } +func (h *ProposalHandler) PreBlocker() sdk.PreBlocker { + return func(ctx sdk.Context, req *abci.FinalizeBlockRequest) error { + if req.Height%keeper2.SYMBIOTIC_SYNC_PERIOD != 0 || len(req.Txs) == 0 { + return nil + } - // Inject a "fake" tx into the proposal s.t. validators can decode, verify, - // and store the canonical stake-weighted average prices. - proposalTxs = append([][]byte{bz}, proposalTxs...) + var blockHash string + if err := json.Unmarshal(req.Txs[0], &blockHash); err != nil { + return err + } - return &abci.PrepareProposalResponse{ - Txs: proposalTxs, - }, nil -} + block, err := h.keeper.GetBlockByHash(ctx, blockHash) + if err != nil { + return err + } -func (h *ProposalHandler) internalPreBlocker(context sdk.Context, req *abci.FinalizeBlockRequest) error { - if req.Height%keeper2.SYMBIOTIC_SYNC_PERIOD != 0 || len(req.Txs) == 0 { - return nil - } + if block.Time() < h.prevBlockTime || int64(block.Time()) >= ctx.HeaderInfo().Time.Unix() || block.Time() < h.keeper.GetMinBlockTimestamp(ctx) { + err := h.keeper.CacheBlockHash(ctx, stakingtypes.CachedBlockHash{BlockHash: blockHash, Height: req.Height}) + return err + } - var blockHash string - if err := json.Unmarshal(req.Txs[0], &blockHash); err != nil { - return err - } + if err := h.keeper.CacheBlockHash(ctx, stakingtypes.CachedBlockHash{BlockHash: blockHash, Height: req.Height}); err != nil { + return err + } - block, err := h.keeper.GetBlockByHash(context, blockHash) - if err != nil { - return err - } + h.prevBlockTime = block.Time() - if block.Time() < h.prevBlockTime || int64(block.Time()) >= context.HeaderInfo().Time.Unix() || block.Time() < h.keeper.GetMinBlockTimestamp(context) { - h.keeper.CacheBlockHash(keeper2.INVALID_BLOCKHASH, req.Height) return nil } - - h.keeper.CacheBlockHash(blockHash, req.Height) - - h.prevBlockTime = block.Time() - - return nil } diff --git a/x/symStaking/keeper/keeper.go b/x/symStaking/keeper/keeper.go index 9a1f6e257..e78cf6dcb 100644 --- a/x/symStaking/keeper/keeper.go +++ b/x/symStaking/keeper/keeper.go @@ -51,10 +51,11 @@ type Keeper struct { cometInfoService comet.Service apiUrls types.ApiUrls networkMiddlewareAddress string - cachedBlockHash CachedBlockHash Schema collections.Schema + // CachedBlockHash value: CachedBlockHash + CachedBlockHash collections.Item[[]byte] // HistoricalInfo key: Height | value: HistoricalInfo HistoricalInfo collections.Map[uint64, types.HistoricalRecord] // LastTotalPower value: LastTotalPower @@ -111,8 +112,8 @@ func NewKeeper( consensusAddressCodec: consensusAddressCodec, cometInfoService: cometInfoService, apiUrls: types.NewApiUrls(), - cachedBlockHash: CachedBlockHash{}, networkMiddlewareAddress: networkMiddlewareAddress, + CachedBlockHash: collections.NewItem(sb, types.CachedBlockHashKey, "cached_block_hash", collections.BytesValue), LastTotalPower: collections.NewItem(sb, types.LastTotalPowerKey, "last_total_power", sdk.IntValue), HistoricalInfo: collections.NewMap(sb, types.HistoricalInfoKey, "historical_info", collections.Uint64Key, HistoricalInfoCodec(cdc)), UnbondingID: collections.NewSequence(sb, types.UnbondingIDKey, "unbonding_id"), diff --git a/x/symStaking/keeper/symbiotic_state_change.go b/x/symStaking/keeper/symbiotic_state_change.go index a2cdd477c..9c70a3f83 100644 --- a/x/symStaking/keeper/symbiotic_state_change.go +++ b/x/symStaking/keeper/symbiotic_state_change.go @@ -57,11 +57,6 @@ type Validator struct { ConsAddr [32]byte } -type CachedBlockHash struct { - BlockHash string - Height int64 -} - const ( SYMBIOTIC_SYNC_PERIOD = 10 SLEEP_ON_RETRY = 200 @@ -120,9 +115,13 @@ const ( ]` ) -func (k *Keeper) CacheBlockHash(blockHash string, height int64) { - k.cachedBlockHash.BlockHash = blockHash - k.cachedBlockHash.Height = height +func (k *Keeper) CacheBlockHash(ctx context.Context, blockHash stakingtypes.CachedBlockHash) error { + bz, err := json.Marshal(blockHash) + if err != nil { + return err + } + err = k.CachedBlockHash.Set(ctx, bz) + return err } func (k *Keeper) SymbioticUpdateValidatorsPower(ctx context.Context) error { @@ -136,19 +135,38 @@ func (k *Keeper) SymbioticUpdateValidatorsPower(ctx context.Context) error { return nil } - if k.cachedBlockHash.Height != height { - return fmt.Errorf("symbiotic no blockhash cache, actual cached height %v, expected %v", k.cachedBlockHash.Height, height) + exist, err := k.CachedBlockHash.Has(ctx) + if err != nil { + return err } - if k.cachedBlockHash.BlockHash == INVALID_BLOCKHASH { + if !exist { + return nil + } + + data, err := k.CachedBlockHash.Get(ctx) + if err != nil { + return err + } + + var cachedBlockHash stakingtypes.CachedBlockHash + + if err := json.Unmarshal(data, &cachedBlockHash); err != nil { + return err + } + + if cachedBlockHash.Height != height { // TODO need to research failures on processProposal, mb better to skip block if height is old + return fmt.Errorf("symbiotic no blockhash cache, actual cached height %v, expected %v", cachedBlockHash.Height, height) + } + + if cachedBlockHash.BlockHash == INVALID_BLOCKHASH { return nil } var validators []Validator - var err error for i := 0; i < RETRIES; i++ { - validators, err = k.getSymbioticValidatorSet(ctx, k.cachedBlockHash.BlockHash) + validators, err = k.getSymbioticValidatorSet(ctx, cachedBlockHash.BlockHash) if err == nil { break } diff --git a/x/symStaking/keeper/val_state_change.go b/x/symStaking/keeper/val_state_change.go index e93ed614b..8f373cbb9 100644 --- a/x/symStaking/keeper/val_state_change.go +++ b/x/symStaking/keeper/val_state_change.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" gogotypes "github.com/cosmos/gogoproto/types" + "os" "sort" "cosmossdk.io/core/address" @@ -22,7 +23,8 @@ func (k Keeper) BlockValidatorUpdates(ctx context.Context) ([]appmodule.Validato // Calculate validator set changes. // if err := k.SymbioticUpdateValidatorsPower(ctx); err != nil { - panic(errors.Join(types.ErrSymbioticValUpdate, err)) + k.Logger.Error("Symbiotic val update panic", "err", err) + os.Exit(0) // TODO somehow fix, just to restart on failure, panic will be recovered } // NOTE: ApplyAndReturnValidatorSetUpdates has to come before // UnbondAllMatureValidatorQueue. diff --git a/x/symStaking/types/keys.go b/x/symStaking/types/keys.go index c97f1af4c..e4421ef33 100644 --- a/x/symStaking/types/keys.go +++ b/x/symStaking/types/keys.go @@ -49,7 +49,10 @@ var ( ValidatorQueueKey = collections.NewPrefix(67) // prefix for the timestamps in validator queue HistoricalInfoKey = collections.NewPrefix(80) // prefix for the historical info - ParamsKey = collections.NewPrefix(81) // prefix for parameters for module x/symStaking = collections.NewPrefix(106) // prefix for rotated cons address to new cons address + ParamsKey = collections.NewPrefix(81) // prefix for parameters for module x/symStaking + + CachedBlockHashKey = collections.NewPrefix(90) // prefix for finalized blockhash + ) // Reserved kvstore keys diff --git a/x/symStaking/types/symbiotic.go b/x/symStaking/types/symbiotic.go new file mode 100644 index 000000000..5eb2c2666 --- /dev/null +++ b/x/symStaking/types/symbiotic.go @@ -0,0 +1,6 @@ +package types + +type CachedBlockHash struct { + BlockHash string + Height int64 +}