diff --git a/contracts/oasys/contracts.go b/contracts/oasys/contracts.go index 78acf691b..435b9908b 100644 --- a/contracts/oasys/contracts.go +++ b/contracts/oasys/contracts.go @@ -19,6 +19,12 @@ var ( address: "0x520000000000000000000000000000000000002e", } + // Governance + permissionedContractFactory = &contract{ + name: "PermissionedContractFactory", + address: "0x520000000000000000000000000000000000002F", + } + // ERC20 Tokens wrappedOAS = &contract{ name: "WOAS", diff --git a/contracts/oasys/deployments.go b/contracts/oasys/deployments.go index a361cb387..0388a42b6 100644 --- a/contracts/oasys/deployments.go +++ b/contracts/oasys/deployments.go @@ -4,10 +4,10 @@ import ( "encoding/hex" "fmt" "math/big" - "reflect" "strings" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" ) @@ -212,14 +212,14 @@ var ( // mapping(address => address) internal administrators "0x00": genesismap{ params.OasysMainnetGenesisHash: mapping{ - keyType: reflect.TypeOf(common.Address{}), + keyFn: addressKeyFn, values: map[string]interface{}{ "0x0000000000000000000000000000000000000001": "0x2273e9bD041d1405cB3f9DCa42fafC9358b07f79", "0x2273e9bD041d1405cB3f9DCa42fafC9358b07f79": "0x0000000000000000000000000000000000000001", }, }, defaultGenesisHash: mapping{ - keyType: reflect.TypeOf(common.Address{}), + keyFn: addressKeyFn, values: map[string]interface{}{ "0x0000000000000000000000000000000000000001": "0x377b21b3D7d6F9B1dBf00176f96cCf4CABD100d2", "0x377b21b3D7d6F9B1dBf00176f96cCf4CABD100d2": "0x0000000000000000000000000000000000000001", @@ -275,7 +275,7 @@ var ( // Pool > Pauser : mapping(address => bool) public pausers "0x07": genesismap{ params.OasysMainnetGenesisHash: mapping{ - keyType: reflect.TypeOf(common.Address{}), + keyFn: addressKeyFn, values: map[string]interface{}{ "0x1b9dFC56e38b0F92448659C114e2347Bd803911c": "0x1", "0xDfE4F07D1F36B8d559b25082460a4f6A72531de2": "0x1", @@ -286,7 +286,7 @@ var ( }, }, defaultGenesisHash: mapping{ - keyType: reflect.TypeOf(common.Address{}), + keyFn: addressKeyFn, values: map[string]interface{}{ "0x58b529F9084D7eAA598EB3477Fe36064C5B7bbC1": "0x1", }, @@ -295,7 +295,7 @@ var ( // Pool > VolumeControl > Governor : mapping(address => bool) public governors "0x08": genesismap{ params.OasysMainnetGenesisHash: mapping{ - keyType: reflect.TypeOf(common.Address{}), + keyFn: addressKeyFn, values: map[string]interface{}{ "0x1b9dFC56e38b0F92448659C114e2347Bd803911c": "0x1", "0x34dFa1226F8b3E36FE597B34eEa809a2B5c0bBf9": "0x1", @@ -304,7 +304,7 @@ var ( }, }, defaultGenesisHash: mapping{ - keyType: reflect.TypeOf(common.Address{}), + keyFn: addressKeyFn, values: map[string]interface{}{ "0x58b529F9084D7eAA598EB3477Fe36064C5B7bbC1": "0x1", }, @@ -330,7 +330,7 @@ var ( // Pauser : mapping(address => bool) public pausers "0x02": genesismap{ params.OasysMainnetGenesisHash: mapping{ - keyType: reflect.TypeOf(common.Address{}), + keyFn: addressKeyFn, values: map[string]interface{}{ "0x1b9dFC56e38b0F92448659C114e2347Bd803911c": "0x1", "0xDfE4F07D1F36B8d559b25082460a4f6A72531de2": "0x1", @@ -341,7 +341,7 @@ var ( }, }, defaultGenesisHash: mapping{ - keyType: reflect.TypeOf(common.Address{}), + keyFn: addressKeyFn, values: map[string]interface{}{ "0x58b529F9084D7eAA598EB3477Fe36064C5B7bbC1": "0x1", }, @@ -350,7 +350,7 @@ var ( // VolumeControl > Governor : mapping(address => bool) public governors "0x03": genesismap{ params.OasysMainnetGenesisHash: mapping{ - keyType: reflect.TypeOf(common.Address{}), + keyFn: addressKeyFn, values: map[string]interface{}{ "0x1b9dFC56e38b0F92448659C114e2347Bd803911c": "0x1", "0x34dFa1226F8b3E36FE597B34eEa809a2B5c0bBf9": "0x1", @@ -359,7 +359,7 @@ var ( }, }, defaultGenesisHash: mapping{ - keyType: reflect.TypeOf(common.Address{}), + keyFn: addressKeyFn, values: map[string]interface{}{ "0x58b529F9084D7eAA598EB3477Fe36064C5B7bbC1": "0x1", }, @@ -383,7 +383,7 @@ var ( // Pauser : mapping(address => bool) public pausers "0x01": genesismap{ params.OasysMainnetGenesisHash: mapping{ - keyType: reflect.TypeOf(common.Address{}), + keyFn: addressKeyFn, values: map[string]interface{}{ "0x1b9dFC56e38b0F92448659C114e2347Bd803911c": "0x1", "0xDfE4F07D1F36B8d559b25082460a4f6A72531de2": "0x1", @@ -394,7 +394,7 @@ var ( }, }, defaultGenesisHash: mapping{ - keyType: reflect.TypeOf(common.Address{}), + keyFn: addressKeyFn, values: map[string]interface{}{ "0x58b529F9084D7eAA598EB3477Fe36064C5B7bbC1": "0x1", }, @@ -403,7 +403,7 @@ var ( // VolumeControl > Governor : mapping(address => bool) public governors "0x02": genesismap{ params.OasysMainnetGenesisHash: mapping{ - keyType: reflect.TypeOf(common.Address{}), + keyFn: addressKeyFn, values: map[string]interface{}{ "0x1b9dFC56e38b0F92448659C114e2347Bd803911c": "0x1", "0x34dFa1226F8b3E36FE597B34eEa809a2B5c0bBf9": "0x1", @@ -412,7 +412,7 @@ var ( }, }, defaultGenesisHash: mapping{ - keyType: reflect.TypeOf(common.Address{}), + keyFn: addressKeyFn, values: map[string]interface{}{ "0x58b529F9084D7eAA598EB3477Fe36064C5B7bbC1": "0x1", }, @@ -650,7 +650,7 @@ var ( // mapping(address => uint256) private _ids "0x01": genesismap{ params.OasysMainnetGenesisHash: mapping{ - keyType: reflect.TypeOf(common.Address{}), + keyFn: addressKeyFn, values: map[string]interface{}{ "0x86652fE437425AC63211C55b6b067B3181BBcB17": big.NewInt(1), "0xa505014a84e8BdC4A620470A53EAd872b0c1CA5b": big.NewInt(2), @@ -679,7 +679,7 @@ var ( }, }, params.OasysTestnetGenesisHash: mapping{ - keyType: reflect.TypeOf(common.Address{}), + keyFn: addressKeyFn, values: map[string]interface{}{ "0xF886672205399c186638abfA9Dc155dEe9CBBD2e": big.NewInt(1), }, @@ -735,6 +735,67 @@ var ( }, } + deployments10 = []*deployment{ + { + // commit: https://github.com/oasysgames/oasys-governance-contract/blob/be1dff6c29cd84c671ab3f4e0cfb811a0e47634f/contracts/PermissionedContractFactory.sol + contract: permissionedContractFactory, + code: mustDecodeCode(`0x6080604052600436106100b25760003560e01c806336568abe1161006f57806336568abe146101e55780634de79ecc1461020557806365ddb0171461021a57806391d148541461022d578063a217fddf1461024d578063d547741f14610262578063da58f37e1461028257600080fd5b806301ffc9a7146100b757806309b1eca6146100ec5780630b19429e14610124578063248a9ca3146101665780632a50c146146101965780632f2ff15d146101c3575b600080fd5b3480156100c357600080fd5b506100d76100d2366004610d98565b6102a2565b60405190151581526020015b60405180910390f35b3480156100f857600080fd5b5061010c610107366004610e65565b6102d9565b6040516001600160a01b0390911681526020016100e3565b34801561013057600080fd5b506101587f0d8b58cba732a42811e1f217ab43cccb14f1a8263ebb61afbf13838fcdae9df981565b6040519081526020016100e3565b34801561017257600080fd5b50610158610181366004610eac565b60009081526020819052604090206001015490565b3480156101a257600080fd5b506101b66101b1366004610edc565b6102f4565b6040516100e39190610f47565b3480156101cf57600080fd5b506101e36101de366004610f8a565b610433565b005b3480156101f157600080fd5b506101e3610200366004610f8a565b61045d565b34801561021157600080fd5b50600154610158565b61010c610228366004610fb6565b6104db565b34801561023957600080fd5b506100d7610248366004610f8a565b610614565b34801561025957600080fd5b50610158600081565b34801561026e57600080fd5b506101e361027d366004610f8a565b61063d565b34801561028e57600080fd5b506101b661029d366004610eac565b610662565b60006001600160e01b03198216637965db0b60e01b14806102d357506301ffc9a760e01b6001600160e01b03198316145b92915050565b60006102ed838380519060200120306107ca565b9392505050565b604080516060808201835260008083526020830152918101919091526001600160a01b0380831660009081526002602081815260409283902083516060810185528154861681526001820154909516918501919091529081018054919284019161035d90611070565b80601f016020809104026020016040519081016040528092919081815260200182805461038990611070565b80156103d65780601f106103ab576101008083540402835291602001916103d6565b820191906000526020600020905b8154815290600101906020018083116103b957829003601f168201915b5050509190925250505060208101519091506001600160a01b031661042e5760405162461bcd60e51b81526020600482015260096024820152681b9bdd08199bdd5b9960ba1b60448201526064015b60405180910390fd5b919050565b60008281526020819052604090206001015461044e816107f4565b6104588383610801565b505050565b6001600160a01b03811633146104cd5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610425565b6104d78282610885565b5050565b60007f0d8b58cba732a42811e1f217ab43cccb14f1a8263ebb61afbf13838fcdae9df9610507816107f4565b8734146105565760405162461bcd60e51b815260206004820152601a60248201527f5043433a20696e636f727265637420616d6f756e742073656e740000000000006044820152606401610425565b6105618888886108ea565b9150846001600160a01b0316826001600160a01b0316146105be5760405162461bcd60e51b81526020600482015260176024820152765043433a20756e6578706563746564206164647265737360481b6044820152606401610425565b7f388d923fb867b31389c9da49a5a9b552bd44cde0717beb38a215d99ef09778db33898989866040516105f59594939291906110aa565b60405180910390a1610609823386866109ea565b509695505050505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b600082815260208190526040902060010154610658816107f4565b6104588383610885565b6040805160608082018352600080835260208301529181019190915260015461068c836001611103565b11156106cf5760405162461bcd60e51b8152602060048201526012602482015271696e646578206f7574206f662072616e676560701b6044820152606401610425565b60026000600184815481106106e6576106e6611116565b60009182526020808320909101546001600160a01b0390811684528382019490945260409283019091208251606081018452815485168152600182015490941691840191909152600281018054919284019161074190611070565b80601f016020809104026020016040519081016040528092919081815260200182805461076d90611070565b80156107ba5780601f1061078f576101008083540402835291602001916107ba565b820191906000526020600020905b81548152906001019060200180831161079d57829003601f168201915b5050505050815250509050919050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b6107fe8133610b91565b50565b61080b8282610614565b6104d7576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556108413390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b61088f8282610614565b156104d7576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008347101561093c5760405162461bcd60e51b815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610425565b815160000361098d5760405162461bcd60e51b815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610425565b8282516020840186f590506001600160a01b0381166102ed5760405162461bcd60e51b8152602060048201526019602482015278437265617465323a204661696c6564206f6e206465706c6f7960381b6044820152606401610425565b6001600160a01b038481166000908152600260205260409020600101541615610a4a5760405162461bcd60e51b8152602060048201526012602482015271185b1c9958591e481c9959da5cdd195c995960721b6044820152606401610425565b826001600160a01b03167f8d3f2558914d24d1627609279aec4a8b1033bb2e86f4fc8118aba14785e3fc39858484604051610a879392919061112c565b60405180910390a26001805480820182556000919091527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf60180546001600160a01b0319166001600160a01b03868116918217909255604080516060810182529182529185166020808301919091528251601f85018290048202810182018452848152919283019190859085908190840183828082843760009201829052509390945250506001600160a01b03808816825260026020818152604093849020865181549085166001600160a01b031991821617825591870151600182018054919095169216919091179092559184015190925090820190610b8890826111ba565b50505050505050565b610b9b8282610614565b6104d757610ba881610bea565b610bb3836020610bfc565b604051602001610bc492919061127a565b60408051601f198184030181529082905262461bcd60e51b8252610425916004016112e9565b60606102d36001600160a01b03831660145b60606000610c0b8360026112fc565b610c16906002611103565b67ffffffffffffffff811115610c2e57610c2e610dc2565b6040519080825280601f01601f191660200182016040528015610c58576020820181803683370190505b509050600360fc1b81600081518110610c7357610c73611116565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110610ca257610ca2611116565b60200101906001600160f81b031916908160001a9053506000610cc68460026112fc565b610cd1906001611103565b90505b6001811115610d49576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110610d0557610d05611116565b1a60f81b828281518110610d1b57610d1b611116565b60200101906001600160f81b031916908160001a90535060049490941c93610d4281611313565b9050610cd4565b5083156102ed5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610425565b600060208284031215610daa57600080fd5b81356001600160e01b0319811681146102ed57600080fd5b634e487b7160e01b600052604160045260246000fd5b600082601f830112610de957600080fd5b813567ffffffffffffffff80821115610e0457610e04610dc2565b604051601f8301601f19908116603f01168101908282118183101715610e2c57610e2c610dc2565b81604052838152866020858801011115610e4557600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060408385031215610e7857600080fd5b82359150602083013567ffffffffffffffff811115610e9657600080fd5b610ea285828601610dd8565b9150509250929050565b600060208284031215610ebe57600080fd5b5035919050565b80356001600160a01b038116811461042e57600080fd5b600060208284031215610eee57600080fd5b6102ed82610ec5565b60005b83811015610f12578181015183820152602001610efa565b50506000910152565b60008151808452610f33816020860160208601610ef7565b601f01601f19169290920160200192915050565b60208152600060018060a01b03808451166020840152806020850151166040840152506040830151606080840152610f826080840182610f1b565b949350505050565b60008060408385031215610f9d57600080fd5b82359150610fad60208401610ec5565b90509250929050565b60008060008060008060a08789031215610fcf57600080fd5b8635955060208701359450604087013567ffffffffffffffff80821115610ff557600080fd5b6110018a838b01610dd8565b955061100f60608a01610ec5565b9450608089013591508082111561102557600080fd5b818901915089601f83011261103957600080fd5b81358181111561104857600080fd5b8a602082850101111561105a57600080fd5b6020830194508093505050509295509295509295565b600181811c9082168061108457607f821691505b6020821081036110a457634e487b7160e01b600052602260045260246000fd5b50919050565b600060018060a01b03808816835286602084015285604084015260a060608401526110d860a0840186610f1b565b91508084166080840152509695505050505050565b634e487b7160e01b600052601160045260246000fd5b808201808211156102d3576102d36110ed565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b03841681526040602082018190528101829052818360608301376000818301606090810191909152601f909201601f1916010192915050565b601f82111561045857600081815260208120601f850160051c810160208610156111935750805b601f850160051c820191505b818110156111b25782815560010161119f565b505050505050565b815167ffffffffffffffff8111156111d4576111d4610dc2565b6111e8816111e28454611070565b8461116c565b602080601f83116001811461121d57600084156112055750858301515b600019600386901b1c1916600185901b1785556111b2565b600085815260208120601f198616915b8281101561124c5788860151825594840194600190910190840161122d565b508582101561126a5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b8152600083516112ac816017850160208801610ef7565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516112dd816028840160208801610ef7565b01602801949350505050565b6020815260006102ed6020830184610f1b565b80820281158282048414176102d3576102d36110ed565b600081611322576113226110ed565b50600019019056fea26469706673582212206921a9f7c5bb12866f25cbc8403a852dd261b38e2deb870825f95c96e3b64db864736f6c63430008120033`), + storage: storage{ + // mapping(bytes32 => RoleData) private _roles + "0x00": mapping{ + keyFn: func(key string) common.Hash { + if key == "DEFAULT_ADMIN_ROLE" { + return common.Hash{} + } + return common.BytesToHash(crypto.Keccak256([]byte(key))) + }, + values: map[string]interface{}{ + "DEFAULT_ADMIN_ROLE": structValue{ + // mapping(address => bool) members + { + pos: 0, + value: genesismap{ + params.OasysMainnetGenesisHash: mapping{ + keyFn: addressKeyFn, + values: map[string]interface{}{ + "0xe04EEaCb1f181cD23501f3De39014F4cbb7C1Cd8": "0x1", + }, + }, + params.OasysTestnetGenesisHash: mapping{ + keyFn: addressKeyFn, + values: map[string]interface{}{ + "0xbe32b47A35C31d294B3c58d92ca83876DdC38776": "0x1", + }, + }, + }, + }, + }, + "CONTRACT_CREATOR_ROLE": structValue{ + // mapping(address => bool) members + { + pos: 0, + value: genesismap{ + params.OasysMainnetGenesisHash: mapping{ + keyFn: addressKeyFn, + values: map[string]interface{}{ + "0xc0bACBDA16Bb494d8C5be6DE84540465Fd83333E": "0x1", + }, + }, + params.OasysTestnetGenesisHash: mapping{ + keyFn: addressKeyFn, + values: map[string]interface{}{ + "0xBb5a4FF43683a1281800A6Bc8a94365f055F444F": "0x1", + }, + }, + }, + }, + }, + }, + }, + }, + }, + } + deploymentSets = map[common.Hash]map[uint64]deploymentSet{ params.OasysMainnetGenesisHash: { 1: deploymentSet{deployments0}, @@ -744,6 +805,7 @@ var ( 557100: deploymentSet{deployments6}, 971800: deploymentSet{deployments7}, 1529980: deploymentSet{deployments9}, + 1892000: deploymentSet{deployments10}, }, params.OasysTestnetGenesisHash: { 1: deploymentSet{deployments0}, @@ -755,6 +817,7 @@ var ( 546400: deploymentSet{deployments6}, 955400: deploymentSet{deployments7, deployments8}, 1519840: deploymentSet{deployments9}, + 1880660: deploymentSet{deployments10}, }, defaultGenesisHash: { 2: deploymentSet{ @@ -768,6 +831,7 @@ var ( deployments7, deployments8, deployments9, + deployments10, }, }, } diff --git a/contracts/oasys/oasys_test.go b/contracts/oasys/oasys_test.go index e60467357..33706e703 100644 --- a/contracts/oasys/oasys_test.go +++ b/contracts/oasys/oasys_test.go @@ -1019,6 +1019,34 @@ func _deployments9(genesisHash common.Hash, contracts wantContracts) { } } +func _deployments10(genesisHash common.Hash, contracts wantContracts) { + appends := wantContracts{ + "0x520000000000000000000000000000000000002F": { + name: "PermissionedContractFactory", + codeHash: "36ef0cfff03bcac398171fc8c608a6fb", + }, + } + + switch genesisHash { + case params.OasysMainnetGenesisHash: + // PermissionedContractFactory + appends["0x520000000000000000000000000000000000002F"].storage = map[string]string{ + "0x0bce92cc78449169524412e83bbfd32ee216dec5bba171ae073372f5ed4cecef": "0x0000000000000000000000000000000000000000000000000000000000000001", + "0x7b2a9f35ae3460479c151abacf19c3f133eb204503bb0a42027ce683342103af": "0x0000000000000000000000000000000000000000000000000000000000000001", + } + case params.OasysTestnetGenesisHash: + // PermissionedContractFactory + appends["0x520000000000000000000000000000000000002F"].storage = map[string]string{ + "0x8544f4d9501cd2ef57e66ff394f96f2a0b39125d6cdb5f1740571be3740295b6": "0x0000000000000000000000000000000000000000000000000000000000000001", + "0xdf9cbebfc4724c8cf2eaa7e61614a9d0061eda58cfd1e1e47131ced2975d6e46": "0x0000000000000000000000000000000000000000000000000000000000000001", + } + } + + for k, v := range appends { + contracts[k] = v + } +} + func TestDeploy(t *testing.T) { type wantDeployments []struct { block uint64 @@ -1043,6 +1071,7 @@ func TestDeploy(t *testing.T) { {557100, []deployFn{_deployments6}}, {971800, []deployFn{_deployments7}}, {1529980, []deployFn{_deployments9}}, + {1892000, []deployFn{_deployments10}}, }, }, { @@ -1059,6 +1088,7 @@ func TestDeploy(t *testing.T) { {546400, []deployFn{_deployments6}}, {955400, []deployFn{_deployments7, _deployments8}}, {1519840, []deployFn{_deployments9}}, + {1880660, []deployFn{_deployments10}}, }, }, { @@ -1077,6 +1107,7 @@ func TestDeploy(t *testing.T) { _deployments7, _deployments8, _deployments9, + _deployments10, }}, }, }, diff --git a/contracts/oasys/storage.go b/contracts/oasys/storage.go index ba30e6548..a1e3009bc 100644 --- a/contracts/oasys/storage.go +++ b/contracts/oasys/storage.go @@ -5,7 +5,6 @@ import ( "encoding/hex" "fmt" "math/big" - "reflect" "strconv" "strings" @@ -66,18 +65,18 @@ func (a *array) add(storage map[common.Hash]common.Hash, rootSlot common.Hash) e // `mapping` type storage. type mapping struct { - keyType reflect.Type - values map[string]interface{} + keyFn func(key string) common.Hash + values map[string]interface{} } +var ( + addressKeyFn = func(key string) common.Hash { return common.HexToHash(key) } +) + // Add mapping values to storage. func (m *mapping) add(storage map[common.Hash]common.Hash, rootSlot common.Hash) error { - if m.keyType != reflect.TypeOf(common.Address{}) { - return fmt.Errorf("unsupported key type: %s", m.keyType) - } - for mkey, mval := range m.values { - k := bytes.Join([][]byte{common.HexToHash(mkey).Bytes(), rootSlot[:]}, nil) + k := bytes.Join([][]byte{m.keyFn(mkey).Bytes(), rootSlot[:]}, nil) slot := common.BytesToHash(crypto.Keccak256(k)) if err := setStorage(storage, slot, mval); err != nil { return err @@ -87,6 +86,24 @@ func (m *mapping) add(storage map[common.Hash]common.Hash, rootSlot common.Hash) return nil } +// `struct` type value. +type structValue []struct { + pos int64 + value interface{} +} + +// Add members to storage. +func (s structValue) add(storage map[common.Hash]common.Hash, rootSlot common.Hash) error { + for _, member := range s { + memberSlot := new(big.Int).Add(rootSlot.Big(), big.NewInt(member.pos)) + if err := setStorage(storage, common.BigToHash(memberSlot), member.value); err != nil { + return err + } + } + + return nil +} + func setStorage(storage map[common.Hash]common.Hash, slot common.Hash, val interface{}) error { switch t := val.(type) { case common.Hash: @@ -101,6 +118,8 @@ func setStorage(storage map[common.Hash]common.Hash, slot common.Hash, val inter return t.add(storage, slot) case genesismap: return t.add(storage, slot) + case structValue: + return t.add(storage, slot) case string: isHex := strings.HasPrefix(t, hexPrefix) if isHex { diff --git a/params/version.go b/params/version.go index 653e7cf3d..251d55abb 100644 --- a/params/version.go +++ b/params/version.go @@ -22,7 +22,7 @@ import ( const ( VersionMajor = 1 // Major version component of the current release - VersionMinor = 1 // Minor version component of the current release + VersionMinor = 2 // Minor version component of the current release VersionPatch = 0 // Patch version component of the current release VersionMeta = "" // Version metadata to append to the version string ) @@ -43,7 +43,8 @@ var VersionWithMeta = func() string { // ArchiveVersion holds the textual version string used for Geth archives. // e.g. "1.8.11-dea1ce05" for stable releases, or -// "1.8.13-unstable-21c059b6" for unstable releases +// +// "1.8.13-unstable-21c059b6" for unstable releases func ArchiveVersion(gitCommit string) string { vsn := Version if VersionMeta != "stable" {