Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func CommandServe(cfg *config.Config) *cli.Command {
EnvVars: []string{envPrefix + strings.ToUpper(categoryL2) + "_MONITOR_FLASHBLOCK_NUMBER_CONTRACT_FUNCTION_SIGNATURE"},
Name: categoryL2 + "-monitor-flashblock-number-contract-function-signature",
Usage: "l2 builder flashblock number contract function `signature` to monitor",
Value: "incrementFlashblockNumber()",
Value: "permitIncrementFlashblockNumber(uint256,bytes)",
},

&cli.Int64Flag{
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ OPTIONS:
--l2-monitor-builder-policy-contract address l2 builder flashtestations policy contract address to monitor [$CHAIN_MONITOR_L2_MONITOR_BUILDER_POLICY_CONTRACT]
--l2-monitor-builder-policy-contract-function-signature signature l2 builder flashtestations policy contract function signature to monitor (default: "permitVerifyBlockBuilderProof(uint8,bytes32,uint256,bytes)") [$CHAIN_MONITOR_L2_MONITOR_BUILDER_POLICY_CONTRACT_FUNCTION_SIGNATURE]
--l2-monitor-flashblock-number-contract address l2 builder flashblock number contract address to monitor [$CHAIN_MONITOR_L2_MONITOR_FLASHBLOCK_NUMBER_CONTRACT]
--l2-monitor-flashblock-number-contract-function-signature signature l2 builder flashblock number contract function signature to monitor (default: "incrementFlashblockNumber()") [$CHAIN_MONITOR_L2_MONITOR_FLASHBLOCK_NUMBER_CONTRACT_FUNCTION_SIGNATURE]
--l2-monitor-flashblock-number-contract-function-signature signature l2 builder flashblock number contract function signature to monitor (default: "permitIncrementFlashblockNumber(uint256,bytes)") [$CHAIN_MONITOR_L2_MONITOR_FLASHBLOCK_NUMBER_CONTRACT_FUNCTION_SIGNATURE]
--l2-monitor-flashblocks-main-public-stream value the name of the main public l2 flashblocks stream [$CHAIN_MONITOR_L2_MONITOR_FLASHBLOCKS_MAIN_PUBLIC_STREAM]
--l2-monitor-flashblocks-max-ws-message-size-kb value max size (in kb) of l2 builder flashblocks ws messages (default: 256) [$CHAIN_MONITOR_L2_MONITOR_FLASHBLOCKS_MAX_WS_MESSAGE_SIZE_KB]
--l2-monitor-flashblocks-private-stream value [ --l2-monitor-flashblocks-private-stream value ] private websocket stream(s) of l2 flashblocks [$CHAIN_MONITOR_L2_MONITOR_FLASHBLOCKS_PRIVATE_STREAMS]
Expand Down
19 changes: 1 addition & 18 deletions server/l2/block_inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,24 +1015,7 @@ func (bi *BlockInspector) isFlashblockNumberTx(
return false
}

from, err := ethtypes.Sender(ethtypes.LatestSignerForChainID(tx.ChainId()), tx)
if err != nil {
l := logutils.LoggerFromContext(ctx)

l.Warn("Failed to determine the sender for flashblock number transaction",
zap.Error(err),
zap.String("tx", tx.Hash().Hex()),
zap.String("block", block.Number().String()),
)

return false
}

if from.Cmp(bi.cfg.builderAddr) != 0 {
return false
}

return true
return tx.From().Cmp(bi.cfg.builderAddr) == 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue:

From() is for deposit txes only. it panics on the "normal" ones:

// From is an OP-Stack addition to the Transaction type to easily get a deposit
// transaction sender address.
// It can be difficult to create a correct signer just to extract the From field
// from a deposit transaction if the chain ID is not known.
func (tx *Transaction) From() common.Address {
	if tx.Type() != DepositTxType {
		panic("From() called on non-deposit transaction")
	}
	return tx.inner.(interface{ from() common.Address }).from()
}

}

func (bi *BlockInspector) isProbeTx(
Expand Down
25 changes: 2 additions & 23 deletions server/l2/workload_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ const (
// Raw quote has a 48-byte header before the TD10ReportBody
HEADER_LENGTH = 48
TD_REPORT10_LENGTH = 584

// TDX workload constants
TD_XFAM_FPU = 0x0000000000000001
TD_XFAM_SSE = 0x0000000000000002
TD_TDATTRS_VE_DISABLED = 0x0000000010000000
TD_TDATTRS_PKS = 0x0000000040000000
TD_TDATTRS_KL = 0x0000000080000000
)

// ComputeWorkloadID computes the workload ID from Automata's serialized verifier output
Expand Down Expand Up @@ -51,24 +44,10 @@ func ComputeWorkloadID(rawQuote []byte) ([32]byte, error) {
xfam := binary.BigEndian.Uint64(reportBody[128 : 128+8])
tdAttributes := binary.BigEndian.Uint64(reportBody[120 : 120+8])

// Apply transformations as per the Solidity implementation
// expectedXfamBits = TD_XFAM_FPU | TD_XFAM_SSE
expectedXfamBits := uint64(TD_XFAM_FPU | TD_XFAM_SSE)

// ignoredTdAttributesBitmask = TD_TDATTRS_VE_DISABLED | TD_TDATTRS_PKS | TD_TDATTRS_KL
ignoredTdAttributesBitmask := uint64(TD_TDATTRS_VE_DISABLED | TD_TDATTRS_PKS | TD_TDATTRS_KL)

// Transform xFAM: xFAM ^ expectedXfamBits
transformedXfam := xfam ^ expectedXfamBits

// Transform tdAttributes: tdAttributes & ~ignoredTdAttributesBitmask
transformedTdAttributes := tdAttributes & ^ignoredTdAttributesBitmask

// Convert transformed values back to bytes (big-endian, to match Solidity bytes8)
xfamBytes := make([]byte, 8)
tdAttributesBytes := make([]byte, 8)
binary.BigEndian.PutUint64(xfamBytes, transformedXfam)
binary.BigEndian.PutUint64(tdAttributesBytes, transformedTdAttributes)
binary.BigEndian.PutUint64(xfamBytes, xfam)
binary.BigEndian.PutUint64(tdAttributesBytes, tdAttributes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question:

what happens here (and why)? could you please add to the PR description?


// Concatenate all fields
var concatenated []byte
Expand Down