Golem QQ group:348383097
GOLEM 架构一览我们通过算力任务执行过程了解Golem的工作机制到底如何运行。
首先是算力请求方需要通过Golem网络发布算力任务。或许是个CGI设计师刚刚完成动画制作,希望将其作品渲染为高质量影像,亦或者是位数据科学家,想测试他的机器学习算法。
如果一个请求方任务属于Golem平台预设类型,请求方可以从任务集中找到任务模板。任务模板中包括所有计算逻辑。有需要运行的源代码,知道如何将任务分为子任务,这些子任务再被分配到不同的节点。知道如何验证结果,并合并形成最后结果。目前模板集主要是一些已有模板(Blender渲染任务,Luxrender渲染任务),模板集逐渐会成为“Golem 店铺”,用户可以增加和下载新的应用案例。
如果用户任务比较特殊,并不存在与“任务集”中,就必须用“任务自定义框架”写下自己的代码。Brass(铜)和Clay(黏土)用户级别仅可以在固定任务集中做选择。(也就是在Golem开发者预设任务中进行选择)。任务自定义框架适用于 Golem Stone级别用户,是一种通用模板,用户利用开放式界面创建新类型任务。可以存储于本地供创建者专用,也可以上传到“Golem 商铺”。
请求方一旦选择任务模板并定义一个新任务,该任务会列入“任务管理器”中,任务管理器负责记录跟踪来自于该节点的任务请求,接着新任务信息就会在Golem网络中进行广播。
算力供应商的“转账系统”收集所有广播要约并选择最佳要约。该系统在“信誉评级系统”检查每个节点的信誉等级,并退回来自于信誉不良节点要约。然后,算力供应商的Golem与请求方节点连接,并上传报价和机器计算能力(性能,CPU核数)。请求方“转账系统”检查算力供应商信誉等级,并拒绝信誉不良供应商的报价。如果“任务管理器”确定某个子任务符合报价要约,相关资源会发给算力供应商,供应商可以从IPFS下载。
当所有资源载入算力供应商机器中后,“任务计算机”(算力供应商机器)便可开始计算。
“任务计算机”负责运行和管理计算任务。可以开启Docker容器引擎,执行相关源代码,也可以检查错误或超时。在未来,也可以在虚拟机(速度慢但安全)或者直接在主机上运行(快但不安全)。当然第二种选项仅仅适用于特殊情况,而且算力供应商只从“任务集”中选择检查安全的任务后再运行代码。
计算任务结束,其结果和log记录便通过IPFS网络反馈给请求方。“任务管理器”将这些信息传递给任务模板进行验证。该过程因任务类型而异。根据冗余度来判断最受欢迎的一个。有些子任务可能会被发往多个节点(请求方可以决定频率和次数)并且对计算结果进行对比。有些情况,就没有必要进行对比,因为验证方法及其简单,比如任务本身是个PoW之类。请求方也可以计算随机的一小部分任务并将其与结果对比。比如,渲染任务中,可以在本地渲染一部分像素并与接收到的图片进行对比。有时可以多个方法并用。
如果任务结果通过验证,“支付系统”中就会收到付款通知,并通过以太坊智能合约发送对应正确以太币数量。详情请参考之前的文章,一遍了解其工作原理,以及我们选择以太坊的原因。与此同时,算力供应商的信誉等级在供应商信誉评级系统中得到提升(反之则降级)。信誉降级中,如果算力供应商发送计算过程中的错误信息或者根本没有发送计算结果(大部分这种情况是因为技术问题造成),信誉降级程度较低;如果计算结果错误,则降级程度较高。(计算错误造成信誉降级的权重比报错信息或无结果造成信誉降级的权重更大)
算力供应商的支付系统监控以太区块链和付款时效。如果付款延时,算力请求方信誉会严重下降。信誉评级系统记录某个节点与其他节点交互的正反经历,并以此计算等级。有两种独立的评级:算力供应商一方,及算力请求方。该系统通过“差异闲话算法”交换评级信息。促使信誉向量汇聚成现实的全球通用财富。采用一个有效的评级系统并非易事,并且也是整个项目中最大的挑战。在未来,我们打算引进另一种机制--类似一种基于以太坊的信誉等级系统,但要根据其在以太坊生态中的实际开发程度而定。
当然这些仅仅是冰山一角,对Golem典型工作流程的管中窥豹。在未来,我们将提供对每个系统的详细解释。