Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy "hello world" contract to Evmos #11

Closed
1 task
jbowen93 opened this issue Jan 31, 2022 · 9 comments
Closed
1 task

Deploy "hello world" contract to Evmos #11

jbowen93 opened this issue Jan 31, 2022 · 9 comments
Assignees

Comments

@jbowen93
Copy link

jbowen93 commented Jan 31, 2022

The first goal for Evmos is to be able to accept an extremely simple EVM contract. This will provide some validation that the networking and storage of the various components is working as expected.

A "hello world" style contract that writes and reads from state should be sufficient

contract Storage {

   uint256 number;

   /**
    * @dev Store value in variable
    * @param num value to store
    */
   function store(uint256 num) public {
       number = num;
   }

   /**
    * @dev Return value 
    * @return value of 'number'
    */
   function retrieve() public view returns (uint256){
       return number;
   }
}
@jbowen93 jbowen93 self-assigned this Jan 31, 2022
@jbowen93 jbowen93 moved this to TODO in Celestia Node Jan 31, 2022
@jbowen93
Copy link
Author

jbowen93 commented Jan 31, 2022

Current state is that simple peer-to-peer transactions work. However, when you attempt to retrieve the transaction with something like foundry's cast tx $tx_hash we hit this line in ethermint.

@jbowen93
Copy link
Author

The first issue with retrieving the transaction is that the transaction is submitted with the following tendermint Query.Conditions

conditions: []query.Condition{query.Condition{CompositeKey:"ethereum_tx.ethereumTxHash", Op:0x4, Operand:"0x23375d55471fec45a7dfdf5b2152f083bd665a39cd80ca86c33b083053838251"}}

where the CompositeKey uses Ethermint's evmtypes.TypeMsgEthereumTx and evmtypes.AttributeKeyEthereumTxHash but the Optimint lookForHash function was checking for Tendermint's types.TxHashKey.

I resolved this manually which got the GetTransactionByHash call to reach Optimint's store.BadgetKv.Get call. The internal call to txn.Get(key) seems to be panicking:

t=2022-01-31T23:19:32+0000 lvl=eror msg="RPC method eth_getTransactionByHash crashed: key not found\ngoroutine 924 [running]:\ngithub.com/ethereum/go-ethereum/rpc.(*callback).call.func1()\n\tgithub.com/ethereum/[email protected]/rpc/service.go:200 +0x89\npanic({0x1f17880, 0xc0005931f0})\n\truntime/panic.go:1038 +0x215\ngithub.com/celestiaorg/optimint/state/txindex/kv.(*TxIndex).Get(0xc00013cd30, {0xc008d6cc80, 0x236a191, 0x40})\n\tgithub.com/celestiaorg/[email protected]/state/txindex/kv/kv.go:52 +0x2a8\ngithub.com/celestiaorg/optimint/state/txindex/kv.(*TxIndex).Search(0x2920ac0, {0x296f568, 0xc000054050}, 0xc0097c2e58)\n\tgithub.com/celestiaorg/[email protected]/state/txindex/kv/kv.go:205 +0x44c\ngithub.com/celestiaorg/optimint/rpc/client.(*Client).TxSearch(0xc001b0edb0, {0x296f568, 0xc000054050}, {0xc001b59020, 0x5f}, 0xfe, 0xc00937cc80, 0x0, {0x0, 0x0})\n\tgithub.com/celestiaorg/[email protected]/rpc/client/client.go:422 +0x21d\ngithub.com/tharsis/ethermint/rpc/ethereum/backend.(*EVMBackend).GetTxByEthHash(0xc00880f000, {0x23, 0x37, 0x5d, 0x55, 0x47, 0x1f, 0xec, 0x45, 0xa7, ...})\n\tgithub.com/tharsis/[email protected]/rpc/ethereum/backend/backend.go:740 +0x1e2\ngithub.com/tharsis/ethermint/rpc/ethereum/backend.(*EVMBackend).GetTransactionByHash(0xc00880f000, {0x23, 0x37, 0x5d, 0x55, 0x47, 0x1f, 0xec, 0x45, 0xa7, ...})\n\tgithub.com/tharsis/[email protected]/rpc/ethereum/backend/backend.go:657 +0x11e\ngithub.com/tharsis/ethermint/rpc/ethereum/namespaces/eth.(*PublicAPI).GetTransactionByHash(0xc0087352c0, {0x23, 0x37, 0x5d, 0x55, 0x47, 0x1f, 0xec, 0x45, 0xa7, ...})\n\tgithub.com/tharsis/[email protected]/rpc/ethereum/namespaces/eth/api.go:658 +0x105\nreflect.Value.call({0xc0088b9d40, 0xc000011a28, 0x7f9a190105b8}, {0x2244108, 0x4}, {0xc0086fe0a0, 0x2, 0xc008c9ac80})\n\treflect/value.go:556 +0x845\nreflect.Value.Call({0xc0088b9d40, 0xc000011a28, 0x5429c8}, {0xc0086fe0a0, 0x2, 0x3})\n\treflect/value.go:339 +0xc5\ngithub.com/ethereum/go-ethereum/rpc.(*callback).call(0xc0088b9da0, {0x296f530, 0xc0013c1140}, {0xc000053470, 0x18}, {0xc0097c2e10, 0x1, 0x500917})\n\tgithub.com/ethereum/[email protected]/rpc/service.go:206 +0x3f0\ngithub.com/ethereum/go-ethereum/rpc.(*handler).runMethod(0xc00954b360, {0x296f530, 0xc0013c1140}, 0xc008d745b0, 0x23, {0xc0097c2e10, 0x0, 0x203001})\n\tgithub.com/ethereum/[email protected]/rpc/handler.go:389 +0x45\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleCall(0xc008711a70, 0xc007cd5d70, 0xc008d745b0)\n\tgithub.com/ethereum/[email protected]/rpc/handler.go:337 +0x239\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleCallMsg(0xc008711a70, 0xc000600000, 0xc008d745b0)\n\tgithub.com/ethereum/[email protected]/rpc/handler.go:298 +0xd1\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleMsg.func1(0xc007cd5d70)\n\tgithub.com/ethereum/[email protected]/rpc/handler.go:139 +0x35\ngithub.com/ethereum/go-ethereum/rpc.(*handler).startCallProc.func1()\n\tgithub.com/ethereum/[email protected]/rpc/handler.go:226 +0xc5\ncreated by github.com/ethereum/go-ethereum/rpc.(*handler).startCallProc\n\tgithub.com/ethereum/[email protected]/rpc/handler.go:222 +0x92\n"

