Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kernel contract eth-proxy #218

Open
wants to merge 91 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
fa3e0e3
update error check
Jun 11, 2021
5b207a9
Add contract QueryTx and QueryBlock in Contract (#204)
chenfengjin Jul 12, 2021
5cb17cd
RFC: Add unit test
Jul 10, 2021
dfade08
Add unit test
Jul 10, 2021
2af0ea7
RFC: Add unit test
Jul 10, 2021
22c5b57
trigger ci
Jul 12, 2021
0cf4275
go mod tidy
Jul 12, 2021
6fb07cc
RFC: update unit test
Jul 30, 2021
9d1b4e6
RFC: Add testdata
Jul 30, 2021
2c7f0ff
update chain core test
Aug 8, 2021
f3e2b0b
update helper.go
Aug 8, 2021
c837913
remove xxx_ field in helper.go
Aug 9, 2021
102d803
remove useless field in fakechaincore
Aug 9, 2021
8de5134
update test helper
Aug 9, 2021
5e9baa9
update test helper
Aug 9, 2021
11ada75
secp256k1 first version
Jul 23, 2021
067286d
trigger ci
Jul 12, 2021
1a6d6e2
Add evm proxy
Jul 26, 2021
542c9e8
Add evm proxy
Jul 26, 2021
24d6564
RFC: Add testdata
Jul 26, 2021
dd7e67e
eth-proxy ok
Jul 27, 2021
558e522
RFC: evmproxy using contract call ok
Jul 31, 2021
76a3e06
counter increase down
Aug 2, 2021
c4719ca
initiator ok
Aug 2, 2021
7e49156
WIP: add kernel contract eth-proxy
Aug 2, 2021
4c9cb9b
Add signature verification
Aug 3, 2021
9b2c96a
use rpl to generate tx msg
Aug 3, 2021
9519120
RFC: Add signature verify code
Aug 3, 2021
609c9c3
signature verify ok
Aug 4, 2021
d7c208a
trigger ci
Jul 12, 2021
e37e0b8
evm proxy to seperate proxy
chenfengjin Aug 4, 2021
885b718
reorg code
Aug 5, 2021
da8bec9
Add .SendTransaction
Aug 5, 2021
02f6e06
use kernel contract evm
Aug 5, 2021
8e26ec5
Add SendRawContract and Call
Aug 5, 2021
6ff9f1e
remove useless code
Aug 5, 2021
991ab38
remove useless code
Aug 5, 2021
a523226
Revert "remove useless code"
Aug 5, 2021
00c5363
remove useless manager test
Aug 5, 2021
3f1fac1
remove useless manager test
Aug 5, 2021
57e2fb2
Add test helper
Aug 5, 2021
f8c5dce
Add test helper
Aug 5, 2021
b2f3a00
Add test helper
Aug 5, 2021
486b9c2
Add test helper
Aug 5, 2021
ec7ebcd
fix ci problems
Aug 6, 2021
bb075f8
update send transaction
Aug 6, 2021
0c0855c
Add transfer support
Aug 6, 2021
5d9aedf
Add transfer support
Aug 6, 2021
590649f
update go.mod
Aug 6, 2021
ff1d480
update burrow dependency
Aug 6, 2021
550da64
Remvoe setevmproxy
Aug 6, 2021
7a46fc8
Remove useless code
Aug 6, 2021
575fe17
Remove useless code
Aug 6, 2021
59916e9
enable contract permission check
Aug 6, 2021
c348111
update evm proxy test
Aug 8, 2021
770b24d
update evm proxy test
Aug 8, 2021
691572a
update evm proxy test
Aug 8, 2021
1f11111
update evm proxy test
Aug 8, 2021
a1beb2c
update test helper
Aug 8, 2021
54ef204
Add unit test for SendRawTransaction and ContractCall
Aug 9, 2021
49d5b9b
resolve conflix
Aug 9, 2021
f5787b3
resolve conflix
Aug 9, 2021
64f3596
remove binary file
Aug 9, 2021
05cf515
format code
Aug 9, 2021
71ff8d7
format code
Aug 9, 2021
82c5437
format code
Aug 9, 2021
06c1a19
update code style
Aug 9, 2021
cf967f2
remove uesless code
Aug 9, 2021
4e7923d
format code
Aug 9, 2021
d566584
add testdata
Aug 9, 2021
0f7a15f
update unit test
Aug 9, 2021
9999d67
store eth transaction when sendRawTransaction
Aug 9, 2021
3db9e82
comment out sendtransaction as it is not used
Aug 9, 2021
d985765
remove testdata
Aug 9, 2021
913b54e
rename filename to lower case as linux is case sensitive
Aug 9, 2021
99713fd
comment out ContractCall as it can be replaced by preexec
Aug 19, 2021
8381281
Add GetTransactionReceipt method
Aug 19, 2021
5ed6cc7
resolve confliction
Aug 19, 2021
adc058a
generate txHash in proxy contract
Aug 24, 2021
0f8532b
RFC: remove transfer in evm contract
chenfengjin Aug 26, 2021
05c1c73
WIP: add balance
chenfengjin Aug 27, 2021
4f862c9
fix hex encoding
chenfengjin Aug 27, 2021
9388d4a
add transfer and balance of
chenfengjin Aug 27, 2021
5981847
add transfer and BalanceOf && remove ContractCall and SendTransaction
chenfengjin Aug 28, 2021
f12ebb1
update burrow version
chenfengjin Aug 28, 2021
9747c76
Add TransactionCount
chenfengjin Aug 29, 2021
0bfc3c0
Add TransactionCount
chenfengjin Aug 29, 2021
becacea
update GetTransactionCount
chenfengjin Aug 29, 2021
c665616
RFC: Add coin base process&& add inititlaizeAccount for unit test
chenfengjin Aug 29, 2021
47524e3
RFC: fix fee problem
chenfengjin Aug 30, 2021
044383d
Add Pledge Redeem Allowance (#3)
chenfengjin Aug 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,18 @@ require (
github.com/libp2p/go-libp2p-kbucket v0.4.2
github.com/libp2p/go-libp2p-record v0.1.2
github.com/libp2p/go-libp2p-secio v0.2.2
github.com/mr-tron/base58 v1.2.0
github.com/multiformats/go-multiaddr v0.3.1
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/prometheus/client_golang v1.1.0
github.com/prometheus/client_golang v1.11.0
github.com/spf13/cobra v1.0.0
github.com/spf13/viper v1.6.2
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca
github.com/xuperchain/crypto v0.0.0-20201028025054-4d560674bcd6
github.com/xuperchain/log15 v0.0.0-20190620081506-bc88a9198230
github.com/xuperchain/xvm v0.0.0-20210126142521-68fd016c56d7
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
google.golang.org/grpc v1.35.0
)

replace github.com/hyperledger/burrow => github.com/xuperchain/burrow v0.30.6-0.20210317023017-369050d94f4a
replace github.com/hyperledger/burrow => github.com/xuperchain/burrow v0.30.6-0.20210806065218-1c6d40be4365
81 changes: 64 additions & 17 deletions go.sum

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion kernel/contract/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ type KContext interface {
Initiator() string
Caller() string
AuthRequire() []string

TransferAmount() string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TransferAmount的签名参考go sdk的签名

ContractName() string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

覆盖Kcontext的transfer方法,只能通过合约名字转账,不用加ContractName

// 状态修改接口
StateSandbox

Expand Down
8 changes: 8 additions & 0 deletions kernel/contract/kernel/kcontext_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,11 @@ func (k *kcontextImpl) EmitAsyncTask(event string, args interface{}) (err error)
k.AddEvent(&e)
return
}

func (k *kcontextImpl) TransferAmount() string {
return k.ctx.TransferAmount
}

func (k *kcontextImpl) ContractName() string {
return k.ctx.ContractName
}
11 changes: 7 additions & 4 deletions kernel/contract/mock/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package mock
import (
"crypto/rand"
"encoding/json"
"github.com/xuperchain/xupercore/kernel/contract/bridge"
"io/ioutil"
"math/big"
"os"

"github.com/golang/protobuf/proto"

"github.com/xuperchain/xupercore/kernel/contract"
"github.com/xuperchain/xupercore/kernel/contract/bridge"
"github.com/xuperchain/xupercore/kernel/contract/sandbox"
"github.com/xuperchain/xupercore/kernel/ledger"
"github.com/xuperchain/xupercore/kernel/permission/acl/utils"
Expand Down Expand Up @@ -75,8 +76,7 @@ func (t *TestHelper) UTXOState() *contract.UTXORWSet {

func (t *TestHelper) initAccount() {
t.state.Put(utils.GetAccountBucket(), []byte(ContractAccount), &ledger.VersionedData{
RefTxid: []byte("txid"),
PureData: nil,
RefTxid: []byte("txid"),
})

utxoReader := sandbox.NewUTXOReaderFromInput([]*protos.TxInput{
Expand All @@ -91,6 +91,9 @@ func (t *TestHelper) initAccount() {

t.utxoReader = utxoReader
}
func (t *TestHelper) SetUtxoReader(reader contract.UtxoReader) {
t.utxoReader = reader
}

func (t *TestHelper) Deploy(module, lang, contractName string, bin []byte, args map[string][]byte) (*contract.Response, error) {
m := t.Manager()
Expand Down Expand Up @@ -192,8 +195,8 @@ func (t *TestHelper) Invoke(module, contractName, method string, args map[string
return nil, err
}
defer ctx.Release()

resp, err := ctx.Invoke(method, args)

if err != nil {
return nil, err
}
Expand Down
7 changes: 7 additions & 0 deletions kernel/engines/xuperos/agent/rely.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package agent

import (
"fmt"
"github.com/xuperchain/xupercore/kernel/evm"
"path/filepath"

"github.com/xuperchain/xupercore/lib/logs"
Expand Down Expand Up @@ -207,6 +208,12 @@ func (t *ChainRelyAgentImpl) CreateProposal() (propose.ProposeManager, error) {
return proposalObj, nil
}

func (t *ChainRelyAgentImpl) CreateEVManager() (evm.EVMProxy, error) {
ctx := t.chain.Context()
proxy, err := evm.NewEVMProxy(ctx.Contract)
return proxy, err
}

// 创建定时器任务实例
func (t *ChainRelyAgentImpl) CreateTimerTask() (timerTask.TimerManager, error) {
ctx := t.chain.Context()
Expand Down
6 changes: 6 additions & 0 deletions kernel/engines/xuperos/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,12 @@ func (t *Chain) initChainCtx() error {
t.ctx.State.SetTimerTaskMG(t.ctx.TimerTask)
t.log.Trace("create timer_task succ", "bcName", t.ctx.BCName)
t.log.Trace("create chain succ", "bcName", t.ctx.BCName)
// 11. EVM Proxy
_, err = t.relyAgent.CreateEVManager()
if err != nil {
t.log.Error("create evm proxy failed", "bcname", t.ctx.BCName, "err", err)
return fmt.Errorf("create evm proxy error")
}
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions kernel/engines/xuperos/common/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/xuperchain/xupercore/kernel/contract/proposal/propose"
timerTask "github.com/xuperchain/xupercore/kernel/contract/proposal/timer"
"github.com/xuperchain/xupercore/kernel/engines"
"github.com/xuperchain/xupercore/kernel/evm"
kledger "github.com/xuperchain/xupercore/kernel/ledger"
"github.com/xuperchain/xupercore/kernel/network"
aclBase "github.com/xuperchain/xupercore/kernel/permission/acl/base"
Expand Down Expand Up @@ -61,6 +62,7 @@ type ChainRelyAgent interface {
CreateGovernToken() (governToken.GovManager, error)
CreateProposal() (propose.ProposeManager, error)
CreateTimerTask() (timerTask.TimerManager, error)
CreateEVManager() (evm.EVMProxy, error)
}

type ChainManager interface {
Expand Down
Loading