diff --git a/core/types/confidential.go b/core/types/confidential.go index ee9c5125a4..21ec2b029d 100644 --- a/core/types/confidential.go +++ b/core/types/confidential.go @@ -16,7 +16,7 @@ type ConfidentialComputeRequest struct { func (tx *ConfidentialComputeRequest) copy() TxData { cpy := &ConfidentialComputeRequest{ ExecutionNode: tx.ExecutionNode, - Wrapped: tx.Wrapped, + Wrapped: *NewTx(tx.Wrapped.inner), ChainID: new(big.Int), } @@ -83,7 +83,7 @@ type SuaveTransaction struct { func (tx *SuaveTransaction) copy() TxData { cpy := &SuaveTransaction{ ExecutionNode: tx.ExecutionNode, - ConfidentialComputeRequest: tx.ConfidentialComputeRequest, + ConfidentialComputeRequest: *NewTx(tx.ConfidentialComputeRequest.inner), ConfidentialComputeResult: common.CopyBytes(tx.ConfidentialComputeResult), ChainID: new(big.Int), V: new(big.Int), diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index cfdb0fb148..f5f8664646 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -40,10 +40,10 @@ type sigCache struct { func MakeSigner(config *params.ChainConfig, blockNumber *big.Int, blockTime uint64) Signer { var signer Signer switch { - case config.IsCancun(blockNumber, blockTime): - signer = NewCancunSigner(config.ChainID) case config.IsSuave(blockNumber): signer = NewSuaveSigner(config.ChainID) + case config.IsCancun(blockNumber, blockTime): + signer = NewCancunSigner(config.ChainID) case config.IsLondon(blockNumber): signer = NewLondonSigner(config.ChainID) case config.IsBerlin(blockNumber): @@ -67,12 +67,12 @@ func MakeSigner(config *params.ChainConfig, blockNumber *big.Int, blockTime uint // have the current block number available, use MakeSigner instead. func LatestSigner(config *params.ChainConfig) Signer { if config.ChainID != nil { - if config.CancunTime != nil { - return NewCancunSigner(config.ChainID) - } if config.SuaveBlock != nil { return NewSuaveSigner(config.ChainID) } + if config.CancunTime != nil { + return NewCancunSigner(config.ChainID) + } if config.LondonBlock != nil { return NewLondonSigner(config.ChainID) } @@ -271,7 +271,7 @@ func (s suaveSigner) Sender(tx *Transaction) (common.Address, error) { var confidentialComputeRequestTx *Transaction = tx if tx.Type() == SuaveTxType { // Verify ExecutionNode's signature inner := tx.inner.(*SuaveTransaction) - confidentialComputeRequestTx = NewTx(&ConfidentialComputeRequest{ExecutionNode: inner.ExecutionNode, Wrapped: inner.ConfidentialComputeRequest, ChainID: inner.ChainID}) + confidentialComputeRequestTx = &inner.ConfidentialComputeRequest V, R, S := tx.RawSignatureValues() // DynamicFee txs are defined to use 0 and 1 as their recovery diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 2b300e4e8d..b8c4a0b22f 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -2006,7 +2006,7 @@ func (s *TransactionAPI) executeConfidentialCall(ctx context.Context, tx *types. computeResult = result.ReturnData // Or should it be nil maybe in this case? } - suaveResultTxData := &types.SuaveTransaction{ExecutionNode: confidentialRequestTx.ExecutionNode, ConfidentialComputeRequest: confidentialRequestTx.Wrapped, ConfidentialComputeResult: computeResult} + suaveResultTxData := &types.SuaveTransaction{ExecutionNode: confidentialRequestTx.ExecutionNode, ConfidentialComputeRequest: *tx, ConfidentialComputeResult: computeResult} signed, err := wallet.SignTx(account, types.NewTx(suaveResultTxData), s.b.ChainConfig().ChainID) if err != nil { diff --git a/internal/ethapi/transaction_args.go b/internal/ethapi/transaction_args.go index 9fb2bc0c51..3cabb43fc7 100644 --- a/internal/ethapi/transaction_args.go +++ b/internal/ethapi/transaction_args.go @@ -45,6 +45,7 @@ type TransactionArgs struct { ExecutionNode *common.Address `json:"executionNode"` IsConfidential bool `json:"IsConfidential"` ConfidentialInputs *hexutil.Bytes `json:"confidentialInputs"` // TODO: testme + ConfidentialResult *hexutil.Bytes `json:"ConfidentialResult"` // TODO: testme Nonce *hexutil.Uint64 `json:"nonce"` // We accept "data" and "input" for backwards-compatibility reasons. @@ -314,6 +315,30 @@ func (args *TransactionArgs) toTransaction() *types.Transaction { Data: args.data(), AccessList: *args.AccessList, } + case args.ConfidentialResult != nil: + requestArgs := *args + requestArgs.ConfidentialResult = nil + + var confResult []byte + if args.ConfidentialResult != nil { + confResult = []byte(*args.ConfidentialResult) + } + + data = &types.SuaveTransaction{ + ExecutionNode: *args.ExecutionNode, + ChainID: (*big.Int)(args.ChainID), + ConfidentialComputeRequest: *requestArgs.toTransaction(), + ConfidentialComputeResult: confResult, + } + case args.ExecutionNode != nil: + wrappedArgs := *args + wrappedArgs.ExecutionNode = nil + + data = &types.ConfidentialComputeRequest{ + ExecutionNode: *args.ExecutionNode, + Wrapped: *wrappedArgs.toTransaction(), + ChainID: (*big.Int)(args.ChainID), + } default: data = &types.LegacyTx{ To: args.To, diff --git a/suave/core/engine.go b/suave/core/engine.go index 79d4e2f683..074355541b 100644 --- a/suave/core/engine.go +++ b/suave/core/engine.go @@ -344,7 +344,7 @@ func (e *ConfidentialStoreEngine) NewMessage(message DAMessage) error { _, err = e.backend.Store(message.Bid, message.Caller, message.Key, message.Value) if err != nil { - panic(fmt.Errorf("unexpected error while storing, the message was not validated properly: %w (%v)", err, message.Caller)) + return fmt.Errorf("unexpected error while storing: %w", err) } return nil