Fee Delegation

WEMIX3.0에 적용된 Fee Delegation에 대한 설명입니다.

WEMIX3.0의 Applepie HF에 적용된 메커니즘인 Fee Delegation은 Sender가 실행하고자 하는 Transaction에 지불되는 수수료를 FeePayer가 대신 지불하는 기능입니다.

Fee Delegation Transaction은 Sender가 서명한 기존 Transaction에 FeePayer 정보를 포함하여 FeePayer가 서명한 서명 정보를 추가하여 전송 함으로써 이루어집니다.

Fee Delegation

Fee Delegation Transaction

DynamicFeeTxType Transaction(with signature of Sender) + FeePayer address + signature of FeePayer

Fee Delegation Transaction은 기존 Transaction 중 DynamicFeeTxType만 지원하며 LegacyTxType이나 AccessListTxType은 지원하지 않습니다.

Fee Delegation Transaction 구현을 위해 중요 변경 내용은 아래와 같으며 자세한 변경 내용은 공개된 소스를 참조하시기 바랍니다.

Fee Delegation Transaction Type (transaction.go)

const (
  LegacyTxType = iota
  AccessListTxType
  DynamicFeeTxType
  FeeDelegateDynamicFeeTxType = 22 //fee delegation
)

Fee Delegation Transaction 구조(transaction.go)

type FeeDelegateDynamicFeeTx struct {
  SenderTx DynamicFeeTx
  FeePayer *common.Address rlp:"nil"

  // Signature values
  FV *big.Int json:"fv" gencodec:"required" // feePayer V
  FR *big.Int json:"fr" gencodec:"required" // feePayer R
  FS *big.Int json:"fs" gencodec:"required" // feePayer S
}

서명을 위한 Fee Delegation Transaction Hash 함수(transaction_signing.go)

func (s feeDelegateSigner) Hash(tx *Transaction) common.Hash {
  senderV, senderR, senderS := tx.RawSignatureValues()
  return prefixedRlpHash(
    tx.Type(),
    []interface{}{
      []interface{}{
        s.chainId,
        tx.Nonce(),
        tx.GasTipCap(),
        tx.GasFeeCap(),
        tx.Gas(),
        tx.To(),
        tx.Value(),
        tx.Data(),
        tx.AccessList(),
        senderV,
        senderR,
        senderS,
      },
      tx.FeePayer(),
    })
}

Last updated