Skip to content

Commit

Permalink
stashing
Browse files Browse the repository at this point in the history
  • Loading branch information
badgersrus committed Sep 19, 2024
1 parent d069a8c commit 211757a
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 21 deletions.
6 changes: 0 additions & 6 deletions go/enclave/components/rollup_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,8 @@ func (rc *rollupConsumerImpl) ProcessBlobsInBlock(ctx context.Context, b *common
}
if err := rc.storage.StoreRollup(ctx, rollup, internalHeader); err != nil {
rc.logger.Error("Failed storing rollup", log.RollupHashKey, rollup.Hash(), log.ErrKey, err)
println("ENCLAVE FAILED STORING ROLLUP at batch: ", rollup.Header.LastBatchSeqNo)
return err
}
println("ENCLAVE STORED ROLLUP at batch: ", rollup.Header.LastBatchSeqNo)
}

return nil
Expand Down Expand Up @@ -146,10 +144,6 @@ func (rc *rollupConsumerImpl) extractAndVerifyRollups(br *common.BlockAndReceipt
return nil, fmt.Errorf("could not create blob sidecar and blob hashes. Cause: %w", err)
}

for i, rollupHash := range rollupHashes.BlobHashes {
println("rollup hash: ", i, " ", rollupHash.Hex())
}

if err := verifyBlobHashes(rollupHashes, blobHashes); err != nil {
return nil, fmt.Errorf("failed to verify the rollup hashes with blobhashes. Cause: %w", err)
}
Expand Down
1 change: 0 additions & 1 deletion go/enclave/enclave.go
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,6 @@ func (e *enclaveImpl) EnclavePublicConfig(context.Context) (*common.EnclavePubli
}

func (e *enclaveImpl) rejectBlockErr(ctx context.Context, cause error) *errutil.BlockRejectError {
println("REJECTING L1 BLOCK: ", cause.Error())
var hash common.L1BlockHash
l1Head, err := e.l1BlockProcessor.GetHead(ctx)
// todo - handle error
Expand Down
4 changes: 0 additions & 4 deletions go/host/enclave/guardian.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,6 @@ func (g *Guardian) submitL1Block(block *common.L1Block, isLatest bool) (bool, er
}

_, rollupTxs, blobsAndHashes, _ := g.sl.L1Publisher().ExtractTenTransactionsAndBlobs(block)
if len(rollupTxs) > 0 {
println("Successfully decoded rollup with txReceipts: ", len(txWithReceipts))
println("Successfully decoded rollup with blobsAndHashes: ", len(blobsAndHashes))
}
resp, err := g.enclaveClient.SubmitL1Block(context.Background(), block.Header(), txWithReceipts, blobsAndHashes)

g.submitDataLock.Unlock() // lock is only guarding the enclave call, so we can release it now
Expand Down
2 changes: 1 addition & 1 deletion integration/ethereummock/mock_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewBlock(parent *types.Block, nodeID common.Address, txs []*types.Transacti
Number: big.NewInt(int64(height)),
GasLimit: 0,
GasUsed: 0,
Time: 0, // Set the block time here
Time: blockTime, // Set the block time here
Extra: nil,
MixDigest: common.Hash{},
Nonce: types.BlockNonce{},
Expand Down
9 changes: 2 additions & 7 deletions integration/ethereummock/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ func (m *Node) FetchLastBatchSeqNo(gethcommon.Address) (*big.Int, error) {
}
rollup := m.getRollupFromBlock(currentBlock)
if rollup != nil {
println("Last batch number from rollup: ", rollup.Header.LastBatchSeqNo)
return big.NewInt(int64(rollup.Header.LastBatchSeqNo)), nil
}
}
Expand Down Expand Up @@ -460,25 +459,21 @@ func (m *Node) startMining() {

// Generate a random number, and wait for that number of ms. Equivalent to PoW
// Include all rollups received during this period.
blockTime := uint64(time.Now().Unix())
async.Schedule(m.cfg.PowTime(), func() {
toInclude := findNotIncludedTxs(canonicalBlock, mempool, m.Resolver, m.db)
// todo - iterate through the rollup transactions and include only the ones with the proof on the canonical chain
if atomic.LoadInt32(m.interrupt) == 1 {
return
}

block, blobs := NewBlock(canonicalBlock, m.l2ID, toInclude, uint64(time.Now().Unix()))
block, blobs := NewBlock(canonicalBlock, m.l2ID, toInclude, blockTime)
blobPointers := make([]*kzg4844.Blob, len(blobs))
for i := range blobs {

Check failure on line 472 in integration/ethereummock/node.go

View workflow job for this annotation

GitHub Actions / lint

S1001: should use copy(to, from) instead of a loop (gosimple)
blobPointers[i] = blobs[i] // Assign the address of each blob
}
slot, _ := ethadapter.TimeToSlot(block.Time(), MockGenesisBlock.Time(), SecondsPerSlot)
if len(blobs) > 0 {
//println("rollup blobs: ", len(blobs))
//for _, blob := range blobs {
// commitment, _ := kzg4844.BlobToCommitment(blob)
// println("blob hash: ", ethadapter.KZGToVersionedHash(commitment).Hex())
//}
_ = m.BeaconServer.StoreBlobs(slot, blobs)
}
m.miningCh <- block
Expand Down
2 changes: 1 addition & 1 deletion integration/simulation/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func setupSimTestLog(simType string) {
LogDir: testLogs,
TestType: "sim-log",
TestSubtype: simType,
LogLevel: log.LvlDebug,
LogLevel: log.LvlInfo,
})
}

Expand Down
2 changes: 1 addition & 1 deletion integration/simulation/validate_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const (
// For example, all injected transactions were processed correctly, the height of the rollup chain is a function of the total
// time of the simulation and the average block duration, that all TEN nodes are roughly in sync, etc
func checkNetworkValidity(t *testing.T, s *Simulation) {
time.Sleep(2 * time.Second)
time.Sleep(5 * time.Second)
checkTransactionsInjected(t, s)
l1MaxHeight := checkEthereumBlockchainValidity(t, s)
checkTenBlockchainValidity(t, s, l1MaxHeight)
Expand Down

0 comments on commit 211757a

Please sign in to comment.