Documentation ¶
Index ¶
- Constants
- Variables
- func MakeContractKey(h common.Address) []byte
- type Bridge
- func (b *Bridge) ContractCall_Payable_lock(ic InteropContext, to common.Address) error
- func (b *Bridge) ContractCall__View_getMinted(ic InteropContext, depositId int64) ([]byte, error)
- func (b *Bridge) ContractCall_requestMint(ic InteropContext, headerIndex uint32, txid *big.Int, txProof []byte, ...) error
- func (b *Bridge) ContractCall_syncHeader(ic InteropContext, rawHeader []byte) error
- func (b *Bridge) ContractCall_syncStateRoot(ic InteropContext, rawStateroot []byte) error
- func (b *Bridge) ContractCall_syncStateRootValidatorsAddress(ic InteropContext, headerIndex uint32, txid *big.Int, txProof []byte, ...) error
- func (b *Bridge) ContractCall_syncValidators(ic InteropContext, headerIndex uint32, txid *big.Int, txProof []byte, ...) error
- func (b *Bridge) GetMinted(d *dao.Simple, depositId int64) (common.Hash, error)
- func (d *Bridge) RequiredGas(ic InteropContext, input []byte) uint64
- func (d *Bridge) Run(ic InteropContext, input []byte) ([]byte, error)
- type Contracts
- type Designate
- func (d *Designate) ContractCall_initialize(ic InteropContext) error
- func (d *Designate) GetConsensusAddress(s *dao.Simple, index uint32) (common.Address, error)
- func (d *Designate) GetDesignatedByRole(s *dao.Simple, r noderoles.Role, index uint32) (keys.PublicKeys, uint32, error)
- func (d *Designate) GetDesignatedByRoleFromStorage(s *dao.Simple, r noderoles.Role, index uint32) (keys.PublicKeys, uint32, error)
- func (d *Designate) GetSysAddresses(s *dao.Simple, index uint32) ([]common.Address, error)
- func (d *Designate) GetValidators(s *dao.Simple, index uint32) (keys.PublicKeys, error)
- func (d *Designate) PostPersist(s *dao.Simple, _ *block.Block) error
- func (d *Designate) RequiredGas(ic InteropContext, input []byte) uint64
- func (d *Designate) Run(ic InteropContext, input []byte) ([]byte, error)
- func (d *Designate) UpdateCache(s *dao.Simple) error
- type DesignationCache
- type GAS
- func (g *GAS) AddBalance(d *dao.Simple, h common.Address, amount *big.Int)
- func (g *GAS) Burn(d *dao.Simple, address common.Address, amount *big.Int) error
- func (g *GAS) ContractCall_initialize(ic InteropContext) error
- func (g *GAS) GetBalance(d *dao.Simple, h common.Address) *big.Int
- func (g *GAS) Mint(d *dao.Simple, address common.Address, amount *big.Int) error
- func (g *GAS) OnPersist(d *dao.Simple, block *block.Block) error
- func (g *GAS) RequiredGas(ic InteropContext, input []byte) uint64
- func (g *GAS) Run(ic InteropContext, input []byte) ([]byte, error)
- func (g *GAS) SubBalance(d *dao.Simple, h common.Address, amount *big.Int)
- type GasState
- type InteropContext
- type Ledger
- type Management
- func (m *Management) ContractCall_initialize(ic InteropContext) error
- func (m *Management) Destroy(s *dao.Simple, addr common.Address) bool
- func (m *Management) GetCode(s *dao.Simple, addr common.Address) []byte
- func (m *Management) GetCodeHash(s *dao.Simple, addr common.Address) common.Hash
- func (m *Management) GetCodeSize(s *dao.Simple, addr common.Address) int
- func (m *Management) GetContract(s *dao.Simple, addr common.Address) *state.Contract
- func (m *Management) RequiredGas(ic InteropContext, input []byte) uint64
- func (m *Management) Run(ic InteropContext, input []byte) ([]byte, error)
- func (m *Management) SetCode(s *dao.Simple, addr common.Address, code []byte)
- type Policy
- func (p *Policy) ContractCall_blockAccount(ic InteropContext, address common.Address) error
- func (p *Policy) ContractCall_initialize(ic InteropContext) error
- func (p *Policy) ContractCall_setFeePerByte(ic InteropContext, fee uint64) error
- func (p *Policy) ContractCall_setGasPrice(ic InteropContext, gasPrice uint64) error
- func (p *Policy) ContractCall_unblockAccount(ic InteropContext, address common.Address) error
- func (p *Policy) GetFeePerByte(s *dao.Simple) uint64
- func (p *Policy) GetFeePerByteFromStorage(s *dao.Simple) uint64
- func (p *Policy) GetGasPrice(s *dao.Simple) *big.Int
- func (p *Policy) GetGasPriceFromStorage(s *dao.Simple) *big.Int
- func (p *Policy) IsBlocked(d *dao.Simple, address common.Address) bool
- func (p *Policy) PostPersist(d *dao.Simple, _ *block.Block) error
- func (p *Policy) RequiredGas(ic InteropContext, input []byte) uint64
- func (p *Policy) Run(ic InteropContext, input []byte) ([]byte, error)
- func (p *Policy) UpdateCache(d *dao.Simple) error
Constants ¶
View Source
const ( MainRoleManagementId = int32(-8) MainBrdgeConractDepositPrefix = 0x01 MainBridgeContractValidatorsKey = 0x03 MainStateValidatorRoleValue = 0x04 PUSHINT8 = 0 PUSHINT16 = 1 PUSH0 = 16 PUSH1 = 17 PUSH16 = 32 PUSHDATA1 = 12 SYSCALL = 65 SystemCryptoCheckSig uint32 = 666101590 SystemCryptoCheckMultisig uint32 = 987549854 )
View Source
const ( PrefixHeader = 0x00 PrefixStateRoot = 0x01 ValidatorsKey = 0x02 PrefixMainStateValidatorsAddress = 0x03 PrefixDepositId = 0x04 LockIdKey = 0x05 PrefixLock = 0x06 JointHeadersKey = 0x11 JointStateRootsKey = 0x12 )
View Source
const ( DefaultFeePerByte uint64 = 1000 DefaultGasPrice uint64 = 10000000000 //10GWei PrefixFeePerByte byte = 0x01 PrefixGasPrice byte = 0x08 PrefixBlockedAcount byte = 0x11 )
View Source
const (
GASDecimal = 18
)
View Source
const (
MaxNodeCount = 21
)
Variables ¶
View Source
var ( ErrInvalidSignature = errors.New("invalid signature") ErrInvalidHeader = errors.New("invalid header") ErrInvalidStateRoot = errors.New("invalid state root") ErrHeaderNotFound = errors.New("header not found") ErrStateRootNotFound = errors.New("state root not found") ErrTxInexistent = errors.New("tx inexistent") ErrAlreadySynced = errors.New("already synced") ErrAlreadyMinted = errors.New("already minted") ErrInvalidMPTProof = errors.New("invalid mpt proof") ErrTxIdNotMatchDepositedState = errors.New("txid and deposited state unmatch") ErrValidatorsOutdated = errors.New("synced validators outdated") ErrInvalidMainValidatorsState = errors.New("invalid main validators state") ErrUnreachThreshold = errors.New("mint amount unreach threshold") BridgeAddress common.Address = common.Address(common.BytesToAddress([]byte{nativeids.Bridge})) MintThreashold = big.NewInt(100000000) //1GAS BaseBonous = big.NewInt(3000000) //0.03GAS )
View Source
var ( ErrEmptyInput = errors.New("empty input") ErrInvalidInput = errors.New("invalid input") ErrInvalidMethodID = errors.New("invalid method id") ErrEmptyNodeList = errors.New("node list is empty") ErrLargeNodeList = errors.New("node list is too large") ErrInvalidRole = errors.New("invalid role") ErrInvalidSender = errors.New("sender check failed") ErrNoBlock = errors.New("no persisting block in the context") ErrInitialize = errors.New("initialize should only execute in genesis block") ErrInvalidContractCallInputs = errors.New("need at least 1 for InteropContext in contract call") ErrInvalidContractCallReturn = errors.New("invalid return value in contract call") )
View Source
var ( PolicyAddress = common.Address(common.BytesToAddress([]byte{nativeids.Policy})) ErrAccountBlocked = errors.New("account blocked") ErrContractBlocked = errors.New("contract blocked") )
View Source
var (
DesignationAddress common.Address = common.Address(common.BytesToAddress([]byte{nativeids.Designation}))
)
View Source
var (
GASAddress common.Address = common.Address(common.BytesToAddress([]byte{nativeids.GAS}))
)
View Source
var (
LedgerAddress common.Address = common.Address(common.BytesToAddress([]byte{nativeids.Ledger}))
)
View Source
var ManagementAddress common.Address = common.Address(common.BytesToAddress([]byte{nativeids.Management}))
Functions ¶
func MakeContractKey ¶
Types ¶
type Bridge ¶
type Bridge struct { state.NativeContract // contains filtered or unexported fields }
func (*Bridge) ContractCall_Payable_lock ¶
func (b *Bridge) ContractCall_Payable_lock(ic InteropContext, to common.Address) error
func (*Bridge) ContractCall__View_getMinted ¶
func (b *Bridge) ContractCall__View_getMinted(ic InteropContext, depositId int64) ([]byte, error)
func (*Bridge) ContractCall_requestMint ¶
func (*Bridge) ContractCall_syncHeader ¶
func (b *Bridge) ContractCall_syncHeader(ic InteropContext, rawHeader []byte) error
func (*Bridge) ContractCall_syncStateRoot ¶
func (b *Bridge) ContractCall_syncStateRoot(ic InteropContext, rawStateroot []byte) error
func (*Bridge) ContractCall_syncStateRootValidatorsAddress ¶
func (*Bridge) ContractCall_syncValidators ¶
func (*Bridge) RequiredGas ¶
func (d *Bridge) RequiredGas(ic InteropContext, input []byte) uint64
type Contracts ¶
type Contracts struct { GAS *GAS Ledger *Ledger Designate *Designate Management *Management Policy *Policy Bridge *Bridge Contracts []state.NativeContract }
func NewContracts ¶
func NewContracts(cfg config.ProtocolConfiguration) *Contracts
type Designate ¶
type Designate struct { state.NativeContract StandbyValidators keys.PublicKeys // contains filtered or unexported fields }
func NewDesignate ¶
func NewDesignate(cfg config.ProtocolConfiguration) *Designate
func (*Designate) ContractCall_initialize ¶
func (d *Designate) ContractCall_initialize(ic InteropContext) error
func (*Designate) GetConsensusAddress ¶
func (*Designate) GetDesignatedByRole ¶
func (*Designate) GetDesignatedByRoleFromStorage ¶
func (*Designate) GetSysAddresses ¶
func (*Designate) GetValidators ¶
func (*Designate) PostPersist ¶
func (*Designate) RequiredGas ¶
func (d *Designate) RequiredGas(ic InteropContext, input []byte) uint64
type DesignationCache ¶
type DesignationCache struct {
// contains filtered or unexported fields
}
type GAS ¶
type GAS struct { state.NativeContract // contains filtered or unexported fields }
func (*GAS) ContractCall_initialize ¶
func (g *GAS) ContractCall_initialize(ic InteropContext) error
func (*GAS) RequiredGas ¶
func (g *GAS) RequiredGas(ic InteropContext, input []byte) uint64
type InteropContext ¶
type InteropContext interface { Log(*types.Log) Sender() common.Address Dao() *dao.Simple Container() *transaction.Transaction PersistingBlock() *block.Block }
type Ledger ¶
type Ledger struct {
state.NativeContract
}
type Management ¶
type Management struct { state.NativeContract // contains filtered or unexported fields }
func NewManagement ¶
func NewManagement(cs *Contracts) *Management
func (*Management) ContractCall_initialize ¶
func (m *Management) ContractCall_initialize(ic InteropContext) error
func (*Management) GetCodeHash ¶
func (*Management) GetCodeSize ¶
func (*Management) GetContract ¶
func (*Management) RequiredGas ¶
func (m *Management) RequiredGas(ic InteropContext, input []byte) uint64
func (*Management) Run ¶
func (m *Management) Run(ic InteropContext, input []byte) ([]byte, error)
type Policy ¶
type Policy struct { state.NativeContract // contains filtered or unexported fields }
func (*Policy) ContractCall_blockAccount ¶
func (p *Policy) ContractCall_blockAccount(ic InteropContext, address common.Address) error
func (*Policy) ContractCall_initialize ¶
func (p *Policy) ContractCall_initialize(ic InteropContext) error
func (*Policy) ContractCall_setFeePerByte ¶
func (p *Policy) ContractCall_setFeePerByte(ic InteropContext, fee uint64) error
func (*Policy) ContractCall_setGasPrice ¶
func (p *Policy) ContractCall_setGasPrice(ic InteropContext, gasPrice uint64) error
func (*Policy) ContractCall_unblockAccount ¶
func (p *Policy) ContractCall_unblockAccount(ic InteropContext, address common.Address) error
func (*Policy) GetFeePerByteFromStorage ¶
func (*Policy) GetGasPriceFromStorage ¶
func (*Policy) RequiredGas ¶
func (p *Policy) RequiredGas(ic InteropContext, input []byte) uint64
Source Files ¶
Click to show internal directories.
Click to hide internal directories.