Documentation ¶
Overview ¶
Package store is used to keep application events in sync between the database on the node and the blockchain.
Config ¶
Config contains the local configuration options that the application will adhere to.
CallerSubscriberClient ¶
This makes use of Go-Ethereum's functions to interact with the blockchain. The underlying functions can be viewed here:
go-ethereum/rpc/client.go
KeyStore ¶
KeyStore also utilizes Go-Ethereum's functions to store encrypted keys on the local file system. The underlying functions can be viewed here:
go-ethereum/accounts/keystore/keystore.go
Store ¶
The Store is the persistence layer for the application. It saves the the application state and most interaction with the node needs to occur through the store.
Tx Manager ¶
The transaction manager is used to syncronize interactions on the Ethereum blockchain with the application and database.
Index ¶
- Constants
- Variables
- func CheckSquashUpgrade(db *gorm.DB) error
- func PromUpdateEthBalance(balance *assets.Eth, from common.Address)
- type HeadTrackable
- type InMemoryKeyStore
- type KeyStore
- func (ks *KeyStore) Delete(address common.Address) error
- func (ks *KeyStore) Export(address common.Address, newPassword string) ([]byte, error)
- func (ks *KeyStore) GetAccountByAddress(address common.Address) (accounts.Account, error)
- func (ks *KeyStore) GetAccounts() []accounts.Account
- func (ks *KeyStore) HasAccountWithAddress(address common.Address) bool
- func (ks *KeyStore) HasAccounts() bool
- func (ks *KeyStore) Import(keyJSON []byte, oldPassword string) (accounts.Account, error)
- func (ks *KeyStore) NewAccount() (accounts.Account, error)
- func (ks *KeyStore) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
- func (ks *KeyStore) Unlock(password string) error
- type KeyStoreGenerator
- type KeyStoreInterface
- type NotifyNewEthTx
- type Store
- func (s *Store) ArchiveKey(address common.Address) error
- func (s *Store) AuthorizedUserWithSession(sessionID string) (models.User, error)
- func (s *Store) Close() error
- func (s *Store) DeleteKey(address common.Address) error
- func (s *Store) ImportKey(keyJSON []byte, oldPassword string) error
- func (s *Store) Start() error
- func (s *Store) SyncDiskKeyStoreToDB() error
- func (s *Store) Unscoped() *Store
- type VRFKeyStore
- func (ks *VRFKeyStore) Archive(key vrfkey.PublicKey) (err error)
- func (ks *VRFKeyStore) CreateKey(phrase string) (vrfkey.PublicKey, error)
- func (ks *VRFKeyStore) CreateWeakInMemoryEncryptedKeyXXXTestingOnly(phrase string) (*vrfkey.EncryptedVRFKey, error)
- func (ks *VRFKeyStore) Delete(key vrfkey.PublicKey) (err error)
- func (ks *VRFKeyStore) Forget(k vrfkey.PublicKey) error
- func (ks *VRFKeyStore) GenerateProof(k vrfkey.PublicKey, i vrf.PreSeedData) (vrf.MarshaledOnChainResponse, error)
- func (ks *VRFKeyStore) Get(k ...vrfkey.PublicKey) ([]*vrfkey.EncryptedVRFKey, error)
- func (ks *VRFKeyStore) GetSpecificKey(k vrfkey.PublicKey) (*vrfkey.EncryptedVRFKey, error)
- func (ks *VRFKeyStore) Import(keyjson []byte, auth string) error
- func (ks *VRFKeyStore) ListKeys() (publicKeys []*vrfkey.PublicKey, err error)
- func (ks *VRFKeyStore) Store(key *vrfkey.PrivateKey, phrase string, scryptParams utils.ScryptParams) error
- func (ks *VRFKeyStore) StoreInMemoryXXXTestingOnly(key *vrfkey.PrivateKey)
- func (ks *VRFKeyStore) Unlock(phrase string) (keysUnlocked []vrfkey.PublicKey, merr error)
Constants ¶
const (
// AutoMigrate is a flag that automatically migrates the DB when passed to initializeORM
AutoMigrate = "auto_migrate"
)
const EthereumMessageHashPrefix = "\x19Ethereum Signed Message:\n32"
EthereumMessageHashPrefix is a Geth-originating message prefix that seeks to prevent arbitrary message data to be representable as a valid Ethereum transaction For more information, see: https://github.com/ethereum/go-ethereum/issues/3731
Variables ¶
var AttemptToDeleteNonExistentKeyFromDB = errors.New("key is not present in DB")
AttemptToDeleteNonExistentKeyFromDB is returned when Delete is asked to delete a key it can't find in the DB.
var ErrKeyStoreLocked = errors.New("keystore is locked (HINT: did you forget to call keystore.Unlock?)")
var MatchingVRFKeyError = errors.New(
`key with matching public key already stored in DB`)
MatchingVRFKeyError is returned when Import attempts to import key with a PublicKey matching one already in the database
Functions ¶
func CheckSquashUpgrade ¶
Types ¶
type HeadTrackable ¶
type HeadTrackable interface { Connect(head *models.Head) error Disconnect() OnNewLongestChain(ctx context.Context, head models.Head) }
HeadTrackable represents any object that wishes to respond to ethereum events, after being attached to HeadTracker.
type InMemoryKeyStore ¶
type InMemoryKeyStore = map[vrfkey.PublicKey]vrfkey.PrivateKey
type KeyStore ¶
KeyStore manages a key storage directory on disk.
func InsecureKeyStoreGen ¶
func NewInsecureKeyStore ¶
NewInsecureKeyStore creates an *INSECURE* keystore for the given directory. NOTE: Should only be used for testing!
func NewKeyStore ¶
func NewKeyStore(keyDir string, scryptParams utils.ScryptParams) *KeyStore
NewKeyStore creates a keystore for the given directory.
func StandardKeyStoreGen ¶
func (*KeyStore) GetAccountByAddress ¶
GetAccountByAddress returns the account matching the address provided, or an error if it is missing
func (*KeyStore) GetAccounts ¶
GetAccounts returns all accounts
func (*KeyStore) HasAccountWithAddress ¶
func (*KeyStore) HasAccounts ¶
HasAccounts returns true if there are accounts located at the keystore directory.
func (*KeyStore) NewAccount ¶
NewAccount adds an account to the keystore
type KeyStoreGenerator ¶
type KeyStoreInterface ¶
type KeyStoreInterface interface { Unlock(password string) error Accounts() []accounts.Account Wallets() []accounts.Wallet HasAccounts() bool HasAccountWithAddress(common.Address) bool NewAccount() (accounts.Account, error) Import(keyJSON []byte, oldPassword string) (accounts.Account, error) Export(address common.Address, newPassword string) ([]byte, error) Delete(address common.Address) error GetAccounts() []accounts.Account GetAccountByAddress(common.Address) (accounts.Account, error) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) }
type NotifyNewEthTx ¶
type NotifyNewEthTx interface {
Trigger()
}
NotifyNewEthTx allows to notify the ethBroadcaster of a new transaction
type Store ¶
type Store struct { *orm.ORM Config *orm.Config Clock utils.AfterNower KeyStore KeyStoreInterface VRFKeyStore *VRFKeyStore OCRKeyStore *offchainreporting.KeyStore EthClient eth.Client NotifyNewEthTx NotifyNewEthTx AdvisoryLocker postgres.AdvisoryLocker // contains filtered or unexported fields }
Store contains fields for the database, Config, and KeyStore for keeping the application state in sync with the database.
func NewInsecureStore ¶
func NewInsecureStore(config *orm.Config, ethClient eth.Client, advisoryLocker postgres.AdvisoryLocker, shutdownSignal gracefulpanic.Signal) (*Store, error)
NewInsecureStore creates a new store with the given config using an insecure keystore. NOTE: Should only be used for testing!
func NewStore ¶
func NewStore(config *orm.Config, ethClient eth.Client, advisoryLock postgres.AdvisoryLocker, shutdownSignal gracefulpanic.Signal, keyStoreGenerator KeyStoreGenerator) (*Store, error)
NewStore will create a new store
func (*Store) ArchiveKey ¶
ArchiveKey soft-deletes a key whose address matches the supplied address.
func (*Store) AuthorizedUserWithSession ¶
AuthorizedUserWithSession will return the one API user if the Session ID exists and hasn't expired, and update session's LastUsed field.
func (*Store) SyncDiskKeyStoreToDB ¶
SyncDiskKeyStoreToDB writes all keys in the keys directory to the underlying orm.
type VRFKeyStore ¶
type VRFKeyStore struct {
// contains filtered or unexported fields
}
VRFKeyStore tracks auxiliary VRF secret keys, and generates their VRF proofs
VRF proofs need access to the actual secret key, which geth does not expose. Similar to the way geth's KeyStore exposes signing capability, VRFKeyStore exposes VRF proof generation without the caller needing explicit knowledge of the secret key.
func NewVRFKeyStore ¶
func NewVRFKeyStore(store *Store) *VRFKeyStore
NewVRFKeyStore returns an empty VRFKeyStore
func (*VRFKeyStore) Archive ¶
func (ks *VRFKeyStore) Archive(key vrfkey.PublicKey) (err error)
Archive soft-deletes keys with this public key from the keystore and the DB, if present.
func (*VRFKeyStore) CreateKey ¶
func (ks *VRFKeyStore) CreateKey(phrase string) (vrfkey.PublicKey, error)
CreateKey returns a public key which is immediately unlocked in memory, and saved in DB encrypted with phrase. If p is given, its parameters are used for key derivation from the phrase.
func (*VRFKeyStore) CreateWeakInMemoryEncryptedKeyXXXTestingOnly ¶
func (ks *VRFKeyStore) CreateWeakInMemoryEncryptedKeyXXXTestingOnly(phrase string) (*vrfkey.EncryptedVRFKey, error)
CreateWeakInMemoryEncryptedKeyXXXTestingOnly is for testing only! It returns an encrypted key which is fast to unlock, but correspondingly easy to brute force. It is not persisted to the DB, because no one should be keeping such keys lying around.
func (*VRFKeyStore) Delete ¶
func (ks *VRFKeyStore) Delete(key vrfkey.PublicKey) (err error)
Delete removes keys with this public key from the keystore and the DB, if present.
func (*VRFKeyStore) GenerateProof ¶
func (ks *VRFKeyStore) GenerateProof(k vrfkey.PublicKey, i vrf.PreSeedData) ( vrf.MarshaledOnChainResponse, error)
GenerateProof is marshaled randomness proof given k and VRF input seed computed from the SeedData
Key must have already been unlocked in ks, as constructing the VRF proof requires the secret key.
func (*VRFKeyStore) Get ¶
func (ks *VRFKeyStore) Get(k ...vrfkey.PublicKey) ([]*vrfkey.EncryptedVRFKey, error)
Get retrieves all EncryptedVRFKey's associated with k, or all encrypted keys if k is nil, or errors
func (*VRFKeyStore) GetSpecificKey ¶
func (ks *VRFKeyStore) GetSpecificKey( k vrfkey.PublicKey) (*vrfkey.EncryptedVRFKey, error)
func (*VRFKeyStore) Import ¶
func (ks *VRFKeyStore) Import(keyjson []byte, auth string) error
Import adds this encrypted key to the DB and unlocks it in in-memory store with passphrase auth, and returns any resulting errors
func (*VRFKeyStore) ListKeys ¶
func (ks *VRFKeyStore) ListKeys() (publicKeys []*vrfkey.PublicKey, err error)
ListKeys lists the public keys contained in the db
func (*VRFKeyStore) Store ¶
func (ks *VRFKeyStore) Store(key *vrfkey.PrivateKey, phrase string, scryptParams utils.ScryptParams) error
Store saves key to ks (in memory), and to the DB, encrypted with phrase
func (*VRFKeyStore) StoreInMemoryXXXTestingOnly ¶
func (ks *VRFKeyStore) StoreInMemoryXXXTestingOnly(key *vrfkey.PrivateKey)
StoreInMemoryXXXTestingOnly memorizes key, only in in-memory store.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package models contain the key job components used by the Adamoracle application.
|
Package models contain the key job components used by the Adamoracle application. |
vrfkey
Package vrfkey tracks the secret keys associated with VRF proofs.
|
Package vrfkey tracks the secret keys associated with VRF proofs. |
Package presenters allow for the specification and result of a Job, its associated TaskSpecs, and every JobRun and TaskRun to be returned in a user friendly human readable format.
|
Package presenters allow for the specification and result of a Job, its associated TaskSpecs, and every JobRun and TaskRun to be returned in a user friendly human readable format. |