From 46949b13e2baedecb13b7178302470f8562805a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Martini=C4=87?= Date: Thu, 23 Jun 2022 18:13:32 +0200 Subject: [PATCH] Upload smart contract code (#33) --- chain/errors.go | 6 + chain/evm/compass.go | 111 ++++++++------- chain/evm/compass_test.go | 81 ++++++++++- chain/evm/deploy_contract.go | 12 +- chain/evm/errors.go | 2 + chain/evm/mock_evmClienter_test.go | 32 +++++ chain/paloma/client.go | 14 +- cmd/sparrow/cmd_evm.go | 6 +- config.example.yaml | 2 +- proto/paloma/evm/turnstone.proto | 2 + types/paloma/x/evm/types/turnstone.pb.go | 170 ++++++++++++++++++----- 11 files changed, 346 insertions(+), 92 deletions(-) diff --git a/chain/errors.go b/chain/errors.go index f598e6d4..6b341773 100644 --- a/chain/errors.go +++ b/chain/errors.go @@ -9,4 +9,10 @@ const ( ErrSignatureDoesNotMatchItsRespectiveSigner = whoops.String("signature does not match its respective signer") ErrTooLittleOrTooManySignaturesProvided = whoops.String("too many or too little signatures provided") ErrProcessorDoesNotSupportThisQueue = whoops.Errorf("processor does not support queue: %s") + + ErrNotFound = whoops.String("not found") + + EnrichedChainID whoops.Field[string] = "chainID" + EnrichedID whoops.Field[uint64] = "id" + EnrichedItemType whoops.Field[string] = "type" ) diff --git a/chain/evm/compass.go b/chain/evm/compass.go index 189a91c2..dd23c944 100644 --- a/chain/evm/compass.go +++ b/chain/evm/compass.go @@ -1,7 +1,10 @@ package evm import ( + "bytes" "context" + goerrors "errors" + "fmt" "math/big" etherum "github.com/ethereum/go-ethereum" @@ -15,6 +18,7 @@ import ( "github.com/palomachain/sparrow/errors" "github.com/palomachain/sparrow/types/paloma/x/evm/types" "github.com/palomachain/sparrow/util/slice" + log "github.com/sirupsen/logrus" "github.com/vizualni/whoops" ) @@ -30,6 +34,7 @@ const ( type evmClienter interface { FilterLogs(ctx context.Context, fq etherum.FilterQuery, currBlockHeight *big.Int, fn func(logs []ethtypes.Log) bool) (bool, error) ExecuteSmartContract(ctx context.Context, contractAbi abi.ABI, addr common.Address, method string, arguments []any) (*etherumtypes.Transaction, error) + DeployContract(ctx context.Context, contractAbi abi.ABI, bytecode, constructorInput []byte) (contractAddr common.Address, tx *ethtypes.Transaction, err error) } type compass struct { @@ -90,9 +95,13 @@ func (t compass) updateValset( currentValset, err := t.paloma.QueryGetEVMValsetByID(ctx, valsetID, t.ChainID) whoops.Assert(err) + if currentValset == nil { + whoops.Assert(fmt.Errorf("oh no")) + } + consensusReached := isConsensusReached(currentValset, origMessage) if !consensusReached { - return + whoops.Assert(ErrNoConsensus) } _, err = t.callCompass(ctx, "update_valset", []any{ @@ -107,12 +116,11 @@ func (t compass) updateValset( func (t compass) submitLogicCall( ctx context.Context, - messageID uint64, msg *types.SubmitLogicCall, origMessage chain.MessageWithSignatures, ) error { return whoops.Try(func() { - executed, err := t.isArbitraryCallAlreadyExecuted(ctx, messageID) + executed, err := t.isArbitraryCallAlreadyExecuted(ctx, origMessage.ID) whoops.Assert(err) if executed { return @@ -126,7 +134,7 @@ func (t compass) submitLogicCall( consensusReached := isConsensusReached(valset, origMessage) if !consensusReached { - return + whoops.Assert(ErrNoConsensus) } con := buildConsensus(ctx, valset, origMessage.Signatures) @@ -143,41 +151,32 @@ func (t compass) submitLogicCall( }) } -// func (t compass) uploadSmartContract( -// ctx context.Context, -// messageID uint64, -// turnstoneID []byte, -// msg *types.UploadSmartContract, -// signatures []chain.ValidatorSignature, -// ) error { -// return whoops.Try(func() { -// executed, err := t.isArbitraryCallAlreadyExecuted(ctx, messageID) -// whoops.Assert(err) -// if executed { -// return -// } - -// valsetID, err := t.findLastValsetMessageID(ctx) -// whoops.Assert(err) - -// snapshot, err := t.Client.paloma.GetSnapshotByID(ctx, valsetID) -// whoops.Assert(err) - -// bind.DeployContract() - -// con := t.buildConsensus(ctx, snapshot, signatures) - -// _, err = t.callSmartContract(ctx, "submit_logic_call", []any{ -// con, -// common.HexToAddress(msg.GetHexContractAddress()), -// msg.GetPayload(), -// msg.GetDeadline(), -// }) -// whoops.Assert(err) - -// return -// }) -// } +func (t compass) uploadSmartContract( + ctx context.Context, + msg *types.UploadSmartContract, + origMessage chain.MessageWithSignatures, +) error { + return whoops.Try(func() { + contractABI, err := abi.JSON(bytes.NewReader(msg.GetAbi())) + whoops.Assert(err) + + // 0 means to get the latest valset + latestValset, err := t.paloma.QueryGetEVMValsetByID(ctx, 0, t.ChainID) + whoops.Assert(err) + + consensusReached := isConsensusReached(latestValset, origMessage) + if !consensusReached { + whoops.Assert(ErrNoConsensus) + } + + addr, tx, err := t.evm.DeployContract(ctx, contractABI, msg.GetBytecode(), msg.GetConstructorInput()) + // TODO: do attestation + _ = addr + _ = tx + whoops.Assert(err) + return + }) +} func (t compass) findLastValsetMessageID(ctx context.Context) (uint64, error) { filter := etherum.FilterQuery{ @@ -292,30 +291,48 @@ func buildConsensus( func (t compass) processMessages(ctx context.Context, queueTypeName string, msgs []chain.MessageWithSignatures) error { var gErr whoops.Group for _, rawMsg := range msgs { + var processingErr error + logger := log.WithFields(log.Fields{ + "processor-chain-id": t.ChainID, + "queue-name": queueTypeName, + "msg-id": rawMsg.ID, + }) + logger.Info("processing") msg := rawMsg.Msg.(*types.Message) switch action := msg.GetAction().(type) { case *types.Message_SubmitLogicCall: - err := t.submitLogicCall( + processingErr = t.submitLogicCall( ctx, - rawMsg.ID, action.SubmitLogicCall, rawMsg, ) - gErr.Add(err) case *types.Message_UpdateValset: - err := t.updateValset( + processingErr = t.updateValset( ctx, action.UpdateValset.Valset, rawMsg, ) - gErr.Add(err) + case *types.Message_UploadSmartContract: + processingErr = t.uploadSmartContract( + ctx, + action.UploadSmartContract, + rawMsg, + ) default: return ErrUnsupportedMessageType.Format(action) } - // TODO: this is temporary - err := t.paloma.DeleteJob(ctx, queueTypeName, rawMsg.ID) - gErr.Add(err) + + switch { + case processingErr == nil: + // TODO: this is temporary + err := t.paloma.DeleteJob(ctx, queueTypeName, rawMsg.ID) + gErr.Add(err) + case goerrors.Is(processingErr, ErrNoConsensus): + // does nothing + default: + gErr.Add(processingErr) + } } if gErr.Err() { diff --git a/chain/evm/compass_test.go b/chain/evm/compass_test.go index 69aaa7cd..dd080190 100644 --- a/chain/evm/compass_test.go +++ b/chain/evm/compass_test.go @@ -99,7 +99,6 @@ func TestMessageProcessing(t *testing.T) { fn := args.Get(3).(func([]etherumtypes.Log) bool) fn(isArbitraryCallExecutedLogs) }) - paloma.On("DeleteJob", mock.Anything, "queue-name", uint64(666)).Return(nil) return evm, paloma @@ -208,7 +207,6 @@ func TestMessageProcessing(t *testing.T) { }, nil, ) - paloma.On("DeleteJob", mock.Anything, "queue-name", uint64(555)).Return(nil) return evm, paloma }, @@ -345,10 +343,89 @@ func TestMessageProcessing(t *testing.T) { nil, ) + return evm, paloma + }, + }, + { + name: "upload_smart_contract/happy path", + msgs: []chain.MessageWithSignatures{ + { + QueuedMessage: chain.QueuedMessage{ + ID: 555, + BytesToSign: ethCompatibleBytesToSign, + Msg: &types.Message{ + Action: &types.Message_UploadSmartContract{ + UploadSmartContract: &types.UploadSmartContract{ + Bytecode: []byte("bytecode"), + Abi: StoredContracts()["simple"].Source, + ConstructorInput: []byte("constructor input"), + }, + }, + }, + }, + Signatures: []chain.ValidatorSignature{ + addValidSignature(bobPK), + }, + }, + }, + setup: func(t *testing.T) (*mockEvmClienter, *mockPalomaClienter) { + evm, paloma := newMockEvmClienter(t), newMockPalomaClienter(t) + + currentValsetID := int64(0) + + paloma.On("QueryGetEVMValsetByID", mock.Anything, uint64(currentValsetID), "internal-chain-id").Return( + &types.Valset{ + Validators: []string{crypto.PubkeyToAddress(bobPK.PublicKey).Hex()}, + Powers: []uint64{powerThreshold + 1}, + ValsetID: uint64(currentValsetID), + }, + nil, + ) + + evm.On("DeployContract", mock.Anything, StoredContracts()["simple"].ABI, []byte("bytecode"), []byte("constructor input")).Return(nil, nil, nil) + paloma.On("DeleteJob", mock.Anything, "queue-name", uint64(555)).Return(nil) return evm, paloma }, }, + { + name: "upload_smart_contract/without a consensus it returns an error", + msgs: []chain.MessageWithSignatures{ + { + QueuedMessage: chain.QueuedMessage{ + ID: 555, + BytesToSign: ethCompatibleBytesToSign, + Msg: &types.Message{ + Action: &types.Message_UploadSmartContract{ + UploadSmartContract: &types.UploadSmartContract{ + Bytecode: []byte("bytecode"), + Abi: StoredContracts()["simple"].Source, + ConstructorInput: []byte("constructor input"), + }, + }, + }, + }, + Signatures: []chain.ValidatorSignature{ + addValidSignature(bobPK), + }, + }, + }, + setup: func(t *testing.T) (*mockEvmClienter, *mockPalomaClienter) { + evm, paloma := newMockEvmClienter(t), newMockPalomaClienter(t) + + currentValsetID := int64(0) + + paloma.On("QueryGetEVMValsetByID", mock.Anything, uint64(currentValsetID), "internal-chain-id").Return( + &types.Valset{ + Validators: []string{crypto.PubkeyToAddress(bobPK.PublicKey).Hex()}, + Powers: []uint64{5}, + ValsetID: uint64(currentValsetID), + }, + nil, + ) + return evm, paloma + }, + }, } { t.Run(tt.name, func(t *testing.T) { ctx := context.Background() diff --git a/chain/evm/deploy_contract.go b/chain/evm/deploy_contract.go index 13f48dd7..e9e692aa 100644 --- a/chain/evm/deploy_contract.go +++ b/chain/evm/deploy_contract.go @@ -15,7 +15,7 @@ import ( "github.com/vizualni/whoops" ) -func (c Client) DeployContract(ctx context.Context, contractAbi abi.ABI, bytecode []byte, constructorArgs []any) (contractAddr common.Address, tx *ethtypes.Transaction, err error) { +func (c Client) DeployContract(ctx context.Context, contractAbi abi.ABI, bytecode, constructorInput []byte) (contractAddr common.Address, tx *ethtypes.Transaction, err error) { return deployContract( ctx, c.conn, @@ -24,7 +24,7 @@ func (c Client) DeployContract(ctx context.Context, contractAbi abi.ABI, bytecod c.config.GetChainID(), contractAbi, bytecode, - constructorArgs, + constructorInput, ) } @@ -36,11 +36,10 @@ func deployContract( chainID *big.Int, contractAbi abi.ABI, bytecode []byte, - constructorArgs []any, + constructorInput []byte, ) (contractAddr common.Address, tx *ethtypes.Transaction, err error) { logger := log.WithField("chainID", chainID) err = whoops.Try(func() { - nonce, err := ethClient.PendingNonceAt(ctx, signingAddr) whoops.Assert(err) @@ -62,6 +61,11 @@ func deployContract( "tx-opts": txOpts, }) + // hack begins here + constructorArgs, err := contractAbi.Constructor.Inputs.Unpack(constructorInput) + whoops.Assert(err) + // hack ends here + logger.Info("deploying contract") contractAddr, tx, _, err = bind.DeployContract( txOpts, diff --git a/chain/evm/errors.go b/chain/evm/errors.go index 9bd4656b..5264244f 100644 --- a/chain/evm/errors.go +++ b/chain/evm/errors.go @@ -9,4 +9,6 @@ const ( ErrInvalidAddress = whoops.Errorf("provided address: '%s' is not valid") ErrAddressNotFoundInKeyStore = whoops.Errorf("address: '%s' not found in keystore: %s") ErrUnsupportedMessageType = whoops.Errorf("unsupported message type: %T") + + ErrNoConsensus = whoops.String("no consensus reached") ) diff --git a/chain/evm/mock_evmClienter_test.go b/chain/evm/mock_evmClienter_test.go index dc50cf68..5f07b26a 100644 --- a/chain/evm/mock_evmClienter_test.go +++ b/chain/evm/mock_evmClienter_test.go @@ -25,6 +25,38 @@ type mockEvmClienter struct { mock.Mock } +// DeployContract provides a mock function with given fields: ctx, contractAbi, bytecode, constructorInput +func (_m *mockEvmClienter) DeployContract(ctx context.Context, contractAbi abi.ABI, bytecode []byte, constructorInput []byte) (common.Address, *types.Transaction, error) { + ret := _m.Called(ctx, contractAbi, bytecode, constructorInput) + + var r0 common.Address + if rf, ok := ret.Get(0).(func(context.Context, abi.ABI, []byte, []byte) common.Address); ok { + r0 = rf(ctx, contractAbi, bytecode, constructorInput) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(common.Address) + } + } + + var r1 *types.Transaction + if rf, ok := ret.Get(1).(func(context.Context, abi.ABI, []byte, []byte) *types.Transaction); ok { + r1 = rf(ctx, contractAbi, bytecode, constructorInput) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*types.Transaction) + } + } + + var r2 error + if rf, ok := ret.Get(2).(func(context.Context, abi.ABI, []byte, []byte) error); ok { + r2 = rf(ctx, contractAbi, bytecode, constructorInput) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + // ExecuteSmartContract provides a mock function with given fields: ctx, contractAbi, addr, method, arguments func (_m *mockEvmClienter) ExecuteSmartContract(ctx context.Context, contractAbi abi.ABI, addr common.Address, method string, arguments []interface{}) (*types.Transaction, error) { ret := _m.Called(ctx, contractAbi, addr, method, arguments) diff --git a/chain/paloma/client.go b/chain/paloma/client.go index d0a49504..95f509f5 100644 --- a/chain/paloma/client.go +++ b/chain/paloma/client.go @@ -7,6 +7,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/gogo/protobuf/grpc" + "github.com/vizualni/whoops" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/palomachain/sparrow/chain" @@ -180,7 +181,11 @@ func (c Client) QueryGetSnapshotByID(ctx context.Context, id uint64) (*valset.Sn }) if err != nil { if strings.Contains(err.Error(), "item not found in store") { - return nil, nil + return nil, whoops.Enrich( + chain.ErrNotFound, + chain.EnrichedItemType.Val("snapshot"), + chain.EnrichedID.Val(id), + ) } return nil, err } @@ -196,7 +201,12 @@ func (c Client) QueryGetEVMValsetByID(ctx context.Context, id uint64, chainID st }) if err != nil { if strings.Contains(err.Error(), "item not found in store") { - return nil, nil + return nil, whoops.Enrich( + chain.ErrNotFound, + chain.EnrichedChainID.Val(chainID), + chain.EnrichedID.Val(id), + chain.EnrichedItemType.Val("valset"), + ) } return nil, err } diff --git a/cmd/sparrow/cmd_evm.go b/cmd/sparrow/cmd_evm.go index 4e2ce921..fd4c66ab 100644 --- a/cmd/sparrow/cmd_evm.go +++ b/cmd/sparrow/cmd_evm.go @@ -64,15 +64,11 @@ var ( chainID, contractABIbz, bytecode, packedInput := args[0], args[1], args[2], args[3] c := app.GetEvmClients()[chainID] contractABI := whoops.Must(abi.JSON(strings.NewReader(contractABIbz))) - constructorArgs, err := contractABI.Constructor.Inputs.Unpack(common.FromHex(packedInput)) - if err != nil { - return err - } addr, tx, err := c.DeployContract( cmd.Context(), contractABI, common.FromHex(bytecode), - constructorArgs, + common.FromHex(packedInput), ) if err != nil { return err diff --git a/config.example.yaml b/config.example.yaml index 0afe6698..7ac96a6b 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -9,7 +9,7 @@ paloma: signing-key: my_validator base-rpc-url: http://localhost:26657 gas-adjustment: 2.0 - gas-prices: 0.01grain + gas-prices: 0.001ugrain account-prefix: paloma diff --git a/proto/paloma/evm/turnstone.proto b/proto/paloma/evm/turnstone.proto index 0921b8f7..867be79a 100644 --- a/proto/paloma/evm/turnstone.proto +++ b/proto/paloma/evm/turnstone.proto @@ -26,6 +26,8 @@ message UpdateValset { message UploadSmartContract { bytes bytecode = 1; + bytes abi = 2; + bytes constructorInput = 3; } diff --git a/types/paloma/x/evm/types/turnstone.pb.go b/types/paloma/x/evm/types/turnstone.pb.go index d26a276b..11ef97d6 100644 --- a/types/paloma/x/evm/types/turnstone.pb.go +++ b/types/paloma/x/evm/types/turnstone.pb.go @@ -197,7 +197,9 @@ func (m *UpdateValset) GetValset() *Valset { } type UploadSmartContract struct { - Bytecode []byte `protobuf:"bytes,1,opt,name=bytecode,proto3" json:"bytecode,omitempty"` + Bytecode []byte `protobuf:"bytes,1,opt,name=bytecode,proto3" json:"bytecode,omitempty"` + Abi []byte `protobuf:"bytes,2,opt,name=abi,proto3" json:"abi,omitempty"` + ConstructorInput []byte `protobuf:"bytes,3,opt,name=constructorInput,proto3" json:"constructorInput,omitempty"` } func (m *UploadSmartContract) Reset() { *m = UploadSmartContract{} } @@ -240,6 +242,20 @@ func (m *UploadSmartContract) GetBytecode() []byte { return nil } +func (m *UploadSmartContract) GetAbi() []byte { + if m != nil { + return m.Abi + } + return nil +} + +func (m *UploadSmartContract) GetConstructorInput() []byte { + if m != nil { + return m.ConstructorInput + } + return nil +} + type Message struct { TurnstoneID string `protobuf:"bytes,1,opt,name=turnstoneID,proto3" json:"turnstoneID,omitempty"` ChainID string `protobuf:"bytes,2,opt,name=chainID,proto3" json:"chainID,omitempty"` @@ -365,36 +381,38 @@ func init() { func init() { proto.RegisterFile("paloma/evm/turnstone.proto", fileDescriptor_cf8ba6d72a84c6bd) } var fileDescriptor_cf8ba6d72a84c6bd = []byte{ - // 461 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x53, 0x41, 0x8b, 0xd3, 0x40, - 0x14, 0xce, 0xb4, 0x35, 0xbb, 0x7d, 0x0d, 0xac, 0xcc, 0xca, 0x12, 0x7a, 0x08, 0x21, 0x08, 0x46, - 0x84, 0x04, 0x2b, 0x78, 0x77, 0x5b, 0xa4, 0x15, 0xbd, 0x4c, 0x59, 0x0f, 0x22, 0xc8, 0x24, 0x19, - 0xd2, 0x40, 0x92, 0x09, 0x99, 0x49, 0xdd, 0xfe, 0x04, 0x6f, 0xfe, 0x2c, 0x8f, 0xeb, 0xcd, 0xa3, - 0xb4, 0x7f, 0x64, 0xc9, 0x24, 0x2d, 0xd9, 0xdd, 0xf6, 0xf6, 0xbe, 0x99, 0x37, 0xdf, 0xf7, 0xbd, - 0x6f, 0x78, 0x30, 0x2e, 0x68, 0xca, 0x33, 0xea, 0xb3, 0x75, 0xe6, 0xcb, 0xaa, 0xcc, 0x85, 0xe4, - 0x39, 0xf3, 0x8a, 0x92, 0x4b, 0x8e, 0xaf, 0x9a, 0xbb, 0x70, 0x45, 0x93, 0xdc, 0x6b, 0x6a, 0x8f, - 0xad, 0xb3, 0xf1, 0x8b, 0x98, 0xc7, 0x5c, 0xb5, 0xf8, 0x75, 0xd5, 0x74, 0x3b, 0xdf, 0x41, 0xff, - 0x4a, 0x53, 0xc1, 0x24, 0xb6, 0x00, 0xd6, 0x34, 0x4d, 0x22, 0x2a, 0x79, 0x29, 0x4c, 0x64, 0xf7, - 0xdd, 0x21, 0xe9, 0x9c, 0xe0, 0x2b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1, 0x12, 0x2e, - 0xc4, 0xc3, 0x34, 0x55, 0x00, 0xa3, 0xc9, 0xab, 0x53, 0xde, 0x1f, 0x85, 0x3f, 0xd7, 0xc8, 0x63, - 0x06, 0xfc, 0x09, 0x8c, 0xaa, 0x93, 0x8b, 0xca, 0x6d, 0x34, 0x79, 0x79, 0x8a, 0xb1, 0x9b, 0xe1, - 0x5c, 0x23, 0x0f, 0xde, 0xe2, 0x1f, 0x70, 0x59, 0x3d, 0xcd, 0xc6, 0x7c, 0xa6, 0x28, 0xdf, 0x9c, - 0xa6, 0x7c, 0xf2, 0x64, 0xae, 0x91, 0x63, 0x4c, 0xd7, 0xe7, 0xa0, 0xd3, 0x50, 0x26, 0x3c, 0xbf, - 0x9e, 0xfe, 0xd9, 0x5a, 0xe8, 0x6e, 0x6b, 0xa1, 0xff, 0x5b, 0x0b, 0xfd, 0xde, 0x59, 0xda, 0xdd, - 0xce, 0xd2, 0xfe, 0xed, 0x2c, 0xed, 0xdb, 0xeb, 0x38, 0x91, 0xab, 0x2a, 0xf0, 0x42, 0x9e, 0xf9, - 0x1d, 0xc5, 0xb6, 0xf6, 0x6f, 0x9b, 0xad, 0xd9, 0x14, 0x4c, 0x04, 0xba, 0x5a, 0x82, 0x77, 0xf7, - 0x01, 0x00, 0x00, 0xff, 0xff, 0xeb, 0xa4, 0xa1, 0xf7, 0x50, 0x03, 0x00, 0x00, + // 481 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x53, 0xcf, 0x8b, 0x9b, 0x40, + 0x14, 0xd6, 0x98, 0xba, 0x9b, 0x17, 0x61, 0x97, 0xd9, 0xb2, 0x48, 0x0e, 0x22, 0x52, 0xa8, 0x6d, + 0x41, 0x21, 0x85, 0xde, 0xbb, 0x09, 0x25, 0x29, 0xed, 0x65, 0xc2, 0xf6, 0x50, 0x0a, 0x65, 0xd4, + 0xc1, 0x08, 0xea, 0x88,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 0x2c, 0xbf, 0x9b, 0xfc, 0xde, 0x58, 0xea, 0xe3, 0xc6, 0x52, 0xff, 0x6d, 0x2c, 0xf5, 0xd7, + 0xd6, 0x52, 0x1e, 0xb7, 0x96, 0xf2, 0x77, 0x6b, 0x29, 0x5f, 0x5f, 0xc5, 0x89, 0x58, 0x56, 0x81, + 0x17, 0xb2, 0xcc, 0xef, 0x28, 0xb6, 0xb5, 0xff, 0xd0, 0xfc, 0xb9, 0x75, 0x41, 0x79, 0xa0, 0xcb, + 0x2f, 0xf4, 0xf6, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xae, 0x43, 0x30, 0xbc, 0x8e, 0x03, 0x00, + 0x00, } func (m *Valset) Marshal() (dAtA []byte, err error) { @@ -556,6 +574,20 @@ func (m *UploadSmartContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.ConstructorInput) > 0 { + i -= len(m.ConstructorInput) + copy(dAtA[i:], m.ConstructorInput) + i = encodeVarintTurnstone(dAtA, i, uint64(len(m.ConstructorInput))) + i-- + dAtA[i] = 0x1a + } + if len(m.Abi) > 0 { + i -= len(m.Abi) + copy(dAtA[i:], m.Abi) + i = encodeVarintTurnstone(dAtA, i, uint64(len(m.Abi))) + i-- + dAtA[i] = 0x12 + } if len(m.Bytecode) > 0 { i -= len(m.Bytecode) copy(dAtA[i:], m.Bytecode) @@ -758,6 +790,14 @@ func (m *UploadSmartContract) Size() (n int) { if l > 0 { n += 1 + l + sovTurnstone(uint64(l)) } + l = len(m.Abi) + if l > 0 { + n += 1 + l + sovTurnstone(uint64(l)) + } + l = len(m.ConstructorInput) + if l > 0 { + n += 1 + l + sovTurnstone(uint64(l)) + } return n } @@ -1319,6 +1359,74 @@ func (m *UploadSmartContract) Unmarshal(dAtA []byte) error { m.Bytecode = []byte{} } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Abi", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTurnstone + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTurnstone + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTurnstone + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Abi = append(m.Abi[:0], dAtA[iNdEx:postIndex]...) + if m.Abi == nil { + m.Abi = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConstructorInput", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTurnstone + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTurnstone + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTurnstone + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConstructorInput = append(m.ConstructorInput[:0], dAtA[iNdEx:postIndex]...) + if m.ConstructorInput == nil { + m.ConstructorInput = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTurnstone(dAtA[iNdEx:])