From 51bbb8437f71072157fb9d51eb4d65ccdcc45d56 Mon Sep 17 00:00:00 2001 From: Stefan Iliev <46542846+StefanIliev545@users.noreply.github.com> Date: Wed, 22 May 2024 12:28:06 +0300 Subject: [PATCH 01/11] Fix for interval. (#1926) (#1928) * Fix for interval. * Removed defaulting from guardian as there should already be a default value. * Made the fromSeqNo to be local. * Modify how the local cached seq no is set. * Add missing cfg option. * Another missing default value. --------- Co-authored-by: StefanIliev545 --- go/host/enclave/guardian.go | 20 +++++++++++-------- go/host/l1/publisher.go | 4 ---- integration/simulation/devnetwork/node.go | 1 + .../simulation/network/network_utils.go | 1 + 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/go/host/enclave/guardian.go b/go/host/enclave/guardian.go index 4c5840bbc9..7c472e2d94 100644 --- a/go/host/enclave/guardian.go +++ b/go/host/enclave/guardian.go @@ -629,15 +629,13 @@ func (g *Guardian) periodicRollupProduction() { func (g *Guardian) periodicBundleSubmission() { defer g.logger.Info("Stopping bundle submission") - // check rollup every l1 block time - - interval := g.rollupInterval - if interval == 0 { - interval = g.blockTime - } + interval := g.crossChainInterval + g.logger.Info("Starting cross chain bundle submission", "interval", interval) bundleSubmissionTicker := time.NewTicker(interval) + fromSequenceNumber := uint64(0) + for { select { case <-bundleSubmissionTicker.C: @@ -646,14 +644,20 @@ func (g *Guardian) periodicBundleSubmission() { g.logger.Error("Unable to get bundle range from management contract", log.ErrKey, err) continue } - bundle, err := g.enclaveClient.ExportCrossChainData(context.Background(), from.Uint64(), to.Uint64()) + + if from.Uint64() > fromSequenceNumber { + fromSequenceNumber = from.Uint64() + } + + bundle, err := g.enclaveClient.ExportCrossChainData(context.Background(), fromSequenceNumber, to.Uint64()) if err != nil { g.logger.Error("Unable to export cross chain bundle from enclave", log.ErrKey, err) continue } if len(bundle.CrossChainRootHashes) == 0 { - g.logger.Debug("No cross chain data to submit. Skipping.") + g.logger.Debug("No cross chain data to submit") + fromSequenceNumber = to.Uint64() + 1 continue } diff --git a/go/host/l1/publisher.go b/go/host/l1/publisher.go index 4c56d6761f..94d0ea8220 100644 --- a/go/host/l1/publisher.go +++ b/go/host/l1/publisher.go @@ -286,10 +286,6 @@ func (p *Publisher) PublishCrossChainBundle(bundle *common.ExtCrossChainBundle) return nil } - if len(bundle.CrossChainRootHashes) == 0 { - return fmt.Errorf("nothing to publish in cross chain bundle") - } - managementCtr, err := ManagementContract.NewManagementContract(*p.mgmtContractLib.GetContractAddr(), p.ethClient.EthClient()) if err != nil { p.logger.Error("Unable to instantiate management contract client") diff --git a/integration/simulation/devnetwork/node.go b/integration/simulation/devnetwork/node.go index 9258f50f21..2d6d1669d5 100644 --- a/integration/simulation/devnetwork/node.go +++ b/integration/simulation/devnetwork/node.go @@ -151,6 +151,7 @@ func (n *InMemNodeOperator) createHostContainer() *hostcontainer.HostContainer { BatchInterval: n.config.BatchInterval, RollupInterval: n.config.RollupInterval, L1BlockTime: n.config.L1BlockTime, + CrossChainInterval: n.config.CrossChainInterval, MaxRollupSize: 1024 * 64, } diff --git a/integration/simulation/network/network_utils.go b/integration/simulation/network/network_utils.go index 57ca8d2fd1..b760bb4176 100644 --- a/integration/simulation/network/network_utils.go +++ b/integration/simulation/network/network_utils.go @@ -73,6 +73,7 @@ func createInMemObscuroNode( ManagementContractAddress: *mgtContractAddress, MessageBusAddress: l1BusAddress, BatchInterval: batchInterval, + CrossChainInterval: config.DefaultHostParsedConfig().CrossChainInterval, IsInboundP2PDisabled: incomingP2PDisabled, L1BlockTime: l1BlockTime, UseInMemoryDB: true, From d5f686d10eb6ac699289c960fa4037884ab10bdd Mon Sep 17 00:00:00 2001 From: Stefan Iliev <46542846+StefanIliev545@users.noreply.github.com> Date: Fri, 24 May 2024 11:07:11 +0300 Subject: [PATCH 02/11] Fixing log spam. (#1931) (#1933) Co-authored-by: StefanIliev545 --- go/common/errutil/errors_util.go | 3 ++- go/enclave/nodetype/common.go | 4 ++-- go/host/enclave/guardian.go | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/go/common/errutil/errors_util.go b/go/common/errutil/errors_util.go index 62823f6f46..2e72aeb154 100644 --- a/go/common/errutil/errors_util.go +++ b/go/common/errutil/errors_util.go @@ -23,7 +23,8 @@ var ( ErrBlockAncestorNotFound = errors.New("block ancestor not found") ErrBlockForBatchNotFound = errors.New("block for batch not found") ErrAncestorBatchNotFound = errors.New("parent for batch not found") - ErrCrossChainBundleRepublished = errors.New("Root already added to the message bus") + ErrCrossChainBundleRepublished = errors.New("root already added to the message bus") + ErrCrossChainBundleNoBatches = errors.New("no batches for cross chain bundle") ) // BlockRejectError is used as a standard format for error response from enclave for block submission errors diff --git a/go/enclave/nodetype/common.go b/go/enclave/nodetype/common.go index c9a28978b4..197fef08d1 100644 --- a/go/enclave/nodetype/common.go +++ b/go/enclave/nodetype/common.go @@ -2,11 +2,11 @@ package nodetype import ( "context" - "fmt" "math/big" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ten-protocol/go-ten/go/common" + "github.com/ten-protocol/go-ten/go/common/errutil" "github.com/ten-protocol/go-ten/go/enclave/storage" ) @@ -17,7 +17,7 @@ func ExportCrossChainData(ctx context.Context, storage storage.Storage, fromSeqN } if len(canonicalBatches) == 0 { - return nil, fmt.Errorf("no batches found for export of cross chain data") + return nil, errutil.ErrCrossChainBundleNoBatches } blockHash := canonicalBatches[len(canonicalBatches)-1].Header.L1Proof diff --git a/go/host/enclave/guardian.go b/go/host/enclave/guardian.go index 7c472e2d94..2c6d6a6a36 100644 --- a/go/host/enclave/guardian.go +++ b/go/host/enclave/guardian.go @@ -651,7 +651,9 @@ func (g *Guardian) periodicBundleSubmission() { bundle, err := g.enclaveClient.ExportCrossChainData(context.Background(), fromSequenceNumber, to.Uint64()) if err != nil { - g.logger.Error("Unable to export cross chain bundle from enclave", log.ErrKey, err) + if !errors.Is(err, errutil.ErrCrossChainBundleNoBatches) { + g.logger.Error("Unable to export cross chain bundle from enclave", log.ErrKey, err) + } continue } From 7bcba610e138fbf5267e05ffa4041bcfeff81891 Mon Sep 17 00:00:00 2001 From: Matt <98158711+BedrockSquirrel@users.noreply.github.com> Date: Fri, 24 May 2024 10:52:03 +0100 Subject: [PATCH 03/11] Gateway: add net_version support and test (#1934) (#1935) --- go/enclave/components/batch_executor.go | 2 +- go/enclave/crosschain/common.go | 2 +- go/enclave/genesis/testnet_genesis.go | 6 ++-- go/enclave/nodetype/common.go | 2 +- go/enclave/nodetype/sequencer.go | 1 + .../networktest/tests/gateway/gateway_test.go | 31 +++++++++++++++++++ integration/networktest/userwallet/gateway.go | 4 +++ tools/walletextension/rpcapi/net_api.go | 17 ++++++++++ .../walletextension_container.go | 3 ++ 9 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 tools/walletextension/rpcapi/net_api.go diff --git a/go/enclave/components/batch_executor.go b/go/enclave/components/batch_executor.go index 77aae4e75f..cfead4334b 100644 --- a/go/enclave/components/batch_executor.go +++ b/go/enclave/components/batch_executor.go @@ -379,7 +379,7 @@ func (executor *batchExecutor) populateOutboundCrossChainData(ctx context.Contex encodedTree, err := json.Marshal(xchainTree) if err != nil { - panic(err) //todo: figure out what to do + panic(err) // todo: figure out what to do } batch.Header.CrossChainTree = encodedTree diff --git a/go/enclave/crosschain/common.go b/go/enclave/crosschain/common.go index b6ee881c89..1d64083dbb 100644 --- a/go/enclave/crosschain/common.go +++ b/go/enclave/crosschain/common.go @@ -234,7 +234,7 @@ func (ms MessageStructs) HashPacked(index int) gethcommon.Hash { }, } - //todo @siliev: err + // todo @siliev: err packed, _ := args.Pack(messageStruct.Sender, messageStruct.Sequence, messageStruct.Nonce, messageStruct.Topic, messageStruct.Payload, messageStruct.ConsistencyLevel) hash := crypto.Keccak256Hash(packed) return hash diff --git a/go/enclave/genesis/testnet_genesis.go b/go/enclave/genesis/testnet_genesis.go index 49b48c16ca..fed93c6f0d 100644 --- a/go/enclave/genesis/testnet_genesis.go +++ b/go/enclave/genesis/testnet_genesis.go @@ -9,8 +9,10 @@ import ( ) const TestnetPrefundedPK = "8dfb8083da6275ae3e4f41e3e8a8c19d028d32c9247e24530933782f2a05035b" // The genesis main account private key. -var GasBridgingKeys, _ = crypto.GenerateKey() // todo - make static -var GasWithdrawalKeys, _ = crypto.GenerateKey() // todo - make static +var ( + GasBridgingKeys, _ = crypto.GenerateKey() // todo - make static + GasWithdrawalKeys, _ = crypto.GenerateKey() // todo - make static +) var TestnetGenesis = Genesis{ Accounts: []Account{ diff --git a/go/enclave/nodetype/common.go b/go/enclave/nodetype/common.go index 197fef08d1..a99dc0f690 100644 --- a/go/enclave/nodetype/common.go +++ b/go/enclave/nodetype/common.go @@ -40,6 +40,6 @@ func ExportCrossChainData(ctx context.Context, storage storage.Storage, fromSeqN L1BlockHash: block.Hash(), L1BlockNum: big.NewInt(0).Set(block.Header().Number), CrossChainRootHashes: crossChainHashes, - } //todo: check fromSeqNo + } // todo: check fromSeqNo return bundle, nil } diff --git a/go/enclave/nodetype/sequencer.go b/go/enclave/nodetype/sequencer.go index a0283c2312..16e5117590 100644 --- a/go/enclave/nodetype/sequencer.go +++ b/go/enclave/nodetype/sequencer.go @@ -468,6 +468,7 @@ func (s *sequencer) signCrossChainBundle(bundle *common.ExtCrossChainBundle) err } return nil } + func (s *sequencer) OnL1Block(ctx context.Context, block *types.Block, result *components.BlockIngestionType) error { // nothing to do return nil diff --git a/integration/networktest/tests/gateway/gateway_test.go b/integration/networktest/tests/gateway/gateway_test.go index eb8d5e9c13..6a2bc1985d 100644 --- a/integration/networktest/tests/gateway/gateway_test.go +++ b/integration/networktest/tests/gateway/gateway_test.go @@ -1,12 +1,15 @@ package gateway import ( + "context" + "fmt" "math/big" "testing" "github.com/ten-protocol/go-ten/integration/networktest" "github.com/ten-protocol/go-ten/integration/networktest/actions" "github.com/ten-protocol/go-ten/integration/networktest/env" + "github.com/ten-protocol/go-ten/integration/networktest/userwallet" "github.com/ten-protocol/go-ten/integration/simulation/devnetwork" ) @@ -37,6 +40,34 @@ func TestGatewayHappyPath(t *testing.T) { &actions.VerifyBalanceAfterTest{UserID: 1, ExpectedBalance: _transferAmount}, &actions.VerifyBalanceDiffAfterTest{UserID: 0, Snapshot: actions.SnapAfterAllocation, ExpectedDiff: big.NewInt(0).Neg(_transferAmount)}, + + // test net_version works through the gateway + actions.VerifyOnlyAction(func(ctx context.Context, network networktest.NetworkConnector) error { + user, err := actions.FetchTestUser(ctx, 0) + if err != nil { + return err + } + // verify user is a gateway user + gwUser, ok := user.(*userwallet.GatewayUser) + if !ok { + return fmt.Errorf("user is not a gateway user") + } + ethClient := gwUser.Client() + rpcClient := ethClient.Client() + // check net_version response + var result string + err = rpcClient.CallContext(ctx, &result, "net_version") + if err != nil { + return fmt.Errorf("failed to get net_version: %w", err) + } + fmt.Println("net_version response:", result) + expectedResult := "443" + if result != expectedResult { + return fmt.Errorf("expected net_version to be %s but got %s", expectedResult, result) + } + + return nil + }), ), ) } diff --git a/integration/networktest/userwallet/gateway.go b/integration/networktest/userwallet/gateway.go index 03fa361a9d..9408c4c06c 100644 --- a/integration/networktest/userwallet/gateway.go +++ b/integration/networktest/userwallet/gateway.go @@ -114,6 +114,10 @@ func (g *GatewayUser) Wallet() wallet.Wallet { return g.wal } +func (g *GatewayUser) Client() *ethclient.Client { + return g.client +} + func (g *GatewayUser) WSClient() (*ethclient.Client, error) { if g.wsClient == nil { var err error diff --git a/tools/walletextension/rpcapi/net_api.go b/tools/walletextension/rpcapi/net_api.go new file mode 100644 index 0000000000..855c5b7a42 --- /dev/null +++ b/tools/walletextension/rpcapi/net_api.go @@ -0,0 +1,17 @@ +package rpcapi + +import ( + "context" +) + +type NetAPI struct { + we *Services +} + +func NewNetAPI(we *Services) *NetAPI { + return &NetAPI{we} +} + +func (api *NetAPI) Version(ctx context.Context) (*string, error) { + return UnauthenticatedTenRPCCall[string](ctx, api.we, &CacheCfg{CacheType: LongLiving}, "net_version") +} diff --git a/tools/walletextension/walletextension_container.go b/tools/walletextension/walletextension_container.go index 084044af54..96e322b08c 100644 --- a/tools/walletextension/walletextension_container.go +++ b/tools/walletextension/walletextension_container.go @@ -83,6 +83,9 @@ func NewContainerFromConfig(config wecommon.Config, logger gethlog.Logger) *Cont }, { Namespace: "eth", Service: rpcapi.NewFilterAPI(walletExt), + }, { + Namespace: "net", + Service: rpcapi.NewNetAPI(walletExt), }, }) From 9dab2341b3ab41180fb9225585c66f4d11389411 Mon Sep 17 00:00:00 2001 From: Matt Curtis Date: Fri, 24 May 2024 12:19:11 +0100 Subject: [PATCH 04/11] Gateway: hardcode response to clientVersion request --- .../networktest/tests/gateway/gateway_test.go | 11 ++++++++++ tools/walletextension/rpcapi/web3_api.go | 20 +++++++++++++++++++ .../walletextension_container.go | 3 +++ 3 files changed, 34 insertions(+) create mode 100644 tools/walletextension/rpcapi/web3_api.go diff --git a/integration/networktest/tests/gateway/gateway_test.go b/integration/networktest/tests/gateway/gateway_test.go index 6a2bc1985d..f919db84d9 100644 --- a/integration/networktest/tests/gateway/gateway_test.go +++ b/integration/networktest/tests/gateway/gateway_test.go @@ -66,6 +66,17 @@ func TestGatewayHappyPath(t *testing.T) { return fmt.Errorf("expected net_version to be %s but got %s", expectedResult, result) } + // check web3_clientVersion response + var cvResult string + err = rpcClient.CallContext(ctx, &cvResult, "web3_clientVersion") + if err != nil { + return fmt.Errorf("failed to get web3_clientVersion: %w", err) + } + fmt.Println("web3_clientVersion response:", cvResult) + if cvResult == "" { + return fmt.Errorf("expected web3_clientVersion to be non-empty") + } + return nil }), ), diff --git a/tools/walletextension/rpcapi/web3_api.go b/tools/walletextension/rpcapi/web3_api.go new file mode 100644 index 0000000000..4794e6fd0e --- /dev/null +++ b/tools/walletextension/rpcapi/web3_api.go @@ -0,0 +1,20 @@ +package rpcapi + +import ( + "context" +) + +var _hardcodedClientVersion = "Geth/v10.0.0/drpc" + +type Web3API struct { + we *Services +} + +func NewWeb3API(we *Services) *Web3API { + return &Web3API{we} +} + +func (api *Web3API) ClientVersion(_ context.Context) (*string, error) { + // todo: have this return the Ten version from the node + return &_hardcodedClientVersion, nil +} diff --git a/tools/walletextension/walletextension_container.go b/tools/walletextension/walletextension_container.go index 96e322b08c..f5bf5d36f7 100644 --- a/tools/walletextension/walletextension_container.go +++ b/tools/walletextension/walletextension_container.go @@ -86,6 +86,9 @@ func NewContainerFromConfig(config wecommon.Config, logger gethlog.Logger) *Cont }, { Namespace: "net", Service: rpcapi.NewNetAPI(walletExt), + }, { + Namespace: "web3", + Service: rpcapi.NewWeb3API(walletExt), }, }) From 0953ba8009f5e780f13686c1e2d3a631115962e3 Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Tue, 28 May 2024 12:16:39 +0100 Subject: [PATCH 05/11] replace health-check db query (#1938) (cherry picked from commit 1daffac0341ea9935049d1e5d3a0d80730293c09) --- go/enclave/storage/storage.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/go/enclave/storage/storage.go b/go/enclave/storage/storage.go index 70d9b09ba4..a0f16b73a4 100644 --- a/go/enclave/storage/storage.go +++ b/go/enclave/storage/storage.go @@ -339,13 +339,13 @@ func (s *storageImpl) IsBlockAncestor(ctx context.Context, block *types.Block, m func (s *storageImpl) HealthCheck(ctx context.Context) (bool, error) { defer s.logDuration("HealthCheck", measure.NewStopwatch()) - headBatch, err := s.FetchHeadBatch(ctx) + seqNo, err := s.FetchCurrentSequencerNo(ctx) if err != nil { return false, err } - if headBatch == nil { - return false, fmt.Errorf("head batch is nil") + if seqNo == nil { + return false, fmt.Errorf("no batches are stored") } return true, nil From 1562e9898b9660e06955c9f18965e6ba4b100eef Mon Sep 17 00:00:00 2001 From: Matt <98158711+BedrockSquirrel@users.noreply.github.com> Date: Thu, 30 May 2024 17:07:11 +0100 Subject: [PATCH 06/11] Enclave: fix panic on uninitialised mempool (#1940) --- go/enclave/txpool/txpool.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/go/enclave/txpool/txpool.go b/go/enclave/txpool/txpool.go index 8653d9626f..6deca4a1a4 100644 --- a/go/enclave/txpool/txpool.go +++ b/go/enclave/txpool/txpool.go @@ -51,7 +51,7 @@ func NewTxPool(blockchain *ethchainadapter.EthChainAdapter, gasTip *big.Int, log // Start starts the pool // can only be started after t.blockchain has at least one block inside func (t *TxPool) Start() error { - if t.pool != nil { + if t.running { return fmt.Errorf("tx pool already started") } @@ -75,6 +75,9 @@ func (t *TxPool) PendingTransactions() map[gethcommon.Address][]*gethtxpool.Lazy // Add adds a new transactions to the pool func (t *TxPool) Add(transaction *common.L2Tx) error { + if !t.running { + return fmt.Errorf("tx pool not running") + } var strErrors []string for _, err := range t.pool.Add([]*types.Transaction{transaction}, false, false) { if err != nil { From 5e69e506fbf1a42bb525a090ed540c8a116baa04 Mon Sep 17 00:00:00 2001 From: Matt <98158711+BedrockSquirrel@users.noreply.github.com> Date: Fri, 31 May 2024 11:09:38 +0100 Subject: [PATCH 07/11] Host: avoid spamming stuck L1 transactions (#1941) --- go/ethadapter/geth_rpc_client.go | 14 ++++++-------- go/ethadapter/interface.go | 2 +- go/host/l1/publisher.go | 9 ++++++++- integration/ethereummock/node.go | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/go/ethadapter/geth_rpc_client.go b/go/ethadapter/geth_rpc_client.go index 17745cd903..983ab08877 100644 --- a/go/ethadapter/geth_rpc_client.go +++ b/go/ethadapter/geth_rpc_client.go @@ -246,12 +246,16 @@ func (e *gethRPCClient) FetchLastBatchSeqNo(address gethcommon.Address) (*big.In // PrepareTransactionToSend takes a txData type and overrides the From, Gas and Gas Price field with current values func (e *gethRPCClient) PrepareTransactionToSend(ctx context.Context, txData types.TxData, from gethcommon.Address) (types.TxData, error) { - return e.PrepareTransactionToRetry(ctx, txData, from, 0) + nonce, err := e.EthClient().PendingNonceAt(ctx, from) + if err != nil { + return nil, fmt.Errorf("could not get nonce - %w", err) + } + return e.PrepareTransactionToRetry(ctx, txData, from, nonce, 0) } // PrepareTransactionToRetry takes a txData type and overrides the From, Gas and Gas Price field with current values // it bumps the price by a multiplier for retries. retryNumber is zero on first attempt (no multiplier on price) -func (e *gethRPCClient) PrepareTransactionToRetry(ctx context.Context, txData types.TxData, from gethcommon.Address, retryNumber int) (types.TxData, error) { +func (e *gethRPCClient) PrepareTransactionToRetry(ctx context.Context, txData types.TxData, from gethcommon.Address, nonce uint64, retryNumber int) (types.TxData, error) { unEstimatedTx := types.NewTx(txData) gasPrice, err := e.EthClient().SuggestGasPrice(ctx) if err != nil { @@ -279,12 +283,6 @@ func (e *gethRPCClient) PrepareTransactionToRetry(ctx context.Context, txData ty return nil, fmt.Errorf("could not estimate gas - %w", err) } - // we fetch the current nonce on every retry to avoid any risk of nonce reuse/conflicts - nonce, err := e.EthClient().PendingNonceAt(ctx, from) - if err != nil { - return nil, fmt.Errorf("could not fetch nonce - %w", err) - } - return &types.LegacyTx{ Nonce: nonce, GasPrice: retryPrice, diff --git a/go/ethadapter/interface.go b/go/ethadapter/interface.go index 281f1e6abf..31a1071869 100644 --- a/go/ethadapter/interface.go +++ b/go/ethadapter/interface.go @@ -35,7 +35,7 @@ type EthClient interface { // PrepareTransactionToSend updates the tx with from address, current nonce and current estimates for the gas and the gas price PrepareTransactionToSend(ctx context.Context, txData types.TxData, from gethcommon.Address) (types.TxData, error) - PrepareTransactionToRetry(ctx context.Context, txData types.TxData, from gethcommon.Address, retries int) (types.TxData, error) + PrepareTransactionToRetry(ctx context.Context, txData types.TxData, from gethcommon.Address, nonce uint64, retries int) (types.TxData, error) FetchLastBatchSeqNo(address gethcommon.Address) (*big.Int, error) diff --git a/go/host/l1/publisher.go b/go/host/l1/publisher.go index 94d0ea8220..5971f92bda 100644 --- a/go/host/l1/publisher.go +++ b/go/host/l1/publisher.go @@ -391,12 +391,19 @@ func (p *Publisher) publishTransaction(tx types.TxData) error { retries := -1 + // we keep trying to send the transaction with this nonce until it is included in a block + // note: this is only safe because of the sendingLock guaranteeing only one transaction in-flight at a time + nonce, err := p.ethClient.Nonce(p.hostWallet.Address()) + if err != nil { + return fmt.Errorf("could not get nonce for L1 tx: %w", err) + } + // while the publisher service is still alive we keep trying to get the transaction into the L1 for !p.hostStopper.IsStopping() { retries++ // count each attempt so we can increase gas price // update the tx gas price before each attempt - tx, err := p.ethClient.PrepareTransactionToRetry(p.sendingContext, tx, p.hostWallet.Address(), retries) + tx, err := p.ethClient.PrepareTransactionToRetry(p.sendingContext, tx, p.hostWallet.Address(), nonce, retries) if err != nil { return errors.Wrap(err, "could not estimate gas/gas price for L1 tx") } diff --git a/integration/ethereummock/node.go b/integration/ethereummock/node.go index cb41bac416..669c2de5c1 100644 --- a/integration/ethereummock/node.go +++ b/integration/ethereummock/node.go @@ -99,7 +99,7 @@ func (m *Node) PrepareTransactionToSend(_ context.Context, txData types.TxData, }, nil } -func (m *Node) PrepareTransactionToRetry(ctx context.Context, txData types.TxData, from gethcommon.Address, _ int) (types.TxData, error) { +func (m *Node) PrepareTransactionToRetry(ctx context.Context, txData types.TxData, from gethcommon.Address, _ uint64, _ int) (types.TxData, error) { return m.PrepareTransactionToSend(ctx, txData, from) } From f8780435426388a545992fcbb26220fa87bbb510 Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Tue, 4 Jun 2024 14:37:23 +0100 Subject: [PATCH 08/11] disable xchain message submission (#1945) --- go/host/enclave/guardian.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/host/enclave/guardian.go b/go/host/enclave/guardian.go index 2c6d6a6a36..8ff5ead9ff 100644 --- a/go/host/enclave/guardian.go +++ b/go/host/enclave/guardian.go @@ -123,7 +123,7 @@ func (g *Guardian) Start() error { // Note: after HA work this will need additional check that we are the **active** sequencer enclave go g.periodicBatchProduction() go g.periodicRollupProduction() - go g.periodicBundleSubmission() + //go g.periodicBundleSubmission() } // subscribe for L1 and P2P data From 27bf2e3592204228cfeb922bbb0d41ed6d7130d4 Mon Sep 17 00:00:00 2001 From: Matt <98158711+BedrockSquirrel@users.noreply.github.com> Date: Fri, 7 Jun 2024 12:08:20 +0100 Subject: [PATCH 09/11] Host: ignore empty L1 head status from enclave (#1955) --- go/host/enclave/state.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/go/host/enclave/state.go b/go/host/enclave/state.go index 3af6066278..135da41089 100644 --- a/go/host/enclave/state.go +++ b/go/host/enclave/state.go @@ -120,7 +120,10 @@ func (s *StateTracker) OnEnclaveStatus(es common.Status) { s.m.Lock() defer s.m.Unlock() s.enclaveStatusCode = es.StatusCode - s.enclaveL1Head = es.L1Head + // only update L1 head if non-empty head reported + if es.L1Head != gethutil.EmptyHash { + s.enclaveL1Head = es.L1Head + } s.enclaveL2Head = es.L2Head s.setStatus(s.calculateStatus()) From 52f2d3174df0999417effe9d7dd962bc462c3a97 Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Fri, 7 Jun 2024 15:49:51 +0100 Subject: [PATCH 10/11] rewrite update --- go/enclave/storage/enclavedb/block.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/enclave/storage/enclavedb/block.go b/go/enclave/storage/enclavedb/block.go index c88722a010..52009c873e 100644 --- a/go/enclave/storage/enclavedb/block.go +++ b/go/enclave/storage/enclavedb/block.go @@ -62,7 +62,7 @@ func updateCanonicalValue(ctx context.Context, dbtx *sql.Tx, isCanonical bool, b return err } - updateBatches := "update batch set is_canonical=? where l1_proof in (select id from block where " + currentBlocks + ")" + updateBatches := "update batch set is_canonical=? where " + repeat(" l1_proof_hash=? ", "OR", len(blocks)) _, err = dbtx.ExecContext(ctx, updateBatches, args...) if err != nil { return err From 131b09e04201b64c41bfae58b38cf5948f455d61 Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Thu, 13 Jun 2024 12:19:37 +0100 Subject: [PATCH 11/11] bump enclave heap --- go/enclave/main/enclave-test.json | 2 +- go/enclave/main/enclave.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go/enclave/main/enclave-test.json b/go/enclave/main/enclave-test.json index 260daa7724..8a36ed301c 100644 --- a/go/enclave/main/enclave-test.json +++ b/go/enclave/main/enclave-test.json @@ -2,7 +2,7 @@ "exe": "main", "key": "testnet.pem", "debug": true, - "heapSize": 4096, + "heapSize": 8192, "executableHeap": true, "productID": 1, "securityVersion": 1, diff --git a/go/enclave/main/enclave.json b/go/enclave/main/enclave.json index 7919f528d9..b0cd13b7e2 100644 --- a/go/enclave/main/enclave.json +++ b/go/enclave/main/enclave.json @@ -2,7 +2,7 @@ "exe": "main", "key": "testnet.pem", "debug": true, - "heapSize": 4096, + "heapSize": 8192, "executableHeap": true, "productID": 1, "securityVersion": 1,