From dd5b01c46664b2d3ef67294dd0745c17363553e3 Mon Sep 17 00:00:00 2001 From: Mateusz Morusiewicz <11313015+Ruteri@users.noreply.github.com> Date: Tue, 7 Nov 2023 17:31:54 +0100 Subject: [PATCH] Removes kettle address from suave transaction (#98) --- core/types/confidential.go | 4 +--- core/types/confidential_test.go | 1 - core/types/transaction_marshalling.go | 8 -------- core/types/transaction_signing.go | 5 ++--- internal/ethapi/api.go | 4 +--- internal/ethapi/transaction_args.go | 1 - suave/cstore/engine.go | 2 +- 7 files changed, 5 insertions(+), 20 deletions(-) diff --git a/core/types/confidential.go b/core/types/confidential.go index b88d67497..aeb802298 100644 --- a/core/types/confidential.go +++ b/core/types/confidential.go @@ -132,11 +132,10 @@ func (tx *ConfidentialComputeRequest) setSignatureValues(chainID, v, r, s *big.I } type SuaveTransaction struct { - KettleAddress common.Address `json:"kettleAddress" gencodec:"required"` ConfidentialComputeRequest ConfidentialComputeRecord `json:"confidentialComputeRequest" gencodec:"required"` ConfidentialComputeResult []byte `json:"confidentialComputeResult" gencodec:"required"` - // KettleAddress's signature + // request KettleAddress's signature ChainID *big.Int V *big.Int R *big.Int @@ -146,7 +145,6 @@ type SuaveTransaction struct { // copy creates a deep copy of the transaction data and initializes all fields. func (tx *SuaveTransaction) copy() TxData { cpy := &SuaveTransaction{ - KettleAddress: tx.KettleAddress, ConfidentialComputeRequest: tx.ConfidentialComputeRequest, ConfidentialComputeResult: common.CopyBytes(tx.ConfidentialComputeResult), ChainID: new(big.Int), diff --git a/core/types/confidential_test.go b/core/types/confidential_test.go index 59f8ecbff..4d6471058 100644 --- a/core/types/confidential_test.go +++ b/core/types/confidential_test.go @@ -88,7 +88,6 @@ func TestSuaveTx(t *testing.T) { require.True(t, ok) unsignedTx := NewTx(&SuaveTransaction{ - KettleAddress: crypto.PubkeyToAddress(testKey.PublicKey), ConfidentialComputeRequest: *signedInnerCCR, }) signedTx, err := SignTx(unsignedTx, signer, testKey) diff --git a/core/types/transaction_marshalling.go b/core/types/transaction_marshalling.go index c21dfe454..09d8b4aff 100644 --- a/core/types/transaction_marshalling.go +++ b/core/types/transaction_marshalling.go @@ -148,8 +148,6 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) { enc.S = (*hexutil.Big)(itx.S) case *SuaveTransaction: - enc.KettleAddress = &itx.KettleAddress - wrapped, err := NewTx(&itx.ConfidentialComputeRequest).MarshalJSON() if err != nil { return nil, err @@ -523,12 +521,6 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error { var itx SuaveTransaction inner = &itx - if dec.KettleAddress == nil { - return errors.New("missing required field 'kettleAddress' in transaction") - } - - itx.KettleAddress = *dec.KettleAddress - if dec.Wrapped == nil { return errors.New("missing required field 'wrapped' in transaction") } diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index f0b7340b9..85214a68c 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -285,8 +285,8 @@ func (s suaveSigner) Sender(tx *Transaction) (common.Address, error) { return common.Address{}, err } - if recovered != txdata.KettleAddress { - return common.Address{}, fmt.Errorf("compute request %s signed by incorrect execution node %s, expected %s", tx.Hash().Hex(), recovered.Hex(), txdata.KettleAddress.Hex()) + if recovered != ccr.KettleAddress { + return common.Address{}, fmt.Errorf("compute request %s signed by incorrect execution node %s, expected %s", tx.Hash().Hex(), recovered.Hex(), ccr.KettleAddress.Hex()) } case *ConfidentialComputeRequest: ccr = &txdata.ConfidentialComputeRecord @@ -354,7 +354,6 @@ func (s suaveSigner) Hash(tx *Transaction) common.Hash { return prefixedRlpHash( tx.Type(), []interface{}{ - txdata.KettleAddress, s.Hash(NewTx(&txdata.ConfidentialComputeRequest)), txdata.ConfidentialComputeResult, }) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 2c50babc3..8d91df548 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1468,8 +1468,6 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber return nil } - result.KettleAddress = &inner.KettleAddress - // TODO: should be rpc marshaled rrBytes, err := types.NewTx(&inner.ConfidentialComputeRequest).MarshalJSON() if err != nil { @@ -2005,7 +2003,7 @@ func runMEVM(ctx context.Context, b Backend, state *state.StateDB, header *types computeResult = result.ReturnData // Or should it be nil maybe in this case? } - suaveResultTxData := &types.SuaveTransaction{KettleAddress: confidentialRequest.KettleAddress, ConfidentialComputeRequest: confidentialRequest.ConfidentialComputeRecord, ConfidentialComputeResult: computeResult} + suaveResultTxData := &types.SuaveTransaction{ConfidentialComputeRequest: confidentialRequest.ConfidentialComputeRecord, ConfidentialComputeResult: computeResult} signed, err := wallet.SignTx(account, types.NewTx(suaveResultTxData), tx.ChainId()) if err != nil { diff --git a/internal/ethapi/transaction_args.go b/internal/ethapi/transaction_args.go index d7e35b2a2..979302a3e 100644 --- a/internal/ethapi/transaction_args.go +++ b/internal/ethapi/transaction_args.go @@ -338,7 +338,6 @@ func (args *TransactionArgs) toTransaction() *types.Transaction { } data = &types.SuaveTransaction{ - KettleAddress: kettleAddress, ChainID: (*big.Int)(args.ChainID), ConfidentialComputeRequest: ccr, ConfidentialComputeResult: confResult, diff --git a/suave/cstore/engine.go b/suave/cstore/engine.go index 1f3760ab1..6b9818520 100644 --- a/suave/cstore/engine.go +++ b/suave/cstore/engine.go @@ -442,7 +442,7 @@ func (MockChainSigner) Sender(tx *types.Transaction) (common.Address, error) { func KettleAddressFromTransaction(tx *types.Transaction) (common.Address, error) { innerExecutedTx, ok := types.CastTxInner[*types.SuaveTransaction](tx) if ok { - return innerExecutedTx.KettleAddress, nil + return innerExecutedTx.ConfidentialComputeRequest.KettleAddress, nil } innerRequestTx, ok := types.CastTxInner[*types.ConfidentialComputeRequest](tx)