accounts/abi/bind: eip-1559 comment

This commit is contained in:
siddharth0a 2024-04-04 19:09:23 +09:00
parent 1b139eb53a
commit 44d5ea9672
4 changed files with 19 additions and 3 deletions

View file

@ -54,16 +54,20 @@ type CallOpts struct {
// TransactOpts is the collection of authorization data required to create a // TransactOpts is the collection of authorization data required to create a
// valid Ethereum transaction. // valid Ethereum transaction.
// TransactOpts는 유효한 이더리움 트랜잭션을 생성하기 위해 필요한 authorization data의 집합이다.
type TransactOpts struct { type TransactOpts struct {
From common.Address // Ethereum account to send the transaction from From common.Address // Ethereum account to send the transaction from
Nonce *big.Int // Nonce to use for the transaction execution (nil = use pending state) Nonce *big.Int // Nonce to use for the transaction execution (nil = use pending state)
Signer SignerFn // Method to use for signing the transaction (mandatory) Signer SignerFn // Method to use for signing the transaction (mandatory)
// 트랜잭션 사인에 사용하는 메소드
Value *big.Int // Funds to transfer along the transaction (nil = 0 = no funds) Value *big.Int // Funds to transfer along the transaction (nil = 0 = no funds)
GasPrice *big.Int // Gas price to use for the transaction execution (nil = gas price oracle) GasPrice *big.Int // Gas price to use for the transaction execution (nil = gas price oracle)
GasFeeCap *big.Int // Gas fee cap to use for the 1559 transaction execution (nil = gas price oracle) GasFeeCap *big.Int // Gas fee cap to use for the 1559 transaction execution (nil = gas price oracle)
// 1559 transaction을 실행하기 위해 필요한 최대 가스 한도
GasTipCap *big.Int // Gas priority fee cap to use for the 1559 transaction execution (nil = gas price oracle) GasTipCap *big.Int // Gas priority fee cap to use for the 1559 transaction execution (nil = gas price oracle)
GasLimit uint64 // Gas limit to set for the transaction execution (0 = estimate) // 1559 transaction을 실행하기 위해 필요한 최대 가스 팁 한도
GasLimit uint64 // Gas limit to set for the transaction execution (0 = estimate)
Context context.Context // Network context to support cancellation and timeouts (nil = no timeout) Context context.Context // Network context to support cancellation and timeouts (nil = no timeout)
@ -112,6 +116,9 @@ func (m *MetaData) GetAbi() (*abi.ABI, error) {
// BoundContract is the base wrapper object that reflects a contract on the // BoundContract is the base wrapper object that reflects a contract on the
// Ethereum network. It contains a collection of methods that are used by the // Ethereum network. It contains a collection of methods that are used by the
// higher level contract bindings to operate. // higher level contract bindings to operate.
// BoundContract는 이더리움 네트워크에 컨트랙트를 반영시키는 wrapper 객체입니다.
// 이는 상위레벨의 컨트랙트가 실행될 수 있도록 연결하는데 사용되는 메소드의 집합을 포함합니다.
// 쉽게 생각하면 smart contract <=> 이더리움 간의 호환을 위한 객체
type BoundContract struct { type BoundContract struct {
address common.Address // Deployment address of the contract on the Ethereum blockchain address common.Address // Deployment address of the contract on the Ethereum blockchain
abi abi.ABI // Reflect based ABI to access the correct Ethereum methods abi abi.ABI // Reflect based ABI to access the correct Ethereum methods
@ -385,8 +392,10 @@ func (c *BoundContract) getNonce(opts *TransactOpts) (uint64, error) {
// transact executes an actual transaction invocation, first deriving any missing // transact executes an actual transaction invocation, first deriving any missing
// authorization fields, and then scheduling the transaction for execution. // authorization fields, and then scheduling the transaction for execution.
// transact는 실제 트랜잭션 호출을 실행하고, 먼저 누락된 authorization 필드를 도출한 다음 트랜잭션을 실행하도록 스케줄링합니다.
func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, input []byte) (*types.Transaction, error) { func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, input []byte) (*types.Transaction, error) {
if opts.GasPrice != nil && (opts.GasFeeCap != nil || opts.GasTipCap != nil) { if opts.GasPrice != nil && (opts.GasFeeCap != nil || opts.GasTipCap != nil) {
// 트랜잭션은 GasPrice 혹은 (GasFeeCap or GasTipCap) 중 하나는 지정되어 있어야 합니다.
return nil, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified") return nil, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
} }
// Create the transaction // Create the transaction
@ -395,11 +404,15 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i
err error err error
) )
if opts.GasPrice != nil { if opts.GasPrice != nil {
// GasPrice가 설정되어 있으면 legacy transaction 실행을 실행합니다.
rawTx, err = c.createLegacyTx(opts, contract, input) rawTx, err = c.createLegacyTx(opts, contract, input)
} else if opts.GasFeeCap != nil && opts.GasTipCap != nil { } else if opts.GasFeeCap != nil && opts.GasTipCap != nil {
// GasFeeCap, GasTipCap 모두 설정되어 있으면 EIP-1559 transaction을 실행합니다.
rawTx, err = c.createDynamicTx(opts, contract, input, nil) rawTx, err = c.createDynamicTx(opts, contract, input, nil)
} else { } else {
// Only query for basefee if gasPrice not specified // Only query for basefee if gasPrice not specified
// gasPrice가 지정되지 않으면 baseFee만 쿼리하고, baseFee 존재시 EIP-1559 transaction, 없으면 legacy transaction을 실행합니다.
// 사용자가 명시적으로 가스 관련한 field를 지정하지 않았을때 네트워크 config에 맞게 자동으로 트랜잭션 유형을 결정하기 위한 조건입니다.
if head, errHead := c.transactor.HeaderByNumber(ensureContext(opts.Context), nil); errHead != nil { if head, errHead := c.transactor.HeaderByNumber(ensureContext(opts.Context), nil); errHead != nil {
return nil, errHead return nil, errHead
} else if head.BaseFee != nil { } else if head.BaseFee != nil {

View file

@ -62,7 +62,8 @@ func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Heade
func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int { func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
// If the current block is the first EIP-1559 block, return the InitialBaseFee. // If the current block is the first EIP-1559 block, return the InitialBaseFee.
// 현재 블록이 EIP-1559의 첫번째 블록이면, InitialBaseFee를 반환한다. // 현재 블록이 EIP-1559의 첫번째 블록이면, InitialBaseFee를 반환한다.
// -----런던인지 검사하는데 첫번째 블록과 어떤 관련성 있는지? // -----Config가 런던인지 검사하는데 첫번째 블록과 어떤 관련성 있는지?
// ----->EIP-1559는 런던 하드포크에서 시행됨, 즉 런던 하드포크의 첫번째 블록부터 BaseFee시행
if !config.IsLondon(parent.Number) { if !config.IsLondon(parent.Number) {
return new(big.Int).SetUint64(params.InitialBaseFee) return new(big.Int).SetUint64(params.InitialBaseFee)
} }

View file

@ -24,7 +24,7 @@ import (
// VerifyGaslimit verifies the header gas limit according increase/decrease // VerifyGaslimit verifies the header gas limit according increase/decrease
// in relation to the parent gas limit. // in relation to the parent gas limit.
// VerifyGaslimit은 header gas limit관 parentgas limit의 증가/감소관계를 확인한다. // VerifyGaslimit은 header gas limit과 parent gas limit의 증가/감소관계를 확인한다.
func VerifyGaslimit(parentGasLimit, headerGasLimit uint64) error { func VerifyGaslimit(parentGasLimit, headerGasLimit uint64) error {
// Verify that the gas limit remains within allowed bounds // Verify that the gas limit remains within allowed bounds
// gas limit이 허용된 범위안에 있는지 확인한다 // gas limit이 허용된 범위안에 있는지 확인한다

View file

@ -52,9 +52,11 @@ const (
) )
// Transaction is an Ethereum transaction. // Transaction is an Ethereum transaction.
// 이더리움의 트랜잭션 구조체
type Transaction struct { type Transaction struct {
inner TxData // Consensus contents of a transaction inner TxData // Consensus contents of a transaction
time time.Time // Time first seen locally (spam avoidance) time time.Time // Time first seen locally (spam avoidance)
//로컬 시간 사용
// caches // caches
hash atomic.Value hash atomic.Value