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

Renames ExecutioNode to KettleAddress #97

Merged
merged 5 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Let’s take a look at how you can request confidential computation through an e
```go
allowedPeekers := []common.Address{newBlockBidPeeker, newBundleBidPeeker, buildEthBlockPeeker} // express which contracts should have access to your data (by their addresses)
confidentialComputeRecord := &types.ConfidentialComputeRecord{
ExecutionNode: "0x4E2B0c0e428AE1CDE26d5BcF17Ba83f447068E5B",
KettleAddress: "0x4E2B0c0e428AE1CDE26d5BcF17Ba83f447068E5B",
Nonce: suaveAccNonce,
To: &newBundleBidAddress,
Value: nil,
Expand Down Expand Up @@ -189,7 +189,7 @@ We introduce a few new transaction types.

```go
type ConfidentialComputeRecord struct {
ExecutionNode common.Address
KettleAddress common.Address
ConfidentialInputsHash common.Hash

// LegacyTx fields
Expand Down Expand Up @@ -217,11 +217,11 @@ We introduce a few new transaction types.

* `SuaveTransaction`

A specialized transaction type that encapsulates the result of a confidential computation request. It includes the `ConfidentialComputeRequest`, signed by the user, which ensures that the result comes from the expected computor, as the `SuaveTransaction`'s signer must match the `ExecutionNode`.
A specialized transaction type that encapsulates the result of a confidential computation request. It includes the `ConfidentialComputeRequest`, signed by the user, which ensures that the result comes from the expected computor, as the `SuaveTransaction`'s signer must match the `KettleAddress`.

```go
type SuaveTransaction struct {
ExecutionNode common.Address
KettleAddress common.Address
ConfidentialComputeRequest ConfidentialComputeRecord
ConfidentialComputeResult []byte
/* Execution node's signature fields */
Expand Down Expand Up @@ -374,8 +374,8 @@ The mempool operates on the underlying Confidential Store, thereby maintaining t

### Changes to RPC methods

1. New `IsConfidential` and `ExecutionNode` fields are added to TransactionArgs, used in `eth_sendTransaction` and `eth_call` methods.
If `IsConfidential` is set to true, the call will be performed as a confidential call, using the `ExecutionNode` passed in for constructing `ConfidentialComputeRequest`.
1. New `IsConfidential` and `KettleAddress` fields are added to TransactionArgs, used in `eth_sendTransaction` and `eth_call` methods.
If `IsConfidential` is set to true, the call will be performed as a confidential call, using the `KettleAddress` passed in for constructing `ConfidentialComputeRequest`.
`SuaveTransaction` is the result of `eth_sendTransaction`!

2. New optional argument - `confidential_data` is added to `eth_sendRawTransaction`, `eth_sendTransaction` and `eth_call` methods.
Expand Down
10 changes: 5 additions & 5 deletions core/types/confidential.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type ConfidentialComputeRecord struct {
Value *big.Int
Data []byte

ExecutionNode common.Address
KettleAddress common.Address
ConfidentialInputsHash common.Hash

ChainID *big.Int
Expand All @@ -28,7 +28,7 @@ func (tx *ConfidentialComputeRecord) copy() TxData {
To: copyAddressPtr(tx.To),
Data: common.CopyBytes(tx.Data),
Gas: tx.Gas,
ExecutionNode: tx.ExecutionNode,
KettleAddress: tx.KettleAddress,
ConfidentialInputsHash: tx.ConfidentialInputsHash,

Value: new(big.Int),
Expand Down Expand Up @@ -132,11 +132,11 @@ func (tx *ConfidentialComputeRequest) setSignatureValues(chainID, v, r, s *big.I
}

type SuaveTransaction struct {
ExecutionNode common.Address `json:"executionNode" gencodec:"required"`
KettleAddress common.Address `json:"kettleAddress" gencodec:"required"`
ConfidentialComputeRequest ConfidentialComputeRecord `json:"confidentialComputeRequest" gencodec:"required"`
ConfidentialComputeResult []byte `json:"confidentialComputeResult" gencodec:"required"`

// ExecutionNode's signature
// KettleAddress's signature
ChainID *big.Int
V *big.Int
R *big.Int
Expand All @@ -146,7 +146,7 @@ type SuaveTransaction struct {
// copy creates a deep copy of the transaction data and initializes all fields.
func (tx *SuaveTransaction) copy() TxData {
cpy := &SuaveTransaction{
ExecutionNode: tx.ExecutionNode,
KettleAddress: tx.KettleAddress,
ConfidentialComputeRequest: tx.ConfidentialComputeRequest,
ConfidentialComputeResult: common.CopyBytes(tx.ConfidentialComputeResult),
ChainID: new(big.Int),
Expand Down
6 changes: 3 additions & 3 deletions core/types/confidential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestCCRequestToRecord(t *testing.T) {
signer := NewSuaveSigner(new(big.Int))
unsignedTx := NewTx(&ConfidentialComputeRequest{
ConfidentialComputeRecord: ConfidentialComputeRecord{
ExecutionNode: crypto.PubkeyToAddress(testKey.PublicKey),
KettleAddress: crypto.PubkeyToAddress(testKey.PublicKey),
},
ConfidentialInputs: []byte{0x46},
})
Expand Down Expand Up @@ -80,15 +80,15 @@ func TestSuaveTx(t *testing.T) {
signer := NewSuaveSigner(new(big.Int))

signedCCR, err := SignTx(NewTx(&ConfidentialComputeRecord{
ExecutionNode: crypto.PubkeyToAddress(testKey.PublicKey),
KettleAddress: crypto.PubkeyToAddress(testKey.PublicKey),
}), signer, testKey)
require.NoError(t, err)

signedInnerCCR, ok := CastTxInner[*ConfidentialComputeRecord](signedCCR)
require.True(t, ok)

unsignedTx := NewTx(&SuaveTransaction{
ExecutionNode: crypto.PubkeyToAddress(testKey.PublicKey),
KettleAddress: crypto.PubkeyToAddress(testKey.PublicKey),
ConfidentialComputeRequest: *signedInnerCCR,
})
signedTx, err := SignTx(unsignedTx, signer, testKey)
Expand Down
26 changes: 13 additions & 13 deletions core/types/transaction_marshalling.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type txJSON struct {
Input *hexutil.Bytes `json:"input"`
AccessList *AccessList `json:"accessList,omitempty"`
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
ExecutionNode *common.Address `json:"executionNode,omitempty"`
KettleAddress *common.Address `json:"kettleAddress,omitempty"`
ConfidentialInputsHash *common.Hash `json:"confidentialInputsHash,omitempty"`
ConfidentialInputs *hexutil.Bytes `json:"confidentialInputs,omitempty"`
Wrapped *json.RawMessage `json:"wrapped,omitempty"`
Expand Down Expand Up @@ -119,7 +119,7 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) {
enc.S = (*hexutil.Big)(itx.S.ToBig())

case *ConfidentialComputeRecord:
enc.ExecutionNode = &itx.ExecutionNode
enc.KettleAddress = &itx.KettleAddress
enc.ConfidentialInputsHash = &itx.ConfidentialInputsHash
enc.Nonce = (*hexutil.Uint64)(&itx.Nonce)
enc.To = tx.To()
Expand All @@ -133,7 +133,7 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) {
enc.S = (*hexutil.Big)(itx.S)

case *ConfidentialComputeRequest:
enc.ExecutionNode = &itx.ExecutionNode
enc.KettleAddress = &itx.KettleAddress
enc.ConfidentialInputs = (*hexutil.Bytes)(&itx.ConfidentialInputs)
enc.ConfidentialInputsHash = &itx.ConfidentialInputsHash
enc.Nonce = (*hexutil.Uint64)(&itx.Nonce)
Expand All @@ -148,7 +148,7 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) {
enc.S = (*hexutil.Big)(itx.S)

case *SuaveTransaction:
enc.ExecutionNode = &itx.ExecutionNode
enc.KettleAddress = &itx.KettleAddress

wrapped, err := NewTx(&itx.ConfidentialComputeRequest).MarshalJSON()
if err != nil {
Expand Down Expand Up @@ -401,10 +401,10 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {
var itx ConfidentialComputeRequest
inner = &itx

if dec.ExecutionNode == nil {
return errors.New("missing required field 'executionNode' in transaction")
if dec.KettleAddress == nil {
return errors.New("missing required field 'kettleAddress' in transaction")
}
itx.ExecutionNode = *dec.ExecutionNode
itx.KettleAddress = *dec.KettleAddress

if dec.ConfidentialInputsHash != nil {
itx.ConfidentialInputsHash = *dec.ConfidentialInputsHash
Expand Down Expand Up @@ -460,10 +460,10 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {
var itx ConfidentialComputeRequest
inner = &itx

if dec.ExecutionNode == nil {
return errors.New("missing required field 'executionNode' in transaction")
if dec.KettleAddress == nil {
return errors.New("missing required field 'kettleAddress' in transaction")
}
itx.ExecutionNode = *dec.ExecutionNode
itx.KettleAddress = *dec.KettleAddress

if dec.ConfidentialInputsHash != nil {
itx.ConfidentialInputsHash = *dec.ConfidentialInputsHash
Expand Down Expand Up @@ -523,11 +523,11 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {
var itx SuaveTransaction
inner = &itx

if dec.ExecutionNode == nil {
return errors.New("missing required field 'executionNode' in transaction")
if dec.KettleAddress == nil {
return errors.New("missing required field 'kettleAddress' in transaction")
}

itx.ExecutionNode = *dec.ExecutionNode
itx.KettleAddress = *dec.KettleAddress

if dec.Wrapped == nil {
return errors.New("missing required field 'wrapped' in transaction")
Expand Down
10 changes: 5 additions & 5 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.ExecutionNode {
return common.Address{}, fmt.Errorf("compute request %s signed by incorrect execution node %s, expected %s", tx.Hash().Hex(), recovered.Hex(), txdata.ExecutionNode.Hex())
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())
}
case *ConfidentialComputeRequest:
ccr = &txdata.ConfidentialComputeRecord
Expand Down Expand Up @@ -354,15 +354,15 @@ func (s suaveSigner) Hash(tx *Transaction) common.Hash {
return prefixedRlpHash(
tx.Type(),
[]interface{}{
txdata.ExecutionNode,
txdata.KettleAddress,
s.Hash(NewTx(&txdata.ConfidentialComputeRequest)),
txdata.ConfidentialComputeResult,
})
case *ConfidentialComputeRequest:
return prefixedRlpHash(
ConfidentialComputeRecordTxType, // Note: this is the same as the Record so that hashes match!
[]interface{}{
txdata.ExecutionNode,
txdata.KettleAddress,
txdata.ConfidentialInputsHash,
tx.Nonce(),
tx.GasPrice(),
Expand All @@ -375,7 +375,7 @@ func (s suaveSigner) Hash(tx *Transaction) common.Hash {
return prefixedRlpHash(
tx.Type(),
[]interface{}{
txdata.ExecutionNode,
txdata.KettleAddress,
txdata.ConfidentialInputsHash,
tx.Nonce(),
tx.GasPrice(),
Expand Down
4 changes: 2 additions & 2 deletions core/vm/contracts_suave_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestSuavePrecompileStub(t *testing.T) {

reqTx := types.NewTx(&types.ConfidentialComputeRequest{
ConfidentialComputeRecord: types.ConfidentialComputeRecord{
ExecutionNode: common.Address{},
KettleAddress: common.Address{},
},
})

Expand Down Expand Up @@ -175,7 +175,7 @@ func newTestBackend(t *testing.T) *suaveRuntime {

reqTx := types.NewTx(&types.ConfidentialComputeRequest{
ConfidentialComputeRecord: types.ConfidentialComputeRecord{
ExecutionNode: common.Address{},
KettleAddress: common.Address{},
},
})

Expand Down
20 changes: 10 additions & 10 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1023,9 +1023,9 @@ func DoCall(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash
}

if args.IsConfidential {
if args.ExecutionNode == nil {
if args.KettleAddress == nil {
acc := b.AccountManager().Accounts()[0]
args.ExecutionNode = &acc
args.KettleAddress = &acc
}

tx := args.ToTransaction()
Expand Down Expand Up @@ -1370,7 +1370,7 @@ type RPCTransaction struct {
Type hexutil.Uint64 `json:"type"`
Accesses *types.AccessList `json:"accessList,omitempty"`
ChainID *hexutil.Big `json:"chainId,omitempty"`
ExecutionNode *common.Address `json:"executionNode,omitempty"`
KettleAddress *common.Address `json:"kettleAddress,omitempty"`
ConfidentialInputsHash *common.Hash `json:"confidentialInputsHash,omitempty"`
ConfidentialInputs *hexutil.Bytes `json:"confidentialInputs,omitempty"`
RequestRecord *json.RawMessage `json:"requestRecord,omitempty"`
Expand Down Expand Up @@ -1437,7 +1437,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
return nil
}

result.ExecutionNode = &inner.ExecutionNode
result.KettleAddress = &inner.KettleAddress

// if a legacy transaction has an EIP-155 chain id, include it explicitly
if id := tx.ChainId(); id.Sign() != 0 {
Expand All @@ -1452,7 +1452,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
return nil
}

result.ExecutionNode = &inner.ExecutionNode
result.KettleAddress = &inner.KettleAddress

// if a legacy transaction has an EIP-155 chain id, include it explicitly
if id := tx.ChainId(); id.Sign() != 0 {
Expand All @@ -1468,7 +1468,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
return nil
}

result.ExecutionNode = &inner.ExecutionNode
result.KettleAddress = &inner.KettleAddress

// TODO: should be rpc marshaled
rrBytes, err := types.NewTx(&inner.ConfidentialComputeRequest).MarshalJSON()
Expand Down Expand Up @@ -1956,7 +1956,7 @@ func runMEVM(ctx context.Context, b Backend, state *state.StateDB, header *types
}

// Look up the wallet containing the requested execution node
account := accounts.Account{Address: confidentialRequest.ExecutionNode}
account := accounts.Account{Address: confidentialRequest.KettleAddress}
wallet, err := b.AccountManager().Find(account)
if err != nil {
return nil, nil, nil, err
Expand Down Expand Up @@ -2005,7 +2005,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{ExecutionNode: confidentialRequest.ExecutionNode, ConfidentialComputeRequest: confidentialRequest.ConfidentialComputeRecord, ConfidentialComputeResult: computeResult}
suaveResultTxData := &types.SuaveTransaction{KettleAddress: confidentialRequest.KettleAddress, ConfidentialComputeRequest: confidentialRequest.ConfidentialComputeRecord, ConfidentialComputeResult: computeResult}

signed, err := wallet.SignTx(account, types.NewTx(suaveResultTxData), tx.ChainId())
if err != nil {
Expand Down Expand Up @@ -2334,7 +2334,7 @@ func toHexSlice(b [][]byte) []string {
return r
}

// ExecutionAddress returns the execution addresseses available in the Kettle.
func (s *TransactionAPI) ExecutionAddress(ctx context.Context) ([]common.Address, error) {
// KettleAddress returns the execution addresseses available in the Kettle.
func (s *TransactionAPI) KettleAddress(ctx context.Context) ([]common.Address, error) {
return s.b.AccountManager().Accounts(), nil
}
14 changes: 7 additions & 7 deletions internal/ethapi/transaction_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type TransactionArgs struct {
MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"`
Value *hexutil.Big `json:"value"`
IsConfidential bool `json:"isConfidential"`
ExecutionNode *common.Address `json:"executionNode"`
KettleAddress *common.Address `json:"kettleAddress"`
ConfidentialInputs *hexutil.Bytes `json:"confidentialInputs"` // TODO: testme
ConfidentialResult *hexutil.Bytes `json:"confidentialResult"` // TODO: testme
Nonce *hexutil.Uint64 `json:"nonce"`
Expand Down Expand Up @@ -286,9 +286,9 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (*
// toTransaction converts the arguments to a transaction.
// This assumes that setDefaults has been called.
func (args *TransactionArgs) toTransaction() *types.Transaction {
var executionNode common.Address
if args.IsConfidential && args.ExecutionNode != nil {
executionNode = *args.ExecutionNode
var kettleAddress common.Address
if args.IsConfidential && args.KettleAddress != nil {
kettleAddress = *args.KettleAddress
}

var data types.TxData
Expand Down Expand Up @@ -338,20 +338,20 @@ func (args *TransactionArgs) toTransaction() *types.Transaction {
}

data = &types.SuaveTransaction{
ExecutionNode: executionNode,
KettleAddress: kettleAddress,
ChainID: (*big.Int)(args.ChainID),
ConfidentialComputeRequest: ccr,
ConfidentialComputeResult: confResult,
}
case args.ExecutionNode != nil:
case args.KettleAddress != nil:
var confidentialInputs []byte
if args.ConfidentialInputs != nil {
confidentialInputs = *args.ConfidentialInputs
}

data = &types.ConfidentialComputeRequest{
ConfidentialComputeRecord: types.ConfidentialComputeRecord{
ExecutionNode: executionNode,
KettleAddress: kettleAddress,
// TODO: hashme
To: args.To,
Nonce: uint64(*args.Nonce),
Expand Down
Loading
Loading