Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
badgersrus committed Dec 18, 2024
1 parent e4b03f0 commit 5591b14
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 6 deletions.
1 change: 0 additions & 1 deletion go/enclave/components/block_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ func (bp *l1BlockProcessor) HealthCheck() (bool, error) {
}

func (bp *l1BlockProcessor) tryAndInsertBlock(ctx context.Context, block *types.Header) (*BlockIngestionType, error) {

// We insert the block into the L1 chain and store it.
// in case the block already exists in the database, this will be treated like a fork, because the head changes to
// the block that was already saved
Expand Down
4 changes: 3 additions & 1 deletion go/enclave/components/rollup_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package components
import (
"context"
"fmt"

"github.com/ethereum/go-ethereum/crypto/kzg4844"

gethcommon "github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -161,7 +162,8 @@ func (rc *rollupConsumerImpl) extractAndVerifyRollups(processed *common.Processe
if len(rollups) > 1 {
println("HERE")
if rollups[0].Hash() == rollups[1].Hash() {
println("ROLLUPS THE SAME")
println("ROLLUPS THE SAME: ", rollups[0].Hash().Hex())
rc.logger.Crit("DUPLICATE ROLLUP")
}
}
return rollups, nil
Expand Down
1 change: 1 addition & 0 deletions go/enclave/components/shared_secret_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package components
import (
"context"
"fmt"

"github.com/ten-protocol/go-ten/go/ethadapter"

gethcommon "github.com/ethereum/go-ethereum/common"
Expand Down
2 changes: 2 additions & 0 deletions go/enclave/enclave_admin_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ func (e *enclaveAdminService) CreateRollup(ctx context.Context, fromSeqNo uint64
if err != nil {
return nil, responses.ToInternalError(err)
}
println("----ROLLUP PRODUCTION----")
println("SEQUENCER CREATING ROLLUP WITH HASH: ", rollup.Hash().Hex())
return rollup, nil
}

Expand Down
2 changes: 1 addition & 1 deletion go/host/container/host_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func NewHostContainerFromConfig(cfg *hostconfig.HostConfig, logger gethlog.Logge
}, logger)

mgmtContractLib := mgmtcontractlib.NewMgmtContractLib(&cfg.ManagementContractAddress, logger)
//obscuroRelevantContracts := []gethcommon.Address{cfg.ManagementContractAddress, cfg.MessageBusAddress}
// obscuroRelevantContracts := []gethcommon.Address{cfg.ManagementContractAddress, cfg.MessageBusAddress}
beaconClient := ethadapter.NewBeaconHTTPClient(new(http.Client), cfg.L1BeaconUrl)
beaconFallback := ethadapter.NewBeaconHTTPClient(new(http.Client), cfg.L1BlobArchiveUrl)
blobResolver := l1.NewBlobResolver(ethadapter.NewL1BeaconClient(beaconClient, beaconFallback))
Expand Down
17 changes: 15 additions & 2 deletions go/host/enclave/guardian.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,13 +662,22 @@ func (g *Guardian) periodicRollupProduction() {
// or the size of accumulated batches is > g.maxRollupSize
timeExpired := time.Since(lastSuccessfulRollup) > g.rollupInterval
sizeExceeded := estimatedRunningRollupSize >= g.maxRollupSize
if timeExpired || sizeExceeded {
g.logger.Info("Trigger rollup production.", "timeExpired", timeExpired, "sizeExceeded", sizeExceeded)
// if rollup retry takes longer than the block time then we need to allow time to publish
// todo better name
justPublished := time.Since(lastSuccessfulRollup) >= g.blockTime
if timeExpired || sizeExceeded && !justPublished {
g.logger.Info("Trigger rollup production.", "timeExpired", timeExpired, "sizeExceeded", sizeExceeded, "justPublished", justPublished)
producedRollup, err := g.enclaveClient.CreateRollup(context.Background(), fromBatch)
if err != nil {
g.logger.Error("Unable to create rollup", log.BatchSeqNoKey, fromBatch, log.ErrKey, err)
continue
}
println("GUARDIAN produced rollup: ", producedRollup.Hash().Hex(), " fromBatch: ", fromBatch, " toBatch: ", producedRollup.Header.LastBatchSeqNo)
println("GUARDIAN timeExpired: ", timeExpired, " sizeExceeded: ", sizeExceeded)
println("rollupSize: ", estimatedRunningRollupSize, " availBatchesSumSize: ", availBatchesSumSize)
if sizeExceeded {
println("HERE")
}
// this method waits until the receipt is received
g.sl.L1Publisher().PublishRollup(producedRollup)
lastSuccessfulRollup = time.Now()
Expand Down Expand Up @@ -791,6 +800,10 @@ func (g *Guardian) calculateNonRolledupBatchesSize(seqNo uint64) (uint64, error)
currentNo++
}

if size > 131072 {
println("HERE")
}

return size, nil
}

Expand Down
4 changes: 4 additions & 0 deletions go/host/l1/blockrepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ func (r *Repository) ExtractTenTransactions(block *common.L1Block) (*common.Proc
return nil, err
}

// println("--- LOG LOOP FOR block --- ", block.Hash().Hex())
// println("LOGS length ", len(logs))
// we have to loop through to preserve receipt order
for _, l := range logs {
txData, err := r.createTransactionData(l.TxHash)
Expand All @@ -222,6 +224,8 @@ func (r *Repository) ExtractTenTransactions(block *common.L1Block) (*common.Proc
continue
}

// println("LOG at index: ", i, " with hash ", l.TxHash.Hex())

switch l.Topics[0] {
case crosschain.CrossChainEventID:
r.processCrossChainLogs(l, txData, processed)
Expand Down
1 change: 1 addition & 0 deletions integration/ethereummock/mgmt_contract_lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/gob"
"fmt"

"github.com/ten-protocol/go-ten/go/host/l1"

"github.com/ten-protocol/go-ten/go/ethadapter"
Expand Down
6 changes: 5 additions & 1 deletion integration/simulation/devnetwork/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,12 @@ func (n *InMemNodeOperator) createHostContainer() *hostcontainer.HostContainer {
}
rpcServer := node.NewServer(&rpcConfig, n.logger)
mgmtContractLib := mgmtcontractlib.NewMgmtContractLib(&hostConfig.ManagementContractAddress, n.logger)
l1Repo := l1.NewL1Repository(n.l1Client, []gethcommon.Address{hostConfig.ManagementContractAddress, hostConfig.MessageBusAddress}, n.logger)
contractAddresses := map[l1.ContractType][]gethcommon.Address{
l1.MgmtContract: {hostConfig.ManagementContractAddress},
l1.MsgBus: {hostConfig.MessageBusAddress},
}
blobResolver := l1.NewBlobResolver(ethadapter.NewL1BeaconClient(ethadapter.NewBeaconHTTPClient(new(http.Client), fmt.Sprintf("127.0.0.1:%d", n.config.L1BeaconPort))))
l1Repo := l1.NewL1Repository(n.l1Client, n.logger, mgmtContractLib, blobResolver, contractAddresses)
return hostcontainer.NewHostContainer(hostConfig, svcLocator, nodeP2p, n.l1Client, l1Repo, enclaveClients, mgmtContractLib, n.l1Wallet, rpcServer, hostLogger, metrics.New(false, 0, n.logger), blobResolver)
}

Expand Down

0 comments on commit 5591b14

Please sign in to comment.