@jbowen93
Copy link
Author

jbowen93 commented Feb 1, 2022

There is an issue when making a Type Assertion on the msg in the Block to an Ethermint evmtypes.MsgEthereumTx here. This failing type assertion gives us false for ok and nil for ethMsg.

The type assertion is from sdk.MsgSend to evmtypes.MsgEthereumTx where
sdk => github.com/cosmos/cosmos-sdk/types
evmtypes => github.com/tharsis/ethermint/x/evm/types

@jbowen93 jbowen93 moved this from TODO to In Progress in Celestia Node Feb 1, 2022
@jbowen93
Copy link
Author

https://gist.github.com/jbowen93/6e811954cac6aa634e123dfd12ab6321

@jbowen93
Copy link
Author

Refer to celestiaorg/cosmos-sdk#66 and celestiaorg/ethermint#1 as initial steps to get "tendermint compatibility"

@jbowen93
Copy link
Author

jbowen93 commented Feb 28, 2022

To get past errors returned due to lack of support for Validators:

8:27PM INF ABCIQuery data=0A3365766D6F7376616C636F6E73313764666C73733877337735666C346B6664767039743977383630726A3735753978676B743932 module=events path=/ethermint.evm.v1.Query/ValidatorAccount result={"code":111222,"codespace":"undefined","height":"0","index":"0","info":"","key":null,"log":"panic message redacted to hide potentially sensitive system info: panic","proofOps":null,"value":null}

I've commented out the relevant section. See jbowen93/ethermint@76a1739

@jbowen93
Copy link
Author

By manually setting the gas here: jbowen93/ethers-rs@e79f4b6

I'm able to get a successful contract deployment.

method: "eth_getTransactionReceipt"
params: "[\"0xc45f96457d1619effb3217c38586ff14f88f6bc68cc3b8baaffb8813c2ff9ca7\"]"
Deployer: 0x0a62b19c95cc8f6099ecac4bc8009ff8f94f1175
Deployed to: 0x72f92b82575c8032314f96c75698ade48f1f0d85
Transaction hash: 0xc45f96457d1619effb3217c38586ff14f88f6bc68cc3b8baaffb8813c2ff9ca7

@jbowen93
Copy link
Author

The contract (shown above) doesn't seem to be actually storing data on the store call.

Logs from cast call $ADDR "retrieve()"

10:45PM INF ABCIQuery data=0AFD017B2266726F6D223A22307830303030303030303030303030303030303030303030303030303030303030303030303030303030222C22746F223A22307837326639326238323537356338303332333134663936633735363938616465343866316630643835222C22676173223A6E756C6C2C226761735072696365223A6E756C6C2C226D6178466565506572476173223A6E756C6C2C226D61785072696F72697479466565506572476173223A6E756C6C2C2276616C7565223A6E756C6C2C226E6F6E6365223A6E756C6C2C2264617461223A2230783265363463656331222C22696E707574223A6E756C6C2C226163636573734C697374223A5B5D7D10C0F0F50B module=events path=/ethermint.evm.v1.Query/EthCall result={"code":0,"codespace":"","height":"248","index":"0","info":"","key":null,"log":"","proofOps":null,"value":"CkIweDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAaIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKI62AQ=="}

Logs from cast call $ADDR "store(uint256)" 1

10:46PM INF ABCIQuery data=0ABD027B2266726F6D223A22307830303030303030303030303030303030303030303030303030303030303030303030303030303030222C22746F223A22307837326639326238323537356338303332333134663936633735363938616465343866316630643835222C22676173223A6E756C6C2C226761735072696365223A6E756C6C2C226D6178466565506572476173223A6E756C6C2C226D61785072696F72697479466565506572476173223A6E756C6C2C2276616C7565223A6E756C6C2C226E6F6E6365223A6E756C6C2C2264617461223A223078363035373336316430303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303634222C22696E707574223A6E756C6C2C226163636573734C697374223A5B5D7D10C0F0F50B module=events path=/ethermint.evm.v1.Query/EthCall result={"code":0,"codespace":"","height":"250","index":"0","info":"","key":null,"log":"","proofOps":null,"value":"CkIweDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAo/NMC"}

@jbowen93
Copy link
Author

jbowen93 commented Mar 4, 2022

Closing this because contract deployment works.

Contract calls also work, I just needed to use cast send not cast call. See #22

@jbowen93 jbowen93 closed this as completed Mar 4, 2022
Repository owner moved this from In Progress to Done in Celestia Node Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

No branches or pull requests

1 participant