Skip to content

Commit

Permalink
Removes kettle address from suave transaction (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruteri authored Nov 7, 2023
1 parent ac0ef28 commit dd5b01c
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 20 deletions.
4 changes: 1 addition & 3 deletions core/types/confidential.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand Down
1 change: 0 additions & 1 deletion core/types/confidential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 0 additions & 8 deletions core/types/transaction_marshalling.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
}
Expand Down
5 changes: 2 additions & 3 deletions core/types/transaction_signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
})
Expand Down
4 changes: 1 addition & 3 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion internal/ethapi/transaction_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ func (args *TransactionArgs) toTransaction() *types.Transaction {
}

data = &types.SuaveTransaction{
KettleAddress: kettleAddress,
ChainID: (*big.Int)(args.ChainID),
ConfidentialComputeRequest: ccr,
ConfidentialComputeResult: confResult,
Expand Down
2 changes: 1 addition & 1 deletion suave/cstore/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit dd5b01c

Please sign in to comment.