diff --git a/.circleci/config.yml b/.circleci/config.yml index 00f8566170b..15425292e59 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1800,12 +1800,14 @@ workflows: - circleci-repo-readonly-authenticated-github-token - discord - contracts-bedrock-tests: + filters: "false" # Test everything except PreimageOracle.t.sol since it's slow. name: contracts-bedrock-tests test_list: find test -name "*.t.sol" -not -name "PreimageOracle.t.sol" context: - circleci-repo-readonly-authenticated-github-token - contracts-bedrock-tests: + filters: "false" # PreimageOracle test is slow, run it separately to unblock CI. name: contracts-bedrock-tests-preimage-oracle test_list: find test -name "PreimageOracle.t.sol" @@ -1831,6 +1833,7 @@ workflows: context: - circleci-repo-readonly-authenticated-github-token - contracts-bedrock-checks: + filters: "false" requires: - contracts-bedrock-build context: @@ -1878,6 +1881,7 @@ workflows: context: - circleci-repo-readonly-authenticated-github-token - go-tests: + filters: "false" name: go-tests-short no_output_timeout: 19m test_timeout: 20m @@ -2279,6 +2283,7 @@ workflows: - op-acceptance-tests: # Acceptance Testing params name: kurtosis-simple + filters: "false" devnet: simple gate: base # CircleCI params @@ -2290,6 +2295,7 @@ workflows: - op-acceptance-tests: # Acceptance Testing params name: kurtosis-isthmus + filters: "false" devnet: isthmus gate: isthmus # CircleCI params @@ -2301,6 +2307,7 @@ workflows: - op-acceptance-tests: # Acceptance Testing params name: kurtosis-interop + filters: "false" devnet: interop gate: interop # CircleCI params @@ -2324,6 +2331,7 @@ workflows: # KURTOSIS (Simple) - op-acceptance-tests: # Acceptance Testing params + filters: "false" name: kurtosis-simple devnet: simple gate: base @@ -2336,6 +2344,7 @@ workflows: - op-acceptance-tests: # Acceptance Testing params name: kurtosis-isthmus + filters: "false" devnet: isthmus gate: isthmus # CircleCI params diff --git a/.github/workflows/contracts-l1-tests.yaml b/.github/workflows/contracts-l1-tests.yaml new file mode 100644 index 00000000000..4bf7c87397b --- /dev/null +++ b/.github/workflows/contracts-l1-tests.yaml @@ -0,0 +1,49 @@ +name: L1 Contracts Tests + +on: + pull_request: + push: + branches: + - "celo-integration*" + - "main" + - "develop" + workflow_dispatch: + +jobs: + contracts-test: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly-654c8f01721e43dbc8a53c7a3b022548cb82b2f9 + + - name: Install Just + uses: extractions/setup-just@v2 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + + - name: Install dependencies + working-directory: packages/contracts-bedrock + run: just install + + - name: Build go-ffi + working-directory: packages/contracts-bedrock + run: just build-go-ffi + + - name: Check formatting + working-directory: packages/contracts-bedrock + run: forge fmt --check + + - name: Run L1 contracts tests + working-directory: packages/contracts-bedrock + run: forge test --match-path "test/L1/*.t.sol" -vv + diff --git a/.github/workflows/espresso-devnet-tests.yaml b/.github/workflows/espresso-devnet-tests.yaml index 71b9506ec9d..95d71846e23 100644 --- a/.github/workflows/espresso-devnet-tests.yaml +++ b/.github/workflows/espresso-devnet-tests.yaml @@ -60,9 +60,6 @@ jobs: - name: Run Batcher Restart test run: go test -timeout 30m -p 1 -count 1 -run 'TestBatcherRestart' -v ./espresso/devnet-tests/... - - name: Run Key Rotation test - run: go test -timeout 30m -p 1 -count 1 -run 'TestKeyRotation' -v ./espresso/devnet-tests/... - - name: Run Change Batch Inbox Owner test run: go test -timeout 30m -p 1 -count 1 -run 'TestChangeBatchInboxOwner' -v ./espresso/devnet-tests/... diff --git a/espresso/.env b/espresso/.env index e64f70e8520..0df5761cdf2 100644 --- a/espresso/.env +++ b/espresso/.env @@ -50,6 +50,9 @@ BATCH_AUTHENTICATOR_OWNER_PRIVATE_KEY=0x7c852118294e51e653712a81e05800f419141751 # cast wallet address --mnemonic "test test ... junk" --hd-path "m/44'/60'/0'/0/1" PROPOSER_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 +# cast wallet address --mnemonic "test test ... junk" --hd-path "m/44'/60'/0'/0/5" +NON_TEE_BATCHER_ADDRESS=0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc + L1_CHAIN_ID=11155111 L2_CHAIN_ID=22266222 diff --git a/espresso/devnet-tests/key_rotation_test.go b/espresso/devnet-tests/key_rotation_test.go index d82188acfd5..c9c658406dd 100644 --- a/espresso/devnet-tests/key_rotation_test.go +++ b/espresso/devnet-tests/key_rotation_test.go @@ -8,54 +8,11 @@ import ( "github.com/ethereum-optimism/optimism/op-batcher/bindings" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait" - "github.com/ethereum-optimism/optimism/op-service/eth" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" ) -func TestRotateBatcherKey(t *testing.T) { - - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - d := NewDevnet(ctx, t) - - // We're going to change batcher key to Bob's, verify that it won't be a no-op - require.NotEqual(t, d.secrets.Batcher, d.secrets.Bob) - - require.NoError(t, d.Up(NON_TEE)) - defer func() { - require.NoError(t, d.Down()) - }() - - // Send a transaction just to check that everything has started up ok. - require.NoError(t, d.RunSimpleL2Burn()) - - // Shut down the batcher - require.NoError(t, d.ServiceDown("op-batcher")) - d.SleepOutageDuration() - - // Change the batch sender key to Bob - contract, owner, err := d.SystemConfig(ctx) - require.NoError(t, err) - - tx, err := contract.SetBatcherHash(owner, eth.AddressAsLeftPaddedHash(d.secrets.Addresses().Bob)) - require.NoError(t, err) - - _, err = d.SendL1Tx(ctx, tx) - require.NoError(t, err) - - d.secrets.Batcher = d.secrets.Bob - - // Restart the batcher - require.NoError(t, d.ServiceUp("op-batcher")) - d.SleepOutageDuration() - - // Send a transaction to check the L2 still runs - require.NoError(t, d.RunSimpleL2Burn()) -} - func TestChangeBatchInboxOwner(t *testing.T) { // Load environment variables from .env file err := LoadDevnetEnv() diff --git a/espresso/scripts/prepare-allocs.sh b/espresso/scripts/prepare-allocs.sh index fd40faa9b6e..a2505eeb95f 100755 --- a/espresso/scripts/prepare-allocs.sh +++ b/espresso/scripts/prepare-allocs.sh @@ -73,7 +73,11 @@ op-deployer init --l1-chain-id "${L1_CHAIN_ID}" \ --outdir ${DEPLOYER_DIR} dasel put -f "${DEPLOYER_DIR}/intent.toml" -s .chains.[0].espressoEnabled -t bool -v true -dasel put -f "${DEPLOYER_DIR}/intent.toml" -s .chains.[0].preApprovedBatcherKey -v "${OPERATOR_ADDRESS}" + +# Configure Espresso batchers for devnet. We reuse the operator address for both +# the non-TEE and TEE batchers to ensure they are non-zero and consistent. +dasel put -f "${DEPLOYER_DIR}/intent.toml" -s .chains.[0].nonTeeBatcher -v "${OPERATOR_ADDRESS}" +dasel put -f "${DEPLOYER_DIR}/intent.toml" -s .chains.[0].teeBatcher -v "${OPERATOR_ADDRESS}" dasel put -f "${DEPLOYER_DIR}/intent.toml" -s .l1ContractsLocator -v "${ARTIFACTS_DIR}" dasel put -f "${DEPLOYER_DIR}/intent.toml" -s .l2ContractsLocator -v "${ARTIFACTS_DIR}" dasel put -f "${DEPLOYER_DIR}/intent.toml" -s .opcmAddress -v `jq -r .opcmAddress < ${DEPLOYER_DIR}/bootstrap_implementations.json` diff --git a/justfile b/justfile index 8c8272e884c..c63af035b1d 100644 --- a/justfile +++ b/justfile @@ -30,6 +30,9 @@ golint: compile-contracts: (cd packages/contracts-bedrock && just build-dev) +run-l1-espresso-contracts-tests: compile-contracts + (cd packages/contracts-bedrock && forge test --match-path "/**/test/L1/Batch*.t.sol") + compile-contracts-fast: (cd packages/contracts-bedrock && forge build --offline --skip "/**/test/**") diff --git a/op-batcher/bindings/batch_authenticator.go b/op-batcher/bindings/batch_authenticator.go index fdd512720c2..2747dea26d1 100644 --- a/op-batcher/bindings/batch_authenticator.go +++ b/op-batcher/bindings/batch_authenticator.go @@ -31,8 +31,8 @@ var ( // BatchAuthenticatorMetaData contains all meta data concerning the BatchAuthenticator contract. var BatchAuthenticatorMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"_espressoTEEVerifier\",\"type\":\"address\",\"internalType\":\"contractEspressoTEEVerifier\"},{\"name\":\"_preApprovedBatcher\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"authenticateBatchInfo\",\"inputs\":[{\"name\":\"commitment\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"decodeAttestationTbs\",\"inputs\":[{\"name\":\"attestation\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"espressoTEEVerifier\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractEspressoTEEVerifier\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"nitroValidator\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractINitroValidator\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"preApprovedBatcher\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"registerSigner\",\"inputs\":[{\"name\":\"attestationTbs\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"registerSignerWithoutAttestationVerification\",\"inputs\":[{\"name\":\"pcr0Hash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"attestationTbs\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"enclaveAddress\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"validBatchInfo\",\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"version\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint8\",\"indexed\":false,\"internalType\":\"uint8\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false}]", - Bin: "0x60e0806040523461011357604081611515803803809161001f828561012a565b8339810103126101135780516001600160a01b038116918282036101135760200151916001600160a01b03831683036101135760049260209260a05260805260405192838092631b01498560e31b82525afa90811561011f575f916100d9575b506001600160a01b031660c0526040516113b3908161016282396080518181816102de0152610b94015260a0518181816101950152818161051f0152818161076b0152610cfd015260c0518181816109020152610c030152f35b90506020813d602011610117575b816100f46020938361012a565b8101031261011357516001600160a01b0381168103610113575f61007f565b5f80fd5b3d91506100e7565b6040513d5f823e3d90fd5b601f909101601f19168101906001600160401b0382119082101761014d57604052565b634e487b7160e01b5f52604160045260245ffdfe6080806040526004361015610012575f80fd5b5f905f3560e01c90816302afd6e314610c27575080631b076a4c14610bb85780631f568b1814610b4957806354fd4d5014610aca578063715018a614610a2c5780638da5cb5b146109da578063a903a27714610849578063ba58e82a146106df578063f2fde38b14610590578063f81f208314610543578063fa14fe6d146104d45763fc619e41146100a2575f80fd5b346104d15760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d15760043560243567ffffffffffffffff81116104cf576100f76100fe913690600401610e21565b3691610f3a565b8051604010156104a25760608101805160f81c80158015610498575b6103db575b505061014b61014373ffffffffffffffffffffffffffffffffffffffff928461109f565b9190916110d4565b16801561037d576040517fd80a4c2800000000000000000000000000000000000000000000000000000000815260208160048173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165afa9081156103455773ffffffffffffffffffffffffffffffffffffffff916020918691610350575b506024604051809481937f0123d0c1000000000000000000000000000000000000000000000000000000008352876004840152165afa908115610345578491610306575b501590816102c5575b5061026757815260656020526040812060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082541617905580f35b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f496e76616c6964207369676e65720000000000000000000000000000000000006044820152fd5b905073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614155f61022b565b90506020813d60201161033d575b8161032160209383610e4f565b8101031261033957518015158103610339575f610222565b8380fd5b3d9150610314565b6040513d86823e3d90fd5b6103709150823d8411610376575b6103688183610e4f565b810190610f70565b5f6101de565b503d61035e565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f496e76616c6964207369676e61747572650000000000000000000000000000006044820152fd5b601b0160ff811161046b5782516040101561043e5773ffffffffffffffffffffffffffffffffffffffff9261014b927fff000000000000000000000000000000000000000000000000000000000000006101439360f81b16871a9053925061011f565b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526032600452fd5b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b506001811461011a565b6024837f4e487b710000000000000000000000000000000000000000000000000000000081526032600452fd5b825b80fd5b50346104d157807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d157602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b50346104d15760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d15760ff60406020926004358152606584522054166040519015158152f35b50346104d15760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d15760043573ffffffffffffffffffffffffffffffffffffffff81168091036106db576105e9611020565b80156106575773ffffffffffffffffffffffffffffffffffffffff603354827fffffffffffffffffffffffff0000000000000000000000000000000000000000821617603355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152fd5b5080fd5b50346104d15760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d1578060043567ffffffffffffffff811161084657610730903690600401610e21565b9060243567ffffffffffffffff811161084357610751903690600401610e21565b92909173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690813b1561083f57856107db9361080b8296604051988997889687957f35ecb4c1000000000000000000000000000000000000000000000000000000008752606060048801526064870191610f9c565b917ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc858403016024860152610f9c565b6001604483015203925af18015610834576108235750f35b8161082d91610e4f565b6104d15780f35b6040513d84823e3d90fd5b8580fd5b50505b50fd5b50346104d15760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d15760043567ffffffffffffffff81116106db5781366023830112156104d1576108ae6108e9923690602481600401359101610f3a565b604051809381927fa903a277000000000000000000000000000000000000000000000000000000008352602060048401526024830190610ef7565b038173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165afa9182156109ce5780918193610962575b6109508361095e86604051938493604085526040850190610ef7565b908382036020850152610ef7565b0390f35b915091503d8083833e6109758183610e4f565b8101916040828403126104d157815167ffffffffffffffff81116106db578361099f918401610fda565b9160208101519167ffffffffffffffff83116104d157506109509361095e926109c89201610fda565b92610934565b604051903d90823e3d90fd5b50346104d157807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d157602073ffffffffffffffffffffffffffffffffffffffff60335416604051908152f35b50346104d157807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d157610a63611020565b8073ffffffffffffffffffffffffffffffffffffffff6033547fffffffffffffffffffffffff00000000000000000000000000000000000000008116603355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b50346104d157807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d1575061095e604051610b0b604082610e4f565b600581527f312e302e300000000000000000000000000000000000000000000000000000006020820152604051918291602083526020830190610ef7565b50346104d157807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d157602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b50346104d157807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d157602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b905034610dfe5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610dfe5760243567ffffffffffffffff8111610dfe57610c78903690600401610e21565b909160443567ffffffffffffffff8111610dfe57610c9a903690600401610e21565b936064359273ffffffffffffffffffffffffffffffffffffffff8416809403610dfe577fd80a4c2800000000000000000000000000000000000000000000000000000000815260208160048173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165afa8015610df35773ffffffffffffffffffffffffffffffffffffffff915f91610e02575b501691823b15610dfe575f94610d9d94610dcd8793604051998a98899788967f02afd6e30000000000000000000000000000000000000000000000000000000088526004356004890152608060248901526084880191610f9c565b917ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc868403016044870152610f9c565b90606483015203925af18015610df357610de5575080f35b610df191505f90610e4f565b005b6040513d5f823e3d90fd5b5f80fd5b610e1b915060203d602011610376576103688183610e4f565b5f610d42565b9181601f84011215610dfe5782359167ffffffffffffffff8311610dfe5760208381860195010111610dfe57565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117610e9057604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b67ffffffffffffffff8111610e9057601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602080948051918291828752018686015e5f8582860101520116010190565b929192610f4682610ebd565b91610f546040519384610e4f565b829481845281830111610dfe578281602093845f960137010152565b90816020910312610dfe575173ffffffffffffffffffffffffffffffffffffffff81168103610dfe5790565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f8582860101520116010190565b81601f82011215610dfe57805190610ff182610ebd565b92610fff6040519485610e4f565b82845260208383010111610dfe57815f9260208093018386015e8301015290565b73ffffffffffffffffffffffffffffffffffffffff60335416330361104157565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b9060418151145f146110cb576110c791602082015190606060408401519301515f1a906112f7565b9091565b50505f90600290565b60058110156112ca57806110e55750565b6001810361114b5760646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152fd5b600281036111b15760646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152fd5b6003810361123d5760846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152fd5b60041461124657565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841161139b5760ff1690601b82141580611390575b611385576020935f93608093604051938452868401526040830152606082015282805260015afa15610df3575f5173ffffffffffffffffffffffffffffffffffffffff81161561137d57905f90565b505f90600190565b505050505f90600490565b50601c82141561132e565b505050505f9060039056fea164736f6c634300081c000a", + ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"_espressoTEEVerifier\",\"type\":\"address\",\"internalType\":\"contractEspressoTEEVerifier\"},{\"name\":\"_teeBatcher\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_nonTeeBatcher\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_owner\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"activeIsTee\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"authenticateBatchInfo\",\"inputs\":[{\"name\":\"commitment\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"decodeAttestationTbs\",\"inputs\":[{\"name\":\"attestation\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"espressoTEEVerifier\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractEspressoTEEVerifier\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"nitroValidator\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractINitroValidator\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"nonTeeBatcher\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"registerSigner\",\"inputs\":[{\"name\":\"attestationTbs\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"registerSignerWithoutAttestationVerification\",\"inputs\":[{\"name\":\"pcr0Hash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"attestationTbs\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"enclaveAddress\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"switchBatcher\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"teeBatcher\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"validBatchInfo\",\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"version\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false}]", + Bin: "0x6101006040523461007b5761001e610015610197565b9291909161045e565b610026610080565b611dc1610668823960805181818161088001526115ba015260a0518161075e015260c0518181816109b801528181610bc501528181610f9201526114b9015260e05181818161029b0152610e780152611dc190f35b610086565b60405190565b5f80fd5b601f801991011690565b634e487b7160e01b5f52604160045260245ffd5b906100b29061008a565b810190811060018060401b038211176100ca57604052565b610094565b906100e26100db610080565b92836100a8565b565b5f80fd5b60018060a01b031690565b6100fc906100e8565b90565b610108906100f3565b90565b610114816100ff565b0361011b57565b5f80fd5b9050519061012c8261010b565b565b610137816100f3565b0361013e57565b5f80fd5b9050519061014f8261012e565b565b60808183031261019257610167825f830161011f565b9261018f6101788460208501610142565b936101868160408601610142565b93606001610142565b90565b6100e4565b6101b5612429803803806101aa816100cf565b928339810190610151565b90919293565b90565b90565b6101d56101d06101da926101bb565b6101be565b6100e8565b90565b6101e6906101c1565b90565b60209181520190565b60207f6368657200000000000000000000000000000000000000000000000000000000917f426174636841757468656e74696361746f723a207a65726f20746565206261745f8201520152565b61024c60246040926101e9565b610255816101f2565b0190565b61026e9060208101905f81830391015261023f565b90565b1561027857565b610280610080565b62461bcd60e51b81528061029660048201610259565b0390fd5b60207f2062617463686572000000000000000000000000000000000000000000000000917f426174636841757468656e74696361746f723a207a65726f206e6f6e2d7465655f8201520152565b6102f460286040926101e9565b6102fd8161029a565b0190565b6103169060208101905f8183039101526102e7565b90565b1561032057565b610328610080565b62461bcd60e51b81528061033e60048201610301565b0390fd5b61034c90516100ff565b90565b61036361035e610368926100e8565b6101be565b6100e8565b90565b6103749061034f565b90565b6103809061036b565b90565b60e01b90565b610392906100f3565b90565b61039e81610389565b036103a557565b5f80fd5b905051906103b682610395565b565b906020828203126103d1576103ce915f016103a9565b90565b6100e4565b5f0190565b6103e3610080565b3d5f823e3d90fd5b6103f49061036b565b90565b6104009061034f565b90565b61040c906103f7565b90565b5f1b90565b9061042060ff9161040f565b9181191691161790565b151590565b6104389061042a565b90565b90565b9061045361044e61045a9261042f565b61043b565b8254610414565b9055565b906104ea93929161046d61056a565b6104928261048b6104856104805f6101dd565b6100f3565b916100f3565b1415610271565b6104b7836104b06104aa6104a55f6101dd565b6100f3565b916100f3565b1415610319565b60c05260805260a05260206104d46104cf60c0610342565b610377565b63d80a4c28906104e2610080565b948592610383565b825281806104fa600482016103d6565b03915afa80156105655761051c61052191610535945f91610537575b506103eb565b610403565b60e0526105306001600261043e565b6105f7565b565b610558915060203d811161055e575b61055081836100a8565b8101906103b8565b5f610516565b503d610546565b6103db565b61057a61057561065a565b6105f7565b565b5f1c90565b60018060a01b031690565b61059861059d9161057c565b610581565b90565b6105aa905461058c565b90565b906105be60018060a01b039161040f565b9181191691161790565b6105d19061036b565b90565b90565b906105ec6105e76105f3926105c8565b6105d4565b82546105ad565b9055565b6106005f6105a0565b61060a825f6105d7565b9061063e6106387f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0936105c8565b916105c8565b91610647610080565b80610651816103d6565b0390a3565b5f90565b610662610656565b50339056fe60806040526004361015610013575b610ab7565b61001d5f3561010c565b806302afd6e3146101075780631b076a4c1461010257806354fd4d50146100fd578063715018a6146100f85780637877a9ed146100f35780638da5cb5b146100ee578063a903a277146100e9578063b1bd4285146100e4578063ba58e82a146100df578063bc347f47146100da578063d909ba7c146100d5578063f2fde38b146100d0578063f81f2083146100cb578063fa14fe6d146100c65763fc619e410361000e57610a83565b610a08565b610981565b6108f5565b6108a2565b61084b565b610814565b610780565b610726565b6105c8565b610571565b6104d8565b6104a3565b610316565b610250565b60e01c90565b60405190565b5f80fd5b5f80fd5b5f80fd5b90565b61013081610124565b0361013757565b5f80fd5b9050359061014882610127565b565b5f80fd5b5f80fd5b5f80fd5b909182601f830112156101905781359167ffffffffffffffff831161018b57602001926001830284011161018657565b610152565b61014e565b61014a565b60018060a01b031690565b6101a990610195565b90565b6101b5816101a0565b036101bc57565b5f80fd5b905035906101cd826101ac565b565b9190608083820312610246576101e7815f850161013b565b92602081013567ffffffffffffffff81116102415782610208918301610156565b929093604083013567ffffffffffffffff811161023c5761022e83610239928601610156565b9390946060016101c0565b90565b610120565b610120565b61011c565b5f0190565b346102855761026f6102633660046101cf565b94939093929192610bb6565b610277610112565b806102818161024b565b0390f35b610118565b5f91031261029457565b61011c565b7f000000000000000000000000000000000000000000000000000000000000000090565b90565b6102d46102cf6102d992610195565b6102bd565b610195565b90565b6102e5906102c0565b90565b6102f1906102dc565b90565b6102fd906102e8565b9052565b9190610314905f602085019401906102f4565b565b346103465761032636600461028a565b610342610331610299565b610339610112565b91829182610301565b0390f35b610118565b601f801991011690565b634e487b7160e01b5f52604160045260245ffd5b906103739061034b565b810190811067ffffffffffffffff82111761038d57604052565b610355565b906103a561039e610112565b9283610369565b565b67ffffffffffffffff81116103c5576103c160209161034b565b0190565b610355565b906103dc6103d7836103a7565b610392565b918252565b5f7f312e302e30000000000000000000000000000000000000000000000000000000910152565b61041260056103ca565b9061041f602083016103e1565b565b610429610408565b90565b610434610421565b90565b61043f61042c565b90565b5190565b60209181520190565b90825f9392825e0152565b6104796104826020936104879361047081610442565b93848093610446565b9586910161044f565b61034b565b0190565b6104a09160208201915f81840391015261045a565b90565b346104d3576104b336600461028a565b6104cf6104be610437565b6104c6610112565b9182918261048b565b0390f35b610118565b34610506576104e836600461028a565b6104f0610d34565b6104f8610112565b806105028161024b565b0390f35b610118565b1c90565b60ff1690565b61052590600861052a930261050b565b61050f565b90565b906105389154610515565b90565b61054760025f9061052d565b90565b151590565b6105589061054a565b9052565b919061056f905f6020850194019061054f565b565b346105a15761058136600461028a565b61059d61058c61053b565b610594610112565b9182918261055c565b0390f35b610118565b6105af906101a0565b9052565b91906105c6905f602085019401906105a6565b565b346105f8576105d836600461028a565b6105f46105e3610d73565b6105eb610112565b918291826105b3565b0390f35b610118565b5f80fd5b67ffffffffffffffff811161061f5761061b60209161034b565b0190565b610355565b90825f939282370152565b9092919261064461063f82610601565b610392565b938185526020850190828401116106605761065e92610624565b565b6105fd565b9080601f83011215610683578160206106809335910161062f565b90565b61014a565b906020828203126106b8575f82013567ffffffffffffffff81116106b3576106b09201610665565b90565b610120565b61011c565b5190565b60209181520190565b6106e96106f26020936106f7936106e0816106bd565b938480936106c1565b9586910161044f565b61034b565b0190565b90916107156107239360408401908482035f8601526106ca565b9160208184039101526106ca565b90565b346107575761073e610739366004610688565b610e5b565b9061075361074a610112565b928392836106fb565b0390f35b610118565b7f000000000000000000000000000000000000000000000000000000000000000090565b346107b05761079036600461028a565b6107ac61079b61075c565b6107a3610112565b918291826105b3565b0390f35b610118565b909160408284031261080f575f82013567ffffffffffffffff811161080a57836107e0918401610156565b929093602082013567ffffffffffffffff8111610805576108019201610156565b9091565b610120565b610120565b61011c565b34610846576108306108273660046107b5565b92919091610f8a565b610838610112565b806108428161024b565b0390f35b610118565b346108795761085b36600461028a565b6108636110d9565b61086b610112565b806108758161024b565b0390f35b610118565b7f000000000000000000000000000000000000000000000000000000000000000090565b346108d2576108b236600461028a565b6108ce6108bd61087e565b6108c5610112565b918291826105b3565b0390f35b610118565b906020828203126108f0576108ed915f016101c0565b90565b61011c565b346109235761090d6109083660046108d7565b6111ce565b610915610112565b8061091f8161024b565b0390f35b610118565b906020828203126109415761093e915f0161013b565b90565b61011c565b61094f90610124565b90565b9061095c90610946565b5f5260205260405f2090565b61097e906109796001915f92610952565b61052d565b90565b346109b1576109ad61099c610997366004610928565b610968565b6109a4610112565b9182918261055c565b0390f35b610118565b7f000000000000000000000000000000000000000000000000000000000000000090565b6109e3906102dc565b90565b6109ef906109da565b9052565b9190610a06905f602085019401906109e6565b565b34610a3857610a1836600461028a565b610a34610a236109b6565b610a2b610112565b918291826109f3565b0390f35b610118565b919091604081840312610a7e57610a56835f830161013b565b92602082013567ffffffffffffffff8111610a7957610a759201610156565b9091565b610120565b61011c565b34610ab257610a9c610a96366004610a3d565b91611436565b610aa4610112565b80610aae8161024b565b0390f35b610118565b5f80fd5b5f80fd5b60e01b90565b610ace906101a0565b90565b610ada81610ac5565b03610ae157565b5f80fd5b90505190610af282610ad1565b565b90602082820312610b0d57610b0a915f01610ae5565b90565b61011c565b610b1a610112565b3d5f823e3d90fd5b610b2b906102dc565b90565b5f910312610b3857565b61011c565b610b4690610124565b9052565b9190610b6481610b5d81610b69956106c1565b8095610624565b61034b565b0190565b9695939094610b9e88606095610bac95610b91610bb49a5f60808601950190610b3d565b8b830360208d0152610b4a565b9188830360408a0152610b4a565b9401906105a6565b565b9194909293610bff6020610be97f00000000000000000000000000000000000000000000000000000000000000006109da565b63d80a4c2890610bf7610112565b938492610abf565b82528180610c0f6004820161024b565b03915afa8015610cdf57610c2a915f91610cb1575b50610b22565b926302afd6e390949695919295843b15610cac575f96610c5e948894610c6993610c52610112565b9b8c9a8b998a98610abf565b885260048801610b6d565b03925af18015610ca757610c7b575b50565b610c9a905f3d8111610ca0575b610c928183610369565b810190610b2e565b5f610c78565b503d610c88565b610b12565b610abb565b610cd2915060203d8111610cd8575b610cca8183610369565b810190610af4565b5f610c24565b503d610cc0565b610b12565b610cec61174a565b610cf4610d21565b565b90565b610d0d610d08610d1292610cf6565b6102bd565b610195565b90565b610d1e90610cf9565b90565b610d32610d2d5f610d15565b6117c0565b565b610d3c610ce4565b565b5f90565b5f1c90565b60018060a01b031690565b610d5e610d6391610d42565b610d47565b90565b610d709054610d52565b90565b610d7b610d3e565b50610d855f610d66565b90565b606090565b90929192610da2610d9d82610601565b610392565b93818552602085019082840111610dbe57610dbc9261044f565b565b6105fd565b9080601f83011215610de157816020610dde93519101610d8d565b90565b61014a565b919091604081840312610e3e575f81015167ffffffffffffffff8111610e395783610e12918301610dc3565b92602082015167ffffffffffffffff8111610e3457610e319201610dc3565b90565b610120565b610120565b61011c565b610e589160208201915f8184039101526106ca565b90565b905f610ec392610e69610d88565b50610e72610d88565b50610e9c7f00000000000000000000000000000000000000000000000000000000000000006102e8565b610eb863a903a277610eac610112565b96879485938493610abf565b835260048301610e43565b03915afa8015610f03575f80939091610edc575b509190565b9050610efb9192503d805f833e610ef38183610369565b810190610de6565b91905f610ed7565b610b12565b634e487b7160e01b5f52602160045260245ffd5b60021115610f2657565b610f08565b90610f3582610f1c565b565b610f4090610f2b565b90565b610f4c90610f37565b9052565b959492610f8894610f72610f809360409560608b01918b83035f8d0152610b4a565b9188830360208a0152610b4a565b940190610f43565b565b929192610fb67f00000000000000000000000000000000000000000000000000000000000000006109da565b906335ecb4c190929493600191833b1561103857610ff5610fea935f97938894610fde610112565b9a8b998a988997610abf565b875260048701610f50565b03925af1801561103357611007575b50565b611026905f3d811161102c575b61101e8183610369565b810190610b2e565b5f611004565b503d611014565b610b12565b610abb565b61104561174a565b61104d6110ba565b565b61105b61106091610d42565b61050f565b90565b61106d905461104f565b90565b5f1b90565b9061108160ff91611070565b9181191691161790565b6110949061054a565b90565b90565b906110af6110aa6110b69261108b565b611097565b8254611075565b9055565b6110d76110d06110ca6002611063565b1561054a565b600261109a565b565b6110e161103d565b565b6110f4906110ef61174a565b61119e565b565b60207f6464726573730000000000000000000000000000000000000000000000000000917f4f776e61626c653a206e6577206f776e657220697320746865207a65726f20615f8201520152565b6111506026604092610446565b611159816110f6565b0190565b6111729060208101905f818303910152611143565b90565b1561117c57565b611184610112565b62461bcd60e51b81528061119a6004820161115d565b0390fd5b6111cc906111c7816111c06111ba6111b55f610d15565b6101a0565b916101a0565b1415611175565b6117c0565b565b6111d7906110e3565b565b6111e491369161062f565b90565b634e487b7160e01b5f52603260045260245ffd5b90611205826106bd565b81101561121757600160209102010190565b6111e7565b90565b90565b61123661123161123b9261121c565b6102bd565b61121f565b90565b60ff60f81b1690565b611251905161123e565b90565b60f81c90565b60ff1690565b61127461126f6112799261125a565b6102bd565b61125a565b90565b61128861128d91611254565b611260565b90565b6112a461129f6112a992610cf6565b6102bd565b61125a565b90565b90565b6112c36112be6112c8926112ac565b6102bd565b61125a565b90565b90565b6112e26112dd6112e7926112cb565b6102bd565b61125a565b90565b634e487b7160e01b5f52601160045260245ffd5b61130a6113109161125a565b9161125a565b019060ff821161131c57565b6112ea565b60f81b90565b61133b6113366113409261125a565b611321565b61123e565b90565b5f7f496e76616c6964207369676e6174757265000000000000000000000000000000910152565b6113776011602092610446565b61138081611343565b0190565b6113999060208101905f81830391015261136a565b90565b6113a58161054a565b036113ac57565b5f80fd5b905051906113bd8261139c565b565b906020828203126113d8576113d5915f016113b0565b90565b61011c565b5f7f496e76616c6964207369676e6572000000000000000000000000000000000000910152565b611411600e602092610446565b61141a816113dd565b0190565b6114339060208101905f818303910152611404565b90565b916114449061148f926111d9565b61146861146361145e836114586040611222565b906111fb565b611247565b61127c565b8061147b6114755f611290565b9161125a565b1480156116ae575b611673575b508261181f565b806114aa6114a461149f5f610d15565b6101a0565b916101a0565b14611651576114f360206114dd7f00000000000000000000000000000000000000000000000000000000000000006109da565b63d80a4c28906114eb610112565b938492610abf565b825281806115036004820161024b565b03915afa801561164c5761152460209161154e935f9161161f575b50610b22565b630123d0c1906115438592611537610112565b95869485938493610abf565b8352600483016105b3565b03915afa801561161a5761156a915f916115ec575b501561054a565b90816115b0575b5061158e5761158c906115876001916001610952565b61109a565b565b611596610112565b62461bcd60e51b8152806115ac6004820161141e565b0390fd5b90506115e46115de7f00000000000000000000000000000000000000000000000000000000000000006101a0565b916101a0565b14155f611571565b61160d915060203d8111611613575b6116058183610369565b8101906113bf565b5f611563565b503d6115fb565b610b12565b61163f9150833d8111611645575b6116378183610369565b810190610af4565b5f61151e565b503d61162d565b610b12565b611659610112565b62461bcd60e51b81528061166f60048201611384565b0390fd5b61168a61168f91611684601b6112ce565b906112fe565b611327565b6116a7826116a16040935f1a93611222565b906111fb565b535f611488565b50806116c36116bd60016112af565b9161125a565b14611483565b5f7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572910152565b6116fc60208092610446565b611705816116c9565b0190565b61171e9060208101905f8183039101526116f0565b90565b1561172857565b611730610112565b62461bcd60e51b81528061174660048201611709565b0390fd5b611774611755610d73565b61176e611768611763611840565b6101a0565b916101a0565b14611721565b565b9061178760018060a01b0391611070565b9181191691161790565b61179a906102dc565b90565b90565b906117b56117b06117bc92611791565b61179d565b8254611776565b9055565b6117c95f610d66565b6117d3825f6117a0565b906118076118017f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e093611791565b91611791565b91611810610112565b8061181a8161024b565b0390a3565b61183d916118359161182f610d3e565b50611878565b919091611ac7565b90565b611848610d3e565b503390565b5f90565b90565b61186861186361186d92611851565b6102bd565b61121f565b90565b5f90565b5f90565b611880610d3e565b5061188961184d565b50611893826106bd565b6118a66118a06041611854565b9161121f565b145f146118eb576118e5916118b9611870565b506118c2611870565b506118cb611874565b506020810151606060408301519201515f1a909192611c90565b91909190565b50506118f65f610d15565b90600290565b6005111561190657565b610f08565b90611915826118fc565b565b60207f7565000000000000000000000000000000000000000000000000000000000000917f45434453413a20696e76616c6964207369676e6174757265202776272076616c5f8201520152565b6119716022604092610446565b61197a81611917565b0190565b6119939060208101905f818303910152611964565b90565b60207f7565000000000000000000000000000000000000000000000000000000000000917f45434453413a20696e76616c6964207369676e6174757265202773272076616c5f8201520152565b6119f06022604092610446565b6119f981611996565b0190565b611a129060208101905f8183039101526119e3565b90565b5f7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800910152565b611a49601f602092610446565b611a5281611a15565b0190565b611a6b9060208101905f818303910152611a3c565b90565b5f7f45434453413a20696e76616c6964207369676e61747572650000000000000000910152565b611aa26018602092610446565b611aab81611a6e565b0190565b611ac49060208101905f818303910152611a95565b90565b80611ada611ad45f61190b565b9161190b565b145f14611ae45750565b80611af8611af2600161190b565b9161190b565b145f14611b2157611b07610112565b62461bcd60e51b815280611b1d60048201611aaf565b0390fd5b80611b35611b2f600261190b565b9161190b565b145f14611b5e57611b44610112565b62461bcd60e51b815280611b5a60048201611a56565b0390fd5b80611b72611b6c600361190b565b9161190b565b145f14611b9b57611b81610112565b62461bcd60e51b815280611b97600482016119fd565b0390fd5b611bae611ba8600461190b565b9161190b565b14611bb557565b611bbd610112565b62461bcd60e51b815280611bd36004820161197e565b0390fd5b611beb611be6611bf09261121f565b6102bd565b61121f565b90565b611bff611c0491610d42565b611bd7565b90565b90565b611c1e611c19611c2392611c07565b6102bd565b61121f565b90565b90565b611c3d611c38611c4292611c26565b6102bd565b61125a565b90565b611c4e9061125a565b9052565b611c87611c8e94611c7d606094989795611c73608086019a5f870190610b3d565b6020850190611c45565b6040830190610b3d565b0190610b3d565b565b929190611c9b610d3e565b50611ca461184d565b50611cae83611bf3565b611ce0611cda7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0611c0a565b9161121f565b11611da15780611cf9611cf3601b6112ce565b9161125a565b141580611d85575b611d7257611d205f936020959293611d17610112565b94859485611c52565b838052039060015afa15611d6d57611d385f51611070565b80611d53611d4d611d485f610d15565b6101a0565b916101a0565b14611d5d57905f90565b50611d675f610d15565b90600190565b610b12565b50505050611d7f5f610d15565b90600490565b5080611d9a611d94601c611c29565b9161125a565b1415611d01565b50505050611dae5f610d15565b9060039056fea164736f6c634300081e000a", } // BatchAuthenticatorABI is the input ABI used to generate the binding from. @@ -44,7 +44,7 @@ var BatchAuthenticatorABI = BatchAuthenticatorMetaData.ABI var BatchAuthenticatorBin = BatchAuthenticatorMetaData.Bin // DeployBatchAuthenticator deploys a new Ethereum contract, binding an instance of BatchAuthenticator to it. -func DeployBatchAuthenticator(auth *bind.TransactOpts, backend bind.ContractBackend, _espressoTEEVerifier common.Address, _preApprovedBatcher common.Address) (common.Address, *types.Transaction, *BatchAuthenticator, error) { +func DeployBatchAuthenticator(auth *bind.TransactOpts, backend bind.ContractBackend, _espressoTEEVerifier common.Address, _teeBatcher common.Address, _nonTeeBatcher common.Address, _owner common.Address) (common.Address, *types.Transaction, *BatchAuthenticator, error) { parsed, err := BatchAuthenticatorMetaData.GetAbi() if err != nil { return common.Address{}, nil, nil, err @@ -53,7 +53,7 @@ func DeployBatchAuthenticator(auth *bind.TransactOpts, backend bind.ContractBack return common.Address{}, nil, nil, errors.New("GetABI returned nil") } - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(BatchAuthenticatorBin), backend, _espressoTEEVerifier, _preApprovedBatcher) + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(BatchAuthenticatorBin), backend, _espressoTEEVerifier, _teeBatcher, _nonTeeBatcher, _owner) if err != nil { return common.Address{}, nil, nil, err } @@ -202,6 +202,37 @@ func (_BatchAuthenticator *BatchAuthenticatorTransactorRaw) Transact(opts *bind. return _BatchAuthenticator.Contract.contract.Transact(opts, method, params...) } +// ActiveIsTee is a free data retrieval call binding the contract method 0x7877a9ed. +// +// Solidity: function activeIsTee() view returns(bool) +func (_BatchAuthenticator *BatchAuthenticatorCaller) ActiveIsTee(opts *bind.CallOpts) (bool, error) { + var out []interface{} + err := _BatchAuthenticator.contract.Call(opts, &out, "activeIsTee") + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// ActiveIsTee is a free data retrieval call binding the contract method 0x7877a9ed. +// +// Solidity: function activeIsTee() view returns(bool) +func (_BatchAuthenticator *BatchAuthenticatorSession) ActiveIsTee() (bool, error) { + return _BatchAuthenticator.Contract.ActiveIsTee(&_BatchAuthenticator.CallOpts) +} + +// ActiveIsTee is a free data retrieval call binding the contract method 0x7877a9ed. +// +// Solidity: function activeIsTee() view returns(bool) +func (_BatchAuthenticator *BatchAuthenticatorCallerSession) ActiveIsTee() (bool, error) { + return _BatchAuthenticator.Contract.ActiveIsTee(&_BatchAuthenticator.CallOpts) +} + // DecodeAttestationTbs is a free data retrieval call binding the contract method 0xa903a277. // // Solidity: function decodeAttestationTbs(bytes attestation) view returns(bytes, bytes) @@ -296,6 +327,37 @@ func (_BatchAuthenticator *BatchAuthenticatorCallerSession) NitroValidator() (co return _BatchAuthenticator.Contract.NitroValidator(&_BatchAuthenticator.CallOpts) } +// NonTeeBatcher is a free data retrieval call binding the contract method 0xb1bd4285. +// +// Solidity: function nonTeeBatcher() view returns(address) +func (_BatchAuthenticator *BatchAuthenticatorCaller) NonTeeBatcher(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _BatchAuthenticator.contract.Call(opts, &out, "nonTeeBatcher") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// NonTeeBatcher is a free data retrieval call binding the contract method 0xb1bd4285. +// +// Solidity: function nonTeeBatcher() view returns(address) +func (_BatchAuthenticator *BatchAuthenticatorSession) NonTeeBatcher() (common.Address, error) { + return _BatchAuthenticator.Contract.NonTeeBatcher(&_BatchAuthenticator.CallOpts) +} + +// NonTeeBatcher is a free data retrieval call binding the contract method 0xb1bd4285. +// +// Solidity: function nonTeeBatcher() view returns(address) +func (_BatchAuthenticator *BatchAuthenticatorCallerSession) NonTeeBatcher() (common.Address, error) { + return _BatchAuthenticator.Contract.NonTeeBatcher(&_BatchAuthenticator.CallOpts) +} + // Owner is a free data retrieval call binding the contract method 0x8da5cb5b. // // Solidity: function owner() view returns(address) @@ -327,12 +389,12 @@ func (_BatchAuthenticator *BatchAuthenticatorCallerSession) Owner() (common.Addr return _BatchAuthenticator.Contract.Owner(&_BatchAuthenticator.CallOpts) } -// PreApprovedBatcher is a free data retrieval call binding the contract method 0x1f568b18. +// TeeBatcher is a free data retrieval call binding the contract method 0xd909ba7c. // -// Solidity: function preApprovedBatcher() view returns(address) -func (_BatchAuthenticator *BatchAuthenticatorCaller) PreApprovedBatcher(opts *bind.CallOpts) (common.Address, error) { +// Solidity: function teeBatcher() view returns(address) +func (_BatchAuthenticator *BatchAuthenticatorCaller) TeeBatcher(opts *bind.CallOpts) (common.Address, error) { var out []interface{} - err := _BatchAuthenticator.contract.Call(opts, &out, "preApprovedBatcher") + err := _BatchAuthenticator.contract.Call(opts, &out, "teeBatcher") if err != nil { return *new(common.Address), err @@ -344,18 +406,18 @@ func (_BatchAuthenticator *BatchAuthenticatorCaller) PreApprovedBatcher(opts *bi } -// PreApprovedBatcher is a free data retrieval call binding the contract method 0x1f568b18. +// TeeBatcher is a free data retrieval call binding the contract method 0xd909ba7c. // -// Solidity: function preApprovedBatcher() view returns(address) -func (_BatchAuthenticator *BatchAuthenticatorSession) PreApprovedBatcher() (common.Address, error) { - return _BatchAuthenticator.Contract.PreApprovedBatcher(&_BatchAuthenticator.CallOpts) +// Solidity: function teeBatcher() view returns(address) +func (_BatchAuthenticator *BatchAuthenticatorSession) TeeBatcher() (common.Address, error) { + return _BatchAuthenticator.Contract.TeeBatcher(&_BatchAuthenticator.CallOpts) } -// PreApprovedBatcher is a free data retrieval call binding the contract method 0x1f568b18. +// TeeBatcher is a free data retrieval call binding the contract method 0xd909ba7c. // -// Solidity: function preApprovedBatcher() view returns(address) -func (_BatchAuthenticator *BatchAuthenticatorCallerSession) PreApprovedBatcher() (common.Address, error) { - return _BatchAuthenticator.Contract.PreApprovedBatcher(&_BatchAuthenticator.CallOpts) +// Solidity: function teeBatcher() view returns(address) +func (_BatchAuthenticator *BatchAuthenticatorCallerSession) TeeBatcher() (common.Address, error) { + return _BatchAuthenticator.Contract.TeeBatcher(&_BatchAuthenticator.CallOpts) } // ValidBatchInfo is a free data retrieval call binding the contract method 0xf81f2083. @@ -504,6 +566,27 @@ func (_BatchAuthenticator *BatchAuthenticatorTransactorSession) RenounceOwnershi return _BatchAuthenticator.Contract.RenounceOwnership(&_BatchAuthenticator.TransactOpts) } +// SwitchBatcher is a paid mutator transaction binding the contract method 0xbc347f47. +// +// Solidity: function switchBatcher() returns() +func (_BatchAuthenticator *BatchAuthenticatorTransactor) SwitchBatcher(opts *bind.TransactOpts) (*types.Transaction, error) { + return _BatchAuthenticator.contract.Transact(opts, "switchBatcher") +} + +// SwitchBatcher is a paid mutator transaction binding the contract method 0xbc347f47. +// +// Solidity: function switchBatcher() returns() +func (_BatchAuthenticator *BatchAuthenticatorSession) SwitchBatcher() (*types.Transaction, error) { + return _BatchAuthenticator.Contract.SwitchBatcher(&_BatchAuthenticator.TransactOpts) +} + +// SwitchBatcher is a paid mutator transaction binding the contract method 0xbc347f47. +// +// Solidity: function switchBatcher() returns() +func (_BatchAuthenticator *BatchAuthenticatorTransactorSession) SwitchBatcher() (*types.Transaction, error) { + return _BatchAuthenticator.Contract.SwitchBatcher(&_BatchAuthenticator.TransactOpts) +} + // TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. // // Solidity: function transferOwnership(address newOwner) returns() @@ -525,140 +608,6 @@ func (_BatchAuthenticator *BatchAuthenticatorTransactorSession) TransferOwnershi return _BatchAuthenticator.Contract.TransferOwnership(&_BatchAuthenticator.TransactOpts, newOwner) } -// BatchAuthenticatorInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the BatchAuthenticator contract. -type BatchAuthenticatorInitializedIterator struct { - Event *BatchAuthenticatorInitialized // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *BatchAuthenticatorInitializedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(BatchAuthenticatorInitialized) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(BatchAuthenticatorInitialized) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *BatchAuthenticatorInitializedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *BatchAuthenticatorInitializedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// BatchAuthenticatorInitialized represents a Initialized event raised by the BatchAuthenticator contract. -type BatchAuthenticatorInitialized struct { - Version uint8 - Raw types.Log // Blockchain specific contextual infos -} - -// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. -// -// Solidity: event Initialized(uint8 version) -func (_BatchAuthenticator *BatchAuthenticatorFilterer) FilterInitialized(opts *bind.FilterOpts) (*BatchAuthenticatorInitializedIterator, error) { - - logs, sub, err := _BatchAuthenticator.contract.FilterLogs(opts, "Initialized") - if err != nil { - return nil, err - } - return &BatchAuthenticatorInitializedIterator{contract: _BatchAuthenticator.contract, event: "Initialized", logs: logs, sub: sub}, nil -} - -// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. -// -// Solidity: event Initialized(uint8 version) -func (_BatchAuthenticator *BatchAuthenticatorFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *BatchAuthenticatorInitialized) (event.Subscription, error) { - - logs, sub, err := _BatchAuthenticator.contract.WatchLogs(opts, "Initialized") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(BatchAuthenticatorInitialized) - if err := _BatchAuthenticator.contract.UnpackLog(event, "Initialized", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. -// -// Solidity: event Initialized(uint8 version) -func (_BatchAuthenticator *BatchAuthenticatorFilterer) ParseInitialized(log types.Log) (*BatchAuthenticatorInitialized, error) { - event := new(BatchAuthenticatorInitialized) - if err := _BatchAuthenticator.contract.UnpackLog(event, "Initialized", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - // BatchAuthenticatorOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the BatchAuthenticator contract. type BatchAuthenticatorOwnershipTransferredIterator struct { Event *BatchAuthenticatorOwnershipTransferred // Event containing the contract specifics and raw log diff --git a/op-batcher/bindings/batch_inbox.go b/op-batcher/bindings/batch_inbox.go index 2d230320feb..7009f1b2330 100644 --- a/op-batcher/bindings/batch_inbox.go +++ b/op-batcher/bindings/batch_inbox.go @@ -31,8 +31,8 @@ var ( // BatchInboxMetaData contains all meta data concerning the BatchInbox contract. var BatchInboxMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"_batchAuthenticator\",\"type\":\"address\",\"internalType\":\"contractIBatchAuthenticator\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"fallback\",\"stateMutability\":\"nonpayable\"}]", - Bin: "0x60a0604052348015600e575f5ffd5b506040516103f03803806103f0833981016040819052602b91603b565b6001600160a01b03166080526066565b5f60208284031215604a575f5ffd5b81516001600160a01b0381168114605f575f5ffd5b9392505050565b60805161036c6100845f395f8181609d01526101d0015261036c5ff3fe608060405234801561000f575f5ffd5b505f491561018857604080515f80825260208201909252905b804915610067578181496040516020016100439291906102b4565b6040516020818303038152906040529150808061005f906102ce565b915050610028565b815160208301206040517ff81f2083000000000000000000000000000000000000000000000000000000008152600481018290527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063f81f208390602401602060405180830381865afa1580156100f7573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061011b919061032a565b610186576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f496e76616c696420626c6f62206261746368000000000000000000000000000060448201526064015b60405180910390fd5b005b5f5f36604051610199929190610350565b6040519081900381207ff81f20830000000000000000000000000000000000000000000000000000000082526004820181905291507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063f81f208390602401602060405180830381865afa15801561022a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061024e919061032a565b610186576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f496e76616c69642063616c6c6461746120626174636800000000000000000000604482015260640161017d565b5f83518060208601845e9190910191825250602001919050565b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610323577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5060010190565b5f6020828403121561033a575f5ffd5b81518015158114610349575f5ffd5b9392505050565b818382375f910190815291905056fea164736f6c634300081c000a", + ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"_batchAuthenticator\",\"type\":\"address\",\"internalType\":\"contractIBatchAuthenticator\"},{\"name\":\"_owner\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"fallback\",\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"batchAuthenticator\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractIBatchAuthenticator\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"nonTeeBatcher\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false}]", + Bin: "0x60c060405234801561000f575f5ffd5b50604051610f9b380380610f9b8339818101604052810190610031919061029d565b61004d61004261013c60201b60201c565b61014360201b60201c565b5f8273ffffffffffffffffffffffffffffffffffffffff1663b1bd42856040518163ffffffff1660e01b8152600401602060405180830381865afa158015610097573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100bb91906102db565b90508073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508273ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff16815250506101348261014360201b60201c565b505050610306565b5f33905090565b5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f5f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61023182610208565b9050919050565b5f61024282610227565b9050919050565b61025281610238565b811461025c575f5ffd5b50565b5f8151905061026d81610249565b92915050565b61027c81610227565b8114610286575f5ffd5b50565b5f8151905061029781610273565b92915050565b5f5f604083850312156102b3576102b2610204565b5b5f6102c08582860161025f565b92505060206102d185828601610289565b9150509250929050565b5f602082840312156102f0576102ef610204565b5b5f6102fd84828501610289565b91505092915050565b60805160a051610c596103425f395f8181605c0152818161019a0152818161029401526104e101525f818161037201526104bd0152610c595ff3fe608060405234801561000f575f5ffd5b5060043610610059575f3560e01c8063715018a6146104015780638da5cb5b1461040b578063b1bd428514610429578063e758457314610447578063f2fde38b146104655761005a565b5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637877a9ed6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100c3573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100e79190610704565b15610370575f5f1b5f4914610277575f5f67ffffffffffffffff8111156101115761011061072f565b5b6040519080825280601f01601f1916602001820160405280156101435781602001600182028036833780820191505090505b5090505f5f90505b5f5f1b81491461018d578181496040516020016101699291906107d7565b6040516020818303038152906040529150808061018590610834565b91505061014b565b5f828051906020012090507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f81f2083826040518263ffffffff1660e01b81526004016101f1919061088a565b602060405180830381865afa15801561020c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102309190610704565b61026f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610266906108fd565b60405180910390fd5b50505061036b565b5f5f3660405161028892919061094d565b604051809103902090507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f81f2083826040518263ffffffff1660e01b81526004016102eb919061088a565b602060405180830381865afa158015610306573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061032a9190610704565b610369576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610360906109af565b60405180910390fd5b505b6103ff565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103f590610a17565b60405180910390fd5b5b005b610409610481565b005b610413610494565b6040516104209190610a74565b60405180910390f35b6104316104bb565b60405161043e9190610a74565b60405180910390f35b61044f6104df565b60405161045c9190610ae8565b60405180910390f35b61047f600480360381019061047a9190610b2b565b610503565b005b610489610585565b6104925f610603565b565b5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b61050b610585565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610579576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161057090610bc6565b60405180910390fd5b61058281610603565b50565b61058d6106c4565b73ffffffffffffffffffffffffffffffffffffffff166105ab610494565b73ffffffffffffffffffffffffffffffffffffffff1614610601576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105f890610c2e565b60405180910390fd5b565b5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f5f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f33905090565b5f5ffd5b5f8115159050919050565b6106e3816106cf565b81146106ed575f5ffd5b50565b5f815190506106fe816106da565b92915050565b5f60208284031215610719576107186106cb565b5b5f610726848285016106f0565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f81519050919050565b5f81905092915050565b8281835e5f83830152505050565b5f6107888261075c565b6107928185610766565b93506107a2818560208601610770565b80840191505092915050565b5f819050919050565b5f819050919050565b6107d16107cc826107ae565b6107b7565b82525050565b5f6107e2828561077e565b91506107ee82846107c0565b6020820191508190509392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f819050919050565b5f61083e8261082b565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036108705761086f6107fe565b5b600182019050919050565b610884816107ae565b82525050565b5f60208201905061089d5f83018461087b565b92915050565b5f82825260208201905092915050565b7f496e76616c696420626c6f6220626174636800000000000000000000000000005f82015250565b5f6108e76012836108a3565b91506108f2826108b3565b602082019050919050565b5f6020820190508181035f830152610914816108db565b9050919050565b828183375f83830152505050565b5f6109348385610766565b935061094183858461091b565b82840190509392505050565b5f610959828486610929565b91508190509392505050565b7f496e76616c69642063616c6c64617461206261746368000000000000000000005f82015250565b5f6109996016836108a3565b91506109a482610965565b602082019050919050565b5f6020820190508181035f8301526109c68161098d565b9050919050565b7f4261746368496e626f783a20756e617574686f72697a656420626174636865725f82015250565b5f610a016020836108a3565b9150610a0c826109cd565b602082019050919050565b5f6020820190508181035f830152610a2e816109f5565b9050919050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610a5e82610a35565b9050919050565b610a6e81610a54565b82525050565b5f602082019050610a875f830184610a65565b92915050565b5f819050919050565b5f610ab0610aab610aa684610a35565b610a8d565b610a35565b9050919050565b5f610ac182610a96565b9050919050565b5f610ad282610ab7565b9050919050565b610ae281610ac8565b82525050565b5f602082019050610afb5f830184610ad9565b92915050565b610b0a81610a54565b8114610b14575f5ffd5b50565b5f81359050610b2581610b01565b92915050565b5f60208284031215610b4057610b3f6106cb565b5b5f610b4d84828501610b17565b91505092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f20615f8201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b5f610bb06026836108a3565b9150610bbb82610b56565b604082019050919050565b5f6020820190508181035f830152610bdd81610ba4565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725f82015250565b5f610c186020836108a3565b9150610c2382610be4565b602082019050919050565b5f6020820190508181035f830152610c4581610c0c565b905091905056fea164736f6c634300081c000a", } // BatchInboxABI is the input ABI used to generate the binding from. @@ -44,7 +44,7 @@ var BatchInboxABI = BatchInboxMetaData.ABI var BatchInboxBin = BatchInboxMetaData.Bin // DeployBatchInbox deploys a new Ethereum contract, binding an instance of BatchInbox to it. -func DeployBatchInbox(auth *bind.TransactOpts, backend bind.ContractBackend, _batchAuthenticator common.Address) (common.Address, *types.Transaction, *BatchInbox, error) { +func DeployBatchInbox(auth *bind.TransactOpts, backend bind.ContractBackend, _batchAuthenticator common.Address, _owner common.Address) (common.Address, *types.Transaction, *BatchInbox, error) { parsed, err := BatchInboxMetaData.GetAbi() if err != nil { return common.Address{}, nil, nil, err @@ -53,7 +53,7 @@ func DeployBatchInbox(auth *bind.TransactOpts, backend bind.ContractBackend, _ba return common.Address{}, nil, nil, errors.New("GetABI returned nil") } - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(BatchInboxBin), backend, _batchAuthenticator) + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(BatchInboxBin), backend, _batchAuthenticator, _owner) if err != nil { return common.Address{}, nil, nil, err } @@ -202,6 +202,141 @@ func (_BatchInbox *BatchInboxTransactorRaw) Transact(opts *bind.TransactOpts, me return _BatchInbox.Contract.contract.Transact(opts, method, params...) } +// BatchAuthenticator is a free data retrieval call binding the contract method 0xe7584573. +// +// Solidity: function batchAuthenticator() view returns(address) +func (_BatchInbox *BatchInboxCaller) BatchAuthenticator(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _BatchInbox.contract.Call(opts, &out, "batchAuthenticator") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// BatchAuthenticator is a free data retrieval call binding the contract method 0xe7584573. +// +// Solidity: function batchAuthenticator() view returns(address) +func (_BatchInbox *BatchInboxSession) BatchAuthenticator() (common.Address, error) { + return _BatchInbox.Contract.BatchAuthenticator(&_BatchInbox.CallOpts) +} + +// BatchAuthenticator is a free data retrieval call binding the contract method 0xe7584573. +// +// Solidity: function batchAuthenticator() view returns(address) +func (_BatchInbox *BatchInboxCallerSession) BatchAuthenticator() (common.Address, error) { + return _BatchInbox.Contract.BatchAuthenticator(&_BatchInbox.CallOpts) +} + +// NonTeeBatcher is a free data retrieval call binding the contract method 0xb1bd4285. +// +// Solidity: function nonTeeBatcher() view returns(address) +func (_BatchInbox *BatchInboxCaller) NonTeeBatcher(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _BatchInbox.contract.Call(opts, &out, "nonTeeBatcher") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// NonTeeBatcher is a free data retrieval call binding the contract method 0xb1bd4285. +// +// Solidity: function nonTeeBatcher() view returns(address) +func (_BatchInbox *BatchInboxSession) NonTeeBatcher() (common.Address, error) { + return _BatchInbox.Contract.NonTeeBatcher(&_BatchInbox.CallOpts) +} + +// NonTeeBatcher is a free data retrieval call binding the contract method 0xb1bd4285. +// +// Solidity: function nonTeeBatcher() view returns(address) +func (_BatchInbox *BatchInboxCallerSession) NonTeeBatcher() (common.Address, error) { + return _BatchInbox.Contract.NonTeeBatcher(&_BatchInbox.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_BatchInbox *BatchInboxCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _BatchInbox.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_BatchInbox *BatchInboxSession) Owner() (common.Address, error) { + return _BatchInbox.Contract.Owner(&_BatchInbox.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_BatchInbox *BatchInboxCallerSession) Owner() (common.Address, error) { + return _BatchInbox.Contract.Owner(&_BatchInbox.CallOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_BatchInbox *BatchInboxTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _BatchInbox.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_BatchInbox *BatchInboxSession) RenounceOwnership() (*types.Transaction, error) { + return _BatchInbox.Contract.RenounceOwnership(&_BatchInbox.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_BatchInbox *BatchInboxTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _BatchInbox.Contract.RenounceOwnership(&_BatchInbox.TransactOpts) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_BatchInbox *BatchInboxTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _BatchInbox.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_BatchInbox *BatchInboxSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _BatchInbox.Contract.TransferOwnership(&_BatchInbox.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_BatchInbox *BatchInboxTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _BatchInbox.Contract.TransferOwnership(&_BatchInbox.TransactOpts, newOwner) +} + // Fallback is a paid mutator transaction binding the contract fallback function. // // Solidity: fallback() returns() @@ -222,3 +357,156 @@ func (_BatchInbox *BatchInboxSession) Fallback(calldata []byte) (*types.Transact func (_BatchInbox *BatchInboxTransactorSession) Fallback(calldata []byte) (*types.Transaction, error) { return _BatchInbox.Contract.Fallback(&_BatchInbox.TransactOpts, calldata) } + +// BatchInboxOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the BatchInbox contract. +type BatchInboxOwnershipTransferredIterator struct { + Event *BatchInboxOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *BatchInboxOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(BatchInboxOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(BatchInboxOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *BatchInboxOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *BatchInboxOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// BatchInboxOwnershipTransferred represents a OwnershipTransferred event raised by the BatchInbox contract. +type BatchInboxOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_BatchInbox *BatchInboxFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*BatchInboxOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _BatchInbox.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &BatchInboxOwnershipTransferredIterator{contract: _BatchInbox.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_BatchInbox *BatchInboxFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *BatchInboxOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _BatchInbox.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(BatchInboxOwnershipTransferred) + if err := _BatchInbox.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_BatchInbox *BatchInboxFilterer) ParseOwnershipTransferred(log types.Log) (*BatchInboxOwnershipTransferred, error) { + event := new(BatchInboxOwnershipTransferred) + if err := _BatchInbox.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/op-deployer/pkg/deployer/opcm/espresso.go b/op-deployer/pkg/deployer/opcm/espresso.go index 9bd2fdd4c38..d5c2dfef523 100644 --- a/op-deployer/pkg/deployer/opcm/espresso.go +++ b/op-deployer/pkg/deployer/opcm/espresso.go @@ -16,9 +16,10 @@ type DeployAWSNitroVerifierOutput struct { } type DeployEspressoInput struct { - Salt common.Hash - PreApprovedBatcherKey common.Address - NitroTEEVerifier common.Address + Salt common.Hash + NitroTEEVerifier common.Address + NonTeeBatcher common.Address + TeeBatcher common.Address } type DeployEspressoOutput struct { diff --git a/op-deployer/pkg/deployer/pipeline/espresso.go b/op-deployer/pkg/deployer/pipeline/espresso.go index 1702c7bfe53..6b96c13d586 100644 --- a/op-deployer/pkg/deployer/pipeline/espresso.go +++ b/op-deployer/pkg/deployer/pipeline/espresso.go @@ -48,9 +48,10 @@ func DeployEspresso(env *Env, intent *state.Intent, st *state.State, chainID com } eo, err = opcm.DeployEspresso(env.L1ScriptHost, opcm.DeployEspressoInput{ - Salt: st.Create2Salt, - PreApprovedBatcherKey: chainIntent.PreApprovedBatcherKey, - NitroTEEVerifier: nvo.NitroTEEVerifierAddress, + Salt: st.Create2Salt, + NitroTEEVerifier: nvo.NitroTEEVerifierAddress, + NonTeeBatcher: chainIntent.NonTeeBatcher, + TeeBatcher: chainIntent.TeeBatcher, }, batchAuthenticatorOwnwerAddress) if err != nil { return fmt.Errorf("failed to deploy espresso contracts: %w", err) diff --git a/op-deployer/pkg/deployer/state/chain_intent.go b/op-deployer/pkg/deployer/state/chain_intent.go index 600e6e65f30..938c3c8213e 100644 --- a/op-deployer/pkg/deployer/state/chain_intent.go +++ b/op-deployer/pkg/deployer/state/chain_intent.go @@ -76,8 +76,9 @@ type ChainIntent struct { L2DevGenesisParams *L2DevGenesisParams `json:"l2DevGenesisParams,omitempty" toml:"l2DevGenesisParams,omitempty"` // Espresso-specific fields - EspressoEnabled bool `json:"espressoEnabled,omitzero" toml:"espressoEnabled,omitzero"` - PreApprovedBatcherKey common.Address `json:"preApprovedBatcherKey,omitzero" toml:"preApprovedBatcherKey,omitzero"` + EspressoEnabled bool `json:"espressoEnabled,omitzero" toml:"espressoEnabled,omitzero"` + NonTeeBatcher common.Address `json:"nonTeeBatcher,omitzero" toml:"nonTeeBatcher,omitzero"` + TeeBatcher common.Address `json:"teeBatcher,omitzero" toml:"teeBatcher,omitzero"` } type ChainRoles struct { diff --git a/op-e2e/config/init.go b/op-e2e/config/init.go index 0754bdf3676..5d5dd2d6492 100644 --- a/op-e2e/config/init.go +++ b/op-e2e/config/init.go @@ -36,7 +36,7 @@ import ( _ "embed" ) -const ESPRESSO_PRE_APPROVED_BATCHER_PRIVATE_KEY = "5fede428b9506dee864b0d85aefb2409f4728313eb41da4121409299c487f816" +const ESPRESSO_NON_TEE_BATCHER_PRIVATE_KEY = "5fede428b9506dee864b0d85aefb2409f4728313eb41da4121409299c487f816" // legacy geth log levels - the geth command line --verbosity flag wasn't // migrated to use slog's numerical levels. @@ -287,17 +287,15 @@ func initAllocType(root string, allocType AllocType) { } } - if allocType == AllocTypeEspressoWithoutEnclave { - batcherPk, err := crypto.HexToECDSA(ESPRESSO_PRE_APPROVED_BATCHER_PRIVATE_KEY) + // Configure Espresso allocation types + if allocType == AllocTypeEspressoWithoutEnclave || allocType == AllocTypeEspressoWithEnclave { + batcherPk, err := crypto.HexToECDSA(ESPRESSO_NON_TEE_BATCHER_PRIVATE_KEY) if err != nil { panic(fmt.Errorf("failed to parse batcher private key: %w", err)) } intent.Chains[0].EspressoEnabled = true - intent.Chains[0].PreApprovedBatcherKey = crypto.PubkeyToAddress(batcherPk.PublicKey) - } - - if allocType == AllocTypeEspressoWithEnclave { - intent.Chains[0].EspressoEnabled = true + intent.Chains[0].NonTeeBatcher = crypto.PubkeyToAddress(batcherPk.PublicKey) + intent.Chains[0].TeeBatcher = crypto.PubkeyToAddress(batcherPk.PublicKey) } baseUpgradeSchedule := map[string]any{ diff --git a/op-e2e/system/e2esys/setup.go b/op-e2e/system/e2esys/setup.go index b99b6ddbffb..9b8e87a04d6 100644 --- a/op-e2e/system/e2esys/setup.go +++ b/op-e2e/system/e2esys/setup.go @@ -1016,12 +1016,12 @@ func (cfg SystemConfig) Start(t *testing.T, startOpts ...StartOption) (*System, batcherTargetNumFrames = 1 } - testingBatcherPk, err := crypto.HexToECDSA(config.ESPRESSO_PRE_APPROVED_BATCHER_PRIVATE_KEY) + testingBatcherPk, err := crypto.HexToECDSA(config.ESPRESSO_NON_TEE_BATCHER_PRIVATE_KEY) if err != nil { return nil, fmt.Errorf("failed to parse pre-approved batcher private key: %w", err) } espressoCfg := espresso.CLIConfig{ - Enabled: (cfg.AllocType == config.AllocTypeEspressoWithEnclave) || (cfg.AllocType == config.AllocTypeEspressoWithoutEnclave), + Enabled: (cfg.AllocType == config.AllocTypeEspresso) || (cfg.AllocType == config.AllocTypeEspressoWithEnclave) || (cfg.AllocType == config.AllocTypeEspressoWithoutEnclave), PollInterval: 250 * time.Millisecond, L1URL: sys.EthInstances[RoleL1].UserRPC().RPC(), RollupL1URL: sys.EthInstances[RoleL1].UserRPC().RPC(), diff --git a/packages/contracts-bedrock/interfaces/L1/IBatchAuthenticator.sol b/packages/contracts-bedrock/interfaces/L1/IBatchAuthenticator.sol index 9d76da2c58d..b23f92a3480 100644 --- a/packages/contracts-bedrock/interfaces/L1/IBatchAuthenticator.sol +++ b/packages/contracts-bedrock/interfaces/L1/IBatchAuthenticator.sol @@ -23,7 +23,9 @@ interface IBatchAuthenticator { function owner() external view returns (address); - function preApprovedBatcher() external view returns (address); + function teeBatcher() external view returns (address); + + function nonTeeBatcher() external view returns (address); function registerSigner( bytes memory attestationTbs, @@ -36,9 +38,14 @@ interface IBatchAuthenticator { function validBatchInfo(bytes32) external view returns (bool); + function activeIsTee() external view returns (bool); + + function switchBatcher() external; + function __constructor__( address _espressoTEEVerifier, - address _preApprovedBatcher, + address _teeBatcher, + address _nonTeeBatcher, address _owner ) external; } diff --git a/packages/contracts-bedrock/interfaces/L1/IBatchInbox.sol b/packages/contracts-bedrock/interfaces/L1/IBatchInbox.sol index afddfcc3c1e..4dc60a997e7 100644 --- a/packages/contracts-bedrock/interfaces/L1/IBatchInbox.sol +++ b/packages/contracts-bedrock/interfaces/L1/IBatchInbox.sol @@ -6,5 +6,5 @@ interface IBatchInbox { function version() external view returns (string memory); - function __constructor__(address _batchAuthenticator) external; + function __constructor__(address _batchAuthenticator, address _owner) external; } diff --git a/packages/contracts-bedrock/scripts/deploy/DeployEspresso.s.sol b/packages/contracts-bedrock/scripts/deploy/DeployEspresso.s.sol index 0b1ee985b06..ba4a28af069 100644 --- a/packages/contracts-bedrock/scripts/deploy/DeployEspresso.s.sol +++ b/packages/contracts-bedrock/scripts/deploy/DeployEspresso.s.sol @@ -14,8 +14,9 @@ import { EspressoTEEVerifier } from "@espresso-tee-contracts/EspressoTEEVerifier contract DeployEspressoInput is BaseDeployIO { bytes32 internal _salt; - address internal _preApprovedBatcherKey; address internal _nitroTEEVerifier; + address internal _nonTeeBatcher; + address internal _teeBatcher; function set(bytes4 _sel, bytes32 _val) public { if (_sel == this.salt.selector) _salt = _val; @@ -23,10 +24,12 @@ contract DeployEspressoInput is BaseDeployIO { } function set(bytes4 _sel, address _val) public { - if (_sel == this.preApprovedBatcherKey.selector) { - _preApprovedBatcherKey = _val; - } else if (_sel == this.nitroTEEVerifier.selector) { + if (_sel == this.nitroTEEVerifier.selector) { _nitroTEEVerifier = _val; + } else if (_sel == this.nonTeeBatcher.selector) { + _nonTeeBatcher = _val; + } else if (_sel == this.teeBatcher.selector) { + _teeBatcher = _val; } else { revert("DeployEspressoInput: unknown selector"); } @@ -41,8 +44,12 @@ contract DeployEspressoInput is BaseDeployIO { return _nitroTEEVerifier; } - function preApprovedBatcherKey() public view returns (address) { - return _preApprovedBatcherKey; + function nonTeeBatcher() public view returns (address) { + return _nonTeeBatcher; + } + + function teeBatcher() public view returns (address) { + return _teeBatcher; } } @@ -76,7 +83,7 @@ contract DeployEspresso is Script { function run(DeployEspressoInput input, DeployEspressoOutput output, address deployerAddress) public { IEspressoTEEVerifier teeVerifier = deployTEEVerifier(input); IBatchAuthenticator batchAuthenticator = deployBatchAuthenticator(input, output, teeVerifier, deployerAddress); - deployBatchInbox(input, output, batchAuthenticator); + deployBatchInbox(input, output, batchAuthenticator, deployerAddress); checkOutput(output); } @@ -90,7 +97,6 @@ contract DeployEspresso is Script { returns (IBatchAuthenticator) { bytes32 salt = input.salt(); - address preApprovedBatcherKey = input.preApprovedBatcherKey(); vm.broadcast(msg.sender); IBatchAuthenticator impl = IBatchAuthenticator( DeployUtils.create2({ @@ -98,7 +104,8 @@ contract DeployEspresso is Script { _salt: salt, _args: DeployUtils.encodeConstructor( abi.encodeCall( - IBatchAuthenticator.__constructor__, (address(teeVerifier), preApprovedBatcherKey, owner) + IBatchAuthenticator.__constructor__, + (address(teeVerifier), input.teeBatcher(), input.nonTeeBatcher(), owner) ) ) }) @@ -124,7 +131,8 @@ contract DeployEspresso is Script { function deployBatchInbox( DeployEspressoInput input, DeployEspressoOutput output, - IBatchAuthenticator batchAuthenticator + IBatchAuthenticator batchAuthenticator, + address owner ) public { @@ -135,7 +143,7 @@ contract DeployEspresso is Script { _name: "BatchInbox", _salt: salt, _args: DeployUtils.encodeConstructor( - abi.encodeCall(IBatchInbox.__constructor__, (address(batchAuthenticator))) + abi.encodeCall(IBatchInbox.__constructor__, (address(batchAuthenticator), owner)) ) }) ); diff --git a/packages/contracts-bedrock/src/L1/BatchAuthenticator.sol b/packages/contracts-bedrock/src/L1/BatchAuthenticator.sol index 0545c40860c..26170f2a90c 100644 --- a/packages/contracts-bedrock/src/L1/BatchAuthenticator.sol +++ b/packages/contracts-bedrock/src/L1/BatchAuthenticator.sol @@ -1,10 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity 0.8.28; import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { ISemver } from "interfaces/universal/ISemver.sol"; -import { EspressoTEEVerifier } from "@espresso-tee-contracts/EspressoTEEVerifier.sol"; import { IEspressoTEEVerifier } from "@espresso-tee-contracts/interface/IEspressoTEEVerifier.sol"; interface INitroValidator { @@ -22,15 +21,36 @@ contract BatchAuthenticator is ISemver, Ownable { /// @notice Mapping of batches verified by this contract mapping(bytes32 => bool) public validBatchInfo; - address public immutable preApprovedBatcher; + /// @notice Address of the TEE batcher whose signatures may authenticate batches. + address public immutable teeBatcher; - EspressoTEEVerifier public immutable espressoTEEVerifier; + /// @notice Address of the non-TEE (fallback) batcher that can post when TEE is inactive. + address public immutable nonTeeBatcher; + + IEspressoTEEVerifier public immutable espressoTEEVerifier; INitroValidator public immutable nitroValidator; - constructor(EspressoTEEVerifier _espressoTEEVerifier, address _preApprovedBatcher, address _owner) Ownable() { + /// @notice Flag indicating which batcher is currently active. + /// @dev When true the TEE batcher is active; when false the non-TEE batcher is active. + bool public activeIsTee; + + constructor( + IEspressoTEEVerifier _espressoTEEVerifier, + address _teeBatcher, + address _nonTeeBatcher, + address _owner + ) + Ownable() + { + require(_teeBatcher != address(0), "BatchAuthenticator: zero tee batcher"); + require(_nonTeeBatcher != address(0), "BatchAuthenticator: zero non-tee batcher"); + espressoTEEVerifier = _espressoTEEVerifier; - preApprovedBatcher = _preApprovedBatcher; + teeBatcher = _teeBatcher; + nonTeeBatcher = _nonTeeBatcher; nitroValidator = INitroValidator(address(espressoTEEVerifier.espressoNitroTEEVerifier())); + // By default, start with the TEE batcher active. + activeIsTee = true; _transferOwnership(_owner); } @@ -38,6 +58,11 @@ contract BatchAuthenticator is ISemver, Ownable { return nitroValidator.decodeAttestationTbs(attestation); } + /// @notice Toggles the active batcher between the TEE and non-TEE batcher. + function switchBatcher() external onlyOwner { + activeIsTee = !activeIsTee; + } + function authenticateBatchInfo(bytes32 commitment, bytes calldata _signature) external { // https://github.com/ethereum/go-ethereum/issues/19751#issuecomment-504900739 bytes memory signature = _signature; @@ -52,7 +77,7 @@ contract BatchAuthenticator is ISemver, Ownable { revert("Invalid signature"); } - if (!espressoTEEVerifier.espressoNitroTEEVerifier().registeredSigners(signer) && signer != preApprovedBatcher) { + if (!espressoTEEVerifier.espressoNitroTEEVerifier().registeredSigners(signer) && signer != teeBatcher) { revert("Invalid signer"); } diff --git a/packages/contracts-bedrock/src/L1/BatchInbox.sol b/packages/contracts-bedrock/src/L1/BatchInbox.sol index d9650326cdc..8c29b66cdaa 100644 --- a/packages/contracts-bedrock/src/L1/BatchInbox.sol +++ b/packages/contracts-bedrock/src/L1/BatchInbox.sol @@ -1,31 +1,58 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.28; +import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IBatchAuthenticator } from "interfaces/L1/IBatchAuthenticator.sol"; -contract BatchInbox { - IBatchAuthenticator immutable batchAuthenticator; +/// @title BatchInbox +/// @notice Receives batches from either a TEE batcher or a non-TEE batcher and enforces +/// that TEE batches are authenticated by the configured batch authenticator. +contract BatchInbox is Ownable { + /// @notice Address of the non-TEE (fallback) batcher. + address public immutable nonTeeBatcher; - constructor(IBatchAuthenticator _batchAuthenticator) { + /// @notice Contract responsible for authenticating TEE batch commitments. + IBatchAuthenticator public immutable batchAuthenticator; + + /// @notice Initializes the contract with the batch authenticator. + /// @param _batchAuthenticator Address of the batch authenticator contract. + constructor(IBatchAuthenticator _batchAuthenticator, address _owner) Ownable() { + address _nonTeeBatcher = _batchAuthenticator.nonTeeBatcher(); + nonTeeBatcher = _nonTeeBatcher; batchAuthenticator = _batchAuthenticator; + _transferOwnership(_owner); } + /// @notice Fallback entry point for batch submissions. + /// @dev Enforces that the caller matches the currently active batcher and, when + /// the TEE batcher is active, that the batch commitment is approved by + /// the batch authenticator. For non-TEE batches, only the caller check + /// is enforced. fallback() external { - if (blobhash(0) != 0) { - bytes memory concatenatedHashes = new bytes(0); - uint256 currentBlob = 0; - while (blobhash(currentBlob) != 0) { - concatenatedHashes = bytes.concat(concatenatedHashes, blobhash(currentBlob)); - currentBlob++; - } - bytes32 hash = keccak256(concatenatedHashes); - if (!batchAuthenticator.validBatchInfo(hash)) { - revert("Invalid blob batch"); + // TEE batchers require batch authentication + if (batchAuthenticator.activeIsTee()) { + if (blobhash(0) != 0) { + bytes memory concatenatedHashes = new bytes(0); + uint256 currentBlob = 0; + while (blobhash(currentBlob) != 0) { + concatenatedHashes = bytes.concat(concatenatedHashes, blobhash(currentBlob)); + currentBlob++; + } + bytes32 hash = keccak256(concatenatedHashes); + if (!batchAuthenticator.validBatchInfo(hash)) { + revert("Invalid blob batch"); + } + } else { + bytes32 hash = keccak256(msg.data); + if (!batchAuthenticator.validBatchInfo(hash)) { + revert("Invalid calldata batch"); + } } } else { - bytes32 hash = keccak256(msg.data); - if (!batchAuthenticator.validBatchInfo(hash)) { - revert("Invalid calldata batch"); + // Non TEE batcher require batcher address authentication + if (msg.sender != nonTeeBatcher) { + // For the non active TEE case, the batcher must be authenticated in the Inbox contract + revert("BatchInbox: unauthorized batcher"); } } } diff --git a/packages/contracts-bedrock/test/L1/BatchAuthenticator.t.sol b/packages/contracts-bedrock/test/L1/BatchAuthenticator.t.sol new file mode 100644 index 00000000000..16a26434830 --- /dev/null +++ b/packages/contracts-bedrock/test/L1/BatchAuthenticator.t.sol @@ -0,0 +1,163 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.28; + +// Testing +import { Test } from "forge-std/Test.sol"; + +// Contracts +import { BatchAuthenticator } from "src/L1/BatchAuthenticator.sol"; +import { IEspressoTEEVerifier } from "@espresso-tee-contracts/interface/IEspressoTEEVerifier.sol"; +import { IEspressoNitroTEEVerifier } from "@espresso-tee-contracts/interface/IEspressoNitroTEEVerifier.sol"; +import { IEspressoSGXTEEVerifier } from "@espresso-tee-contracts/interface/IEspressoSGXTEEVerifier.sol"; + +contract MockNitroTEEVerifier is IEspressoNitroTEEVerifier { + mapping(address => bool) private _registeredSigners; + + function registeredSigners(address signer) external view override returns (bool) { + return _registeredSigners[signer]; + } + + function registeredEnclaveHash(bytes32) external pure override returns (bool) { + return false; + } + + function registerSigner(bytes calldata, bytes calldata) external pure override { } + + function registerSignerWithoutAttestationVerification( + bytes32, + bytes calldata, + bytes calldata, + address + ) + external + pure + override + { } + + function verifyCACert(bytes calldata, bytes32) external pure override { } + + function verifyClientCert(bytes calldata, bytes32) external pure override { } + + function certVerified(bytes32) external pure override returns (bool) { + return false; + } + + function setEnclaveHash(bytes32, bool) external pure override { } + + function deleteRegisteredSigners(address[] memory) external pure override { } + + // Test helper + function setRegisteredSigner(address signer, bool value) external { + _registeredSigners[signer] = value; + } +} + +contract MockEspressoTEEVerifier is IEspressoTEEVerifier { + IEspressoNitroTEEVerifier public nitro; + IEspressoSGXTEEVerifier public sgx; + + constructor(IEspressoNitroTEEVerifier _nitro) { + nitro = _nitro; + sgx = IEspressoSGXTEEVerifier(address(0)); + } + + function espressoNitroTEEVerifier() external view override returns (IEspressoNitroTEEVerifier) { + return nitro; + } + + function espressoSGXTEEVerifier() external view override returns (IEspressoSGXTEEVerifier) { + return sgx; + } + + function verify(bytes memory, bytes32, TeeType) external pure override returns (bool) { + return true; + } + + function registerSigner(bytes calldata, bytes calldata, TeeType) external pure override { } + + function registeredSigners(address, TeeType) external pure override returns (bool) { + return false; + } + + function registeredEnclaveHashes(bytes32, TeeType) external pure override returns (bool) { + return false; + } + + function setEspressoSGXTEEVerifier(IEspressoSGXTEEVerifier _sgx) external override { + sgx = _sgx; + } + + function setEspressoNitroTEEVerifier(IEspressoNitroTEEVerifier _nitro) external override { + nitro = _nitro; + } +} + +/// @title BatchAuthenticator_SwitchBatcher_Test +/// @notice Tests ownership restrictions on BatchAuthenticator switchBatcher behavior +contract BatchAuthenticator_SwitchBatcher_Test is Test { + address public deployer = address(0xABCD); + address public unauthorized = address(0xDEAD); + + address public teeBatcher = address(0x1234); + address public nonTeeBatcher = address(0x5678); + + MockNitroTEEVerifier public nitroVerifier; + MockEspressoTEEVerifier public teeVerifier; + BatchAuthenticator public authenticator; + + function setUp() public { + nitroVerifier = new MockNitroTEEVerifier(); + teeVerifier = new MockEspressoTEEVerifier(nitroVerifier); + + vm.prank(deployer); + authenticator = + new BatchAuthenticator(IEspressoTEEVerifier(address(teeVerifier)), teeBatcher, nonTeeBatcher, deployer); + } + + /// @notice Test that only the owner can switch the active batcher + function test_switchBatcher_revertsForNonOwner() external { + // Owner can switch batcher successfully. + vm.startPrank(deployer); + bool initialIsTee = authenticator.activeIsTee(); + authenticator.switchBatcher(); + assertEq(authenticator.activeIsTee(), !initialIsTee, "owner should be able to switch batcher"); + vm.stopPrank(); + + // Non-owner cannot switch batcher. + vm.startPrank(unauthorized); + vm.expectRevert("Ownable: caller is not the owner"); + authenticator.switchBatcher(); + vm.stopPrank(); + } +} + +contract BatchAuthenticator_Constructor_Test is Test { + address public teeBatcher = address(0x1234); + address public nonTeeBatcher = address(0x5678); + address public owner = address(0xBEEF); + + MockNitroTEEVerifier public nitroVerifier; + MockEspressoTEEVerifier public teeVerifier; + + function setUp() public { + nitroVerifier = new MockNitroTEEVerifier(); + teeVerifier = new MockEspressoTEEVerifier(nitroVerifier); + } + + function test_constructor_revertsWhenTeeBatcherIsZero() external { + vm.expectRevert("BatchAuthenticator: zero tee batcher"); + new BatchAuthenticator(IEspressoTEEVerifier(address(teeVerifier)), address(0), nonTeeBatcher, owner); + } + + function test_constructor_revertsWhenNonTeeBatcherIsZero() external { + vm.expectRevert("BatchAuthenticator: zero non-tee batcher"); + new BatchAuthenticator(IEspressoTEEVerifier(address(teeVerifier)), teeBatcher, address(0), owner); + } + + function test_constructor_succeedsWithValidAddresses() external { + BatchAuthenticator authenticator = + new BatchAuthenticator(IEspressoTEEVerifier(address(teeVerifier)), teeBatcher, nonTeeBatcher, owner); + assertEq(authenticator.teeBatcher(), teeBatcher); + assertEq(authenticator.nonTeeBatcher(), nonTeeBatcher); + } +} diff --git a/packages/contracts-bedrock/test/L1/BatchInbox.t.sol b/packages/contracts-bedrock/test/L1/BatchInbox.t.sol new file mode 100644 index 00000000000..61b9d559dc2 --- /dev/null +++ b/packages/contracts-bedrock/test/L1/BatchInbox.t.sol @@ -0,0 +1,186 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.28; + +// Testing +import { Test } from "forge-std/Test.sol"; + +// Contracts +import { BatchInbox } from "src/L1/BatchInbox.sol"; +import { BatchAuthenticator } from "src/L1/BatchAuthenticator.sol"; +import { IBatchAuthenticator } from "interfaces/L1/IBatchAuthenticator.sol"; +import { IEspressoTEEVerifier } from "@espresso-tee-contracts/interface/IEspressoTEEVerifier.sol"; +import { MockNitroTEEVerifier, MockEspressoTEEVerifier } from "./BatchAuthenticator.t.sol"; + +contract TestBatchAuthenticator is BatchAuthenticator { + constructor( + IEspressoTEEVerifier _espressoTEEVerifier, + address _teeBatcher, + address _nonTeeBatcher, + address _owner + ) + BatchAuthenticator(_espressoTEEVerifier, _teeBatcher, _nonTeeBatcher, _owner) + { } + + // Test helper to bypass signature verification in authenticateBatchInfo. + function setValidBatchInfo(bytes32 hash, bool valid) external { + validBatchInfo[hash] = valid; + } +} + +/// @title BatchInbox_Test +/// @notice Base test contract with common setup +contract BatchInbox_Test is Test { + BatchInbox public inbox; + TestBatchAuthenticator public authenticator; + + MockNitroTEEVerifier public nitroVerifier; + MockEspressoTEEVerifier public teeVerifier; + + address public teeBatcher = address(0x1234); + address public nonTeeBatcher = address(0x5678); + address public deployer = address(0xABCD); + address public unauthorized = address(0xDEAD); + + function setUp() public virtual { + nitroVerifier = new MockNitroTEEVerifier(); + teeVerifier = new MockEspressoTEEVerifier(nitroVerifier); + + vm.prank(deployer); + authenticator = + new TestBatchAuthenticator(IEspressoTEEVerifier(address(teeVerifier)), teeBatcher, nonTeeBatcher, deployer); + + inbox = new BatchInbox(IBatchAuthenticator(address(authenticator)), deployer); + } +} + +/// @notice Minimal authenticator mock that returns a zero non-TEE batcher. +contract ConstructorMockBatchAuthenticatorZeroNonTee { + function nonTeeBatcher() external pure returns (address) { + return address(0); + } +} + +/// @notice Minimal authenticator mock that returns a configured non-TEE batcher. +contract ConstructorMockBatchAuthenticatorNonZero { + address public nonTeeBatcherValue; + + constructor(address _nonTeeBatcherValue) { + nonTeeBatcherValue = _nonTeeBatcherValue; + } + + function nonTeeBatcher() external view returns (address) { + return nonTeeBatcherValue; + } +} + +/// @title BatchInbox_Fallback_Test +/// @notice Tests for the fallback function +/// @dev Behavior matrix: +/// - When the TEE batcher is active (`activeIsTee == true`), any caller must provide +/// a previously authenticated batch commitment via `batchAuthenticator.validBatchInfo`. +/// - When the non-TEE batcher is active (`activeIsTee == false`), only `nonTeeBatcher` +/// may send batches and no additional authentication is required. +contract BatchInbox_Fallback_Test is BatchInbox_Test { + /// @notice Test that non-TEE batcher can post after switching + function test_fallback_nonTeeBatcherCanPostAfterSwitch() external { + // Switch to non-TEE batcher + vm.prank(deployer); + authenticator.switchBatcher(); + + // Non-TEE batcher should be able to post + vm.prank(nonTeeBatcher); + (bool success,) = address(inbox).call("hello"); + assertTrue(success, "Non-TEE batcher should be able to post"); + } + + /// @notice Test that inactive batcher reverts + function test_fallback_inactiveBatcherReverts() external { + // Switch to non-TEE batcher (making TEE batcher inactive) + vm.prank(deployer); + authenticator.switchBatcher(); + + // TEE batcher (now inactive) should revert + vm.prank(teeBatcher); + (bool success, bytes memory returnData) = address(inbox).call("unauthorized"); + assertFalse(success, "Should revert"); + // Check the revert reason + assertEq( + string(returnData), string(abi.encodeWithSignature("Error(string)", "BatchInbox: unauthorized batcher")) + ); + } + + /// @notice Test that TEE batcher requires authentication + function test_fallback_teeBatcherRequiresAuthentication() external { + // TEE batcher is active by default + bytes memory data = "needs-auth"; + bytes32 hash = keccak256(data); + + // Don't set the hash as valid in authenticator + authenticator.setValidBatchInfo(hash, false); + + // TEE batcher should revert due to invalid authentication + vm.prank(teeBatcher); + (bool success, bytes memory returnData) = address(inbox).call(data); + assertFalse(success, "Should revert"); + // Check the revert reason + assertEq(string(returnData), string(abi.encodeWithSignature("Error(string)", "Invalid calldata batch"))); + } + + /// @notice Test that TEE batcher succeeds with valid authentication + function test_fallback_teeBatcherSucceedsWithValidAuth() external { + // TEE batcher is active by default + bytes memory data = "valid-batch"; + bytes32 hash = keccak256(data); + + // Set the hash as valid in authenticator + authenticator.setValidBatchInfo(hash, true); + + // TEE batcher should succeed + vm.prank(teeBatcher); + (bool success,) = address(inbox).call(data); + assertTrue(success, "TEE batcher should succeed with valid auth"); + } + + /// @notice Test that non-TEE batcher doesn't require authentication + function test_fallback_nonTeeBatcherDoesNotRequireAuth() external { + // Switch to non-TEE batcher + vm.prank(deployer); + authenticator.switchBatcher(); + + bytes memory data = "no-auth-needed"; + bytes32 hash = keccak256(data); + authenticator.setValidBatchInfo(hash, false); + + // Non-TEE batcher should succeed without authentication + vm.prank(nonTeeBatcher); + (bool success,) = address(inbox).call(data); + assertTrue(success, "Non-TEE batcher should not require auth"); + } + + /// @notice Test that unauthorized address cannot post + function test_fallback_unauthorizedAddressReverts() external { + // Switch to non-TEE batcher. In this case the batch inbox should revert if the batcher is not authorized. + vm.prank(deployer); + authenticator.switchBatcher(); + vm.prank(unauthorized); + (bool success,) = address(inbox).call("unauthorized"); + assertFalse(success, "Unauthorized should revert when non-TEE is active"); + } + + /// @notice Test that non-TEE batcher is rejected while TEE batcher is active if batch is not authenticated + function test_fallback_nonTeeBatcherRevertsWhenTeeActiveAndUnauthenticated() external { + // By default, the TEE batcher is active (activeIsTee == true). + bytes memory data = "nontee-unauth"; + bytes32 hash = keccak256(data); + + // Ensure this batch is not marked as valid in the authenticator. + authenticator.setValidBatchInfo(hash, false); + + // Even though nonTeeBatcher is the configured non-TEE batcher, it must provide + // a previously authenticated batch when the TEE batcher is active. + vm.prank(nonTeeBatcher); + (bool success, bytes memory returnData) = address(inbox).call(data); + assertFalse(success, "Should revert when TEE is active and batch is not authenticated"); + assertEq(string(returnData), string(abi.encodeWithSignature("Error(string)", "Invalid calldata batch"))); + } +}