From 2b40405cecd5ef6c4126b40c38d15d802c394ad2 Mon Sep 17 00:00:00 2001 From: Vladyslav Budichenko Date: Tue, 5 Nov 2024 14:38:11 -0500 Subject: [PATCH] wip: add cdp signers --- ethereum/eip712/eip712.go | 26 -------------------------- rpc/backend/call_tx.go | 1 + rpc/namespaces/ethereum/eth/api.go | 2 ++ x/evm/genesis.go | 1 + x/evm/types/genesis.go | 2 ++ x/evm/types/msg.go | 25 ------------------------- 6 files changed, 6 insertions(+), 51 deletions(-) diff --git a/ethereum/eip712/eip712.go b/ethereum/eip712/eip712.go index 9230e9e6d9..cedf37a03b 100644 --- a/ethereum/eip712/eip712.go +++ b/ethereum/eip712/eip712.go @@ -65,27 +65,15 @@ func ConstructUntypedEIP712Data( panic(err) } - fmt.Println("ConstructUntypedEIP712Data inInterface", inInterface) - - for _, msg := range msgs { - bz := legacytx.RegressionTestingAminoCodec.MustMarshalJSON(msg) - fmt.Println("ConstructUntypedEIP712Data bz for msg: ", msg) - fmt.Println("ConstructUntypedEIP712Data bz for msg: ", bz) - fmt.Println("ConstructUntypedEIP712Data bz for msg: ", sdk.MustSortJSON(bz)) - } - // remove msgs from the sign doc since we will be adding them as separate fields delete(inInterface, "msgs") // Add messages as separate fields for i := 0; i < len(msgs); i++ { - fmt.Println("ConstructUntypedEIP712Data msg", msgs[i]) msg := msgs[i] bz := legacytx.RegressionTestingAminoCodec.MustMarshalJSON(msg) - fmt.Println("ConstructUntypedEIP712Data bz", bz) msgBytes := sdk.MustSortJSON(bz) - fmt.Println("ConstructUntypedEIP712Data msgBytes", json.RawMessage(msgBytes)) //legacyMsg, ok := msg.(legacytx.LegacyMsg) //if !ok { @@ -185,32 +173,18 @@ func EncodeData(typedData apitypes.TypedData, primaryType string, data map[strin // ComputeTypedDataHash computes keccak hash of typed data for signing. func ComputeTypedDataHash(typedData apitypes.TypedData) ([]byte, error) { - fmt.Println("ComputeTypedDataHash", typedData) domainSeparator, err := typedData.HashStruct("EIP712Domain", typedData.Domain.Map()) if err != nil { err = errorsmod.Wrap(err, "failed to pack and hash typedData EIP712Domain") return nil, err } - fmt.Println("domainSeparator", domainSeparator) - fmt.Println("typedData.PrimaryType", typedData.PrimaryType) - fmt.Println("typedData.Message", typedData.Message) - - fmt.Println("before encoding") - - //encodedData, err := typedData.EncodeData(typedData.PrimaryType, typedData.Message, 1) - encodedData, err := EncodeData(typedData, typedData.PrimaryType, typedData.Message, 1) - fmt.Println("encodedData", encodedData) - fmt.Println("err", err) - typedDataHash, err := typedData.HashStruct(typedData.PrimaryType, typedData.Message) if err != nil { err = errorsmod.Wrap(err, "failed to pack and hash typedData primary type") return nil, err } - fmt.Println("typedDataHash", typedDataHash) - rawData := []byte(fmt.Sprintf("\x19\x01%s%s", string(domainSeparator), string(typedDataHash))) return crypto.Keccak256(rawData), nil } diff --git a/rpc/backend/call_tx.go b/rpc/backend/call_tx.go index 7967d06fe2..0dcae6e942 100644 --- a/rpc/backend/call_tx.go +++ b/rpc/backend/call_tx.go @@ -397,6 +397,7 @@ func (b *Backend) DoCall( // GasPrice returns the current gas price based on Ethermint's gas price oracle. func (b *Backend) GasPrice() (*hexutil.Big, error) { + fmt.Println("Backend GasPrice") var ( result *big.Int err error diff --git a/rpc/namespaces/ethereum/eth/api.go b/rpc/namespaces/ethereum/eth/api.go index 4d850af7f5..09abed2922 100644 --- a/rpc/namespaces/ethereum/eth/api.go +++ b/rpc/namespaces/ethereum/eth/api.go @@ -17,6 +17,7 @@ package eth import ( "context" + "fmt" "github.com/ethereum/go-ethereum/signer/core/apitypes" @@ -313,6 +314,7 @@ func (e *PublicAPI) ProtocolVersion() hexutil.Uint { // GasPrice returns the current gas price based on Ethermint's gas price oracle. func (e *PublicAPI) GasPrice() (*hexutil.Big, error) { + fmt.Println("GasPrice eth_gasPrice") e.logger.Debug("eth_gasPrice") return e.backend.GasPrice() } diff --git a/x/evm/genesis.go b/x/evm/genesis.go index a78df30e5c..3a06aef77f 100644 --- a/x/evm/genesis.go +++ b/x/evm/genesis.go @@ -77,6 +77,7 @@ func InitGenesis( } isEnabledPrecompile := make(map[string]struct{}) + fmt.Println("eth evm genesis InitGenesis gs.Params.EnabledPrecompiles", data.Params.EnabledPrecompiles) for _, ep := range data.Params.EnabledPrecompiles { isEnabledPrecompile[ep] = struct{}{} } diff --git a/x/evm/types/genesis.go b/x/evm/types/genesis.go index 3906cf0139..f1bc0b7388 100644 --- a/x/evm/types/genesis.go +++ b/x/evm/types/genesis.go @@ -76,6 +76,8 @@ func (gs GenesisState) Validate() error { return fmt.Errorf("invalid params: %w", err) } + fmt.Println("eth types genesis Validate gs.Params.EnabledPrecompiles", gs.Params.EnabledPrecompiles) + for _, ep := range gs.Params.EnabledPrecompiles { if _, ok := seenAccounts[ep]; !ok { return fmt.Errorf("enabled precompile %s must have a matching genesis account", ep) diff --git a/x/evm/types/msg.go b/x/evm/types/msg.go index 2ca8a84765..1b64baac5f 100644 --- a/x/evm/types/msg.go +++ b/x/evm/types/msg.go @@ -277,31 +277,6 @@ func (msg *MsgEthereumTx) GetSigners() ([][]byte, error) { return [][]byte{signer}, nil } -// func (pc ProtoCodec) GetMsgAnySigners(msg *types.Any) ([][]byte, proto.Message, error) { -// msgv2, err := anyutil.Unpack(&anypb.Any{ -// TypeUrl: msg.TypeUrl, -// Value: msg.Value, -// }, pc.interfaceRegistry, nil) -// if err != nil { -// return nil, nil, err -// } -// -// signers, err := pc.interfaceRegistry.SigningContext().GetSigners(msgv2) -// return signers, msgv2, err -//} - -//func (pc *ProtoCodec) GetMsgV1Signers(msg gogoproto.Message) ([][]byte, proto.Message, error) { -// if msgV2, ok := msg.(proto.Message); ok { -// signers, err := pc.interfaceRegistry.SigningContext().GetSigners(msgV2) -// return signers, msgV2, err -// } -// a, err := types.NewAnyWithValue(msg) -// if err != nil { -// return nil, nil, err -// } -// return pc.GetMsgAnySigners(a) -//} - // TODO(boodyvo): implement this method // func(proto.Message) ([][]byte, error) func GetSigners(msg protov2.Message) ([][]byte, error) {