diff --git a/go/enclave/components/blob_resolver.go b/go/enclave/components/blob_resolver.go index c733b9f40c..ead96a0447 100644 --- a/go/enclave/components/blob_resolver.go +++ b/go/enclave/components/blob_resolver.go @@ -3,6 +3,7 @@ package components import ( "context" "fmt" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto/kzg4844" diff --git a/go/enclave/components/interfaces.go b/go/enclave/components/interfaces.go index 40d55dfa03..1921b374bb 100644 --- a/go/enclave/components/interfaces.go +++ b/go/enclave/components/interfaces.go @@ -3,9 +3,10 @@ package components import ( "context" "errors" + "math/big" + "github.com/ethereum/go-ethereum/crypto/kzg4844" "github.com/ten-protocol/go-ten/go/ethadapter" - "math/big" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" diff --git a/go/enclave/components/rollup_consumer.go b/go/enclave/components/rollup_consumer.go index 7a48c1fde8..2ba710d317 100644 --- a/go/enclave/components/rollup_consumer.go +++ b/go/enclave/components/rollup_consumer.go @@ -3,6 +3,7 @@ package components import ( "context" "fmt" + "github.com/ten-protocol/go-ten/go/enclave/core" "github.com/ten-protocol/go-ten/go/enclave/storage" "github.com/ten-protocol/go-ten/go/ethadapter" diff --git a/go/enclave/enclave.go b/go/enclave/enclave.go index 4caaa3f410..b6a16fe82b 100644 --- a/go/enclave/enclave.go +++ b/go/enclave/enclave.go @@ -5,12 +5,13 @@ import ( "encoding/json" "errors" "fmt" - "github.com/ten-protocol/go-ten/go/ethadapter" "math/big" "net/http" "sync" "time" + "github.com/ten-protocol/go-ten/go/ethadapter" + "github.com/ten-protocol/go-ten/go/common/compression" "github.com/ten-protocol/go-ten/go/common/measure" "github.com/ten-protocol/go-ten/go/enclave/evm/ethchainadapter" @@ -172,10 +173,10 @@ func NewEnclave( gasOracle := gas.NewGasOracle() blockProcessor := components.NewBlockProcessor(storage, crossChainProcessors, gasOracle, logger) registry := components.NewBatchRegistry(storage, logger) - //FIXME put in config - //baseURL := "http://localhost:3500" + // FIXME put in config + // baseURL := "http://localhost:3500" baseURL := "http://localhost:16560" - //baseURL := "https://sepolia-beacon.chainstacklabs.com" + // baseURL := "https://sepolia-beacon.chainstacklabs.com" blobResolver := components.NewBeaconBlobResolver(ethadapter.NewL1BeaconClient(ethadapter.NewBeaconHTTPClient(new(http.Client), baseURL))) batchExecutor := components.NewBatchExecutor(storage, registry, *config, gethEncodingService, crossChainProcessors, genesis, gasOracle, chainConfig, config.GasBatchExecutionLimit, logger) sigVerifier, err := components.NewSignatureValidator(storage) diff --git a/go/enclave/nodetype/common.go b/go/enclave/nodetype/common.go index bff4a94447..c414f63c81 100644 --- a/go/enclave/nodetype/common.go +++ b/go/enclave/nodetype/common.go @@ -20,7 +20,7 @@ func ExportCrossChainData(ctx context.Context, storage storage.Storage, fromSeqN return nil, errutil.ErrCrossChainBundleNoBatches } - //todo - siliev - all those fetches need to be atomic + // todo - siliev - all those fetches need to be atomic header, err := storage.FetchHeadBatchHeader(ctx) if err != nil { return nil, err diff --git a/go/ethadapter/beacon_client.go b/go/ethadapter/beacon_client.go index 9b4095f556..542b0aeb20 100644 --- a/go/ethadapter/beacon_client.go +++ b/go/ethadapter/beacon_client.go @@ -5,7 +5,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/ethereum/go-ethereum/core/types" "io" "net/http" "net/url" @@ -13,6 +12,8 @@ import ( "strconv" "sync" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/crypto/kzg4844" ) @@ -129,7 +130,6 @@ func (bc *BeaconHTTPClient) BeaconBlobSideCars(ctx context.Context, slot uint64, var resp APIGetBlobSidecarsResponse err := bc.request(ctx, &resp, reqPath, reqQuery) - if err != nil { return APIGetBlobSidecarsResponse{}, err } @@ -170,7 +170,8 @@ func NewL1BeaconClient(cl BeaconClient, fallbacks ...BlobSideCarsFetcher) *L1Bea cs := append([]BlobSideCarsFetcher{cl}, fallbacks...) return &L1BeaconClient{ cl: cl, - pool: NewClientPool[BlobSideCarsFetcher](cs...)} + pool: NewClientPool[BlobSideCarsFetcher](cs...), + } } type TimeToSlotFn func(timestamp uint64) (uint64, error) diff --git a/go/ethadapter/beacon_client_test.go b/go/ethadapter/beacon_client_test.go index c170635f7c..fad4294653 100644 --- a/go/ethadapter/beacon_client_test.go +++ b/go/ethadapter/beacon_client_test.go @@ -1,12 +1,13 @@ package ethadapter import ( + "math/big" + "testing" + "github.com/ethereum/go-ethereum/crypto/kzg4844" "github.com/ethereum/go-ethereum/params" "github.com/stretchr/testify/require" "github.com/ten-protocol/go-ten/go/common" - "math/big" - "testing" ) const spareBlobBits = 6 // = math.floor(math.log2(BLS_MODULUS)) % 8 @@ -77,6 +78,7 @@ func TestClientPoolSingle(t *testing.T) { p.MoveToNext() } } + func TestClientPoolSeveral(t *testing.T) { p := NewClientPool[int](0, 1, 2, 3) for i := 0; i < 25; i++ { diff --git a/go/ethadapter/blob.go b/go/ethadapter/blob.go index 8c0a3ab628..2cc1df504e 100644 --- a/go/ethadapter/blob.go +++ b/go/ethadapter/blob.go @@ -3,6 +3,7 @@ package ethadapter import ( "bytes" "fmt" + gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto/kzg4844" "github.com/ethereum/go-ethereum/params" diff --git a/go/ethadapter/blob_api.go b/go/ethadapter/blob_api.go index 88b145cdba..605150caac 100644 --- a/go/ethadapter/blob_api.go +++ b/go/ethadapter/blob_api.go @@ -3,11 +3,12 @@ package ethadapter import ( "crypto/sha256" "fmt" + "reflect" + "strconv" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto/kzg4844" - "reflect" - "strconv" ) type BlobSidecar struct { diff --git a/go/ethadapter/geth_rpc_client.go b/go/ethadapter/geth_rpc_client.go index 6b9c0a8923..16a9985e91 100644 --- a/go/ethadapter/geth_rpc_client.go +++ b/go/ethadapter/geth_rpc_client.go @@ -4,13 +4,14 @@ import ( "bytes" "context" "fmt" - "github.com/ethereum/go-ethereum/consensus/misc/eip4844" - "github.com/ethereum/go-ethereum/params" - "github.com/holiman/uint256" "math" "math/big" "time" + "github.com/ethereum/go-ethereum/consensus/misc/eip4844" + "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" gethcommon "github.com/ethereum/go-ethereum/common" @@ -35,10 +36,8 @@ const ( ) -var ( - // geth enforces a 1 gwei minimum for blob tx fee - minBlobTxFee = big.NewInt(params.GWei) -) +// geth enforces a 1 gwei minimum for blob tx fee +var minBlobTxFee = big.NewInt(params.GWei) // gethRPCClient implements the EthClient interface and allows connection to a real ethereum node type gethRPCClient struct { diff --git a/go/ethadapter/mgmtcontractlib/mgmt_contract_lib.go b/go/ethadapter/mgmtcontractlib/mgmt_contract_lib.go index dd116767de..57e5f50bd3 100644 --- a/go/ethadapter/mgmtcontractlib/mgmt_contract_lib.go +++ b/go/ethadapter/mgmtcontractlib/mgmt_contract_lib.go @@ -3,10 +3,11 @@ package mgmtcontractlib import ( "encoding/base64" "fmt" - "github.com/ethereum/go-ethereum/crypto/kzg4844" "math/big" "strings" + "github.com/ethereum/go-ethereum/crypto/kzg4844" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/core/types" @@ -177,7 +178,7 @@ func (c *contractLibImpl) CreateBlobRollup(t *ethadapter.L1RollupTx) (types.TxDa panic(err) } - //TODO handle when blobs exceed 1Mb + // TODO handle when blobs exceed 1Mb blobs, err := ethadapter.EncodeBlobs(t.Rollup) if err != nil { return nil, fmt.Errorf("failed to encode rollup to blobs: %w", err) diff --git a/go/host/enclave/guardian.go b/go/host/enclave/guardian.go index a3b1097895..4a9895b248 100644 --- a/go/host/enclave/guardian.go +++ b/go/host/enclave/guardian.go @@ -624,9 +624,9 @@ func (g *Guardian) periodicRollupProduction() { g.logger.Error("Unable to create rollup", log.BatchSeqNoKey, fromBatch, log.ErrKey, err) continue } - //println("PRODUCED ROLLUP: ", producedRollup.Hash().Hex()) - //println("PRODUCED timeExpired: ", timeExpired) - //println("PRODUCED sizeExceeded: ", sizeExceeded) + // println("PRODUCED ROLLUP: ", producedRollup.Hash().Hex()) + // println("PRODUCED timeExpired: ", timeExpired) + // println("PRODUCED sizeExceeded: ", sizeExceeded) // this method waits until the receipt is received g.sl.L1Publisher().PublishRollup(producedRollup) lastSuccessfulRollup = time.Now() @@ -658,7 +658,7 @@ func (g *Guardian) periodicBundleSubmission() { } err = g.sl.CrossChainMachine().PublishNextBundle() - //FIXME error here + // FIXME error here if err != nil { if errors.Is(err, errutil.ErrCrossChainBundleNoBatches) { g.logger.Debug("No batches to publish") diff --git a/go/host/host.go b/go/host/host.go index fb9157c372..6090ba55a2 100644 --- a/go/host/host.go +++ b/go/host/host.go @@ -4,9 +4,10 @@ import ( "context" "encoding/json" "fmt" - "github.com/ten-protocol/go-ten/go/enclave/components" "net/http" + "github.com/ten-protocol/go-ten/go/enclave/components" + gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ten-protocol/go-ten/go/host/l2" @@ -98,10 +99,10 @@ func NewHost(config *config.HostConfig, hostServices *ServicesRegistry, p2p host enclService := enclave.NewService(hostIdentity, hostServices, enclGuardians, logger) l2Repo := l2.NewBatchRepository(config, hostServices, hostStorage, logger) subsService := events.NewLogEventManager(hostServices, logger) - //FIXME from config - //baseURL := "http://localhost:3500" + // FIXME from config + // baseURL := "http://localhost:3500" baseURL := "http://localhost:16560" - //baseURL := "https://sepolia-beacon.chainstacklabs.com" + // baseURL := "https://sepolia-beacon.chainstacklabs.com" blobResolver := components.NewBeaconBlobResolver(ethadapter.NewL1BeaconClient(ethadapter.NewBeaconHTTPClient(new(http.Client), baseURL))) l2Repo.SubscribeValidatedBatches(batchListener{newHeads: host.newHeads}) diff --git a/go/host/l1/publisher.go b/go/host/l1/publisher.go index 14d84dc661..cb4af0ee94 100644 --- a/go/host/l1/publisher.go +++ b/go/host/l1/publisher.go @@ -4,12 +4,13 @@ import ( "context" "encoding/json" "fmt" - "github.com/ten-protocol/go-ten/go/enclave/components" "math/big" "strings" "sync" "time" + "github.com/ten-protocol/go-ten/go/enclave/components" + "github.com/ten-protocol/go-ten/contracts/generated/ManagementContract" "github.com/ten-protocol/go-ten/go/common/errutil" "github.com/ten-protocol/go-ten/go/common/stopcontrol" @@ -409,7 +410,7 @@ func (p *Publisher) ResyncImportantContracts() error { // this method is guarded by a lock to ensure that only one transaction is attempted at a time to avoid nonce conflicts // todo (@matt) this method should take a context so we can try to cancel if the tx is no longer required func (p *Publisher) publishTransaction(tx types.TxData) error { - //FIXME config + // FIXME config timeout := 15 * time.Second ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() diff --git a/go/host/storage/storage.go b/go/host/storage/storage.go index d551ed300a..e1ac74b32b 100644 --- a/go/host/storage/storage.go +++ b/go/host/storage/storage.go @@ -23,7 +23,6 @@ type storageImpl struct { } func (s *storageImpl) AddBatch(batch *common.ExtBatch) error { - // Check if the Batch is already stored _, err := hostdb.GetBatchHeader(s.db, batch.Hash()) if err == nil { diff --git a/integration/ethereummock/mgmt_contract_lib.go b/integration/ethereummock/mgmt_contract_lib.go index 0ef09a6d0c..cf0c7cb2d7 100644 --- a/integration/ethereummock/mgmt_contract_lib.go +++ b/integration/ethereummock/mgmt_contract_lib.go @@ -5,6 +5,7 @@ import ( "crypto/sha256" "encoding/gob" "fmt" + "github.com/ethereum/go-ethereum/crypto/kzg4844" "github.com/ethereum/go-ethereum/params" "github.com/ten-protocol/go-ten/go/ethadapter" diff --git a/integration/ethereummock/node.go b/integration/ethereummock/node.go index 3b33cb9c35..6c3a2c75b0 100644 --- a/integration/ethereummock/node.go +++ b/integration/ethereummock/node.go @@ -5,12 +5,13 @@ import ( "context" "errors" "fmt" - "github.com/holiman/uint256" "math/big" "sync" "sync/atomic" "time" + "github.com/holiman/uint256" + "github.com/ten-protocol/go-ten/go/enclave/storage" "github.com/ten-protocol/go-ten/go/common/async" diff --git a/integration/simulation/validate_chain.go b/integration/simulation/validate_chain.go index c059005c06..5a07c828a3 100644 --- a/integration/simulation/validate_chain.go +++ b/integration/simulation/validate_chain.go @@ -3,8 +3,6 @@ package simulation import ( "context" "fmt" - "github.com/ethereum/go-ethereum/rlp" - "github.com/ten-protocol/go-ten/go/enclave/components" "math/big" "net/http" "sort" @@ -13,6 +11,9 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ten-protocol/go-ten/go/enclave/components" + "github.com/ten-protocol/go-ten/contracts/generated/MessageBus" testcommon "github.com/ten-protocol/go-ten/integration/common" @@ -853,8 +854,8 @@ func checkBatchFromTxs(t *testing.T, client rpc.Client, txHash gethcommon.Hash, } func getRollupFromBlobHashes(ctx context.Context, block *types.Block, blobHashes []ethadapter.IndexedBlobHash) (*common.ExtRollup, error) { - //FIXME from config - //baseURL := "http://localhost:3500" + // FIXME from config + // baseURL := "http://localhost:3500" baseURL := "http://localhost:16560" blobResolver := components.NewBeaconBlobResolver(ethadapter.NewL1BeaconClient(ethadapter.NewBeaconHTTPClient(new(http.Client), baseURL))) blobs, err := blobResolver.FetchBlobs(ctx, block.Header(), blobHashes) diff --git a/integration/tenscan/tenscan_test.go b/integration/tenscan/tenscan_test.go index be5d8f77b1..7ef97532d6 100644 --- a/integration/tenscan/tenscan_test.go +++ b/integration/tenscan/tenscan_test.go @@ -78,7 +78,7 @@ func TestTenscan(t *testing.T) { 5, ) - //Timer for running local tests + // Timer for running local tests countdownDuration := 20 * time.Minute tickDuration := 30 * time.Second