Skip to content

Commit fc3e44c

Browse files
authored
Support Sepolia Devnet with TEE (#288)
* update enclave-entrypoint.bash to correctly deal with external url * preserve host name for external url * Skip IsURLAvailable TCP check when using HTTP proxy * skip VerifyCertTransaction for now * reuse socat so that it can work for internal url * comment and skip TestE2eDevnetWithInvalidAttestation
1 parent f435699 commit fc3e44c

File tree

5 files changed

+159
-185
lines changed

5 files changed

+159
-185
lines changed

.github/workflows/docker-images.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ jobs:
344344
contents: read
345345
packages: write
346346
steps:
347+
347348
- name: Checkout
348349
uses: actions/checkout@v4
349350

espresso/environment/5_batch_authentication_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import (
1818
// when provided with an invalid attestation. This test ensures that the batch inbox contract
1919
// properly validates attestations
2020
func TestE2eDevnetWithInvalidAttestation(t *testing.T) {
21+
// Sishan TODO: this test is skipped now as we skip the attestation verification, should be restored after https://app.asana.com/1/1208976916964769/project/1209976130071762/task/1211868671079203?focus=true
22+
// Related task: https://app.asana.com/1/1208976916964769/project/1209976130071762/task/1212349352131215?focus=true
23+
t.Skip("skipping E2E invalid attestation test for now as we skip the attestation verification, should be restored after zk verification added.")
24+
2125
ctx, cancel := context.WithCancel(context.Background())
2226
defer cancel()
2327

op-batcher/batcher/espresso.go

Lines changed: 5 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import (
1212
espressoClient "github.com/EspressoSystems/espresso-network/sdks/go/client"
1313
tagged_base64 "github.com/EspressoSystems/espresso-network/sdks/go/tagged-base64"
1414
espressoCommon "github.com/EspressoSystems/espresso-network/sdks/go/types"
15-
"github.com/ethereum/go-ethereum/accounts/abi"
16-
"github.com/ethereum/go-ethereum/accounts/abi/bind"
15+
1716
"github.com/ethereum/go-ethereum/common"
1817
"github.com/ethereum/go-ethereum/common/hexutil"
1918
"github.com/ethereum/go-ethereum/core/types"
@@ -950,26 +949,6 @@ func (l *BatchSubmitter) fetchBlock(ctx context.Context, blockNumber uint64) (*t
950949
return block, nil
951950
}
952951

953-
// createVerifyCertTransaction creates transactiondata to verify a certificate `cert` against provided certManager.
954-
// Returns (nil, nil) in case `cert` is already verified.
955-
func createVerifyCertTransaction(certManager *bindings.CertManagerCaller, certManagerAbi *abi.ABI, cert []byte, isCa bool, parentCertHash common.Hash) ([]byte, error) {
956-
certHash := crypto.Keccak256Hash(cert)
957-
verified, err := certManager.Verified(nil, certHash)
958-
if err != nil {
959-
return nil, err
960-
}
961-
962-
if len(verified) != 0 {
963-
return nil, nil
964-
}
965-
966-
if isCa {
967-
return certManagerAbi.Pack("verifyCACert", cert, parentCertHash)
968-
} else {
969-
return certManagerAbi.Pack("verifyClientCert", cert, parentCertHash)
970-
}
971-
}
972-
973952
func (l *BatchSubmitter) registerBatcher(ctx context.Context) error {
974953
if l.Attestation == nil {
975954
l.Log.Warn("Attestation is nil, skipping registration")
@@ -985,89 +964,9 @@ func (l *BatchSubmitter) registerBatcher(ctx context.Context) error {
985964
return fmt.Errorf("No contract deployed at this address %w", err)
986965
}
987966

988-
batchAuthenticator, err := bindings.NewBatchAuthenticator(l.RollupConfig.BatchAuthenticatorAddress, l.L1Client)
989-
if err != nil {
990-
return fmt.Errorf("failed to create BatchAuthenticator contract bindings: %w", err)
991-
}
992-
993-
verifierAddress, err := batchAuthenticator.EspressoTEEVerifier(&bind.CallOpts{})
994-
if err != nil {
995-
return fmt.Errorf("failed to get EspressoTEEVerifier address from BatchAuthenticator contract: %w", err)
996-
}
997-
998-
espressoTEEVerifier, err := bindings.NewEspressoTEEVerifierCaller(verifierAddress, l.L1Client)
999-
if err != nil {
1000-
return fmt.Errorf("failed to create EspressoTEEVerifier contract bindings: %w", err)
1001-
}
1002-
1003-
nitroVerifierAddress, err := espressoTEEVerifier.EspressoNitroTEEVerifier(&bind.CallOpts{})
1004-
if err != nil {
1005-
return fmt.Errorf("failed to get EspressoNitroTEEVerifier address from verifier contract: %w", err)
1006-
}
1007-
1008-
nitroVerifier, err := bindings.NewEspressoNitroTEEVerifierCaller(nitroVerifierAddress, l.L1Client)
1009-
if err != nil {
1010-
return fmt.Errorf("failed to create EspressoNitroTEEVerifier contract bindings: %w", err)
1011-
}
1012-
1013-
certManagerAddress, err := nitroVerifier.CertManager(&bind.CallOpts{})
1014-
if err != nil {
1015-
return fmt.Errorf("failed to get CertManager address from EspressoNitroTEEVerifier contract: %w", err)
1016-
}
1017-
1018-
certManager, err := bindings.NewCertManagerCaller(certManagerAddress, l.L1Client)
1019-
if err != nil {
1020-
return fmt.Errorf("failed to create CertManager contract bindings: %w", err)
1021-
}
1022-
1023-
certManagerAbi, err := bindings.CertManagerMetaData.GetAbi()
1024-
if err != nil {
1025-
return fmt.Errorf("failed to create CertManager contract bindings: %w", err)
1026-
}
1027-
1028-
// Verify every CA certiciate in the chain in an individual transaction. This avoids running into block gas limit
1029-
// that could happen if CertManager verifies the whole certificate chain in one transaction.
1030-
parentCertHash := crypto.Keccak256Hash(l.Attestation.Document.CABundle[0])
1031-
for i, cert := range l.Attestation.Document.CABundle {
1032-
txData, err := createVerifyCertTransaction(certManager, certManagerAbi, cert, true, parentCertHash)
1033-
if err != nil {
1034-
return fmt.Errorf("failed to create verify certificate transaction: %w", err)
1035-
}
1036-
1037-
parentCertHash = crypto.Keccak256Hash(cert)
1038-
1039-
// If createVerifyCertTransaction returned nil, certificate is already verified
1040-
// and there's no need to send a verification transaction for this certificate
1041-
if txData == nil {
1042-
continue
1043-
}
1044-
1045-
l.Log.Info("Verifying CABundle", "certNumber", i, "certsTotal", len(l.Attestation.Document.CABundle))
1046-
_, err = l.Txmgr.Send(ctx, txmgr.TxCandidate{
1047-
TxData: txData,
1048-
To: &certManagerAddress,
1049-
})
1050-
1051-
if err != nil {
1052-
return fmt.Errorf("verify certificate transaction failed: %w", err)
1053-
}
1054-
}
1055-
1056-
txData, err := createVerifyCertTransaction(certManager, certManagerAbi, l.Attestation.Document.Certificate, false, parentCertHash)
1057-
if err != nil {
1058-
return fmt.Errorf("failed to create verify client certificate transaction: %w", err)
1059-
}
1060-
if txData != nil {
1061-
l.Log.Info("Verifying Client Certificate")
1062-
_, err = l.Txmgr.Send(ctx, txmgr.TxCandidate{
1063-
TxData: txData,
1064-
To: &certManagerAddress,
1065-
})
1066-
1067-
if err != nil {
1068-
return fmt.Errorf("verify client certificate transaction failed: %w", err)
1069-
}
1070-
}
967+
// Sishan TODO: I've skipped lots of verification for now as this will run out-of-gas, should replace it with zk tee nitro verifier later.
968+
// Sishan TODO: this is also why `TestE2eDevnetWithInvalidAttestation` is failing now and we skipped it.
969+
// Sishan TODO: relevant task and PR https://app.asana.com/1/1208976916964769/project/1209976130071762/task/1211868671079203?focus=true https://app.asana.com/1/1208976916964769/project/1209976130071762/task/1212349352131215?focus=true https://github.com/EspressoSystems/optimism-espresso-integration/pull/288
1071970

1072971
abi, err := bindings.BatchAuthenticatorMetaData.GetAbi()
1073972
if err != nil {
@@ -1082,7 +981,7 @@ func (l *BatchSubmitter) registerBatcher(ctx context.Context) error {
1082981
publicKeyHash := crypto.Keccak256Hash(l.Attestation.Document.PublicKey[1:])
1083982
enclaveAddress := common.BytesToAddress(publicKeyHash[12:])
1084983

1085-
txData, err = abi.Pack("registerSignerWithoutAttestationVerification", pcr0Hash, l.Attestation.COSESign1, l.Attestation.Signature, enclaveAddress)
984+
txData, err := abi.Pack("registerSignerWithoutAttestationVerification", pcr0Hash, l.Attestation.COSESign1, l.Attestation.Signature, enclaveAddress)
1086985
if err != nil {
1087986
return fmt.Errorf("failed to create RegisterSignerWithoutAttestationVerification transaction: %w", err)
1088987
}

0 commit comments

Comments
 (0)