From cc2c52879083b2ddaeadc7a339b97db4b8541350 Mon Sep 17 00:00:00 2001 From: Christian Lohr Date: Fri, 23 Aug 2024 13:52:34 +0200 Subject: [PATCH 1/8] feat: compass handover --- proto/palomachain/paloma/evm/chain_info.proto | 4 + proto/palomachain/paloma/evm/turnstone.proto | 23 +- .../evm/keeper/testdata/sample-abi.json | 1664 +++++++++++------ x/evm/keeper/attest_compass_handover.go | 61 + x/evm/keeper/attest_compass_handover_test.go | 289 +++ x/evm/keeper/attest_submit_logic_call.go | 91 +- x/evm/keeper/attest_submit_logic_call_test.go | 30 +- x/evm/keeper/attest_test.go | 217 ++- x/evm/keeper/attest_upload_smart_contract.go | 175 +- x/evm/keeper/deployment/cache.go | 74 - x/evm/keeper/deployment/cache_test.go | 82 - x/evm/keeper/keeper.go | 3 - x/evm/keeper/smart_contract_deployment.go | 70 +- x/evm/types/chain_info.pb.go | 141 +- x/evm/types/eth_txable.go | 58 + x/evm/types/turnstone.pb.go | 975 +++++++--- x/evm/types/turnstone_abi.go | 66 +- 17 files changed, 2606 insertions(+), 1417 deletions(-) create mode 100644 x/evm/keeper/attest_compass_handover.go create mode 100644 x/evm/keeper/attest_compass_handover_test.go delete mode 100644 x/evm/keeper/deployment/cache.go delete mode 100644 x/evm/keeper/deployment/cache_test.go diff --git a/proto/palomachain/paloma/evm/chain_info.proto b/proto/palomachain/paloma/evm/chain_info.proto index 34fac55d..08cc9520 100644 --- a/proto/palomachain/paloma/evm/chain_info.proto +++ b/proto/palomachain/paloma/evm/chain_info.proto @@ -77,6 +77,10 @@ message SmartContractDeployment { Status status = 4; message ERC20Transfer { + // individual transfers are no longer needed with the new atomic update mechanism + // TODO: remove once the new mechanism is rolled out + option deprecated = true; + // Paloma denom of the ERC20 token string denom = 1; // Address of the ERC20 token on the target chain diff --git a/proto/palomachain/paloma/evm/turnstone.proto b/proto/palomachain/paloma/evm/turnstone.proto index 31fde2b6..67295cad 100644 --- a/proto/palomachain/paloma/evm/turnstone.proto +++ b/proto/palomachain/paloma/evm/turnstone.proto @@ -31,12 +31,21 @@ message SubmitLogicCall { ExecutionRequirements executionRequirements = 7 [ (gogoproto.nullable) = false ]; uint32 retries = 8; - Fees fees = 10 + Fees fees = 10 [ (gogoproto.nullable) = true ]; } -message UpdateValset { - Valset valset = 1; +message UpdateValset { + Valset valset = 1; +} + +message CompassHandover { + message ForwardCallArgs { + string hexContractAddress = 1; + bytes payload = 2; + } + repeated ForwardCallArgs forwardCallArgs = 1 [ (gogoproto.nullable) = false ]; + int64 deadline = 2; } message UploadSmartContract { @@ -74,6 +83,7 @@ message Message { UpdateValset updateValset = 4; UploadSmartContract uploadSmartContract = 5; UploadUserSmartContract uploadUserSmartContract = 11; + CompassHandover compassHandover = 12; } string compassAddr = 6; @@ -97,10 +107,3 @@ message TxExecutedProof { } message SmartContractExecutionErrorProof { string errorMessage = 1; } - -// This is no longer in active use. -message TransferERC20Ownership { - option deprecated = true; - uint64 smartContractID = 1; - bytes newCompassAddress = 2; -} diff --git a/tests/integration/evm/keeper/testdata/sample-abi.json b/tests/integration/evm/keeper/testdata/sample-abi.json index 1e4f1a24..3fb5c8d0 100644 --- a/tests/integration/evm/keeper/testdata/sample-abi.json +++ b/tests/integration/evm/keeper/testdata/sample-abi.json @@ -1,550 +1,1130 @@ [ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "checkpoint", - "type": "bytes32" - }, - { - "indexed": false, - "name": "valset_id", - "type": "uint256" - }, - { - "indexed": false, - "name": "event_id", - "type": "uint256" - } - ], - "name": "ValsetUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "logic_contract_address", - "type": "address" - }, - { - "indexed": false, - "name": "payload", - "type": "bytes" - }, - { - "indexed": false, - "name": "message_id", - "type": "uint256" - }, - { - "indexed": false, - "name": "event_id", - "type": "uint256" - } - ], - "name": "LogicCallEvent", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "token", - "type": "address" - }, - { - "indexed": false, - "name": "sender", - "type": "address" - }, - { - "indexed": false, - "name": "receiver", - "type": "string" - }, - { - "indexed": false, - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "name": "nonce", - "type": "uint256" - }, - { - "indexed": false, - "name": "event_id", - "type": "uint256" - } - ], - "name": "SendToPalomaEvent", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "token", - "type": "address" - }, - { - "indexed": false, - "name": "batch_id", - "type": "uint256" - }, - { - "indexed": false, - "name": "nonce", - "type": "uint256" - }, - { - "indexed": false, - "name": "event_id", - "type": "uint256" - } - ], - "name": "BatchSendEvent", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "paloma_denom", - "type": "string" - }, - { - "indexed": false, - "name": "token_contract", - "type": "address" - }, - { - "indexed": false, - "name": "name", - "type": "string" - }, - { - "indexed": false, - "name": "symbol", - "type": "string" - }, - { - "indexed": false, - "name": "decimals", - "type": "uint8" - }, - { - "indexed": false, - "name": "event_id", - "type": "uint256" - } - ], - "name": "ERC20DeployedEvent", - "type": "event" - }, - { - "inputs": [ - { - "name": "_compass_id", - "type": "bytes32" - }, - { - "name": "_event_id", - "type": "uint256" - }, - { - "name": "_gravity_nonce", - "type": "uint256" - }, - { - "components": [ - { - "name": "validators", - "type": "address[]" - }, - { - "name": "powers", - "type": "uint256[]" - }, - { - "name": "valset_id", - "type": "uint256" - } - ], - "name": "valset", - "type": "tuple" - }, - { - "name": "_fee_manager", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "components": [ - { - "components": [ - { - "name": "validators", - "type": "address[]" - }, - { - "name": "powers", - "type": "uint256[]" - }, - { - "name": "valset_id", - "type": "uint256" - } + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "name":"checkpoint", + "type":"bytes32" + }, + { + "indexed":false, + "name":"valset_id", + "type":"uint256" + }, + { + "indexed":false, + "name":"event_id", + "type":"uint256" + } + ], + "name":"ValsetUpdated", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "name":"logic_contract_address", + "type":"address" + }, + { + "indexed":false, + "name":"payload", + "type":"bytes" + }, + { + "indexed":false, + "name":"message_id", + "type":"uint256" + }, + { + "indexed":false, + "name":"event_id", + "type":"uint256" + } + ], + "name":"LogicCallEvent", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "name":"token", + "type":"address" + }, + { + "indexed":false, + "name":"sender", + "type":"address" + }, + { + "indexed":false, + "name":"receiver", + "type":"bytes32" + }, + { + "indexed":false, + "name":"amount", + "type":"uint256" + }, + { + "indexed":false, + "name":"nonce", + "type":"uint256" + }, + { + "indexed":false, + "name":"event_id", + "type":"uint256" + } + ], + "name":"SendToPalomaEvent", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "name":"token", + "type":"address" + }, + { + "indexed":false, + "name":"batch_id", + "type":"uint256" + }, + { + "indexed":false, + "name":"nonce", + "type":"uint256" + }, + { + "indexed":false, + "name":"event_id", + "type":"uint256" + } + ], + "name":"BatchSendEvent", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "name":"paloma_denom", + "type":"string" + }, + { + "indexed":false, + "name":"token_contract", + "type":"address" + }, + { + "indexed":false, + "name":"name", + "type":"string" + }, + { + "indexed":false, + "name":"symbol", + "type":"string" + }, + { + "indexed":false, + "name":"decimals", + "type":"uint8" + }, + { + "indexed":false, + "name":"event_id", + "type":"uint256" + } + ], + "name":"ERC20DeployedEvent", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "name":"depositor_paloma_address", + "type":"bytes32" + }, + { + "indexed":false, + "name":"sender", + "type":"address" + }, + { + "indexed":false, + "name":"amount", + "type":"uint256" + } + ], + "name":"FundsDepositedEvent", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "name":"receiver", + "type":"address" + }, + { + "indexed":false, + "name":"amount", + "type":"uint256" + } + ], + "name":"FundsWithdrawnEvent", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "name":"contract_address", + "type":"address" + }, + { + "indexed":false, + "name":"payload", + "type":"bytes" + }, + { + "indexed":false, + "name":"event_id", + "type":"uint256" + } + ], + "name":"UpdateCompass", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "name":"contract_address", + "type":"address" + }, + { + "indexed":false, + "name":"buyer", + "type":"address" + }, + { + "indexed":false, + "name":"paloma", + "type":"bytes32" + }, + { + "indexed":false, + "name":"node_count", + "type":"uint256" + }, + { + "indexed":false, + "name":"grain_amount", + "type":"uint256" + }, + { + "indexed":false, + "name":"nonce", + "type":"uint256" + }, + { + "indexed":false, + "name":"event_id", + "type":"uint256" + } + ], + "name":"NodeSaleEvent", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "name":"child", + "type":"address" + }, + { + "indexed":false, + "name":"deployer", + "type":"address" + }, + { + "indexed":false, + "name":"event_id", + "type":"uint256" + } + ], + "name":"ContractDeployed", + "type":"event" + }, + { + "inputs":[ + { + "name":"_compass_id", + "type":"bytes32" + }, + { + "name":"_event_id", + "type":"uint256" + }, + { + "name":"_gravity_nonce", + "type":"uint256" + }, + { + "components":[ + { + "name":"validators", + "type":"address[]" + }, + { + "name":"powers", + "type":"uint256[]" + }, + { + "name":"valset_id", + "type":"uint256" + } ], - "name": "valset", - "type": "tuple" - }, - { - "components": [ - { - "name": "v", - "type": "uint256" - }, - { - "name": "r", - "type": "uint256" - }, - { - "name": "s", - "type": "uint256" - } + "name":"valset", + "type":"tuple" + }, + { + "name":"fee_manager", + "type":"address" + } + ], + "stateMutability":"nonpayable", + "type":"constructor" + }, + { + "inputs":[ + { + "components":[ + { + "components":[ + { + "name":"validators", + "type":"address[]" + }, + { + "name":"powers", + "type":"uint256[]" + }, + { + "name":"valset_id", + "type":"uint256" + } + ], + "name":"valset", + "type":"tuple" + }, + { + "components":[ + { + "name":"v", + "type":"uint256" + }, + { + "name":"r", + "type":"uint256" + }, + { + "name":"s", + "type":"uint256" + } + ], + "name":"signatures", + "type":"tuple[]" + } ], - "name": "signatures", - "type": "tuple[]" - } - ], - "name": "consensus", - "type": "tuple" - }, - { - "components": [ - { - "name": "validators", - "type": "address[]" - }, - { - "name": "powers", - "type": "uint256[]" - }, - { - "name": "valset_id", - "type": "uint256" - } - ], - "name": "new_valset", - "type": "tuple" - } - ], - "name": "update_valset", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "components": [ - { - "name": "validators", - "type": "address[]" - }, - { - "name": "powers", - "type": "uint256[]" - }, - { - "name": "valset_id", - "type": "uint256" - } + "name":"consensus", + "type":"tuple" + }, + { + "components":[ + { + "name":"validators", + "type":"address[]" + }, + { + "name":"powers", + "type":"uint256[]" + }, + { + "name":"valset_id", + "type":"uint256" + } ], - "name": "valset", - "type": "tuple" - }, - { - "components": [ - { - "name": "v", - "type": "uint256" - }, - { - "name": "r", - "type": "uint256" - }, - { - "name": "s", - "type": "uint256" - } + "name":"new_valset", + "type":"tuple" + }, + { + "name":"relayer", + "type":"address" + }, + { + "name":"gas_estimate", + "type":"uint256" + } + ], + "name":"update_valset", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "components":[ + { + "components":[ + { + "name":"validators", + "type":"address[]" + }, + { + "name":"powers", + "type":"uint256[]" + }, + { + "name":"valset_id", + "type":"uint256" + } + ], + "name":"valset", + "type":"tuple" + }, + { + "components":[ + { + "name":"v", + "type":"uint256" + }, + { + "name":"r", + "type":"uint256" + }, + { + "name":"s", + "type":"uint256" + } + ], + "name":"signatures", + "type":"tuple[]" + } ], - "name": "signatures", - "type": "tuple[]" - } - ], - "name": "consensus", - "type": "tuple" - }, - { - "components": [ - { - "name": "logic_contract_address", - "type": "address" - }, - { - "name": "payload", - "type": "bytes" - } - ], - "name": "args", - "type": "tuple" - }, - { - "name": "message_id", - "type": "uint256" - }, - { - "name": "deadline", - "type": "uint256" - } - ], - "name": "submit_logic_call", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "name": "token", - "type": "address" - }, - { - "name": "receiver", - "type": "string" - }, - { - "name": "amount", - "type": "uint256" - } - ], - "name": "send_token_to_paloma", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "components": [ - { - "name": "validators", - "type": "address[]" - }, - { - "name": "powers", - "type": "uint256[]" - }, - { - "name": "valset_id", - "type": "uint256" - } + "name":"consensus", + "type":"tuple" + }, + { + "components":[ + { + "name":"logic_contract_address", + "type":"address" + }, + { + "name":"payload", + "type":"bytes" + } ], - "name": "valset", - "type": "tuple" - }, - { - "components": [ - { - "name": "v", - "type": "uint256" - }, - { - "name": "r", - "type": "uint256" - }, - { - "name": "s", - "type": "uint256" - } + "name":"args", + "type":"tuple" + }, + { + "components":[ + { + "name":"relayer_fee", + "type":"uint256" + }, + { + "name":"community_fee", + "type":"uint256" + }, + { + "name":"security_fee", + "type":"uint256" + }, + { + "name":"fee_payer_paloma_address", + "type":"bytes32" + } ], - "name": "signatures", - "type": "tuple[]" - } - ], - "name": "consensus", - "type": "tuple" - }, - { - "name": "token", - "type": "address" - }, - { - "components": [ - { - "name": "receiver", - "type": "address[]" - }, - { - "name": "amount", - "type": "uint256[]" - } - ], - "name": "args", - "type": "tuple" - }, - { - "name": "batch_id", - "type": "uint256" - }, - { - "name": "deadline", - "type": "uint256" - } - ], - "name": "submit_batch", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "name": "_paloma_denom", - "type": "string" - }, - { - "name": "_name", - "type": "string" - }, - { - "name": "_symbol", - "type": "string" - }, - { - "name": "_decimals", - "type": "uint8" - }, - { - "name": "_blueprint", - "type": "address" - } - ], - "name": "deploy_erc20", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "compass_id", - "outputs": [ - { - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "last_checkpoint", - "outputs": [ - { - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "last_valset_id", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "last_event_id", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "last_gravity_nonce", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "name": "arg0", - "type": "address" - } - ], - "name": "last_batch_id", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "name": "arg0", - "type": "uint256" - } - ], - "name": "message_id_used", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - } + "name":"fee_args", + "type":"tuple" + }, + { + "name":"message_id", + "type":"uint256" + }, + { + "name":"deadline", + "type":"uint256" + }, + { + "name":"relayer", + "type":"address" + } + ], + "name":"submit_logic_call", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "name":"token", + "type":"address" + }, + { + "name":"receiver", + "type":"bytes32" + }, + { + "name":"amount", + "type":"uint256" + } + ], + "name":"send_token_to_paloma", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "components":[ + { + "components":[ + { + "name":"validators", + "type":"address[]" + }, + { + "name":"powers", + "type":"uint256[]" + }, + { + "name":"valset_id", + "type":"uint256" + } + ], + "name":"valset", + "type":"tuple" + }, + { + "components":[ + { + "name":"v", + "type":"uint256" + }, + { + "name":"r", + "type":"uint256" + }, + { + "name":"s", + "type":"uint256" + } + ], + "name":"signatures", + "type":"tuple[]" + } + ], + "name":"consensus", + "type":"tuple" + }, + { + "name":"token", + "type":"address" + }, + { + "components":[ + { + "name":"receiver", + "type":"address[]" + }, + { + "name":"amount", + "type":"uint256[]" + } + ], + "name":"args", + "type":"tuple" + }, + { + "name":"batch_id", + "type":"uint256" + }, + { + "name":"deadline", + "type":"uint256" + }, + { + "name":"relayer", + "type":"address" + }, + { + "name":"gas_estimate", + "type":"uint256" + } + ], + "name":"submit_batch", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "name":"buyer", + "type":"address" + }, + { + "name":"paloma", + "type":"bytes32" + }, + { + "name":"node_count", + "type":"uint256" + }, + { + "name":"grain_amount", + "type":"uint256" + } + ], + "name":"emit_nodesale_event", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "name":"_paloma_denom", + "type":"string" + }, + { + "name":"_name", + "type":"string" + }, + { + "name":"_symbol", + "type":"string" + }, + { + "name":"_decimals", + "type":"uint8" + }, + { + "name":"_blueprint", + "type":"address" + } + ], + "name":"deploy_erc20", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "name":"contract_address", + "type":"address" + }, + { + "name":"payload", + "type":"bytes" + } + ], + "name":"arbitrary_view", + "outputs":[ + { + "name":"", + "type":"bytes" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "name":"depositor_paloma_address", + "type":"bytes32" + }, + { + "name":"amount", + "type":"uint256" + } + ], + "name":"deposit", + "outputs":[ + + ], + "stateMutability":"payable", + "type":"function" + }, + { + "inputs":[ + { + "name":"amount", + "type":"uint256" + }, + { + "name":"dex", + "type":"address" + }, + { + "name":"payload", + "type":"bytes" + }, + { + "name":"min_grain", + "type":"uint256" + } + ], + "name":"withdraw", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "name":"amount", + "type":"uint256" + } + ], + "name":"security_fee_topup", + "outputs":[ + + ], + "stateMutability":"payable", + "type":"function" + }, + { + "inputs":[ + { + "components":[ + { + "components":[ + { + "name":"validators", + "type":"address[]" + }, + { + "name":"powers", + "type":"uint256[]" + }, + { + "name":"valset_id", + "type":"uint256" + } + ], + "name":"valset", + "type":"tuple" + }, + { + "components":[ + { + "name":"v", + "type":"uint256" + }, + { + "name":"r", + "type":"uint256" + }, + { + "name":"s", + "type":"uint256" + } + ], + "name":"signatures", + "type":"tuple[]" + } + ], + "name":"consensus", + "type":"tuple" + }, + { + "name":"message_id", + "type":"uint256" + }, + { + "name":"deadline", + "type":"uint256" + }, + { + "name":"receiver", + "type":"bytes32" + }, + { + "name":"relayer", + "type":"address" + }, + { + "name":"gas_estimate", + "type":"uint256" + }, + { + "name":"amount", + "type":"uint256" + }, + { + "name":"dex", + "type":"address" + }, + { + "name":"payload", + "type":"bytes" + }, + { + "name":"min_grain", + "type":"uint256" + } + ], + "name":"bridge_community_tax_to_paloma", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "components":[ + { + "components":[ + { + "name":"validators", + "type":"address[]" + }, + { + "name":"powers", + "type":"uint256[]" + }, + { + "name":"valset_id", + "type":"uint256" + } + ], + "name":"valset", + "type":"tuple" + }, + { + "components":[ + { + "name":"v", + "type":"uint256" + }, + { + "name":"r", + "type":"uint256" + }, + { + "name":"s", + "type":"uint256" + } + ], + "name":"signatures", + "type":"tuple[]" + } + ], + "name":"consensus", + "type":"tuple" + }, + { + "components":[ + { + "name":"logic_contract_address", + "type":"address" + }, + { + "name":"payload", + "type":"bytes" + } + ], + "name":"update_compass_args", + "type":"tuple[]" + }, + { + "name":"deadline", + "type":"uint256" + }, + { + "name":"gas_estimate", + "type":"uint256" + }, + { + "name":"relayer", + "type":"address" + } + ], + "name":"compass_update_batch", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "components":[ + { + "components":[ + { + "name":"validators", + "type":"address[]" + }, + { + "name":"powers", + "type":"uint256[]" + }, + { + "name":"valset_id", + "type":"uint256" + } + ], + "name":"valset", + "type":"tuple" + }, + { + "components":[ + { + "name":"v", + "type":"uint256" + }, + { + "name":"r", + "type":"uint256" + }, + { + "name":"s", + "type":"uint256" + } + ], + "name":"signatures", + "type":"tuple[]" + } + ], + "name":"consensus", + "type":"tuple" + }, + { + "name":"_deployer", + "type":"address" + }, + { + "name":"_bytecode", + "type":"bytes" + }, + { + "components":[ + { + "name":"relayer_fee", + "type":"uint256" + }, + { + "name":"community_fee", + "type":"uint256" + }, + { + "name":"security_fee", + "type":"uint256" + }, + { + "name":"fee_payer_paloma_address", + "type":"bytes32" + } + ], + "name":"fee_args", + "type":"tuple" + }, + { + "name":"message_id", + "type":"uint256" + }, + { + "name":"deadline", + "type":"uint256" + }, + { + "name":"relayer", + "type":"address" + } + ], + "name":"deploy_contract", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"compass_id", + "outputs":[ + { + "name":"", + "type":"bytes32" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"last_checkpoint", + "outputs":[ + { + "name":"", + "type":"bytes32" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"last_valset_id", + "outputs":[ + { + "name":"", + "type":"uint256" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"last_event_id", + "outputs":[ + { + "name":"", + "type":"uint256" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"last_gravity_nonce", + "outputs":[ + { + "name":"", + "type":"uint256" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "name":"arg0", + "type":"address" + } + ], + "name":"last_batch_id", + "outputs":[ + { + "name":"", + "type":"uint256" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "name":"arg0", + "type":"uint256" + } + ], + "name":"message_id_used", + "outputs":[ + { + "name":"", + "type":"bool" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"slc_switch", + "outputs":[ + { + "name":"", + "type":"bool" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"FEE_MANAGER", + "outputs":[ + { + "name":"", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + } ] diff --git a/x/evm/keeper/attest_compass_handover.go b/x/evm/keeper/attest_compass_handover.go new file mode 100644 index 00000000..163b10aa --- /dev/null +++ b/x/evm/keeper/attest_compass_handover.go @@ -0,0 +1,61 @@ +package keeper + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + keeperutil "github.com/palomachain/paloma/util/keeper" + "github.com/palomachain/paloma/util/liblog" + "github.com/palomachain/paloma/x/evm/types" +) + +type compassHandoverAttester struct { + attestionParameters + action *types.CompassHandover + logger liblog.Logr + k *Keeper +} + +func newCompassHandoverAttester(k *Keeper, l liblog.Logr, p attestionParameters) *compassHandoverAttester { + return &compassHandoverAttester{ + attestionParameters: p, + logger: l, + k: k, + } +} + +func (a *compassHandoverAttester) Execute(ctx sdk.Context) error { + a.logger = a.logger.WithFields("action-msg", "Message_CompassHandover") + a.logger.Debug("Processing compass handover message attestation.") + + a.action = a.msg.Action.(*types.Message_CompassHandover).CompassHandover + + switch winner := a.rawEvidence.(type) { + case *types.TxExecutedProof: + return a.attest(ctx, winner) + case *types.SmartContractExecutionErrorProof: + a.logger.WithFields( + "smart-contract-error", winner.GetErrorMessage()). + Warn("CompassHandover failed") + keeperutil.EmitEvent(a.k, ctx, types.SmartContractExecutionFailedKey, + types.SmartContractExecutionFailedMessageID.With(fmt.Sprintf("%d", a.msgID)), + types.SmartContractExecutionFailedChainReferenceID.With(a.chainReferenceID), + types.SmartContractExecutionFailedError.With(winner.GetErrorMessage()), + types.SmartContractExecutionMessageType.With(fmt.Sprintf("%T", a.action)), + ) + return nil + default: + return ErrUnexpectedError.JoinErrorf("unknown type %t when attesting", winner) + } +} + +func (a *compassHandoverAttester) attest(ctx sdk.Context, evidence *types.TxExecutedProof) (err error) { + _, err = attestTransactionIntegrity(ctx, a.originalMessage, a.k, evidence, + a.chainReferenceID, a.msg.AssigneeRemoteAddress, a.action.VerifyAgainstTX) + if err != nil { + a.logger.WithError(err).Error("Failed to verify transaction integrity.") + return err + } + + return nil +} diff --git a/x/evm/keeper/attest_compass_handover_test.go b/x/evm/keeper/attest_compass_handover_test.go new file mode 100644 index 00000000..0d71cc69 --- /dev/null +++ b/x/evm/keeper/attest_compass_handover_test.go @@ -0,0 +1,289 @@ +package keeper + +import ( + "encoding/hex" + "math/big" + "os" + + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + ethcoretypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + consensusmocks "github.com/palomachain/paloma/x/consensus/keeper/consensus/mocks" + consensustypes "github.com/palomachain/paloma/x/consensus/types" + "github.com/palomachain/paloma/x/evm/types" + evmmocks "github.com/palomachain/paloma/x/evm/types/mocks" + metrixtypes "github.com/palomachain/paloma/x/metrix/types" + "github.com/stretchr/testify/mock" +) + +var _ = Describe("attest compass handover", func() { + var ( + k *Keeper + ms mockedServices + ctx sdk.Context + q *consensusmocks.Queuer + msg *consensustypes.QueuedSignedMessage + consensuskeeper *evmmocks.ConsensusKeeper + evidence []*consensustypes.Evidence + retries uint32 + ) + + valAddr := "cosmosvaloper1pzf9apnk8yw7pjw3v9vtmxvn6guhkslanh8r07" + + testChain := &types.AddChainProposal{ + ChainReferenceID: "eth-main", + Title: "Test Title", + Description: "Test description", + BlockHeight: uint64(123), + BlockHashAtHeight: "0x1234", + } + + compassABI, _ := os.ReadFile("testdata/sample-abi.json") + compassBytecode, _ := os.ReadFile("testdata/sample-bytecode.out") + txData, _ := os.ReadFile("testdata/user-smart-contract-tx-data.hex") + rawData, _ := os.ReadFile("testdata/deployed-contract-event.hex") + deployedContractEventData, _ := hex.DecodeString(string(rawData)) + + testContract := &types.UserSmartContract{ + Author: valAddr, + Title: "Test Contract", + AbiJson: string(compassABI), + Bytecode: string(compassBytecode), + ConstructorInput: "0x00", + } + + BeforeEach(func() { + k, ms, ctx = NewEvmKeeper(GinkgoT()) + consensuskeeper = ms.ConsensusKeeper + q = consensusmocks.NewQueuer(GinkgoT()) + + snapshot := createSnapshot(testChain) + ms.ValsetKeeper.On("GetCurrentSnapshot", mock.Anything).Return(snapshot, nil) + + q.On("ChainInfo").Return("", testChain.ChainReferenceID) + q.On("Remove", mock.Anything, uint64(123)).Return(nil) + ms.SkywayKeeper.On("GetLastObservedSkywayNonce", mock.Anything, mock.Anything). + Return(uint64(100), nil).Maybe() + + contractID, err := setupTestChainSupport(ctx, consensuskeeper, ms.MetrixKeeper, ms.TreasuryKeeper, testChain, k) + Expect(err).To(BeNil()) + + deployment, _ := k.getSmartContractDeploymentByContractID(ctx, contractID, testChain.ChainReferenceID) + deployment.Status = types.SmartContractDeployment_WAITING_FOR_ERC20_OWNERSHIP_TRANSFER + + err = k.updateSmartContractDeployment(ctx, contractID, testChain.ChainReferenceID, deployment) + Expect(err).To(BeNil()) + + err = k.SetSmartContractAsActive(ctx, contractID, testChain.ChainReferenceID) + Expect(err).To(BeNil()) + + // Upload the contract + _, err = k.SaveUserSmartContract(ctx, valAddr, testContract) + Expect(err).To(BeNil()) + + consensuskeeper.On("PutMessageInQueue", + mock.Anything, + mock.Anything, + mock.Anything, + mock.Anything, + ).Return(uint64(10), nil).Once() + + // We need more calls to these two methods here because of the user + // smart contract upload + ms.TreasuryKeeper.On("GetRelayerFeesByChainReferenceID", mock.Anything, mock.Anything).Return(getFees(3), nil).Once() + ms.MetrixKeeper.On("Validators", mock.Anything, mock.Anything).Return(&metrixtypes.QueryValidatorsResponse{ + ValMetrics: getMetrics(3), + }, nil).Once() + + // Create the deployment + _, err = k.CreateUserSmartContractDeployment(ctx, valAddr, 1, testChain.ChainReferenceID) + Expect(err).To(BeNil()) + }) + + JustBeforeEach(func() { + bytecode, _ := hex.DecodeString("0x00") + senderAddr, _ := sdk.ValAddressFromBech32(valAddr) + + consensusMsg, err := codectypes.NewAnyWithValue(&types.Message{ + Action: &types.Message_UploadUserSmartContract{ + UploadUserSmartContract: &types.UploadUserSmartContract{ + Bytecode: bytecode, + Id: 1, + SenderAddress: senderAddr, + BlockHeight: ctx.BlockHeight(), + Retries: retries, + Fees: &types.Fees{ + RelayerFee: 1, + CommunityFee: 2, + SecurityFee: 3, + }, + }, + }, + }) + Expect(err).To(BeNil()) + + sig := make([]byte, 100) + msg = &consensustypes.QueuedSignedMessage{ + Id: 123, + Msg: consensusMsg, + Evidence: evidence, + SignData: []*consensustypes.SignData{{ + ExternalAccountAddress: "addr1", + Signature: sig, + }, { + ExternalAccountAddress: "addr2", + Signature: sig, + }}, + } + }) + + Context("attesting with success proof", func() { + BeforeEach(func() { + tx := ethcoretypes.NewTx(ðcoretypes.DynamicFeeTx{ + ChainID: big.NewInt(1), + Data: common.FromHex(string(txData)), + }) + + signer := ethcoretypes.LatestSignerForChainID(big.NewInt(1)) + privkey, err := crypto.GenerateKey() + Expect(err).To(BeNil()) + + signature, err := crypto.Sign(tx.Hash().Bytes(), privkey) + Expect(err).To(BeNil()) + + signedTX, err := tx.WithSignature(signer, signature) + Expect(err).To(BeNil()) + + serializedTX, err := signedTX.MarshalBinary() + Expect(err).To(BeNil()) + + receipt := ethcoretypes.Receipt{ + Logs: []*ethcoretypes.Log{ + { + Topics: []common.Hash{contractDeployedEvent}, + Data: deployedContractEventData, + }, + }, + } + serializedReceipt, err := receipt.MarshalBinary() + Expect(err).To(BeNil()) + + proof, _ := codectypes.NewAnyWithValue( + &types.TxExecutedProof{ + SerializedTX: serializedTX, + SerializedReceipt: serializedReceipt, + }) + evidence = []*consensustypes.Evidence{{ + ValAddress: sdk.ValAddress("validator-1"), + Proof: proof, + }, { + ValAddress: sdk.ValAddress("validator-2"), + Proof: proof, + }} + }) + + JustBeforeEach(func() { + Expect(k.attestRouter(ctx, q, msg)).To(Succeed()) + }) + + It("should set the deployment information", func() { + contracts, err := k.UserSmartContracts(ctx, valAddr) + Expect(err).To(BeNil()) + Expect(contracts[0].Deployments).To(ConsistOf( + &types.UserSmartContract_Deployment{ + ChainReferenceId: testChain.ChainReferenceID, + Status: types.UserSmartContract_Deployment_ACTIVE, + Address: "0x5eeA9CdF6de50497Df2c5AF93B70A02D616454a0", + }, + )) + }) + }) + + Context("attesting with error proof", func() { + BeforeEach(func() { + proof, _ := codectypes.NewAnyWithValue( + &types.SmartContractExecutionErrorProof{ + ErrorMessage: "an error", + }) + evidence = []*consensustypes.Evidence{{ + ValAddress: sdk.ValAddress("validator-1"), + Proof: proof, + }, { + ValAddress: sdk.ValAddress("validator-2"), + Proof: proof, + }} + }) + + JustBeforeEach(func() { + Expect(k.attestRouter(ctx, q, msg)).To(Succeed()) + }) + + Context("attesting with 0 retries", func() { + BeforeEach(func() { + retries = 0 + consensuskeeper.On("PutMessageInQueue", + mock.Anything, + mock.Anything, + mock.Anything, + mock.Anything, + ).Return(uint64(10), nil).Once() + + // We need to setup additional calls for the retry + ms.TreasuryKeeper.On("GetRelayerFeesByChainReferenceID", mock.Anything, mock.Anything).Return(getFees(3), nil).Once() + ms.MetrixKeeper.On("Validators", mock.Anything, mock.Anything).Return(&metrixtypes.QueryValidatorsResponse{ + ValMetrics: getMetrics(3), + }, nil).Once() + }) + + It("should retry the deployment", func() { + // Should be called twice on setup and again on retry + consensuskeeper.AssertNumberOfCalls(GinkgoT(), "PutMessageInQueue", 3) + }) + + It("should keep the deployment status", func() { + contracts, err := k.UserSmartContracts(ctx, valAddr) + Expect(err).To(BeNil()) + Expect(contracts[0].Deployments).To(ConsistOf( + &types.UserSmartContract_Deployment{ + ChainReferenceId: testChain.ChainReferenceID, + Status: types.UserSmartContract_Deployment_IN_FLIGHT, + Address: "", + }, + )) + }) + + It("should increase retries on the smart contract deployment", func() { + cm, _ := msg.ConsensusMsg(k.cdc) + action := cm.(*types.Message).Action.(*types.Message_UploadUserSmartContract) + Expect(action.UploadUserSmartContract.Retries).To(BeNumerically("==", 1)) + }) + }) + + Context("attesting after retry limit", func() { + BeforeEach(func() { + retries = 2 + }) + + It("should not put message back into the queue", func() { + // Should be called only twice on setup + consensuskeeper.AssertNumberOfCalls(GinkgoT(), "PutMessageInQueue", 2) + }) + + It("should set the deployment status to error", func() { + contracts, err := k.UserSmartContracts(ctx, valAddr) + Expect(err).To(BeNil()) + Expect(contracts[0].Deployments).To(ConsistOf( + &types.UserSmartContract_Deployment{ + ChainReferenceId: testChain.ChainReferenceID, + Status: types.UserSmartContract_Deployment_ERROR, + Address: "", + }, + )) + }) + }) + }) +}) diff --git a/x/evm/keeper/attest_submit_logic_call.go b/x/evm/keeper/attest_submit_logic_call.go index 8d998526..c04ec127 100644 --- a/x/evm/keeper/attest_submit_logic_call.go +++ b/x/evm/keeper/attest_submit_logic_call.go @@ -48,47 +48,6 @@ func (a *submitLogicCallAttester) attest(ctx sdk.Context, evidence *types.TxExec return err } - if a.k.deploymentCache.Has(ctx, a.chainReferenceID, a.msgID) { - smartContractID := a.k.deploymentCache.Get(ctx, a.chainReferenceID, a.msgID) - deployment, _ := a.k.getSmartContractDeploymentByContractID(ctx, smartContractID, a.chainReferenceID) - if deployment == nil { - a.logger.WithError(err).Error("Deployment not found") - return ErrCannotActiveSmartContractThatIsNotDeploying - } - - hasPendingTransfers := false - for i, v := range deployment.Erc20Transfers { - if v.GetMsgID() == a.msgID { - if v.GetStatus() != types.SmartContractDeployment_ERC20Transfer_PENDING { - err = fmt.Errorf("invalid transfer status: %v", v.GetStatus()) - a.logger.WithError(err).WithFields("transfer-status", v.GetStatus()).Error("Failed to attest ERC20 transfer message, invalid status.") - return err - } - deployment.Erc20Transfers[i].Status = types.SmartContractDeployment_ERC20Transfer_OK - } - - if deployment.Erc20Transfers[i].Status != types.SmartContractDeployment_ERC20Transfer_OK { - hasPendingTransfers = true - } - } - - if err := a.k.updateSmartContractDeployment(ctx, smartContractID, a.chainReferenceID, deployment); err != nil { - a.logger.WithError(err).Error("Failed to update smart contract deployment.") - return err - } - - if !hasPendingTransfers { - if err := a.k.SetSmartContractAsActive(ctx, smartContractID, a.chainReferenceID); err != nil { - a.logger.WithError(err).Error("Failed to set smart contract as active") - return err - } - - a.logger.Debug("attestation successful") - } - - a.k.deploymentCache.Delete(ctx, a.chainReferenceID, a.msgID) - } - return nil } @@ -100,41 +59,11 @@ func (a *submitLogicCallAttester) attemptRetry(ctx sdk.Context, proof *types.Sma types.SmartContractExecutionMessageType.With(fmt.Sprintf("%T", a.action)), ) - // Check if failed message was an ERC20 transfer. If so, override any - // max retries and keep going. - // Update deployment accordingly if exists - // Sets existing transfer state to FAILAED and removes it from the cache. - var deployment *types.SmartContractDeployment - var failedTransfer *types.SmartContractDeployment_ERC20Transfer - var smartContractID uint64 - if a.k.deploymentCache.Has(ctx, a.chainReferenceID, a.msgID) { - smartContractID = a.k.deploymentCache.Get(ctx, a.chainReferenceID, a.msgID) - deployment, _ = a.k.getSmartContractDeploymentByContractID(ctx, smartContractID, a.chainReferenceID) - if deployment == nil { - err := fmt.Errorf("no matching deployment found for contract ID %v on chain %v", smartContractID, a.chainReferenceID) - a.logger.WithError(err).Error(err.Error()) - return err - } - - for i, v := range deployment.Erc20Transfers { - if v.GetMsgID() == a.msgID { - if v.GetStatus() != types.SmartContractDeployment_ERC20Transfer_PENDING { - a.logger.WithFields("transfer-status", v.GetStatus()).Error("Unexpected status of failed message") - } - deployment.Erc20Transfers[i].Status = types.SmartContractDeployment_ERC20Transfer_FAIL - failedTransfer = &deployment.Erc20Transfers[i] - } - } - - a.k.deploymentCache.Delete(ctx, a.chainReferenceID, a.msgID) - } - // Retry message if eligible // Must be less than cMaxSubmitLogicCallRetries - // ERC20 transfer do not have a limit var newMsgID uint64 slc := a.action - if slc.Retries < cMaxSubmitLogicCallRetries || failedTransfer != nil { + if slc.Retries < cMaxSubmitLogicCallRetries { slc.Retries++ a.logger.Info("retrying failed SubmitLogicCall message", "message-id", a.msgID, @@ -159,23 +88,5 @@ func (a *submitLogicCallAttester) attemptRetry(ctx sdk.Context, proof *types.Sma "chain-reference-id", a.chainReferenceID) } - // If retry is happening, creates a new transfer record on the - // deployment and adds it to the cache. - if newMsgID != 0 && failedTransfer != nil { - deployment.Erc20Transfers = append(deployment.Erc20Transfers, types.SmartContractDeployment_ERC20Transfer{ - Denom: failedTransfer.Denom, - Erc20: failedTransfer.Erc20, - MsgID: newMsgID, - Status: types.SmartContractDeployment_ERC20Transfer_PENDING, - }) - - if err := a.k.updateSmartContractDeployment(ctx, smartContractID, a.chainReferenceID, deployment); err != nil { - a.logger.WithError(err).Error("Failed to update smart contract deployment.") - return err - } - - a.k.deploymentCache.Add(ctx, a.chainReferenceID, smartContractID, newMsgID) - } - return nil } diff --git a/x/evm/keeper/attest_submit_logic_call_test.go b/x/evm/keeper/attest_submit_logic_call_test.go index 928cb46c..0064927a 100644 --- a/x/evm/keeper/attest_submit_logic_call_test.go +++ b/x/evm/keeper/attest_submit_logic_call_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/mock" ) +// TODO: Implement var _ = Describe("attest submit logic call", func() { var k *Keeper var ctx sdk.Context @@ -132,35 +133,6 @@ var _ = Describe("attest submit logic call", func() { consensuskeeper.AssertNumberOfCalls(GinkgoT(), "PutMessageInQueue", 1) }) }) - - Context("with ERC20 transfer", func() { - BeforeEach(func() { - k.deploymentCache.Add(ctx, testChain.GetChainReferenceID(), 1, 123) - dep, _ := k.getSmartContractDeploymentByContractID(ctx, 1, testChain.GetChainReferenceID()) - dep.Erc20Transfers = append(dep.Erc20Transfers, types.SmartContractDeployment_ERC20Transfer{ - Denom: "test-denom", - Erc20: "test-denom", - MsgID: 123, - Status: types.SmartContractDeployment_ERC20Transfer_FAIL, - }) - k.updateSmartContractDeployment(ctx, 1, testChain.ChainReferenceID, dep) - consensuskeeper.On("PutMessageInQueue", - mock.Anything, - mock.Anything, - mock.Anything, - mock.Anything, - ).Return(uint64(10), nil).Once() - mk.On("Validators", mock.Anything, mock.Anything).Return(&metrixtypes.QueryValidatorsResponse{ - ValMetrics: getMetrics(3), - }, nil) - tk.On("GetRelayerFeesByChainReferenceID", mock.Anything, mock.Anything).Return(getFees(3), nil) - }) - - It("should put message back into the queue", func() { - // Should be called only once on setup - consensuskeeper.AssertNumberOfCalls(GinkgoT(), "PutMessageInQueue", 2) - }) - }) }) }) }) diff --git a/x/evm/keeper/attest_test.go b/x/evm/keeper/attest_test.go index 0f4b4779..fba40e7d 100644 --- a/x/evm/keeper/attest_test.go +++ b/x/evm/keeper/attest_test.go @@ -387,122 +387,139 @@ var _ = g.Describe("attest router", func() { } }) successfulProcess() + }) - g.When("message is attesting to successful erc20 relink", func() { - g.When("no more pending messages after this", func() { - g.It("remove the deployment and activate the chain", func() { - setupChainSupport() - dep, _ := k.getSmartContractDeploymentByContractID(ctx, uint64(1), newChain.GetChainReferenceID()) - Expect(dep).ToNot(BeNil()) - dep.Status = types.SmartContractDeployment_WAITING_FOR_ERC20_OWNERSHIP_TRANSFER - dep.Erc20Transfers = []types.SmartContractDeployment_ERC20Transfer{ - { - Denom: "denom", - Erc20: "address", - MsgID: 123, - Status: types.SmartContractDeployment_ERC20Transfer_PENDING, - }, - } - err := k.updateSmartContractDeployment(ctx, uint64(1), newChain.ChainReferenceID, dep) - Expect(err).To(BeNil()) - k.deploymentCache.Add(ctx, newChain.ChainReferenceID, uint64(1), 123) - Expect(subject()).To(BeNil()) - res, _ := k.getSmartContractDeploymentByContractID(ctx, uint64(1), newChain.GetChainReferenceID()) - Expect(res).To(BeNil()) - info, err := k.GetChainInfo(ctx, newChain.ChainReferenceID) - Expect(err).To(BeNil()) - Expect(info.ActiveSmartContractID).To(Equal(uint64(1))) - }) + g.Context("there is error proof", func() { + g.BeforeEach(func() { + // We're not expecting an error, but the tx won't be + // processed either + isTxProcessed = false + proof, _ := codectypes.NewAnyWithValue(&types.SmartContractExecutionErrorProof{ErrorMessage: "doesn't matter"}) + evidence = []*consensustypes.Evidence{ + { + ValAddress: sdk.ValAddress("validator-1"), + Proof: proof, + }, + { + ValAddress: sdk.ValAddress("validator-2"), + Proof: proof, + }, + } + }) + + g.When("message has not been retried", func() { + g.BeforeEach(func() { + consensusMsg.Action = &types.Message_SubmitLogicCall{ + SubmitLogicCall: &types.SubmitLogicCall{ + Retries: uint32(0), + }, + } + consensukeeper.On("PutMessageInQueue", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(uint64(10), nil).Once() }) - g.When("more pending messages after this", func() { - g.It("updates the deployment", func() { - setupChainSupport() - dep, _ := k.getSmartContractDeploymentByContractID(ctx, uint64(1), newChain.GetChainReferenceID()) - Expect(dep).ToNot(BeNil()) - dep.Status = types.SmartContractDeployment_WAITING_FOR_ERC20_OWNERSHIP_TRANSFER - dep.Erc20Transfers = []types.SmartContractDeployment_ERC20Transfer{ - { - Denom: "denom", - Erc20: "address", - MsgID: 123, - Status: types.SmartContractDeployment_ERC20Transfer_PENDING, - }, - { - Denom: "denom2", - Erc20: "address2", - MsgID: 1234, - Status: types.SmartContractDeployment_ERC20Transfer_PENDING, - }, - } - err := k.updateSmartContractDeployment(ctx, uint64(1), newChain.ChainReferenceID, dep) - Expect(err).To(BeNil()) - k.deploymentCache.Add(ctx, newChain.ChainReferenceID, uint64(1), 123) - Expect(subject()).To(BeNil()) - res, _ := k.getSmartContractDeploymentByContractID(ctx, uint64(1), newChain.GetChainReferenceID()) - Expect(res.Erc20Transfers).To(HaveLen(2)) - Expect(res.Erc20Transfers[0].Status).To(Equal(types.SmartContractDeployment_ERC20Transfer_OK)) - Expect(res.Erc20Transfers[1].Status).To(Equal(types.SmartContractDeployment_ERC20Transfer_PENDING)) - info, err := k.GetChainInfo(ctx, newChain.ChainReferenceID) - Expect(err).To(BeNil()) - Expect(info.ActiveSmartContractID).To(Equal(uint64(0))) - }) + + g.It("should attempt to retry", func() { + setupChainSupport() + Expect(subject()).To(BeNil()) + consensukeeper.AssertNumberOfCalls(g.GinkgoT(), "PutMessageInQueue", 2) }) }) - g.Context("there is error proof", func() { + g.When("message has been retried too many times", func() { g.BeforeEach(func() { - // We're not expecting an error, but the tx won't be - // processed either - isTxProcessed = false - proof, _ := codectypes.NewAnyWithValue(&types.SmartContractExecutionErrorProof{ErrorMessage: "doesn't matter"}) - evidence = []*consensustypes.Evidence{ - { - ValAddress: sdk.ValAddress("validator-1"), - Proof: proof, - }, - { - ValAddress: sdk.ValAddress("validator-2"), - Proof: proof, + consensusMsg.Action = &types.Message_SubmitLogicCall{ + SubmitLogicCall: &types.SubmitLogicCall{ + Retries: uint32(2), }, } }) - g.When("message has not been retried", func() { - g.BeforeEach(func() { - consensusMsg.Action = &types.Message_SubmitLogicCall{ - SubmitLogicCall: &types.SubmitLogicCall{ - Retries: uint32(0), - }, - } - consensukeeper.On("PutMessageInQueue", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(uint64(10), nil).Once() - }) - - g.It("should attempt to retry", func() { - setupChainSupport() - Expect(subject()).To(BeNil()) - consensukeeper.AssertNumberOfCalls(g.GinkgoT(), "PutMessageInQueue", 2) - }) + g.It("should not attempt to retry", func() { + setupChainSupport() + Expect(subject()).To(BeNil()) + consensukeeper.AssertNumberOfCalls(g.GinkgoT(), "PutMessageInQueue", 1) }) + }) + }) - g.When("message has been retried too many times", func() { - g.BeforeEach(func() { - consensusMsg.Action = &types.Message_SubmitLogicCall{ - SubmitLogicCall: &types.SubmitLogicCall{ - Retries: uint32(2), - }, - } - }) - - g.It("should not attempt to retry", func() { - setupChainSupport() - Expect(subject()).To(BeNil()) - consensukeeper.AssertNumberOfCalls(g.GinkgoT(), "PutMessageInQueue", 1) - }) + g.When("message is UpdateValset", func() { + g.BeforeEach(func() { + execTx = valsetTx1 + proof := whoops.Must(codectypes.NewAnyWithValue(&types.TxExecutedProof{SerializedTX: whoops.Must(execTx.MarshalBinary())})) + evidence = []*consensustypes.Evidence{ + { + ValAddress: sdk.ValAddress("validator-1"), + Proof: proof, + }, + { + ValAddress: sdk.ValAddress("validator-2"), + Proof: proof, + }, + { + ValAddress: sdk.ValAddress("validator-3"), + Proof: proof, + }, + } + consensusMsg.Action = &types.Message_UpdateValset{ + UpdateValset: &types.UpdateValset{ + Valset: &types.Valset{ + ValsetID: 1, + Validators: []string{"addr1", "addr2"}, + Powers: []uint64{15, 5}, + }, + }, + } + }) + + g.BeforeEach(func() { + q.On("GetAll", mock.Anything).Return(nil, nil) + }) + + g.When("successfully sets valset for chain", func() { + g.BeforeEach(func() { + v.On("SetSnapshotOnChain", mock.Anything, mock.Anything, mock.Anything).Return(nil) + }) + successfulProcess() + }) + + g.When("unsuccessfully sets valset for chain", func() { + // We still process successfully even if we get an error here + g.BeforeEach(func() { + v.On("SetSnapshotOnChain", mock.Anything, mock.Anything, mock.Anything).Return(errors.New("example error")) }) + successfulProcess() }) }) - g.When("message is UpdateValset", func() { + g.When("message is CompassHandover", func() { + // TODO: Implement + // // TODO: move to attest handover + // g.When("message is attesting to successful erc20 relink", func() { + // g.When("no more pending messages after this", func() { + // g.It("remove the deployment and activate the chain", func() { + // setupChainSupport() + // dep, _ := k.getSmartContractDeploymentByContractID(ctx, uint64(1), newChain.GetChainReferenceID()) + // Expect(dep).ToNot(BeNil()) + // dep.Status = types.SmartContractDeployment_WAITING_FOR_ERC20_OWNERSHIP_TRANSFER + // dep.Erc20Transfers = []types.SmartContractDeployment_ERC20Transfer{ + // { + // Denom: "denom", + // Erc20: "address", + // MsgID: 123, + // Status: types.SmartContractDeployment_ERC20Transfer_PENDING, + // }, + // } + // err := k.updateSmartContractDeployment(ctx, uint64(1), newChain.ChainReferenceID, dep) + // Expect(err).To(BeNil()) + // k.deploymentCache.Add(ctx, newChain.ChainReferenceID, uint64(1), 123) + // Expect(subject()).To(BeNil()) + // res, _ := k.getSmartContractDeploymentByContractID(ctx, uint64(1), newChain.GetChainReferenceID()) + // Expect(res).To(BeNil()) + // info, err := k.GetChainInfo(ctx, newChain.ChainReferenceID) + // Expect(err).To(BeNil()) + // Expect(info.ActiveSmartContractID).To(Equal(uint64(1))) + // }) + // }) + // }) g.BeforeEach(func() { execTx = valsetTx1 proof := whoops.Must(codectypes.NewAnyWithValue(&types.TxExecutedProof{SerializedTX: whoops.Must(execTx.MarshalBinary())})) diff --git a/x/evm/keeper/attest_upload_smart_contract.go b/x/evm/keeper/attest_upload_smart_contract.go index 527a5e92..03dd573d 100644 --- a/x/evm/keeper/attest_upload_smart_contract.go +++ b/x/evm/keeper/attest_upload_smart_contract.go @@ -4,8 +4,12 @@ import ( "errors" "fmt" "math/big" + "strings" + "time" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" @@ -15,6 +19,11 @@ import ( "github.com/palomachain/paloma/x/evm/types" ) +const ( + cErc20HandoverABI string = `[{"inputs": [{"name": "_compass","type": "address"}],"name": "new_compass","outputs": [],"stateMutability": "nonpayable","type": "function"}]` + cFeeMgrHandoverABI string = `[{"inputs":[{"name":"_new_compass","type":"address"}],"name":"update_compass","outputs":[],"stateMutability":"nonpayable","type":"function"}]` +) + type attestionParameters struct { originalMessage consensustypes.QueuedSignedMessageI rawEvidence any @@ -97,21 +106,6 @@ func (a *uploadSmartContractAttester) attest(ctx sdk.Context, evidence *types.Tx return err } - // TODO temporarily disable token relink so we can update to compass 2.0. - // We need to reenable this in v1.16.1 after compass 2.0 is deployed. - // See https://github.com/VolumeFi/paloma/issues/1891 - // - // Get the ERC20 tokens just for this chain - // records, err := a.k.Skyway.CastChainERC20ToDenoms(ctx, a.chainReferenceID) - // if err != nil { - // a.logger.WithError(err).Error("Failed to extract ERC20 records.") - // return err - // } - - // if len(records) > 0 { - // return a.startTokenRelink(ctx, deployment, records, newCompassAddr, smartContractID) - // } - // If this is the first deployment on chain, it won't have a snapshot // assigned to it. We need to assign it a snapshot, or we won't be able to // do SubmitLogicCall or UpdateValset @@ -130,106 +124,75 @@ func (a *uploadSmartContractAttester) attest(ctx sdk.Context, evidence *types.Tx if err != nil { return err } + + return a.startTokenRelink(ctx, deployment, newCompassAddr, smartContractID) } // We don't have any tokens on the target chain. Set contract as active immediately. return a.k.SetSmartContractAsActive(ctx, smartContractID, a.chainReferenceID) } -// func (a *uploadSmartContractAttester) startTokenRelink( -// ctx sdk.Context, -// deployment *types.SmartContractDeployment, -// records []types.ERC20Record, -// newCompassAddr common.Address, -// smartContractID uint64, -// ) error { -// msgIDs := make([]uint64, 0, len(records)) -// transfers := make([]types.SmartContractDeployment_ERC20Transfer, 0, len(records)) -// erc20abi := `[{"inputs": [{"name": "_compass","type": "address"}],"name": "new_compass","outputs": [],"stateMutability": "nonpayable","type": "function"}]` - -// for _, v := range records { -// if v.GetChainReferenceId() != a.chainReferenceID { -// continue -// } - -// payload, err := func() ([]byte, error) { -// evm, err := abi.JSON(strings.NewReader(erc20abi)) -// if err != nil { -// return nil, err -// } -// return evm.Pack("new_compass", newCompassAddr) -// }() -// if err != nil { -// return err -// } - -// // SLCs are usually always authored by either a contract on Paloma, or -// // a specific validator. In this case, this is really a consensus operation -// // without a singular governing entity. For the sake the established -// // technological boundaries, we'll set the sender to the address of the -// // validator that attested this message. -// valAddr, err := sdk.ValAddressFromBech32(a.msg.GetAssignee()) -// if err != nil { -// return fmt.Errorf("validator address from bech32: %w", err) -// } - -// sender := sdk.AccAddress(valAddr.Bytes()) - -// modifiedPayload, err := injectSenderIntoPayload(make([]byte, 32), payload) -// if err != nil { -// return fmt.Errorf("inject zero padding to payload: %w", err) -// } - -// ci, err := a.k.GetChainInfo(ctx, a.chainReferenceID) -// if err != nil { -// return fmt.Errorf("get chain info: %w", err) -// } - -// msgID, err := a.k.AddSmartContractExecutionToConsensus( -// ctx, -// a.chainReferenceID, -// string(ci.GetSmartContractUniqueID()), -// &types.SubmitLogicCall{ -// HexContractAddress: v.GetErc20(), -// Abi: common.FromHex(""), -// Payload: modifiedPayload, -// Deadline: ctx.BlockTime().Add(10 * time.Minute).Unix(), -// SenderAddress: sender, -// ExecutionRequirements: types.SubmitLogicCall_ExecutionRequirements{ -// EnforceMEVRelay: false, -// }, -// }, -// ) -// if err != nil { -// return fmt.Errorf("execute job: %w", err) -// } - -// msgIDs = append(msgIDs, msgID) -// transfers = append(transfers, types.SmartContractDeployment_ERC20Transfer{ -// Denom: v.GetDenom(), -// Erc20: v.GetErc20(), -// MsgID: msgID, -// Status: types.SmartContractDeployment_ERC20Transfer_PENDING, -// }) -// } +func (a *uploadSmartContractAttester) startTokenRelink( + ctx sdk.Context, + deployment *types.SmartContractDeployment, + newCompassAddr common.Address, + smartContractID uint64, +) error { + ci, err := a.k.GetChainInfo(ctx, a.chainReferenceID) + if err != nil { + return fmt.Errorf("get all chain infos: %w", err) + } + tokens, err := a.k.Skyway.CastChainERC20ToDenoms(ctx, a.chainReferenceID) + if err != nil { + return fmt.Errorf("cast chain erc20 to denoms: %w", err) + } + forwardCallArgs := make([]types.CompassHandover_ForwardCallArgs, 0, len(tokens)+1) // +1 for the fee manager handover + erc20abi, err := abi.JSON(strings.NewReader(cErc20HandoverABI)) + if err != nil { + return fmt.Errorf("parse erc20 abi json: %w", err) + } + erc20payload, err := erc20abi.Pack("new_compass", newCompassAddr) + if err != nil { + return fmt.Errorf("pack erc20 payload: %w", err) + } + feemgrabi, err := abi.JSON(strings.NewReader(cFeeMgrHandoverABI)) + if err != nil { + return fmt.Errorf("parse fee manager abi json: %w", err) + } + feemgrpayload, err := feemgrabi.Pack("update_compass", newCompassAddr) + if err != nil { + return fmt.Errorf("pack fee manager payload: %w", err) + } -// // This shouldn't be needed anymore, since we query the ERC20 tokens for -// // this specific chain. However, just to make double sure, we check the -// // transfers. If there's none, just set the contract to active. -// if len(transfers) == 0 { -// return a.k.SetSmartContractAsActive(ctx, smartContractID, a.chainReferenceID) -// } + for _, v := range tokens { + // TODO: what about existing tokens? Can we have a migration that deletes them? + forwardCallArgs = append(forwardCallArgs, types.CompassHandover_ForwardCallArgs{ + HexContractAddress: v.GetErc20(), + Payload: erc20payload, + }) + } -// deployment.Erc20Transfers = transfers -// if err := a.k.updateSmartContractDeployment(ctx, smartContractID, a.chainReferenceID, deployment); err != nil { -// a.logger.WithError(err).Error("Failed to update smart contract deployment") -// return err -// } + forwardCallArgs = append(forwardCallArgs, types.CompassHandover_ForwardCallArgs{ + HexContractAddress: ci.FeeManagerAddr, + Payload: feemgrpayload, + }) + + _, err = a.k.scheduleCompassHandover( + ctx, + a.chainReferenceID, + string(ci.GetSmartContractUniqueID()), + &types.CompassHandover{ + ForwardCallArgs: forwardCallArgs, + Deadline: ctx.BlockTime().Add(10 * time.Minute).Unix(), + }, + ) + if err != nil { + return fmt.Errorf("try compass handover: %w", err) + } -// a.k.deploymentCache.Add(ctx, a.chainReferenceID, smartContractID, msgIDs...) -// a.logger.Debug("attestation successful") -// return nil -// } + a.logger.Debug("attestation successful") + return nil +} func (a *uploadSmartContractAttester) attemptRetry(ctx sdk.Context) { contract := a.action diff --git a/x/evm/keeper/deployment/cache.go b/x/evm/keeper/deployment/cache.go deleted file mode 100644 index c96442cb..00000000 --- a/x/evm/keeper/deployment/cache.go +++ /dev/null @@ -1,74 +0,0 @@ -package deployment - -import ( - "context" -) - -// Cache is meant as an asynchronous KV memcache to reduce -// constant keeper queries. It is NOT threadsafe, it requires -// manual bootstrapping by loading data from the keeper once -// during initialisation and needs to be kept in sync -// with added and removed keeper data manually. -// -// If this works well, I'd like to build this into a v2 -// that functions basically like a keeper wrapper, agnostic -// of the underlaying data and keeping in sync with added -// and removed items automatically. -type Cache struct { - data map[string]map[uint64]uint64 - bootstrap func(context.Context, *Cache) - initialised bool -} - -func NewCache(bootstrap func(context.Context, *Cache)) *Cache { - return &Cache{ - data: make(map[string]map[uint64]uint64), - bootstrap: bootstrap, - } -} - -func (c *Cache) Add(ctx context.Context, chainReferenceID string, smartContractID uint64, msgIDs ...uint64) { - c.assertExists(ctx, chainReferenceID) - - for _, v := range msgIDs { - c.data[chainReferenceID][v] = smartContractID - } -} - -func (c *Cache) Delete(ctx context.Context, chainReferenceID string, msgIDs ...uint64) { - c.assertExists(ctx, chainReferenceID) - - for _, v := range msgIDs { - delete(c.data[chainReferenceID], v) - } -} - -func (c *Cache) Has(ctx context.Context, chainReferenceID string, msgID uint64) bool { - c.assertExists(ctx, chainReferenceID) - - _, found := c.data[chainReferenceID][msgID] - return found -} - -func (c *Cache) Get(ctx context.Context, chainReferenceID string, msgID uint64) uint64 { - c.assertExists(ctx, chainReferenceID) - - return c.data[chainReferenceID][msgID] -} - -func (c *Cache) assertExists(ctx context.Context, chainReferenceID string) { - c.assertInitialised(ctx) - - if _, found := c.data[chainReferenceID]; !found { - c.data[chainReferenceID] = make(map[uint64]uint64) - } -} - -func (c *Cache) assertInitialised(ctx context.Context) { - if c.initialised { - return - } - - c.initialised = true - c.bootstrap(ctx, c) -} diff --git a/x/evm/keeper/deployment/cache_test.go b/x/evm/keeper/deployment/cache_test.go deleted file mode 100644 index 326fbe10..00000000 --- a/x/evm/keeper/deployment/cache_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package deployment_test - -import ( - "context" - "testing" - - "github.com/palomachain/paloma/x/evm/keeper/deployment" - "github.com/stretchr/testify/assert" -) - -var ( - dummyBootstrapper = func(_ context.Context, _ *deployment.Cache) {} - ctx = context.Background() -) - -func TestDeploymentCache_Add(t *testing.T) { - cache := deployment.NewCache(dummyBootstrapper) - - // Add a message ID to a chain reference ID - cache.Add(ctx, "chain1", 1, 5) - - // Check if the message ID exists in the chain reference ID - assert.True(t, cache.Has(ctx, "chain1", 5)) -} - -func TestDeploymentCache_Delete(t *testing.T) { - cache := deployment.NewCache(dummyBootstrapper) - - // Add a message ID to a chain reference ID - cache.Add(ctx, "chain1", 1, 5) - - // Delete the message ID from the chain reference ID - cache.Delete(ctx, "chain1", 5) - - // Check if the message ID no longer exists in the chain reference ID - assert.False(t, cache.Has(ctx, "chain1", 5)) -} - -func TestDeploymentCache_Has(t *testing.T) { - cache := deployment.NewCache(dummyBootstrapper) - - // Add a message ID to a chain reference ID - cache.Add(ctx, "chain1", 1, 5) - - // Check if the message ID exists in the chain reference ID - assert.True(t, cache.Has(ctx, "chain1", 5)) - - // Check if a non-existent message ID exists in the chain reference ID - assert.False(t, cache.Has(ctx, "chain1", 1)) -} - -func TestCache_Get(t *testing.T) { - // Create a new cache - cache := deployment.NewCache(func(ctx context.Context, c *deployment.Cache) { - c.Add(ctx, "chain1", 100, 1) - c.Add(ctx, "chain1", 200, 2) - - c.Add(ctx, "chain2", 300, 1) - c.Add(ctx, "chain2", 400, 2) - }) - - // Test case 1: Existing chainReferenceID and msgID - expectedResult := uint64(200) - result := cache.Get(ctx, "chain1", 2) - if result != expectedResult { - t.Errorf("Expected %d, but got %d", expectedResult, result) - } - - // Test case 2: Non-existing chainReferenceID - expectedResult = uint64(0) - result = cache.Get(ctx, "chain3", 1) - if result != expectedResult { - t.Errorf("Expected %d, but got %d", expectedResult, result) - } - - // Test case 3: Non-existing msgID - expectedResult = uint64(0) - result = cache.Get(ctx, "chain2", 3) - if result != expectedResult { - t.Errorf("Expected %d, but got %d", expectedResult, result) - } -} diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 3ee8b9c8..bee1b455 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -29,7 +29,6 @@ import ( "github.com/palomachain/paloma/util/liblog" "github.com/palomachain/paloma/x/consensus/keeper/consensus" consensustypes "github.com/palomachain/paloma/x/consensus/types" - "github.com/palomachain/paloma/x/evm/keeper/deployment" "github.com/palomachain/paloma/x/evm/types" metrixtypes "github.com/palomachain/paloma/x/metrix/types" ptypes "github.com/palomachain/paloma/x/paloma/types" @@ -118,7 +117,6 @@ type Keeper struct { msgSender types.MsgSender msgAssigner types.MsgAssigner AddressCodec address.Codec - deploymentCache *deployment.Cache onMessageAttestedListeners []metrixtypes.OnConsensusMessageAttestedListener consensusChecker *libcons.ConsensusChecker @@ -146,7 +144,6 @@ func NewKeeper( } k.msgAssigner = newMsgAssigner(valsetKeeper, metrixKeeper, treasuryKeeper, k.Logger) - k.deploymentCache = deployment.NewCache(provideDeploymentCacheBootstrapper(k)) k.ider = keeperutil.NewIDGenerator(keeperutil.StoreGetterFn(k.provideSmartContractStore), []byte("id-key")) k.consensusChecker = libcons.New(k.Valset.GetCurrentSnapshot, k.cdc) diff --git a/x/evm/keeper/smart_contract_deployment.go b/x/evm/keeper/smart_contract_deployment.go index 658d876a..ce0eb1e4 100644 --- a/x/evm/keeper/smart_contract_deployment.go +++ b/x/evm/keeper/smart_contract_deployment.go @@ -17,10 +17,8 @@ import ( "github.com/ethereum/go-ethereum/common" xchain "github.com/palomachain/paloma/internal/x-chain" keeperutil "github.com/palomachain/paloma/util/keeper" - "github.com/palomachain/paloma/util/liblog" "github.com/palomachain/paloma/x/consensus/keeper/consensus" consensustypes "github.com/palomachain/paloma/x/consensus/types" - "github.com/palomachain/paloma/x/evm/keeper/deployment" "github.com/palomachain/paloma/x/evm/types" ) @@ -57,23 +55,10 @@ func (k Keeper) HasAnySmartContractDeployment(ctx context.Context, chainReferenc func (k Keeper) DeleteSmartContractDeploymentByContractID(ctx context.Context, smartContractID uint64, chainReferenceID string) { sdkCtx := sdk.UnwrapSDKContext(ctx) - c, key := k.getSmartContractDeploymentByContractID(sdkCtx, smartContractID, chainReferenceID) + _, key := k.getSmartContractDeploymentByContractID(sdkCtx, smartContractID, chainReferenceID) if key == nil { return } - lkup := make(map[string]bool) - for _, v := range c.Erc20Transfers { - if ok, fnd := lkup[v.GetErc20()]; fnd && ok { - continue - } - lkup[v.GetErc20()] = v.GetStatus() == types.SmartContractDeployment_ERC20Transfer_OK - } - for _, v := range c.Erc20Transfers { - if !lkup[v.GetErc20()] { - liblog.FromSDKLogger(k.Logger(ctx)).WithFields("erc20", k).Error("cannot delete smart contract deployment due to pending erc20 transfer", "erc20", key) - return - } - } k.Logger(ctx).Info("removing a smart contract deployment", "smart-contract-id", smartContractID, "chain-reference-id", chainReferenceID) k.provideSmartContractDeploymentStore(sdkCtx).Delete(key) } @@ -199,6 +184,40 @@ func (k Keeper) AddSmartContractExecutionToConsensus( }) } +func (k Keeper) scheduleCompassHandover( + ctx context.Context, + chainReferenceID, + turnstoneID string, + handover *types.CompassHandover, +) (uint64, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + assignee, remoteAddr, err := k.PickValidatorForMessage(ctx, chainReferenceID, nil) + if err != nil { + return 0, err + } + + return k.ConsensusKeeper.PutMessageInQueue( + ctx, + consensustypes.Queue( + types.ConsensusTurnstoneMessage, + xchainType, + chainReferenceID, + ), + &types.Message{ + ChainReferenceID: chainReferenceID, + TurnstoneID: turnstoneID, + Action: &types.Message_CompassHandover{ + CompassHandover: handover, + }, + Assignee: assignee, + AssigneeRemoteAddress: remoteAddr, + AssignedAtBlockHeight: sdkmath.NewInt(sdkCtx.BlockHeight()), + }, &consensus.PutOptions{ + RequireGasEstimation: true, + RequireSignatures: true, + }) +} + func (k Keeper) deploySmartContractToChain(ctx context.Context, chainInfo *types.ChainInfo, smartContract *types.SmartContract) (retErr error) { defer func() { args := []any{ @@ -466,22 +485,3 @@ func (k Keeper) provideLastCompassContractStore(ctx context.Context) storetypes. kvstore := runtime.KVStoreAdapter(k.storeKey.OpenKVStore(ctx)) return prefix.NewStore(kvstore, []byte("latest-smart-contract")) } - -func provideDeploymentCacheBootstrapper(k *Keeper) func(context.Context, *deployment.Cache) { - return func(ctx context.Context, c *deployment.Cache) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - d, err := k.AllSmartContractsDeployments(sdkCtx) - if err != nil { - liblog.FromSDKLogger(k.Logger(sdkCtx)).WithError(err).Error("Failed to load smart contract deployments") - // This should only happen once during cache initialisation. - // A better approach would be to use the cache as a wrapper that gets cold data on demand. - panic(err) - } - - for _, v := range d { - for _, t := range v.Erc20Transfers { - c.Add(ctx, v.GetChainReferenceID(), t.GetMsgID()) - } - } - } -} diff --git a/x/evm/types/chain_info.pb.go b/x/evm/types/chain_info.pb.go index ca218faa..2715a076 100644 --- a/x/evm/types/chain_info.pb.go +++ b/x/evm/types/chain_info.pb.go @@ -5,17 +5,20 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -142,9 +145,11 @@ func (*ChainInfo) ProtoMessage() {} func (*ChainInfo) Descriptor() ([]byte, []int) { return fileDescriptor_61bfdb7d30bf7e88, []int{0} } + func (m *ChainInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *ChainInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_ChainInfo.Marshal(b, m, deterministic) @@ -157,12 +162,15 @@ func (m *ChainInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } + func (m *ChainInfo) XXX_Merge(src proto.Message) { xxx_messageInfo_ChainInfo.Merge(m, src) } + func (m *ChainInfo) XXX_Size() int { return m.Size() } + func (m *ChainInfo) XXX_DiscardUnknown() { xxx_messageInfo_ChainInfo.DiscardUnknown(m) } @@ -293,9 +301,11 @@ func (*SmartContract) ProtoMessage() {} func (*SmartContract) Descriptor() ([]byte, []int) { return fileDescriptor_61bfdb7d30bf7e88, []int{1} } + func (m *SmartContract) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *SmartContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_SmartContract.Marshal(b, m, deterministic) @@ -308,12 +318,15 @@ func (m *SmartContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error return b[:n], nil } } + func (m *SmartContract) XXX_Merge(src proto.Message) { xxx_messageInfo_SmartContract.Merge(m, src) } + func (m *SmartContract) XXX_Size() int { return m.Size() } + func (m *SmartContract) XXX_DiscardUnknown() { xxx_messageInfo_SmartContract.DiscardUnknown(m) } @@ -368,9 +381,11 @@ func (*SmartContractDeployment) ProtoMessage() {} func (*SmartContractDeployment) Descriptor() ([]byte, []int) { return fileDescriptor_61bfdb7d30bf7e88, []int{2} } + func (m *SmartContractDeployment) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *SmartContractDeployment) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_SmartContractDeployment.Marshal(b, m, deterministic) @@ -383,12 +398,15 @@ func (m *SmartContractDeployment) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } + func (m *SmartContractDeployment) XXX_Merge(src proto.Message) { xxx_messageInfo_SmartContractDeployment.Merge(m, src) } + func (m *SmartContractDeployment) XXX_Size() int { return m.Size() } + func (m *SmartContractDeployment) XXX_DiscardUnknown() { xxx_messageInfo_SmartContractDeployment.DiscardUnknown(m) } @@ -437,6 +455,7 @@ func (m *SmartContractDeployment) GetNewSmartContractAddress() string { return "" } +// Deprecated: Do not use. type SmartContractDeployment_ERC20Transfer struct { // Paloma denom of the ERC20 token Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` @@ -455,9 +474,11 @@ func (*SmartContractDeployment_ERC20Transfer) ProtoMessage() {} func (*SmartContractDeployment_ERC20Transfer) Descriptor() ([]byte, []int) { return fileDescriptor_61bfdb7d30bf7e88, []int{2, 0} } + func (m *SmartContractDeployment_ERC20Transfer) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *SmartContractDeployment_ERC20Transfer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_SmartContractDeployment_ERC20Transfer.Marshal(b, m, deterministic) @@ -470,12 +491,15 @@ func (m *SmartContractDeployment_ERC20Transfer) XXX_Marshal(b []byte, determinis return b[:n], nil } } + func (m *SmartContractDeployment_ERC20Transfer) XXX_Merge(src proto.Message) { xxx_messageInfo_SmartContractDeployment_ERC20Transfer.Merge(m, src) } + func (m *SmartContractDeployment_ERC20Transfer) XXX_Size() int { return m.Size() } + func (m *SmartContractDeployment_ERC20Transfer) XXX_DiscardUnknown() { xxx_messageInfo_SmartContractDeployment_ERC20Transfer.DiscardUnknown(m) } @@ -525,58 +549,58 @@ func init() { } var fileDescriptor_61bfdb7d30bf7e88 = []byte{ - // 801 bytes of a gzipped FileDescriptorProto + // 806 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x51, 0x6f, 0xe3, 0x44, 0x10, 0x8e, 0xdd, 0x34, 0x6d, 0x26, 0x6d, 0x6a, 0x56, 0x85, 0x5b, 0xf2, 0x10, 0xa2, 0xe8, 0xc4, - 0x99, 0x13, 0x72, 0x4e, 0x01, 0x21, 0x1e, 0x40, 0x90, 0x26, 0x6e, 0x6b, 0x28, 0x4e, 0xb5, 0xce, - 0x5d, 0x25, 0x84, 0x64, 0x6d, 0x9c, 0x4d, 0x6a, 0x5d, 0xbc, 0x0e, 0xf6, 0xa6, 0x47, 0x7f, 0x05, - 0xbc, 0xf3, 0x1b, 0xf8, 0x1f, 0xf7, 0x78, 0x8f, 0xf7, 0x84, 0x50, 0xfb, 0x47, 0x90, 0xd7, 0x69, - 0x54, 0x3b, 0xce, 0x03, 0xe2, 0x6d, 0xe7, 0x9b, 0xd9, 0x99, 0xf1, 0x37, 0xdf, 0x78, 0xe1, 0xd9, - 0x82, 0xce, 0xc3, 0x80, 0x7a, 0xd7, 0xd4, 0xe7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x8b, 0x46, 0x25, 0xf9, 0xe8, 0x7c, 0xf6, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x20, 0xc2, + 0x5b, 0x28, 0xf9, 0x06, 0x00, 0x00, } func (m *ChainInfo) Marshal() (dAtA []byte, err error) { @@ -881,6 +905,7 @@ func encodeVarintChainInfo(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *ChainInfo) Size() (n int) { if m == nil { return 0 @@ -1028,9 +1053,11 @@ func (m *SmartContractDeployment_ERC20Transfer) Size() (n int) { func sovChainInfo(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozChainInfo(x uint64) (n int) { return sovChainInfo(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *ChainInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1538,6 +1565,7 @@ func (m *ChainInfo) Unmarshal(dAtA []byte) error { } return nil } + func (m *SmartContract) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1673,6 +1701,7 @@ func (m *SmartContract) Unmarshal(dAtA []byte) error { } return nil } + func (m *SmartContractDeployment) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1893,6 +1922,7 @@ func (m *SmartContractDeployment) Unmarshal(dAtA []byte) error { } return nil } + func (m *SmartContractDeployment_ERC20Transfer) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2045,6 +2075,7 @@ func (m *SmartContractDeployment_ERC20Transfer) Unmarshal(dAtA []byte) error { } return nil } + func skipChainInfo(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/evm/types/eth_txable.go b/x/evm/types/eth_txable.go index f715bb4e..83b3ab72 100644 --- a/x/evm/types/eth_txable.go +++ b/x/evm/types/eth_txable.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/palomachain/paloma/util/liblog" + "github.com/palomachain/paloma/util/slice" consensustypes "github.com/palomachain/paloma/x/consensus/types" ) @@ -136,6 +137,63 @@ func (m *SubmitLogicCall) VerifyAgainstTX( return ErrEthTxNotVerified } +func (m *CompassHandover) VerifyAgainstTX( + ctx context.Context, + tx *ethtypes.Transaction, + msg consensustypes.QueuedSignedMessageI, + valset *Valset, + compass *SmartContract, + relayer string, +) error { + logger := liblog.FromSDKLogger(sdk.UnwrapSDKContext(ctx).Logger()). + WithFields("tx_hash", tx.Hash().Hex(), "valset_id", valset.ValsetID) + + // TODO: Remove + logger.WithFields("tx-data", tx.Data()).Info("DEBUGTEST") + + logger.Debug("CompassHandover VerifyAgainstTX") + + if valset == nil || compass == nil { + err := errors.New("missing valset or compass for tx verification") + logger.WithError(err).Error("failed to verify tx") + return err + } + + contractABI, err := abi.JSON(strings.NewReader(compass.GetAbiJSON())) + if err != nil { + logger.WithError(err).Warn("CompassHandover VerifyAgainstTX failed to parse compass ABI") + return err + } + + // compass_update_batch((address,bytes)[],uint256,address,uint256) + m.GetForwardCallArgs() + args := []any{ + slice.Map(m.GetForwardCallArgs(), func(arg CompassHandover_ForwardCallArgs) CompassLogicCallArgs { + return CompassLogicCallArgs{ + common.HexToAddress(arg.GetHexContractAddress()), + arg.GetPayload(), + } + }), + big.NewInt(m.GetDeadline()), + common.HexToAddress(relayer), + big.NewInt(0).SetUint64(msg.GetGasEstimate()), + } + + input, err := contractABI.Pack("compass_update_batch", args...) + if err != nil { + logger.WithError(err).Warn("CompassHandover VerifyAgainstTX failed to pack ABI") + return err + } + + if bytes.Equal(tx.Data(), input) { + logger.Debug("CompassHandover VerifyAgainstTX success") + return nil + } + + logger.Warn("CompassHandover VerifyAgainstTX failed") + return ErrEthTxNotVerified +} + func (m *UpdateValset) VerifyAgainstTX( ctx context.Context, tx *ethtypes.Transaction, diff --git a/x/evm/types/turnstone.pb.go b/x/evm/types/turnstone.pb.go index 13a51f6f..f36a1190 100644 --- a/x/evm/types/turnstone.pb.go +++ b/x/evm/types/turnstone.pb.go @@ -4,21 +4,24 @@ package types import ( - cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + + cosmossdk_io_math "cosmossdk.io/math" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -39,9 +42,11 @@ func (*Valset) ProtoMessage() {} func (*Valset) Descriptor() ([]byte, []int) { return fileDescriptor_86cc126a804337fd, []int{0} } + func (m *Valset) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *Valset) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_Valset.Marshal(b, m, deterministic) @@ -54,12 +59,15 @@ func (m *Valset) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } + func (m *Valset) XXX_Merge(src proto.Message) { xxx_messageInfo_Valset.Merge(m, src) } + func (m *Valset) XXX_Size() int { return m.Size() } + func (m *Valset) XXX_DiscardUnknown() { xxx_messageInfo_Valset.DiscardUnknown(m) } @@ -99,9 +107,11 @@ func (*Fees) ProtoMessage() {} func (*Fees) Descriptor() ([]byte, []int) { return fileDescriptor_86cc126a804337fd, []int{1} } + func (m *Fees) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *Fees) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_Fees.Marshal(b, m, deterministic) @@ -114,12 +124,15 @@ func (m *Fees) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } + func (m *Fees) XXX_Merge(src proto.Message) { xxx_messageInfo_Fees.Merge(m, src) } + func (m *Fees) XXX_Size() int { return m.Size() } + func (m *Fees) XXX_DiscardUnknown() { xxx_messageInfo_Fees.DiscardUnknown(m) } @@ -165,9 +178,11 @@ func (*SubmitLogicCall) ProtoMessage() {} func (*SubmitLogicCall) Descriptor() ([]byte, []int) { return fileDescriptor_86cc126a804337fd, []int{2} } + func (m *SubmitLogicCall) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *SubmitLogicCall) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_SubmitLogicCall.Marshal(b, m, deterministic) @@ -180,12 +195,15 @@ func (m *SubmitLogicCall) XXX_Marshal(b []byte, deterministic bool) ([]byte, err return b[:n], nil } } + func (m *SubmitLogicCall) XXX_Merge(src proto.Message) { xxx_messageInfo_SubmitLogicCall.Merge(m, src) } + func (m *SubmitLogicCall) XXX_Size() int { return m.Size() } + func (m *SubmitLogicCall) XXX_DiscardUnknown() { xxx_messageInfo_SubmitLogicCall.DiscardUnknown(m) } @@ -265,9 +283,11 @@ func (*SubmitLogicCall_ExecutionRequirements) ProtoMessage() {} func (*SubmitLogicCall_ExecutionRequirements) Descriptor() ([]byte, []int) { return fileDescriptor_86cc126a804337fd, []int{2, 0} } + func (m *SubmitLogicCall_ExecutionRequirements) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *SubmitLogicCall_ExecutionRequirements) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_SubmitLogicCall_ExecutionRequirements.Marshal(b, m, deterministic) @@ -280,12 +300,15 @@ func (m *SubmitLogicCall_ExecutionRequirements) XXX_Marshal(b []byte, determinis return b[:n], nil } } + func (m *SubmitLogicCall_ExecutionRequirements) XXX_Merge(src proto.Message) { xxx_messageInfo_SubmitLogicCall_ExecutionRequirements.Merge(m, src) } + func (m *SubmitLogicCall_ExecutionRequirements) XXX_Size() int { return m.Size() } + func (m *SubmitLogicCall_ExecutionRequirements) XXX_DiscardUnknown() { xxx_messageInfo_SubmitLogicCall_ExecutionRequirements.DiscardUnknown(m) } @@ -309,9 +332,11 @@ func (*UpdateValset) ProtoMessage() {} func (*UpdateValset) Descriptor() ([]byte, []int) { return fileDescriptor_86cc126a804337fd, []int{3} } + func (m *UpdateValset) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *UpdateValset) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_UpdateValset.Marshal(b, m, deterministic) @@ -324,12 +349,15 @@ func (m *UpdateValset) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } + func (m *UpdateValset) XXX_Merge(src proto.Message) { xxx_messageInfo_UpdateValset.Merge(m, src) } + func (m *UpdateValset) XXX_Size() int { return m.Size() } + func (m *UpdateValset) XXX_DiscardUnknown() { xxx_messageInfo_UpdateValset.DiscardUnknown(m) } @@ -343,6 +371,120 @@ func (m *UpdateValset) GetValset() *Valset { return nil } +type CompassHandover struct { + ForwardCallArgs []CompassHandover_ForwardCallArgs `protobuf:"bytes,1,rep,name=forwardCallArgs,proto3" json:"forwardCallArgs"` + Deadline int64 `protobuf:"varint,2,opt,name=deadline,proto3" json:"deadline,omitempty"` +} + +func (m *CompassHandover) Reset() { *m = CompassHandover{} } +func (m *CompassHandover) String() string { return proto.CompactTextString(m) } +func (*CompassHandover) ProtoMessage() {} +func (*CompassHandover) Descriptor() ([]byte, []int) { + return fileDescriptor_86cc126a804337fd, []int{4} +} + +func (m *CompassHandover) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *CompassHandover) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CompassHandover.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} + +func (m *CompassHandover) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompassHandover.Merge(m, src) +} + +func (m *CompassHandover) XXX_Size() int { + return m.Size() +} + +func (m *CompassHandover) XXX_DiscardUnknown() { + xxx_messageInfo_CompassHandover.DiscardUnknown(m) +} + +var xxx_messageInfo_CompassHandover proto.InternalMessageInfo + +func (m *CompassHandover) GetForwardCallArgs() []CompassHandover_ForwardCallArgs { + if m != nil { + return m.ForwardCallArgs + } + return nil +} + +func (m *CompassHandover) GetDeadline() int64 { + if m != nil { + return m.Deadline + } + return 0 +} + +type CompassHandover_ForwardCallArgs struct { + HexContractAddress string `protobuf:"bytes,1,opt,name=hexContractAddress,proto3" json:"hexContractAddress,omitempty"` + Payload []byte `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"` +} + +func (m *CompassHandover_ForwardCallArgs) Reset() { *m = CompassHandover_ForwardCallArgs{} } +func (m *CompassHandover_ForwardCallArgs) String() string { return proto.CompactTextString(m) } +func (*CompassHandover_ForwardCallArgs) ProtoMessage() {} +func (*CompassHandover_ForwardCallArgs) Descriptor() ([]byte, []int) { + return fileDescriptor_86cc126a804337fd, []int{4, 0} +} + +func (m *CompassHandover_ForwardCallArgs) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *CompassHandover_ForwardCallArgs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CompassHandover_ForwardCallArgs.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} + +func (m *CompassHandover_ForwardCallArgs) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompassHandover_ForwardCallArgs.Merge(m, src) +} + +func (m *CompassHandover_ForwardCallArgs) XXX_Size() int { + return m.Size() +} + +func (m *CompassHandover_ForwardCallArgs) XXX_DiscardUnknown() { + xxx_messageInfo_CompassHandover_ForwardCallArgs.DiscardUnknown(m) +} + +var xxx_messageInfo_CompassHandover_ForwardCallArgs proto.InternalMessageInfo + +func (m *CompassHandover_ForwardCallArgs) GetHexContractAddress() string { + if m != nil { + return m.HexContractAddress + } + return "" +} + +func (m *CompassHandover_ForwardCallArgs) GetPayload() []byte { + if m != nil { + return m.Payload + } + return nil +} + type UploadSmartContract struct { Bytecode []byte `protobuf:"bytes,1,opt,name=bytecode,proto3" json:"bytecode,omitempty"` Abi string `protobuf:"bytes,2,opt,name=abi,proto3" json:"abi,omitempty"` @@ -355,11 +497,13 @@ func (m *UploadSmartContract) Reset() { *m = UploadSmartContract{} } func (m *UploadSmartContract) String() string { return proto.CompactTextString(m) } func (*UploadSmartContract) ProtoMessage() {} func (*UploadSmartContract) Descriptor() ([]byte, []int) { - return fileDescriptor_86cc126a804337fd, []int{4} + return fileDescriptor_86cc126a804337fd, []int{5} } + func (m *UploadSmartContract) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *UploadSmartContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_UploadSmartContract.Marshal(b, m, deterministic) @@ -372,12 +516,15 @@ func (m *UploadSmartContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *UploadSmartContract) XXX_Merge(src proto.Message) { xxx_messageInfo_UploadSmartContract.Merge(m, src) } + func (m *UploadSmartContract) XXX_Size() int { return m.Size() } + func (m *UploadSmartContract) XXX_DiscardUnknown() { xxx_messageInfo_UploadSmartContract.DiscardUnknown(m) } @@ -434,11 +581,13 @@ func (m *UploadUserSmartContract) Reset() { *m = UploadUserSmartContract func (m *UploadUserSmartContract) String() string { return proto.CompactTextString(m) } func (*UploadUserSmartContract) ProtoMessage() {} func (*UploadUserSmartContract) Descriptor() ([]byte, []int) { - return fileDescriptor_86cc126a804337fd, []int{5} + return fileDescriptor_86cc126a804337fd, []int{6} } + func (m *UploadUserSmartContract) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *UploadUserSmartContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_UploadUserSmartContract.Marshal(b, m, deterministic) @@ -451,12 +600,15 @@ func (m *UploadUserSmartContract) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } + func (m *UploadUserSmartContract) XXX_Merge(src proto.Message) { xxx_messageInfo_UploadUserSmartContract.Merge(m, src) } + func (m *UploadUserSmartContract) XXX_Size() int { return m.Size() } + func (m *UploadUserSmartContract) XXX_DiscardUnknown() { xxx_messageInfo_UploadUserSmartContract.DiscardUnknown(m) } @@ -528,6 +680,7 @@ type Message struct { // *Message_UpdateValset // *Message_UploadSmartContract // *Message_UploadUserSmartContract + // *Message_CompassHandover Action isMessage_Action `protobuf_oneof:"action"` CompassAddr string `protobuf:"bytes,6,opt,name=compassAddr,proto3" json:"compassAddr,omitempty"` Assignee string `protobuf:"bytes,7,opt,name=assignee,proto3" json:"assignee,omitempty"` @@ -541,11 +694,13 @@ func (m *Message) Reset() { *m = Message{} } func (m *Message) String() string { return proto.CompactTextString(m) } func (*Message) ProtoMessage() {} func (*Message) Descriptor() ([]byte, []int) { - return fileDescriptor_86cc126a804337fd, []int{6} + return fileDescriptor_86cc126a804337fd, []int{7} } + func (m *Message) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_Message.Marshal(b, m, deterministic) @@ -558,12 +713,15 @@ func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } + func (m *Message) XXX_Merge(src proto.Message) { xxx_messageInfo_Message.Merge(m, src) } + func (m *Message) XXX_Size() int { return m.Size() } + func (m *Message) XXX_DiscardUnknown() { xxx_messageInfo_Message.DiscardUnknown(m) } @@ -588,11 +746,15 @@ type Message_UploadSmartContract struct { type Message_UploadUserSmartContract struct { UploadUserSmartContract *UploadUserSmartContract `protobuf:"bytes,11,opt,name=uploadUserSmartContract,proto3,oneof" json:"uploadUserSmartContract,omitempty"` } +type Message_CompassHandover struct { + CompassHandover *CompassHandover `protobuf:"bytes,12,opt,name=compassHandover,proto3,oneof" json:"compassHandover,omitempty"` +} func (*Message_SubmitLogicCall) isMessage_Action() {} func (*Message_UpdateValset) isMessage_Action() {} func (*Message_UploadSmartContract) isMessage_Action() {} func (*Message_UploadUserSmartContract) isMessage_Action() {} +func (*Message_CompassHandover) isMessage_Action() {} func (m *Message) GetAction() isMessage_Action { if m != nil { @@ -643,6 +805,13 @@ func (m *Message) GetUploadUserSmartContract() *UploadUserSmartContract { return nil } +func (m *Message) GetCompassHandover() *CompassHandover { + if x, ok := m.GetAction().(*Message_CompassHandover); ok { + return x.CompassHandover + } + return nil +} + func (m *Message) GetCompassAddr() string { if m != nil { return m.CompassAddr @@ -671,6 +840,7 @@ func (*Message) XXX_OneofWrappers() []interface{} { (*Message_UpdateValset)(nil), (*Message_UploadSmartContract)(nil), (*Message_UploadUserSmartContract)(nil), + (*Message_CompassHandover)(nil), } } @@ -683,11 +853,13 @@ func (m *TxExecutedProof) Reset() { *m = TxExecutedProof{} } func (m *TxExecutedProof) String() string { return proto.CompactTextString(m) } func (*TxExecutedProof) ProtoMessage() {} func (*TxExecutedProof) Descriptor() ([]byte, []int) { - return fileDescriptor_86cc126a804337fd, []int{7} + return fileDescriptor_86cc126a804337fd, []int{8} } + func (m *TxExecutedProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *TxExecutedProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_TxExecutedProof.Marshal(b, m, deterministic) @@ -700,12 +872,15 @@ func (m *TxExecutedProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, err return b[:n], nil } } + func (m *TxExecutedProof) XXX_Merge(src proto.Message) { xxx_messageInfo_TxExecutedProof.Merge(m, src) } + func (m *TxExecutedProof) XXX_Size() int { return m.Size() } + func (m *TxExecutedProof) XXX_DiscardUnknown() { xxx_messageInfo_TxExecutedProof.DiscardUnknown(m) } @@ -734,11 +909,13 @@ func (m *SmartContractExecutionErrorProof) Reset() { *m = SmartContractE func (m *SmartContractExecutionErrorProof) String() string { return proto.CompactTextString(m) } func (*SmartContractExecutionErrorProof) ProtoMessage() {} func (*SmartContractExecutionErrorProof) Descriptor() ([]byte, []int) { - return fileDescriptor_86cc126a804337fd, []int{8} + return fileDescriptor_86cc126a804337fd, []int{9} } + func (m *SmartContractExecutionErrorProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *SmartContractExecutionErrorProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_SmartContractExecutionErrorProof.Marshal(b, m, deterministic) @@ -751,12 +928,15 @@ func (m *SmartContractExecutionErrorProof) XXX_Marshal(b []byte, deterministic b return b[:n], nil } } + func (m *SmartContractExecutionErrorProof) XXX_Merge(src proto.Message) { xxx_messageInfo_SmartContractExecutionErrorProof.Merge(m, src) } + func (m *SmartContractExecutionErrorProof) XXX_Size() int { return m.Size() } + func (m *SmartContractExecutionErrorProof) XXX_DiscardUnknown() { xxx_messageInfo_SmartContractExecutionErrorProof.DiscardUnknown(m) } @@ -770,73 +950,19 @@ func (m *SmartContractExecutionErrorProof) GetErrorMessage() string { return "" } -// This is no longer in active use. -// -// Deprecated: Do not use. -type TransferERC20Ownership struct { - SmartContractID uint64 `protobuf:"varint,1,opt,name=smartContractID,proto3" json:"smartContractID,omitempty"` - NewCompassAddress []byte `protobuf:"bytes,2,opt,name=newCompassAddress,proto3" json:"newCompassAddress,omitempty"` -} - -func (m *TransferERC20Ownership) Reset() { *m = TransferERC20Ownership{} } -func (m *TransferERC20Ownership) String() string { return proto.CompactTextString(m) } -func (*TransferERC20Ownership) ProtoMessage() {} -func (*TransferERC20Ownership) Descriptor() ([]byte, []int) { - return fileDescriptor_86cc126a804337fd, []int{9} -} -func (m *TransferERC20Ownership) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *TransferERC20Ownership) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_TransferERC20Ownership.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *TransferERC20Ownership) XXX_Merge(src proto.Message) { - xxx_messageInfo_TransferERC20Ownership.Merge(m, src) -} -func (m *TransferERC20Ownership) XXX_Size() int { - return m.Size() -} -func (m *TransferERC20Ownership) XXX_DiscardUnknown() { - xxx_messageInfo_TransferERC20Ownership.DiscardUnknown(m) -} - -var xxx_messageInfo_TransferERC20Ownership proto.InternalMessageInfo - -func (m *TransferERC20Ownership) GetSmartContractID() uint64 { - if m != nil { - return m.SmartContractID - } - return 0 -} - -func (m *TransferERC20Ownership) GetNewCompassAddress() []byte { - if m != nil { - return m.NewCompassAddress - } - return nil -} - func init() { proto.RegisterType((*Valset)(nil), "palomachain.paloma.evm.Valset") proto.RegisterType((*Fees)(nil), "palomachain.paloma.evm.Fees") proto.RegisterType((*SubmitLogicCall)(nil), "palomachain.paloma.evm.SubmitLogicCall") proto.RegisterType((*SubmitLogicCall_ExecutionRequirements)(nil), "palomachain.paloma.evm.SubmitLogicCall.ExecutionRequirements") proto.RegisterType((*UpdateValset)(nil), "palomachain.paloma.evm.UpdateValset") + proto.RegisterType((*CompassHandover)(nil), "palomachain.paloma.evm.CompassHandover") + proto.RegisterType((*CompassHandover_ForwardCallArgs)(nil), "palomachain.paloma.evm.CompassHandover.ForwardCallArgs") proto.RegisterType((*UploadSmartContract)(nil), "palomachain.paloma.evm.UploadSmartContract") proto.RegisterType((*UploadUserSmartContract)(nil), "palomachain.paloma.evm.UploadUserSmartContract") proto.RegisterType((*Message)(nil), "palomachain.paloma.evm.Message") proto.RegisterType((*TxExecutedProof)(nil), "palomachain.paloma.evm.TxExecutedProof") proto.RegisterType((*SmartContractExecutionErrorProof)(nil), "palomachain.paloma.evm.SmartContractExecutionErrorProof") - proto.RegisterType((*TransferERC20Ownership)(nil), "palomachain.paloma.evm.TransferERC20Ownership") } func init() { @@ -844,72 +970,75 @@ func init() { } var fileDescriptor_86cc126a804337fd = []byte{ - // 1039 bytes of a gzipped FileDescriptorProto + // 1083 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0x41, 0x6f, 0x1b, 0x45, - 0x14, 0xf6, 0xda, 0x8e, 0x63, 0x8f, 0x5d, 0x92, 0x4c, 0x49, 0xba, 0x44, 0xc8, 0xb5, 0x56, 0x15, - 0x98, 0x02, 0xeb, 0xca, 0xa0, 0x1e, 0x90, 0x38, 0x24, 0x69, 0xa2, 0xa4, 0xa2, 0x02, 0x4d, 0x92, - 0x0a, 0x21, 0xa4, 0x68, 0xbc, 0xfb, 0x62, 0x8f, 0xb2, 0xbb, 0xb3, 0xcc, 0xcc, 0x26, 0x31, 0xbf, - 0x82, 0x2b, 0x3f, 0x00, 0x89, 0x23, 0x07, 0x7e, 0x44, 0x2f, 0x48, 0x15, 0x27, 0xc4, 0xa1, 0x42, - 0xc9, 0x01, 0xf1, 0x2f, 0xd0, 0xcc, 0xae, 0x9d, 0xb5, 0xbd, 0x81, 0xf6, 0xb2, 0x9a, 0xf7, 0xcd, - 0x9b, 0xf7, 0xde, 0xbc, 0xf7, 0xbd, 0x37, 0x8b, 0xde, 0x8b, 0x69, 0xc0, 0x43, 0xea, 0x8d, 0x28, - 0x8b, 0x7a, 0xe9, 0xba, 0x07, 0xe7, 0x61, 0x4f, 0x25, 0x22, 0x92, 0x8a, 0x47, 0xe0, 0xc6, 0x82, - 0x2b, 0x8e, 0x37, 0x72, 0x7a, 0x6e, 0xba, 0x76, 0xe1, 0x3c, 0xdc, 0x7c, 0x7b, 0xc8, 0x87, 0xdc, - 0xa8, 0xf4, 0xf4, 0x2a, 0xd5, 0xde, 0x7c, 0xc7, 0xe3, 0x32, 0xe4, 0xf2, 0x24, 0xdd, 0x48, 0x85, - 0x6c, 0x6b, 0x8d, 0x86, 0x2c, 0xe2, 0x3d, 0xf3, 0x4d, 0x21, 0xe7, 0x5b, 0x54, 0x7b, 0x4e, 0x03, - 0x09, 0x0a, 0xb7, 0x11, 0x3a, 0xa7, 0x01, 0xf3, 0xa9, 0xe2, 0x42, 0xda, 0x56, 0xa7, 0xd2, 0x6d, - 0x90, 0x1c, 0x82, 0x37, 0x50, 0x2d, 0xe6, 0x17, 0x20, 0xa4, 0x5d, 0xee, 0x54, 0xba, 0x55, 0x92, - 0x49, 0x78, 0x13, 0xd5, 0xcf, 0x8d, 0x85, 0x83, 0x27, 0x76, 0xa5, 0x63, 0x75, 0xab, 0x64, 0x2a, - 0x3b, 0x01, 0xaa, 0xee, 0x01, 0x48, 0x6d, 0x5b, 0x40, 0x40, 0xc7, 0x20, 0xf6, 0x00, 0x6c, 0xcb, - 0x68, 0xe5, 0x10, 0xec, 0xa0, 0x96, 0xc7, 0xc3, 0x30, 0x89, 0x98, 0x1a, 0x6b, 0x8d, 0xb2, 0xd1, - 0x98, 0xc1, 0x70, 0x07, 0x35, 0x25, 0x78, 0x89, 0xc8, 0x54, 0x52, 0x57, 0x79, 0xc8, 0xf9, 0xa7, - 0x82, 0x56, 0x0e, 0x93, 0x41, 0xc8, 0xd4, 0x17, 0x7c, 0xc8, 0xbc, 0x1d, 0x1a, 0x04, 0xd8, 0x45, - 0x78, 0x04, 0x97, 0x3b, 0x3c, 0x52, 0x82, 0x7a, 0x6a, 0xcb, 0xf7, 0x05, 0x48, 0x69, 0x22, 0x68, - 0x90, 0x82, 0x1d, 0xbc, 0x8a, 0x2a, 0x74, 0xc0, 0x4c, 0x00, 0x2d, 0xa2, 0x97, 0xd8, 0x46, 0xcb, - 0x31, 0x1d, 0x07, 0x9c, 0xfa, 0xc6, 0x67, 0x8b, 0x4c, 0x44, 0x7d, 0x73, 0x1f, 0xa8, 0x1f, 0xb0, - 0x08, 0xec, 0x6a, 0xc7, 0xea, 0x56, 0xc8,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b8, + 0x5f, 0x0a, 0xce, 0xc7, 0xfa, 0xae, 0x21, 0x41, 0x30, 0xea, 0xb1, 0xef, 0xc1, 0x7d, 0xf2, 0x55, + 0x32, 0x47, 0x32, 0x18, 0x1e, 0xa0, 0x9b, 0x2f, 0x6d, 0x02, 0x0e, 0xb0, 0x50, 0xc5, 0x33, 0x34, + 0x91, 0xe0, 0xea, 0x76, 0xe7, 0x00, 0xb5, 0x33, 0xdf, 0x75, 0xf1, 0x87, 0xdb, 0x17, 0x82, 0x8b, + 0x45, 0x6e, 0xd0, 0x56, 0xa2, 0xdb, 0x44, 0xa8, 0x19, 0x6c, 0x77, 0xef, 0xd9, 0x65, 0xcb, 0x7a, + 0x7e, 0xd9, 0xb2, 0xfe, 0xba, 0x6c, 0x59, 0x3f, 0x5c, 0xb5, 0x0a, 0xcf, 0xaf, 0x5a, 0x85, 0x3f, + 0xae, 0x5a, 0x85, 0xaf, 0x3f, 0x98, 0x30, 0x35, 0x8d, 0x46, 0x3d, 0x87, 0xfb, 0xfd, 0x9c, 0xab, + 0xe3, 0x45, 0x7c, 0x79, 0x9c, 0x85, 0x20, 0x47, 0x15, 0x73, 0xbb, 0xfb, 0xf8, 0xbf, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x29, 0x39, 0xf1, 0x34, 0x63, 0x0a, 0x00, 0x00, } func (m *Valset) Marshal() (dAtA []byte, err error) { @@ -1163,6 +1292,85 @@ func (m *UpdateValset) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *CompassHandover) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CompassHandover) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CompassHandover) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Deadline != 0 { + i = encodeVarintTurnstone(dAtA, i, uint64(m.Deadline)) + i-- + dAtA[i] = 0x10 + } + if len(m.ForwardCallArgs) > 0 { + for iNdEx := len(m.ForwardCallArgs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ForwardCallArgs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTurnstone(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *CompassHandover_ForwardCallArgs) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CompassHandover_ForwardCallArgs) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CompassHandover_ForwardCallArgs) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Payload) > 0 { + i -= len(m.Payload) + copy(dAtA[i:], m.Payload) + i = encodeVarintTurnstone(dAtA, i, uint64(len(m.Payload))) + i-- + dAtA[i] = 0x12 + } + if len(m.HexContractAddress) > 0 { + i -= len(m.HexContractAddress) + copy(dAtA[i:], m.HexContractAddress) + i = encodeVarintTurnstone(dAtA, i, uint64(len(m.HexContractAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *UploadSmartContract) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1391,6 +1599,7 @@ func (m *Message_SubmitLogicCall) MarshalToSizedBuffer(dAtA []byte) (int, error) } return len(dAtA) - i, nil } + func (m *Message_UpdateValset) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) @@ -1412,6 +1621,7 @@ func (m *Message_UpdateValset) MarshalToSizedBuffer(dAtA []byte) (int, error) { } return len(dAtA) - i, nil } + func (m *Message_UploadSmartContract) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) @@ -1433,6 +1643,7 @@ func (m *Message_UploadSmartContract) MarshalToSizedBuffer(dAtA []byte) (int, er } return len(dAtA) - i, nil } + func (m *Message_UploadUserSmartContract) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) @@ -1454,10 +1665,33 @@ func (m *Message_UploadUserSmartContract) MarshalToSizedBuffer(dAtA []byte) (int } return len(dAtA) - i, nil } -func (m *TxExecutedProof) Marshal() (dAtA []byte, err error) { + +func (m *Message_CompassHandover) MarshalTo(dAtA []byte) (int, error) { size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Message_CompassHandover) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.CompassHandover != nil { + { + size, err := m.CompassHandover.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTurnstone(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x62 + } + return len(dAtA) - i, nil +} + +func (m *TxExecutedProof) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1521,41 +1755,6 @@ func (m *SmartContractExecutionErrorProof) MarshalToSizedBuffer(dAtA []byte) (in return len(dAtA) - i, nil } -func (m *TransferERC20Ownership) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *TransferERC20Ownership) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *TransferERC20Ownership) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.NewCompassAddress) > 0 { - i -= len(m.NewCompassAddress) - copy(dAtA[i:], m.NewCompassAddress) - i = encodeVarintTurnstone(dAtA, i, uint64(len(m.NewCompassAddress))) - i-- - dAtA[i] = 0x12 - } - if m.SmartContractID != 0 { - i = encodeVarintTurnstone(dAtA, i, uint64(m.SmartContractID)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - func encodeVarintTurnstone(dAtA []byte, offset int, v uint64) int { offset -= sovTurnstone(v) base := offset @@ -1567,6 +1766,7 @@ func encodeVarintTurnstone(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *Valset) Size() (n int) { if m == nil { return 0 @@ -1676,6 +1876,41 @@ func (m *UpdateValset) Size() (n int) { return n } +func (m *CompassHandover) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ForwardCallArgs) > 0 { + for _, e := range m.ForwardCallArgs { + l = e.Size() + n += 1 + l + sovTurnstone(uint64(l)) + } + } + if m.Deadline != 0 { + n += 1 + sovTurnstone(uint64(m.Deadline)) + } + return n +} + +func (m *CompassHandover_ForwardCallArgs) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.HexContractAddress) + if l > 0 { + n += 1 + l + sovTurnstone(uint64(l)) + } + l = len(m.Payload) + if l > 0 { + n += 1 + l + sovTurnstone(uint64(l)) + } + return n +} + func (m *UploadSmartContract) Size() (n int) { if m == nil { return 0 @@ -1786,6 +2021,7 @@ func (m *Message_SubmitLogicCall) Size() (n int) { } return n } + func (m *Message_UpdateValset) Size() (n int) { if m == nil { return 0 @@ -1798,6 +2034,7 @@ func (m *Message_UpdateValset) Size() (n int) { } return n } + func (m *Message_UploadSmartContract) Size() (n int) { if m == nil { return 0 @@ -1810,6 +2047,7 @@ func (m *Message_UploadSmartContract) Size() (n int) { } return n } + func (m *Message_UploadUserSmartContract) Size() (n int) { if m == nil { return 0 @@ -1822,46 +2060,44 @@ func (m *Message_UploadUserSmartContract) Size() (n int) { } return n } -func (m *TxExecutedProof) Size() (n int) { + +func (m *Message_CompassHandover) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.SerializedTX) - if l > 0 { - n += 1 + l + sovTurnstone(uint64(l)) - } - l = len(m.SerializedReceipt) - if l > 0 { + if m.CompassHandover != nil { + l = m.CompassHandover.Size() n += 1 + l + sovTurnstone(uint64(l)) } return n } -func (m *SmartContractExecutionErrorProof) Size() (n int) { +func (m *TxExecutedProof) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.ErrorMessage) + l = len(m.SerializedTX) + if l > 0 { + n += 1 + l + sovTurnstone(uint64(l)) + } + l = len(m.SerializedReceipt) if l > 0 { n += 1 + l + sovTurnstone(uint64(l)) } return n } -func (m *TransferERC20Ownership) Size() (n int) { +func (m *SmartContractExecutionErrorProof) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.SmartContractID != 0 { - n += 1 + sovTurnstone(uint64(m.SmartContractID)) - } - l = len(m.NewCompassAddress) + l = len(m.ErrorMessage) if l > 0 { n += 1 + l + sovTurnstone(uint64(l)) } @@ -1871,9 +2107,11 @@ func (m *TransferERC20Ownership) Size() (n int) { func sovTurnstone(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozTurnstone(x uint64) (n int) { return sovTurnstone(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *Valset) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2051,6 +2289,7 @@ func (m *Valset) Unmarshal(dAtA []byte) error { } return nil } + func (m *Fees) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2158,6 +2397,7 @@ func (m *Fees) Unmarshal(dAtA []byte) error { } return nil } + func (m *SubmitLogicCall) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2483,6 +2723,7 @@ func (m *SubmitLogicCall) Unmarshal(dAtA []byte) error { } return nil } + func (m *SubmitLogicCall_ExecutionRequirements) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2553,6 +2794,7 @@ func (m *SubmitLogicCall_ExecutionRequirements) Unmarshal(dAtA []byte) error { } return nil } + func (m *UpdateValset) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2639,6 +2881,228 @@ func (m *UpdateValset) Unmarshal(dAtA []byte) error { } return nil } + +func (m *CompassHandover) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTurnstone + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CompassHandover: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CompassHandover: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ForwardCallArgs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTurnstone + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTurnstone + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTurnstone + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ForwardCallArgs = append(m.ForwardCallArgs, CompassHandover_ForwardCallArgs{}) + if err := m.ForwardCallArgs[len(m.ForwardCallArgs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Deadline", wireType) + } + m.Deadline = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTurnstone + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Deadline |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTurnstone(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTurnstone + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *CompassHandover_ForwardCallArgs) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTurnstone + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ForwardCallArgs: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ForwardCallArgs: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HexContractAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTurnstone + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTurnstone + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTurnstone + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.HexContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTurnstone + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTurnstone + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTurnstone + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) + if m.Payload == nil { + m.Payload = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTurnstone(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTurnstone + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + func (m *UploadSmartContract) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2827,6 +3291,7 @@ func (m *UploadSmartContract) Unmarshal(dAtA []byte) error { } return nil } + func (m *UploadUserSmartContract) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3089,6 +3554,7 @@ func (m *UploadUserSmartContract) Unmarshal(dAtA []byte) error { } return nil } + func (m *Message) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3452,6 +3918,41 @@ func (m *Message) Unmarshal(dAtA []byte) error { } m.Action = &Message_UploadUserSmartContract{v} iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CompassHandover", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTurnstone + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTurnstone + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTurnstone + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &CompassHandover{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Action = &Message_CompassHandover{v} + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTurnstone(dAtA[iNdEx:]) @@ -3473,6 +3974,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { } return nil } + func (m *TxExecutedProof) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3591,6 +4093,7 @@ func (m *TxExecutedProof) Unmarshal(dAtA []byte) error { } return nil } + func (m *SmartContractExecutionErrorProof) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3673,109 +4176,7 @@ func (m *SmartContractExecutionErrorProof) Unmarshal(dAtA []byte) error { } return nil } -func (m *TransferERC20Ownership) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTurnstone - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: TransferERC20Ownership: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: TransferERC20Ownership: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SmartContractID", wireType) - } - m.SmartContractID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTurnstone - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SmartContractID |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewCompassAddress", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTurnstone - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTurnstone - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTurnstone - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.NewCompassAddress = append(m.NewCompassAddress[:0], dAtA[iNdEx:postIndex]...) - if m.NewCompassAddress == nil { - m.NewCompassAddress = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTurnstone(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTurnstone - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipTurnstone(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/evm/types/turnstone_abi.go b/x/evm/types/turnstone_abi.go index 76515999..39ceac37 100644 --- a/x/evm/types/turnstone_abi.go +++ b/x/evm/types/turnstone_abi.go @@ -17,6 +17,10 @@ import ( consensustypes "github.com/palomachain/paloma/x/consensus/types" ) +type keccak256able interface { + keccak256(*Message, uint64, uint64) ([]byte, error) +} + type Signature struct { V *big.Int R *big.Int @@ -37,14 +41,19 @@ type CompassConsensus struct { } type CompassLogicCallArgs struct { - Payload []byte LogicContractAddress common.Address + Payload []byte } var ( _ consensustypes.MessageHasher = (*Message)(nil) _ consensustypes.MessageHasher = (*ValidatorBalancesAttestation)(nil) _ consensustypes.MessageHasher = (*ReferenceBlockAttestation)(nil) + _ keccak256able = (*Message_UpdateValset)(nil) + _ keccak256able = (*Message_SubmitLogicCall)(nil) + _ keccak256able = (*Message_UploadSmartContract)(nil) + _ keccak256able = (*Message_UploadUserSmartContract)(nil) + _ keccak256able = (*Message_CompassHandover)(nil) ) func (_m *Message_UpdateValset) keccak256( @@ -209,6 +218,58 @@ func (_m *Message_SubmitLogicCall) keccak256( return crypto.Keccak256(bytes), nil } +func (_m *Message_CompassHandover) keccak256( + orig *Message, + _, gasEstimate uint64, +) ([]byte, error) { + m := _m.CompassHandover + // compass_update_batch((address,bytes)[],uint256,address,uint256) + arguments := abi.Arguments{ + // arguments + {Type: whoops.Must(abi.NewType("tuple[]", "", []abi.ArgumentMarshaling{ + {Name: "address", Type: "address"}, + {Name: "payload", Type: "bytes"}, + }))}, + // deadline + {Type: whoops.Must(abi.NewType("uint256", "", nil))}, + // relayer + {Type: whoops.Must(abi.NewType("address", "", nil))}, + // gas estimate + {Type: whoops.Must(abi.NewType("uint256", "", nil))}, + } + + method := abi.NewMethod("compass_update_batch", "compass_update_batch", abi.Function, "", false, false, arguments, abi.Arguments{}) + estimate := gasEstimate + if estimate == 0 { + // If there's no estimate, we use the same default as pigeon + estimate = 300_000 + } + + type logicCallArg struct { + Address common.Address + Payload []byte + } + + bytes, err := arguments.Pack( + slice.Map(m.GetForwardCallArgs(), func(arg CompassHandover_ForwardCallArgs) logicCallArg { + return logicCallArg{ + common.HexToAddress(arg.GetHexContractAddress()), + arg.GetPayload(), + } + }), + big.NewInt(m.GetDeadline()), + common.HexToAddress(orig.AssigneeRemoteAddress), + big.NewInt(0).SetUint64(estimate), + ) + if err != nil { + return nil, err + } + + bytes = append(method.ID[:], bytes...) + + return crypto.Keccak256(bytes), nil +} + func (_m *Message_UploadUserSmartContract) keccak256( orig *Message, nonce, _ uint64, @@ -284,9 +345,6 @@ func (m *Message) SetAssignee(ctx sdk.Context, val, remoteAddr string) { } func (m *Message) Keccak256WithSignedMessage(q *consensustypes.QueuedSignedMessage) ([]byte, error) { - type keccak256able interface { - keccak256(*Message, uint64, uint64) ([]byte, error) - } k, ok := m.GetAction().(keccak256able) if !ok { return nil, errors.New("message's action is not hashable") From 04f559081e282c0935a66946f3ad56edabdd1fa7 Mon Sep 17 00:00:00 2001 From: Christian Lohr Date: Thu, 29 Aug 2024 11:46:19 +0200 Subject: [PATCH 2/8] fix: always relink tokens --- x/evm/keeper/attest_upload_smart_contract.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/x/evm/keeper/attest_upload_smart_contract.go b/x/evm/keeper/attest_upload_smart_contract.go index 03dd573d..a70e1101 100644 --- a/x/evm/keeper/attest_upload_smart_contract.go +++ b/x/evm/keeper/attest_upload_smart_contract.go @@ -124,12 +124,9 @@ func (a *uploadSmartContractAttester) attest(ctx sdk.Context, evidence *types.Tx if err != nil { return err } - - return a.startTokenRelink(ctx, deployment, newCompassAddr, smartContractID) } - // We don't have any tokens on the target chain. Set contract as active immediately. - return a.k.SetSmartContractAsActive(ctx, smartContractID, a.chainReferenceID) + return a.startTokenRelink(ctx, deployment, newCompassAddr, smartContractID) } func (a *uploadSmartContractAttester) startTokenRelink( From 3bb679ffa7ff32d1d431b3a4b6c7a30908e91b16 Mon Sep 17 00:00:00 2001 From: Christian Lohr Date: Thu, 29 Aug 2024 12:58:53 +0200 Subject: [PATCH 3/8] fix: avoid handover for initial deployment --- x/evm/keeper/attest_test.go | 168 +++++-------------- x/evm/keeper/attest_upload_smart_contract.go | 13 +- 2 files changed, 47 insertions(+), 134 deletions(-) diff --git a/x/evm/keeper/attest_test.go b/x/evm/keeper/attest_test.go index fba40e7d..3a59240d 100644 --- a/x/evm/keeper/attest_test.go +++ b/x/evm/keeper/attest_test.go @@ -15,6 +15,7 @@ import ( ethcoretypes "github.com/ethereum/go-ethereum/core/types" g "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + keeperutil "github.com/palomachain/paloma/util/keeper" "github.com/palomachain/paloma/util/slice" consensusmocks "github.com/palomachain/paloma/x/consensus/keeper/consensus/mocks" consensustypes "github.com/palomachain/paloma/x/consensus/types" @@ -50,15 +51,15 @@ var ( }) ) -// type record struct { -// denom string -// erc20 string -// chain string -// } +type record struct { + denom string + erc20 string + chain string +} -// func (r record) GetDenom() string { return r.denom } -// func (r record) GetErc20() string { return r.erc20 } -// func (r record) GetChainReferenceId() string { return r.chain } +func (r record) GetDenom() string { return r.denom } +func (r record) GetErc20() string { return r.erc20 } +func (r record) GetChainReferenceId() string { return r.chain } func TestKeeperGinkgo(t *testing.T) { RegisterFailHandler(g.Fail) @@ -117,7 +118,7 @@ var _ = g.Describe("attest router", func() { var ctx sdk.Context var q *consensusmocks.Queuer var v *evmmocks.ValsetKeeper - // var gk *evmmocks.SkywayKeeper + var sk *evmmocks.SkywayKeeper var consensukeeper *evmmocks.ConsensusKeeper var mk *evmmocks.MetrixKeeper var tk *evmmocks.TreasuryKeeper @@ -150,7 +151,7 @@ var _ = g.Describe("attest router", func() { ctx = _ctx k = *kpr v = ms.ValsetKeeper - // gk = ms.SkywayKeeper + sk = ms.SkywayKeeper tk = ms.TreasuryKeeper mk = ms.MetrixKeeper consensukeeper = ms.ConsensusKeeper @@ -490,84 +491,6 @@ var _ = g.Describe("attest router", func() { }) }) - g.When("message is CompassHandover", func() { - // TODO: Implement - // // TODO: move to attest handover - // g.When("message is attesting to successful erc20 relink", func() { - // g.When("no more pending messages after this", func() { - // g.It("remove the deployment and activate the chain", func() { - // setupChainSupport() - // dep, _ := k.getSmartContractDeploymentByContractID(ctx, uint64(1), newChain.GetChainReferenceID()) - // Expect(dep).ToNot(BeNil()) - // dep.Status = types.SmartContractDeployment_WAITING_FOR_ERC20_OWNERSHIP_TRANSFER - // dep.Erc20Transfers = []types.SmartContractDeployment_ERC20Transfer{ - // { - // Denom: "denom", - // Erc20: "address", - // MsgID: 123, - // Status: types.SmartContractDeployment_ERC20Transfer_PENDING, - // }, - // } - // err := k.updateSmartContractDeployment(ctx, uint64(1), newChain.ChainReferenceID, dep) - // Expect(err).To(BeNil()) - // k.deploymentCache.Add(ctx, newChain.ChainReferenceID, uint64(1), 123) - // Expect(subject()).To(BeNil()) - // res, _ := k.getSmartContractDeploymentByContractID(ctx, uint64(1), newChain.GetChainReferenceID()) - // Expect(res).To(BeNil()) - // info, err := k.GetChainInfo(ctx, newChain.ChainReferenceID) - // Expect(err).To(BeNil()) - // Expect(info.ActiveSmartContractID).To(Equal(uint64(1))) - // }) - // }) - // }) - g.BeforeEach(func() { - execTx = valsetTx1 - proof := whoops.Must(codectypes.NewAnyWithValue(&types.TxExecutedProof{SerializedTX: whoops.Must(execTx.MarshalBinary())})) - evidence = []*consensustypes.Evidence{ - { - ValAddress: sdk.ValAddress("validator-1"), - Proof: proof, - }, - { - ValAddress: sdk.ValAddress("validator-2"), - Proof: proof, - }, - { - ValAddress: sdk.ValAddress("validator-3"), - Proof: proof, - }, - } - consensusMsg.Action = &types.Message_UpdateValset{ - UpdateValset: &types.UpdateValset{ - Valset: &types.Valset{ - ValsetID: 1, - Validators: []string{"addr1", "addr2"}, - Powers: []uint64{15, 5}, - }, - }, - } - }) - - g.BeforeEach(func() { - q.On("GetAll", mock.Anything).Return(nil, nil) - }) - - g.When("successfully sets valset for chain", func() { - g.BeforeEach(func() { - v.On("SetSnapshotOnChain", mock.Anything, mock.Anything, mock.Anything).Return(nil) - }) - successfulProcess() - }) - - g.When("unsuccessfully sets valset for chain", func() { - // We still process successfully even if we get an error here - g.BeforeEach(func() { - v.On("SetSnapshotOnChain", mock.Anything, mock.Anything, mock.Anything).Return(errors.New("example error")) - }) - successfulProcess() - }) - }) - g.When("message is UploadSmartContract", func() { g.BeforeEach(func() { execTx = uscTx1 @@ -598,10 +521,13 @@ var _ = g.Describe("attest router", func() { consensusMsg.Assignee = address.String() }) - g.When("target chain has no deployed ERC20 tokens", func() { - // g.BeforeEach(func() { - // gk.On("CastChainERC20ToDenoms", mock.Anything, mock.Anything).Return(nil, nil) - // }) + g.When("target chain has no previous deployment of compass", func() { + g.BeforeEach(func() { + v.On("GetLatestSnapshotOnChain", mock.Anything, mock.Anything).Unset() + v.On("GetLatestSnapshotOnChain", mock.Anything, mock.Anything). + Return(nil, keeperutil.ErrNotFound).Once() + v.On("SetSnapshotOnChain", mock.Anything, mock.Anything, mock.Anything).Return(nil) + }) g.It("removes deployment", func() { setupChainSupport() Expect(subject()).To(BeNil()) @@ -618,43 +544,27 @@ var _ = g.Describe("attest router", func() { }) }) - // g.When("target chain has active ERC20 tokens deployed", func() { - // g.BeforeEach(func() { - // gk.On("CastChainERC20ToDenoms", mock.Anything, newChain.ChainReferenceID).Return([]types.ERC20Record{ - // record{"denom", "address1", newChain.ChainReferenceID}, - // record{"denom2", "address2", newChain.ChainReferenceID}, - // }, nil) - // }) - // g.It("updates deployment", func() { - // setupChainSupport() - // Expect(subject()).To(BeNil()) - // v, key := k.getSmartContractDeploymentByContractID(ctx, uint64(1), newChain.GetChainReferenceID()) - // Expect(key).ToNot(BeNil()) - // Expect(v).ToNot(BeNil()) - // Expect(v.GetStatus()).To(BeEquivalentTo(types.SmartContractDeployment_WAITING_FOR_ERC20_OWNERSHIP_TRANSFER)) - // Expect(v.GetErc20Transfers()).To(BeEquivalentTo([]types.SmartContractDeployment_ERC20Transfer{ - // { - // Denom: "denom", - // Erc20: "address1", - // MsgID: 10, - // Status: types.SmartContractDeployment_ERC20Transfer_PENDING, - // }, - // { - // Denom: "denom2", - // Erc20: "address2", - // MsgID: 10, - // Status: types.SmartContractDeployment_ERC20Transfer_PENDING, - // }, - // })) - // }) - // g.It("doesn't set the chain as active", func() { - // setupChainSupport() - // Expect(subject()).To(BeNil()) - // v, err := k.GetChainInfo(ctx, newChain.GetChainReferenceID()) - // Expect(err).To(BeNil()) - // Expect(v.GetActiveSmartContractID()).To(BeEquivalentTo(uint64(0))) - // }) - // }) + g.When("target chain has previous deployment of compass", func() { + g.BeforeEach(func() { + sk.On("CastChainERC20ToDenoms", mock.Anything, mock.Anything).Return([]types.ERC20Record{ + record{ + denom: "ugrain", + erc20: "0xb794f5ea0ba39494ce839613fffba74279579268", + chain: "test-chain", + }, + record{ + denom: "ugrain2", + erc20: "0xc794f5ea0ba39494ce839613fffba74279579268", + chain: "test-chain", + }, + }, nil) + consensukeeper.On("PutMessageInQueue", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(uint64(11), nil) + }) + g.It("puts the handover message in the queue", func() { + setupChainSupport() + Expect(subject()).To(BeNil()) + }) + }) }) g.JustAfterEach(func() { diff --git a/x/evm/keeper/attest_upload_smart_contract.go b/x/evm/keeper/attest_upload_smart_contract.go index a70e1101..e2540fed 100644 --- a/x/evm/keeper/attest_upload_smart_contract.go +++ b/x/evm/keeper/attest_upload_smart_contract.go @@ -124,16 +124,20 @@ func (a *uploadSmartContractAttester) attest(ctx sdk.Context, evidence *types.Tx if err != nil { return err } + + // Since this is the intial deployment, we need to set the smart contract + // as active and can skip the handover process. + return a.k.SetSmartContractAsActive(ctx, smartContractID, a.chainReferenceID) } - return a.startTokenRelink(ctx, deployment, newCompassAddr, smartContractID) + // If we got this far, it means we have a snapshot on chain and we can + // proceed with the handover process. + return a.startCompassHandover(ctx, newCompassAddr) } -func (a *uploadSmartContractAttester) startTokenRelink( +func (a *uploadSmartContractAttester) startCompassHandover( ctx sdk.Context, - deployment *types.SmartContractDeployment, newCompassAddr common.Address, - smartContractID uint64, ) error { ci, err := a.k.GetChainInfo(ctx, a.chainReferenceID) if err != nil { @@ -162,7 +166,6 @@ func (a *uploadSmartContractAttester) startTokenRelink( } for _, v := range tokens { - // TODO: what about existing tokens? Can we have a migration that deletes them? forwardCallArgs = append(forwardCallArgs, types.CompassHandover_ForwardCallArgs{ HexContractAddress: v.GetErc20(), Payload: erc20payload, From 2f5d292ad5ca3bd01a5c9338b13733c4d390ca2e Mon Sep 17 00:00:00 2001 From: Christian Lohr Date: Thu, 29 Aug 2024 15:04:56 +0200 Subject: [PATCH 4/8] fix: enable new chain after handover --- proto/palomachain/paloma/evm/turnstone.proto | 2 + x/evm/keeper/attest.go | 2 + x/evm/keeper/attest_compass_handover.go | 5 + x/evm/keeper/attest_upload_smart_contract.go | 1 + x/evm/types/turnstone.pb.go | 172 +++++++++++-------- 5 files changed, 114 insertions(+), 68 deletions(-) diff --git a/proto/palomachain/paloma/evm/turnstone.proto b/proto/palomachain/paloma/evm/turnstone.proto index 67295cad..cefd75a9 100644 --- a/proto/palomachain/paloma/evm/turnstone.proto +++ b/proto/palomachain/paloma/evm/turnstone.proto @@ -46,6 +46,8 @@ message CompassHandover { } repeated ForwardCallArgs forwardCallArgs = 1 [ (gogoproto.nullable) = false ]; int64 deadline = 2; + // Contains ID of the new smart contract + uint64 id = 3; } message UploadSmartContract { diff --git a/x/evm/keeper/attest.go b/x/evm/keeper/attest.go index cbf7d425..000ac6d2 100644 --- a/x/evm/keeper/attest.go +++ b/x/evm/keeper/attest.go @@ -131,6 +131,8 @@ func (k Keeper) routerAttester(sdkCtx sdk.Context, q consensus.Queuer, msg conse return newUpdateValsetAttester(&k, logger, q, params).Execute(sdkCtx) case *types.Message_SubmitLogicCall: return newSubmitLogicCallAttester(&k, logger, params).Execute(sdkCtx) + case *types.Message_CompassHandover: + return newCompassHandoverAttester(&k, logger, params).Execute(sdkCtx) } return nil diff --git a/x/evm/keeper/attest_compass_handover.go b/x/evm/keeper/attest_compass_handover.go index 163b10aa..4c1d2141 100644 --- a/x/evm/keeper/attest_compass_handover.go +++ b/x/evm/keeper/attest_compass_handover.go @@ -57,5 +57,10 @@ func (a *compassHandoverAttester) attest(ctx sdk.Context, evidence *types.TxExec return err } + if err = a.k.SetSmartContractAsActive(ctx, a.action.GetId(), a.chainReferenceID); err != nil { + a.logger.WithError(err).Error("Failed to set smart contract as active.") + return err + } + return nil } diff --git a/x/evm/keeper/attest_upload_smart_contract.go b/x/evm/keeper/attest_upload_smart_contract.go index e2540fed..edaa4448 100644 --- a/x/evm/keeper/attest_upload_smart_contract.go +++ b/x/evm/keeper/attest_upload_smart_contract.go @@ -182,6 +182,7 @@ func (a *uploadSmartContractAttester) startCompassHandover( a.chainReferenceID, string(ci.GetSmartContractUniqueID()), &types.CompassHandover{ + Id: a.action.GetId(), ForwardCallArgs: forwardCallArgs, Deadline: ctx.BlockTime().Add(10 * time.Minute).Unix(), }, diff --git a/x/evm/types/turnstone.pb.go b/x/evm/types/turnstone.pb.go index f36a1190..a9281252 100644 --- a/x/evm/types/turnstone.pb.go +++ b/x/evm/types/turnstone.pb.go @@ -374,6 +374,8 @@ func (m *UpdateValset) GetValset() *Valset { type CompassHandover struct { ForwardCallArgs []CompassHandover_ForwardCallArgs `protobuf:"bytes,1,rep,name=forwardCallArgs,proto3" json:"forwardCallArgs"` Deadline int64 `protobuf:"varint,2,opt,name=deadline,proto3" json:"deadline,omitempty"` + // Contains ID of the new smart contract + Id uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` } func (m *CompassHandover) Reset() { *m = CompassHandover{} } @@ -428,6 +430,13 @@ func (m *CompassHandover) GetDeadline() int64 { return 0 } +func (m *CompassHandover) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + type CompassHandover_ForwardCallArgs struct { HexContractAddress string `protobuf:"bytes,1,opt,name=hexContractAddress,proto3" json:"hexContractAddress,omitempty"` Payload []byte `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"` @@ -970,75 +979,75 @@ func init() { } var fileDescriptor_86cc126a804337fd = []byte{ - // 1083 bytes of a gzipped FileDescriptorProto + // 1086 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0x41, 0x6f, 0x1b, 0x45, - 0x14, 0xf6, 0xda, 0xae, 0x63, 0x8f, 0x5d, 0xdc, 0x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0x78, 0xf7, 0xd9, 0x1e, 0x65, 0x77, 0x67, 0x99, 0x99, 0x4d, 0x62, 0xae, 0xfc, + 0x01, 0xae, 0x5c, 0x91, 0x90, 0x38, 0x72, 0xe0, 0x47, 0xf4, 0x58, 0x71, 0x42, 0x1c, 0x2a, 0x94, + 0x1c, 0x10, 0xff, 0x02, 0xcd, 0xec, 0xda, 0xdd, 0x5d, 0xaf, 0x4b, 0x7b, 0x59, 0xcd, 0xfb, 0xe6, + 0xcd, 0x9b, 0x37, 0x6f, 0xbe, 0xef, 0xed, 0xa0, 0xf7, 0x42, 0xe2, 0x31, 0x9f, 0x38, 0x33, 0x42, + 0x83, 0x41, 0x3c, 0x1e, 0xc0, 0x99, 0x3f, 0x90, 0x11, 0x0f, 0x84, 0x64, 0x01, 0xd8, 0x21, 0x67, + 0x92, 0x99, 0x5b, 0x29, 0x3f, 0x3b, 0x1e, 0xdb, 0x70, 0xe6, 0x6f, 0xbf, 0x3d, 0x65, 0x53, 0xa6, + 0x5d, 0x06, 0x6a, 0x14, 0x7b, 0x6f, 0xbf, 0xe3, 0x30, 0xe1, 0x33, 0x71, 0x12, 0x4f, 0xc4, 0x46, + 0x32, 0x75, 0x93, 0xf8, 0x34, 0x60, 0x03, 0xfd, 0x8d, 0xa1, 0xde, 0xb7, 0xa8, 0xf6, 0x94, 0x78, + 0x02, 0xa4, 0xd9, 0x41, 0xe8, 0x8c, 0x78, 0xd4, 0x25, 0x92, 0x71, 0x61, 0x19, 0xdd, 0x4a, 0xbf, + 0x81, 0x53, 0x88, 0xb9, 0x85, 0x6a, 0x21, 0x3b, 0x07, 0x2e, 0xac, 0x72, 0xb7, 0xd2, 0xaf, 0xe2, + 0xc4, 0x32, 0xb7, 0x51, 0xfd, 0x4c, 0x47, 0x38, 0x7c, 0x68, 0x55, 0xba, 0x46, 0xbf, 0x8a, 0x97, + 0x76, 0xcf, 0x43, 0xd5, 0x03, 0x00, 0xa1, 0x62, 0x73, 0xf0, 0xc8, 0x1c,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x6c, 0xa2, 0xde, 0x1e, 0x02, 0x38, 0x25, 0x1e, 0xfd, 0x1e, + 0xdc, 0x27, 0x5f, 0x25, 0x7d, 0x24, 0x83, 0x99, 0x43, 0x74, 0xf3, 0xa5, 0x8d, 0xc1, 0x01, 0x1a, + 0xca, 0xb8, 0x87, 0x26, 0x12, 0x5c, 0x9d, 0xee, 0x1d, 0xa0, 0x6e, 0xe6, 0x5e, 0x97, 0x7f, 0xbc, + 0x7d, 0xce, 0x19, 0x5f, 0xee, 0x0d, 0xca, 0x4a, 0x74, 0x9b, 0x08, 0x35, 0x83, 0xed, 0xee, 0x3d, + 0xbb, 0xec, 0x18, 0xcf, 0x2f, 0x3b, 0xc6, 0xdf, 0x97, 0x1d, 0xe3, 0xc7, 0xab, 0x4e, 0xe9, 0xf9, + 0x55, 0xa7, 0xf4, 0xe7, 0x55, 0xa7, 0xf4, 0xf5, 0x07, 0x53, 0x2a, 0x67, 0xd1, 0xd8, 0x76, 0x98, + 0x3f, 0x28, 0x78, 0x4a, 0x5e, 0xc4, 0x8f, 0xc9, 0x79, 0x08, 0x62, 0x5c, 0xd3, 0xaf, 0xbd, 0x8f, + 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xa2, 0x79, 0xe5, 0x92, 0x73, 0x0a, 0x00, 0x00, } func (m *Valset) Marshal() (dAtA []byte, err error) { @@ -1312,6 +1321,11 @@ func (m *CompassHandover) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Id != 0 { + i = encodeVarintTurnstone(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x18 + } if m.Deadline != 0 { i = encodeVarintTurnstone(dAtA, i, uint64(m.Deadline)) i-- @@ -1891,6 +1905,9 @@ func (m *CompassHandover) Size() (n int) { if m.Deadline != 0 { n += 1 + sovTurnstone(uint64(m.Deadline)) } + if m.Id != 0 { + n += 1 + sovTurnstone(uint64(m.Id)) + } return n } @@ -2964,6 +2981,25 @@ func (m *CompassHandover) Unmarshal(dAtA []byte) error { break } } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTurnstone + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTurnstone(dAtA[iNdEx:]) From ba89e962a7e7b8494a952f7eeda2b9b07ac00c53 Mon Sep 17 00:00:00 2001 From: Christian Lohr Date: Thu, 29 Aug 2024 15:37:34 +0200 Subject: [PATCH 5/8] fix: attestation ABI packing --- x/evm/types/eth_txable.go | 49 +++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/x/evm/types/eth_txable.go b/x/evm/types/eth_txable.go index 83b3ab72..72b31633 100644 --- a/x/evm/types/eth_txable.go +++ b/x/evm/types/eth_txable.go @@ -3,6 +3,7 @@ package types import ( "bytes" "context" + "encoding/hex" "errors" "math/big" "strings" @@ -149,7 +150,7 @@ func (m *CompassHandover) VerifyAgainstTX( WithFields("tx_hash", tx.Hash().Hex(), "valset_id", valset.ValsetID) // TODO: Remove - logger.WithFields("tx-data", tx.Data()).Info("DEBUGTEST") + logger.WithFields("tx-data", hex.EncodeToString(tx.Data())).Info("DEBUGTEST") logger.Debug("CompassHandover VerifyAgainstTX") @@ -165,29 +166,33 @@ func (m *CompassHandover) VerifyAgainstTX( return err } - // compass_update_batch((address,bytes)[],uint256,address,uint256) - m.GetForwardCallArgs() - args := []any{ - slice.Map(m.GetForwardCallArgs(), func(arg CompassHandover_ForwardCallArgs) CompassLogicCallArgs { - return CompassLogicCallArgs{ - common.HexToAddress(arg.GetHexContractAddress()), - arg.GetPayload(), - } - }), - big.NewInt(m.GetDeadline()), - common.HexToAddress(relayer), - big.NewInt(0).SetUint64(msg.GetGasEstimate()), - } + // Since some validators might have added their signature to the message + // after a pigeon start relaying it, we iteratively remove the end signature + // until we get a match, or there are no more signatures. + for i := len(msg.GetSignData()); i > 0; i-- { + args := []any{ + BuildCompassConsensus(valset, msg.GetSignData()[0:i]), + slice.Map(m.GetForwardCallArgs(), func(arg CompassHandover_ForwardCallArgs) CompassLogicCallArgs { + return CompassLogicCallArgs{ + common.HexToAddress(arg.GetHexContractAddress()), + arg.GetPayload(), + } + }), + big.NewInt(m.GetDeadline()), + common.HexToAddress(relayer), + big.NewInt(0).SetUint64(msg.GetGasEstimate()), + } - input, err := contractABI.Pack("compass_update_batch", args...) - if err != nil { - logger.WithError(err).Warn("CompassHandover VerifyAgainstTX failed to pack ABI") - return err - } + input, err := contractABI.Pack("compass_update_batch", args...) + if err != nil { + logger.WithError(err).Warn("CompassHandover VerifyAgainstTX failed to pack ABI") + return err + } - if bytes.Equal(tx.Data(), input) { - logger.Debug("CompassHandover VerifyAgainstTX success") - return nil + if bytes.Equal(tx.Data(), input) { + logger.Debug("CompassHandover VerifyAgainstTX success") + return nil + } } logger.Warn("CompassHandover VerifyAgainstTX failed") From 59feef535487e14c5a7c354de5ceddbf1eb97745 Mon Sep 17 00:00:00 2001 From: Christian Lohr Date: Thu, 29 Aug 2024 15:49:57 +0200 Subject: [PATCH 6/8] fix: ABI order --- x/evm/types/eth_txable.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/x/evm/types/eth_txable.go b/x/evm/types/eth_txable.go index 72b31633..86815fbe 100644 --- a/x/evm/types/eth_txable.go +++ b/x/evm/types/eth_txable.go @@ -166,21 +166,23 @@ func (m *CompassHandover) VerifyAgainstTX( return err } + forwardArgs := slice.Map(m.GetForwardCallArgs(), func(arg CompassHandover_ForwardCallArgs) CompassLogicCallArgs { + return CompassLogicCallArgs{ + common.HexToAddress(arg.GetHexContractAddress()), + arg.GetPayload(), + } + }) + // Since some validators might have added their signature to the message // after a pigeon start relaying it, we iteratively remove the end signature // until we get a match, or there are no more signatures. for i := len(msg.GetSignData()); i > 0; i-- { args := []any{ BuildCompassConsensus(valset, msg.GetSignData()[0:i]), - slice.Map(m.GetForwardCallArgs(), func(arg CompassHandover_ForwardCallArgs) CompassLogicCallArgs { - return CompassLogicCallArgs{ - common.HexToAddress(arg.GetHexContractAddress()), - arg.GetPayload(), - } - }), - big.NewInt(m.GetDeadline()), - common.HexToAddress(relayer), + forwardArgs, + new(big.Int).SetInt64(m.GetDeadline()), big.NewInt(0).SetUint64(msg.GetGasEstimate()), + common.HexToAddress(relayer), } input, err := contractABI.Pack("compass_update_batch", args...) From df8303f891b3bb886d4d14926af3214adc98a76b Mon Sep 17 00:00:00 2001 From: Christian Lohr Date: Thu, 29 Aug 2024 16:04:41 +0200 Subject: [PATCH 7/8] chore: remove debug prints --- x/evm/keeper/attest_test.go | 3 +++ x/evm/keeper/testdata/compass-handover-tx-data.hex | 1 + x/evm/types/eth_txable.go | 4 ---- 3 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 x/evm/keeper/testdata/compass-handover-tx-data.hex diff --git a/x/evm/keeper/attest_test.go b/x/evm/keeper/attest_test.go index 3a59240d..83f14dc5 100644 --- a/x/evm/keeper/attest_test.go +++ b/x/evm/keeper/attest_test.go @@ -49,6 +49,9 @@ var ( valsetTx1 = ethcoretypes.NewTx(ðcoretypes.DynamicFeeTx{ Data: common.FromHex(string(whoops.Must(os.ReadFile("testdata/valset-tx-data.hex")))), }) + handoverTx1 = ethcoretypes.NewTx(ðcoretypes.DynamicFeeTx{ + Data: common.FromHex(string(whoops.Must(os.ReadFile("testdata/cosmos-handover-tx-data.hex")))), + }) ) type record struct { diff --git a/x/evm/keeper/testdata/compass-handover-tx-data.hex b/x/evm/keeper/testdata/compass-handover-tx-data.hex new file mode 100644 index 00000000..58fa8761 --- /dev/null +++ b/x/evm/keeper/testdata/compass-handover-tx-data.hex @@ -0,0 +1 @@ +08d2b3e300000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000066d07a1500000000000000000000000000000000000000000000000000000000002a68ba000000000000000000000000a3d47a fd36f72d72f84b9b44c1d546ccccb2f0be000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003000000000000000000000000ac1e9ffdb8fe9e35d94db97222757fb24c4cd535000000000000000000000000a3d47afd36f72d72f84b9b44c1d546ccccb2f0be000000000000000000000000d1cfaf669dc227d3cb185e71bf10bfa8e54801fe00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000001bc8b38aff70b7ab11187bc9421a87648c28cb82e771e4477bf9ab72b32bf0ed2726701dca41e45b402d614ca543efffc1306108acc6a6c906d7c88170489ba9ce000000000000000000000000000000000000000000000000000000000000001bedd82188846e0513212262bec497bda398e6ca3f60f746c9a1342f04c255c6b9267fa68704d232657632b0373ab7b52d9b68860be53d5493892c6a30865b1263000000000000000000000000000000000000000000000000000000000000001bc67606416d56703cebf3e401cf74a580cc6bc04cc9b936005bff00adf20e58f609076da25d46d8d5b541bfc66d3c6b0275a7cc9702d1fabdcf3e7dcd36ba5cb000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000008bca41542fd0eceb586d89958842c62702a4904a0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002406937c5c000000000000000000000000a90c1c62690533deacecac895e2540b069ce7d1700000000000000000000000000000000000000000000000000000000000000000000000000000000904c6e4c0587bc00f39ec2e18b2c4c6f044244f10000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002406937c5c000000000000000000000000a90c1c62690533deacecac895e2540b069ce7d17000000000000000000000000000000000000000000000000000000000000000000000000000000005d1137401c5acfe0eadb392492517299cdebd8c6000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000246974af69000000000000000000000000a90c1c62690533deacecac895e2540b069ce7d1700000000000000000000000000000000000000000000000000000000 diff --git a/x/evm/types/eth_txable.go b/x/evm/types/eth_txable.go index 86815fbe..946d0d18 100644 --- a/x/evm/types/eth_txable.go +++ b/x/evm/types/eth_txable.go @@ -3,7 +3,6 @@ package types import ( "bytes" "context" - "encoding/hex" "errors" "math/big" "strings" @@ -149,9 +148,6 @@ func (m *CompassHandover) VerifyAgainstTX( logger := liblog.FromSDKLogger(sdk.UnwrapSDKContext(ctx).Logger()). WithFields("tx_hash", tx.Hash().Hex(), "valset_id", valset.ValsetID) - // TODO: Remove - logger.WithFields("tx-data", hex.EncodeToString(tx.Data())).Info("DEBUGTEST") - logger.Debug("CompassHandover VerifyAgainstTX") if valset == nil || compass == nil { From b1927e4ef02c0a6118e593641c62a0f5e2b70ecc Mon Sep 17 00:00:00 2001 From: Christian Lohr Date: Thu, 29 Aug 2024 20:02:40 +0200 Subject: [PATCH 8/8] fix: linting --- x/evm/keeper/attest_test.go | 2 +- x/evm/keeper/attest_upload_smart_contract.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x/evm/keeper/attest_test.go b/x/evm/keeper/attest_test.go index 83f14dc5..8729fa2b 100644 --- a/x/evm/keeper/attest_test.go +++ b/x/evm/keeper/attest_test.go @@ -49,7 +49,7 @@ var ( valsetTx1 = ethcoretypes.NewTx(ðcoretypes.DynamicFeeTx{ Data: common.FromHex(string(whoops.Must(os.ReadFile("testdata/valset-tx-data.hex")))), }) - handoverTx1 = ethcoretypes.NewTx(ðcoretypes.DynamicFeeTx{ + _ = ethcoretypes.NewTx(ðcoretypes.DynamicFeeTx{ Data: common.FromHex(string(whoops.Must(os.ReadFile("testdata/cosmos-handover-tx-data.hex")))), }) ) diff --git a/x/evm/keeper/attest_upload_smart_contract.go b/x/evm/keeper/attest_upload_smart_contract.go index edaa4448..76095658 100644 --- a/x/evm/keeper/attest_upload_smart_contract.go +++ b/x/evm/keeper/attest_upload_smart_contract.go @@ -125,7 +125,7 @@ func (a *uploadSmartContractAttester) attest(ctx sdk.Context, evidence *types.Tx return err } - // Since this is the intial deployment, we need to set the smart contract + // Since this is the initial deployment, we need to set the smart contract // as active and can skip the handover process. return a.k.SetSmartContractAsActive(ctx, smartContractID, a.chainReferenceID) }