Documentation ¶
Index ¶
- Constants
- Variables
- func EVMBlockGasLimit(gasLimits *Limits, gasRatio *util.Ratio32) uint64
- func EVMCallGasLimit(gasLimits *Limits, gasRatio *util.Ratio32) uint64
- func EVMGasToISC(evmGas uint64, gasRatio *util.Ratio32) uint64
- func FeeFromGasWithGasPerToken(gasUnits uint64, gasPerToken util.Ratio32) uint64
- func FeeFromGasWithGasPrice(gasUnits uint64, gasPrice *big.Int, l1BaseTokenDecimals uint32) uint64
- func ISCGasBudgetToEVM(iscGasBudget uint64, gasRatio *util.Ratio32) uint64
- func ISCGasBurnedToEVM(iscGasBurned uint64, gasRatio *util.Ratio32) uint64
- type BurnCode
- type BurnCodeRecord
- type BurnFunction
- type BurnLog
- type BurnRecord
- type BurnTable
- type FeePolicy
- func (p *FeePolicy) Bytes() []byte
- func (p *FeePolicy) DefaultGasPriceFullDecimals(l1BaseTokenDecimals uint32) *big.Int
- func (p *FeePolicy) FeeFromGas(gasUnits uint64, gasPrice *big.Int, l1BaseTokenDecimals uint32) uint64
- func (p *FeePolicy) FeeFromGasBurned(gasUnits, availableTokens uint64, gasPrice *big.Int, ...) (sendToOwner, sendToValidator uint64)
- func (p *FeePolicy) GasBudgetFromTokens(availableTokens uint64, gasPrice *big.Int, l1BaseTokenDecimals uint32) uint64
- func (p *FeePolicy) IsEnoughForMinimumFee(availableTokens uint64, gasPrice *big.Int, l1BaseTokenDecimals uint32) bool
- func (p *FeePolicy) MinFee(gasPrice *big.Int, l1BaseTokenDecimals uint32) uint64
- func (p *FeePolicy) Read(r io.Reader) error
- func (p *FeePolicy) String() string
- func (p *FeePolicy) Write(w io.Writer) error
- type Limits
Constants ¶
const ( BurnCodeStorage1P = BurnCode(iota) BurnCodeReadFromState1P BurnCodeCallTargetNotFound BurnCodeGetContext BurnCodeGetCallerData BurnCodeGetAllowance BurnCodeGetStateAnchorInfo BurnCodeGetBalance BurnCodeGetNFTData BurnCodeCallContract BurnCodeDeployContract BurnCodeEmitEvent1P BurnCodeTransferAllowance BurnCodeEstimateStorageDepositCost BurnCodeSendL1Request BurnCodeUtilsHashingBlake2b BurnCodeUtilsHashingSha3 BurnCodeUtilsHashingHname BurnCodeUtilsHexEncode BurnCodeUtilsHexDecode BurnCodeUtilsED25519ValidSig BurnCodeUtilsED25519AddrFromPubKey BurnCodeUtilsBLSValidSignature BurnCodeUtilsBLSAddrFromPubKey BurnCodeUtilsBLSAggregateBLS1P BurnCodeWasm1P BurnCodeMinimumGasPerRequest1P BurnCodeEVM1P )
const ( Coef1Send = 200 CoefBLSAggregate = 400 )
const FeePolicyByteSize = util.RatioByteSize + serializer.OneByte + util.RatioByteSize
GasPerToken + ValidatorFeeShare + EVMGasRatio
Variables ¶
var DefaultEVMGasRatio = util.Ratio32{A: 1, B: 1}
<ISC gas> = <EVM Gas> * <A> / <B>
var DefaultGasPerToken = util.Ratio32{A: 100, B: 1}
By default each token pays for 100 units of gas
var ErrUnknownBurnCode = errors.New("unknown gas burn code")
var LimitsDefault = &Limits{
MaxGasPerBlock: 1_000_000_000,
MinGasPerRequest: 10_000,
MaxGasPerRequest: 50_000_000,
MaxGasExternalViewCall: 50_000_000,
}
Functions ¶
func EVMBlockGasLimit ¶ added in v1.0.3
EVMBlockGasLimit returns the ISC block gas limit converted to EVM gas units
func EVMCallGasLimit ¶ added in v1.0.3
EVMCallGasLimit returns the maximum gas limit accepted for an EVM tx
func FeeFromGasWithGasPerToken ¶ added in v1.1.0
FeeFromGasWithGasPerToken calculates the gas fee using the ISC GasPerToken price
func FeeFromGasWithGasPrice ¶ added in v1.1.0
FeeFromGasWithGasPrice calculates the gas fee using the given gasPrice (expressed in ISC base tokens with 'full decimals').
func ISCGasBudgetToEVM ¶ added in v1.0.3
Types ¶
type BurnCodeRecord ¶
type BurnCodeRecord struct { Name string BurnFunction }
type BurnFunction ¶
type BurnLog ¶
type BurnLog struct {
Records []BurnRecord `json:"records" swagger:"required"`
}
func NewGasBurnLog ¶
func NewGasBurnLog() *BurnLog
type BurnRecord ¶
type BurnTable ¶
type BurnTable map[BurnCode]BurnCodeRecord
type FeePolicy ¶ added in v1.0.3
type FeePolicy struct { // EVMGasRatio expresses the ratio at which EVM gas is converted to ISC gas // X = ISC gas, Y = EVM gas => ISC gas = EVM gas * A/B EVMGasRatio util.Ratio32 `json:"evmGasRatio" swagger:"desc(The EVM gas ratio (ISC gas = EVM gas * A/B)),required"` // GasPerToken specifies how many gas units are paid for each token. GasPerToken util.Ratio32 `json:"gasPerToken" swagger:"desc(The gas per token ratio (A/B) (gas/token)),required"` // 0 mean all goes to Governor // >=100 all goes to Validator ValidatorFeeShare uint8 `json:"validatorFeeShare" swagger:"desc(The validator fee share.),required"` }
func DefaultFeePolicy ¶ added in v1.0.3
func DefaultFeePolicy() *FeePolicy
func FeePolicyFromBytes ¶
func MustFeePolicyFromBytes ¶ added in v1.0.3
func (*FeePolicy) DefaultGasPriceFullDecimals ¶ added in v1.1.0
DefaultGasPriceFullDecimals returns the default gas price to be set in EVM transactions, when using the ISC GasPerToken.
func (*FeePolicy) FeeFromGas ¶ added in v1.0.3
func (*FeePolicy) FeeFromGasBurned ¶ added in v1.0.3
func (p *FeePolicy) FeeFromGasBurned(gasUnits, availableTokens uint64, gasPrice *big.Int, l1BaseTokenDecimals uint32) (sendToOwner, sendToValidator uint64)
FeeFromGasBurned calculates the how many tokens to take and where to deposit them. if gasPriceEVM == nil, the fee is calculated using the ISC GasPerToken price. Otherwise, the given gasPrice (expressed in base tokens with 'full decimals') is used instead.
func (*FeePolicy) GasBudgetFromTokens ¶ added in v1.0.3
func (*FeePolicy) IsEnoughForMinimumFee ¶ added in v1.0.3
type Limits ¶ added in v1.0.3
type Limits struct { MaxGasPerBlock uint64 `json:"maxGasPerBlock" swagger:"desc(The maximum gas per block),required"` MinGasPerRequest uint64 `json:"minGasPerRequest" swagger:"desc(The minimum gas per request),required"` MaxGasPerRequest uint64 `json:"maxGasPerRequest" swagger:"desc(The maximum gas per request),required"` MaxGasExternalViewCall uint64 `json:"maxGasExternalViewCall" swagger:"desc(The maximum gas per external view call),required"` }