mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-29 07:07:16 +00:00
Parse transaction for bor (#604)
* checking if it is a bor tx * ops * checking if sender is empty bytes * no need for borSprint var * fixing lint * still returning p * added isBor to slot * added global var * got rid of sender check * ops * ops two * lint
This commit is contained in:
parent
f418be8e50
commit
1a42afe5f2
16
types/txn.go
16
types/txn.go
@ -96,9 +96,13 @@ type TxSlot struct {
|
||||
//worstIdx int // Index of the transaction in the worst priority queue (of whatever pook it currently belongs to)
|
||||
//local bool // Whether transaction has been injected locally (and hence needs priority when mining or proposing a block)
|
||||
|
||||
IsBor bool // Wether or not the current parsed transaction is a bor transaction or not
|
||||
|
||||
Rlp []byte // TxPool set it to nil after save it to db
|
||||
}
|
||||
|
||||
var emptyHash = make([]byte, 20)
|
||||
|
||||
const (
|
||||
LegacyTxType int = 0
|
||||
AccessListTxType int = 1
|
||||
@ -231,12 +235,18 @@ func (ctx *TxParseContext) ParseTransaction(payload []byte, pos int, slot *TxSlo
|
||||
}
|
||||
// Next follows the destrination address (if present)
|
||||
dataPos, dataLen, err = rlp.String(payload, p)
|
||||
var isEmptyHash bool
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("%w: to len: %s", ErrParseTxn, err)
|
||||
}
|
||||
if dataLen != 0 && dataLen != 20 {
|
||||
return 0, fmt.Errorf("%w: unexpected length of to field: %d", ErrParseTxn, dataLen)
|
||||
}
|
||||
|
||||
if dataLen != 0 {
|
||||
hashBytes := payload[dataPos+1 : dataPos+dataLen]
|
||||
isEmptyHash = bytes.Equal(hashBytes, emptyHash)
|
||||
}
|
||||
// Only note if To field is empty or not
|
||||
slot.Creation = dataLen == 0
|
||||
p = dataPos + dataLen
|
||||
@ -251,6 +261,11 @@ func (ctx *TxParseContext) ParseTransaction(payload []byte, pos int, slot *TxSlo
|
||||
return 0, fmt.Errorf("%w: data len: %s", ErrParseTxn, err)
|
||||
}
|
||||
slot.DataLen = dataLen
|
||||
isDataEmpty := dataLen == 0
|
||||
|
||||
if isEmptyHash && isDataEmpty && legacy {
|
||||
slot.IsBor = true
|
||||
}
|
||||
|
||||
// Zero and non-zero bytes are priced differently
|
||||
slot.DataNonZeroLen = 0
|
||||
@ -462,6 +477,7 @@ func (ctx *TxParseContext) ParseTransaction(payload []byte, pos int, slot *TxSlo
|
||||
_, _ = ctx.Keccak2.(io.Reader).Read(ctx.buf[:32])
|
||||
//take last 20 bytes as address
|
||||
copy(sender, ctx.buf[12:32])
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user